Skip to content
Snippets Groups Projects
Commit b01842d2 authored by Jared Hancock's avatar Jared Hancock
Browse files

role: Add option to use primary role on assignment

parent b33a0315
No related branches found
No related tags found
No related merge requests found
...@@ -413,6 +413,10 @@ implements AuthenticatedUser, EmailContact, TemplateVariable { ...@@ -413,6 +413,10 @@ implements AuthenticatedUser, EmailContact, TemplateVariable {
} }
} }
function usePrimaryRoleOnAssignment() {
return $this->getExtraAttr('def_assn_role', true);
}
function getLanguage() { function getLanguage() {
return (isset($this->lang)) ? $this->lang : false; return (isset($this->lang)) ? $this->lang : false;
} }
...@@ -437,8 +441,11 @@ implements AuthenticatedUser, EmailContact, TemplateVariable { ...@@ -437,8 +441,11 @@ implements AuthenticatedUser, EmailContact, TemplateVariable {
if ($access = $this->dept_access->findFirst(array('dept_id' => $deptId))) if ($access = $this->dept_access->findFirst(array('dept_id' => $deptId)))
return $this->_roles[$deptId] = $access->role; return $this->_roles[$deptId] = $access->role;
// View only access if (!$this->usePrimaryRoleOnAssignment())
return new Role(array()); // View only access
return new Role(array());
// Fall through to primary role
} }
// For the primary department, use the primary role // For the primary department, use the primary role
return $this->role; return $this->role;
...@@ -563,15 +570,17 @@ implements AuthenticatedUser, EmailContact, TemplateVariable { ...@@ -563,15 +570,17 @@ implements AuthenticatedUser, EmailContact, TemplateVariable {
if (!isset($this->_extra) && isset($this->extra)) if (!isset($this->_extra) && isset($this->extra))
$this->_extra = JsonDataParser::decode($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) { function setExtraAttr($attr, $value, $commit=true) {
$this->getExtraAttr(); $this->getExtraAttr();
$this->_extra[$attr] = $value; $this->_extra[$attr] = $value;
$this->extra = JsonDataEncoder::encode($this->_extra);
if ($commit) { if ($commit) {
$this->extra = JsonDataEncoder::encode($this->_extra);
$this->save(); $this->save();
} }
} }
...@@ -1011,6 +1020,8 @@ implements AuthenticatedUser, EmailContact, TemplateVariable { ...@@ -1011,6 +1020,8 @@ implements AuthenticatedUser, EmailContact, TemplateVariable {
} }
} }
$this->updateAccess($access, $errors); $this->updateAccess($access, $errors);
$this->setExtraAttr('def_assn_role',
isset($vars['assign_use_pri_role']), false);
// Format team membership as [array(team_id, alerts?)] // Format team membership as [array(team_id, alerts?)]
$teams = array(); $teams = array();
......
...@@ -73,12 +73,22 @@ assigned_group: ...@@ -73,12 +73,22 @@ assigned_group:
primary_department: primary_department:
title: Primary Department title: Primary Department
content: > 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: links:
- title: Manage Departments - title: Manage Departments
href: /scp/departments.php 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: daylight_saving:
title: Daylight Saving title: Daylight Saving
content: > content: >
......
...@@ -213,7 +213,7 @@ if (count($bks) > 1) { ...@@ -213,7 +213,7 @@ if (count($bks) > 1) {
<table class="table two-column" width="940" border="0" cellspacing="0" cellpadding="2"> <table class="table two-column" width="940" border="0" cellspacing="0" cellpadding="2">
<tbody> <tbody>
<tr class="header"> <tr class="header">
<th colspan="2"> <th colspan="3">
<?php echo __('Primary Department and Role'); ?> <?php echo __('Primary Department and Role'); ?>
<span class="error">*</span> <span class="error">*</span>
<div><small><?php echo __( <div><small><?php echo __(
...@@ -249,6 +249,18 @@ if (count($bks) > 1) { ...@@ -249,6 +249,18 @@ if (count($bks) > 1) {
<option value="0" data-quick-add>&mdash; <?php echo __('Add New');?> &mdash;</option> <option value="0" data-quick-add>&mdash; <?php echo __('Add New');?> &mdash;</option>
</select> </select>
<i class="offset help-tip icon-question-sign" href="#primary_role"></i> <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> <div class="error"><?php echo $errors['role_id']; ?></div>
</td> </td>
</tr> </tr>
...@@ -268,7 +280,8 @@ if (count($bks) > 1) { ...@@ -268,7 +280,8 @@ if (count($bks) > 1) {
?> ?>
<option value="0" data-quick-add>&mdash; <?php echo __('Add New');?> &mdash;</option> <option value="0" data-quick-add>&mdash; <?php echo __('Add New');?> &mdash;</option>
</select> </select>
<span style="display:inline-block;width:20px"> </span> </td>
<td>
<label class="inline checkbox"> <label class="inline checkbox">
<input type="checkbox" data-name="dept_access_alerts" value="1" /> <input type="checkbox" data-name="dept_access_alerts" value="1" />
<?php echo __('Alerts'); ?> <?php echo __('Alerts'); ?>
...@@ -280,7 +293,7 @@ if (count($bks) > 1) { ...@@ -280,7 +293,7 @@ if (count($bks) > 1) {
</tbody> </tbody>
<tbody> <tbody>
<tr class="header"> <tr class="header">
<th colspan="2"> <th colspan="3">
<?php echo __('Extended Access'); ?> <?php echo __('Extended Access'); ?>
</th> </th>
</tr> </tr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment