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
Branches
Tags
No related merge requests found
......@@ -276,8 +276,17 @@ class TicketsAjaxAPI extends AjaxController {
}
function manageForms($ticket_id) {
$forms = DynamicFormEntry::forTicket($ticket_id);
$info = array('action' => '#tickets/'.Format::htmlchars($ticket_id).'/forms/manage');
global $thisstaff;
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');
}
......@@ -288,7 +297,7 @@ class TicketsAjaxAPI extends AjaxController {
Http::response(403, "Login required");
elseif (!($ticket = Ticket::lookup($ticket_id)))
Http::response(404, "No such ticket");
elseif (!$ticket->checkStaffPerm($thisstaff))
elseif (!$ticket->checkStaffPerm($thisstaff, Ticket::PERM_EDIT))
Http::response(403, "Access Denied");
elseif (!isset($_POST['forms']))
Http::response(422, "Send updated forms list");
......
......@@ -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();
......
......@@ -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: >
......
......@@ -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>&mdash; <?php echo __('Add New');?> &mdash;</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>&mdash; <?php echo __('Add New');?> &mdash;</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>
......
......@@ -168,11 +168,15 @@ if($ticket->isOverdue())
<?php
}
} ?>
<?php
if ($role->hasPerm(Ticket::PERM_EDIT)) { ?>
<li><a href="#ajax.php/tickets/<?php echo $ticket->getId();
?>/forms/manage" onclick="javascript:
$.dialog($(this).attr('href').substr(1), 201);
return false"
><i class="icon-paste"></i> <?php echo __('Manage Forms'); ?></a></li>
<?php
} ?>
<?php if ($thisstaff->hasPerm(Email::PERM_BANLIST)) {
if(!$emailBanned) {?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment