Skip to content
Snippets Groups Projects
Commit 3e2616d0 authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #2832 from greezybacon/issue/assignment-role


role: Add option to use primary role on assignment

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents b33a0315 bbeae81b
No related branches found
No related tags found
No related merge requests found
...@@ -276,8 +276,17 @@ class TicketsAjaxAPI extends AjaxController { ...@@ -276,8 +276,17 @@ class TicketsAjaxAPI extends AjaxController {
} }
function manageForms($ticket_id) { function manageForms($ticket_id) {
$forms = DynamicFormEntry::forTicket($ticket_id); global $thisstaff;
$info = array('action' => '#tickets/'.Format::htmlchars($ticket_id).'/forms/manage');
if (!$thisstaff)
Http::response(403, "Login required");
elseif (!($ticket = Ticket::lookup($ticket_id)))
Http::response(404, "No such ticket");
elseif (!$ticket->checkStaffPerm($thisstaff, Ticket::PERM_EDIT))
Http::response(403, "Access Denied");
$forms = DynamicFormEntry::forTicket($ticket->getId());
$info = array('action' => '#tickets/'.$ticket->getId().'/forms/manage');
include(STAFFINC_DIR . 'templates/form-manage.tmpl.php'); include(STAFFINC_DIR . 'templates/form-manage.tmpl.php');
} }
...@@ -288,7 +297,7 @@ class TicketsAjaxAPI extends AjaxController { ...@@ -288,7 +297,7 @@ class TicketsAjaxAPI extends AjaxController {
Http::response(403, "Login required"); Http::response(403, "Login required");
elseif (!($ticket = Ticket::lookup($ticket_id))) elseif (!($ticket = Ticket::lookup($ticket_id)))
Http::response(404, "No such ticket"); Http::response(404, "No such ticket");
elseif (!$ticket->checkStaffPerm($thisstaff)) elseif (!$ticket->checkStaffPerm($thisstaff, Ticket::PERM_EDIT))
Http::response(403, "Access Denied"); Http::response(403, "Access Denied");
elseif (!isset($_POST['forms'])) elseif (!isset($_POST['forms']))
Http::response(422, "Send updated forms list"); Http::response(422, "Send updated forms list");
......
...@@ -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>
......
...@@ -168,11 +168,15 @@ if($ticket->isOverdue()) ...@@ -168,11 +168,15 @@ if($ticket->isOverdue())
<?php <?php
} }
} ?> } ?>
<?php
if ($role->hasPerm(Ticket::PERM_EDIT)) { ?>
<li><a href="#ajax.php/tickets/<?php echo $ticket->getId(); <li><a href="#ajax.php/tickets/<?php echo $ticket->getId();
?>/forms/manage" onclick="javascript: ?>/forms/manage" onclick="javascript:
$.dialog($(this).attr('href').substr(1), 201); $.dialog($(this).attr('href').substr(1), 201);
return false" return false"
><i class="icon-paste"></i> <?php echo __('Manage Forms'); ?></a></li> ><i class="icon-paste"></i> <?php echo __('Manage Forms'); ?></a></li>
<?php
} ?>
<?php if ($thisstaff->hasPerm(Email::PERM_BANLIST)) { <?php if ($thisstaff->hasPerm(Email::PERM_BANLIST)) {
if(!$emailBanned) {?> if(!$emailBanned) {?>
......
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