diff --git a/include/class.staff.php b/include/class.staff.php index e3273fae5c5e0b3715b90905944caa0327377818..0c1b40712b5a0effa657c6a3f32891da3fb14b2a 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -413,6 +413,10 @@ implements AuthenticatedUser, EmailContact, TemplateVariable { } } + function usePrimaryRoleOnAssignment() { + return $this->getExtraAttr('def_assn_role', true); + } + function getLanguage() { return (isset($this->lang)) ? $this->lang : false; } @@ -437,8 +441,11 @@ implements AuthenticatedUser, EmailContact, TemplateVariable { if ($access = $this->dept_access->findFirst(array('dept_id' => $deptId))) return $this->_roles[$deptId] = $access->role; - // View only access - return new Role(array()); + if (!$this->usePrimaryRoleOnAssignment()) + // View only access + return new Role(array()); + + // Fall through to primary role } // For the primary department, use the primary role return $this->role; @@ -563,15 +570,17 @@ implements AuthenticatedUser, EmailContact, TemplateVariable { if (!isset($this->_extra) && isset($this->extra)) $this->_extra = JsonDataParser::decode($this->extra); - return $attr ? (@$this->_extra[$attr] ?: $default) : $this->_extra; + return $attr + ? (isset($this->_extra[$attr]) ? $this->_extra[$attr] : $default) + : $this->_extra; } function setExtraAttr($attr, $value, $commit=true) { $this->getExtraAttr(); $this->_extra[$attr] = $value; + $this->extra = JsonDataEncoder::encode($this->_extra); if ($commit) { - $this->extra = JsonDataEncoder::encode($this->_extra); $this->save(); } } @@ -1011,6 +1020,8 @@ implements AuthenticatedUser, EmailContact, TemplateVariable { } } $this->updateAccess($access, $errors); + $this->setExtraAttr('def_assn_role', + isset($vars['assign_use_pri_role']), false); // Format team membership as [array(team_id, alerts?)] $teams = array(); diff --git a/include/i18n/en_US/help/tips/staff.agent.yaml b/include/i18n/en_US/help/tips/staff.agent.yaml index 298faa1bbe19ab208561d6949618eb88129987d2..fc0aa372ad9dd3dd2e231927d841b325faaaa4c9 100644 --- a/include/i18n/en_US/help/tips/staff.agent.yaml +++ b/include/i18n/en_US/help/tips/staff.agent.yaml @@ -73,12 +73,22 @@ assigned_group: primary_department: title: Primary Department content: > - Choose the primary <span class="doc-desc-title">department</span> to which this Agent belongs. + Choose the primary <span class="doc-desc-title">department</span> to + which this Agent belongs and an effective <span class="doc-desc-title">Role</span>. links: - title: Manage Departments href: /scp/departments.php +primary_role_on_assign: + title: Use Primary Role For Assignments + content: > + Enable this to fallback to the <span class="doc-desc-title">primary + role</span> when this agent is assigned tickets and tasks outside + of the <span class="doc-desc-title">primary department</span> and + <span class="doc-desc-title">extended access</span> departments. + Otherwise the agent will have view only access. + daylight_saving: title: Daylight Saving content: > diff --git a/include/staff/staff.inc.php b/include/staff/staff.inc.php index bf6c8d730307a8cb40790b4c2701dca0fd5fd024..7c8c18c9c08b43e69bc1deadefe67e99ff844655 100644 --- a/include/staff/staff.inc.php +++ b/include/staff/staff.inc.php @@ -213,7 +213,7 @@ if (count($bks) > 1) { <table class="table two-column" width="940" border="0" cellspacing="0" cellpadding="2"> <tbody> <tr class="header"> - <th colspan="2"> + <th colspan="3"> <?php echo __('Primary Department and Role'); ?> <span class="error">*</span> <div><small><?php echo __( @@ -249,6 +249,18 @@ if (count($bks) > 1) { <option value="0" data-quick-add>— <?php echo __('Add New');?> —</option> </select> <i class="offset help-tip icon-question-sign" href="#primary_role"></i> + </td> + <td> + <label class="inline checkbox"> + <input type="checkbox" name="assign_use_pri_role" <?php + if ($staff->usePrimaryRoleOnAssignment()) + echo 'checked="checked"'; + ?> /> + <?php echo __('Fall back to primary role on assigned tickets'); ?> + <i class="icon-question-sign help-tip" + href="#primary_role_on_assign"></i> + </label> + <div class="error"><?php echo $errors['role_id']; ?></div> </td> </tr> @@ -268,7 +280,8 @@ if (count($bks) > 1) { ?> <option value="0" data-quick-add>— <?php echo __('Add New');?> —</option> </select> - <span style="display:inline-block;width:20px"> </span> + </td> + <td> <label class="inline checkbox"> <input type="checkbox" data-name="dept_access_alerts" value="1" /> <?php echo __('Alerts'); ?> @@ -280,7 +293,7 @@ if (count($bks) > 1) { </tbody> <tbody> <tr class="header"> - <th colspan="2"> + <th colspan="3"> <?php echo __('Extended Access'); ?> </th> </tr>