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

Merge branch 'issue/default-role' into develop-next

parents a452940a 280ec6f5
Branches
Tags
No related merge requests found
...@@ -476,8 +476,10 @@ implements AuthenticatedUser, EmailContact, TemplateVariable, Searchable { ...@@ -476,8 +476,10 @@ implements AuthenticatedUser, EmailContact, TemplateVariable, Searchable {
if ($assigned && $this->usePrimaryRoleOnAssignment()) if ($assigned && $this->usePrimaryRoleOnAssignment())
return $this->role; return $this->role;
// View only access // Ticket Create & View only access
return new Role(array()); $perms = JSONDataEncoder::encode(array(
Ticket::PERM_CREATE => 1));
return new Role(array('permissions' => $perms));
} }
function hasPerm($perm, $global=true) { function hasPerm($perm, $global=true) {
......
...@@ -118,7 +118,8 @@ if($ticket->isOverdue()) ...@@ -118,7 +118,8 @@ if($ticket->isOverdue())
|| $dept->isMember($thisstaff)) || $dept->isMember($thisstaff))
) { ?> ) { ?>
<li><a class="no-pjax ticket-action" <li><a class="no-pjax ticket-action"
data-redirect="tickets.php" data-redirect="tickets.php?id=<?php echo
$ticket->getId(); ?>"
href="#tickets/<?php echo $ticket->getId(); ?>/claim"><i href="#tickets/<?php echo $ticket->getId(); ?>/claim"><i
class="icon-chevron-sign-down"></i> <?php echo __('Claim'); ?></a> class="icon-chevron-sign-down"></i> <?php echo __('Claim'); ?></a>
<?php <?php
......
...@@ -30,7 +30,7 @@ $redirect = false; ...@@ -30,7 +30,7 @@ $redirect = false;
if($_REQUEST['id'] || $_REQUEST['number']) { if($_REQUEST['id'] || $_REQUEST['number']) {
if($_REQUEST['id'] && !($ticket=Ticket::lookup($_REQUEST['id']))) if($_REQUEST['id'] && !($ticket=Ticket::lookup($_REQUEST['id'])))
$errors['err']=sprintf(__('%s: Unknown or invalid ID.'), __('ticket')); $errors['err']=sprintf(__('%s: Unknown or invalid ID.'), __('ticket'));
elseif($_REQUEST['number'] && !($ticket=Ticket::lookup(['number' => $_REQUEST['number']]))) elseif($_REQUEST['number'] && !($ticket=Ticket::lookup(array('number' => $_REQUEST['number']))))
$errors['err']=sprintf(__('%s: Unknown or invalid number.'), __('ticket')); $errors['err']=sprintf(__('%s: Unknown or invalid number.'), __('ticket'));
elseif(!$ticket->checkStaffPerm($thisstaff)) { elseif(!$ticket->checkStaffPerm($thisstaff)) {
$errors['err']=__('Access denied. Contact admin if you believe this is in error'); $errors['err']=__('Access denied. Contact admin if you believe this is in error');
...@@ -192,9 +192,12 @@ if($_POST && !$errors): ...@@ -192,9 +192,12 @@ if($_POST && !$errors):
'ticket.response.' . $ticket->getId(), 'ticket.response.' . $ticket->getId(),
$thisstaff->getId()); $thisstaff->getId());
// Go back to the ticket listing page on reply if ($ticket->isClosed())
$ticket = null; $ticket = null;
$redirect = 'tickets.php'; $redirect = 'tickets.php';
if ($ticket)
$redirect = 'tickets.php?id='.$ticket->getId();
} elseif(!$errors['err']) { } elseif(!$errors['err']) {
$errors['err']=sprintf('%s %s', $errors['err']=sprintf('%s %s',
...@@ -225,7 +228,12 @@ if($_POST && !$errors): ...@@ -225,7 +228,12 @@ if($_POST && !$errors):
$wasOpen = ($ticket->isOpen()); $wasOpen = ($ticket->isOpen());
if(($note=$ticket->postNote($vars, $errors, $thisstaff))) { if(($note=$ticket->postNote($vars, $errors, $thisstaff))) {
$msg=__('Internal note posted successfully'); $msg = sprintf(__('%s: %s posted successfully'),
sprintf(__('Ticket #%s'),
sprintf('<a href="tickets.php?id=%d"><b>%s</b></a>',
$ticket->getId(), $ticket->getNumber())),
__('Internal note')
);
// Clear attachment list // Clear attachment list
$note_form->setSource(array()); $note_form->setSource(array());
$note_form->getField('attachments')->reset(); $note_form->getField('attachments')->reset();
...@@ -241,6 +249,9 @@ if($_POST && !$errors): ...@@ -241,6 +249,9 @@ if($_POST && !$errors):
$thisstaff->getId()); $thisstaff->getId());
$redirect = 'tickets.php'; $redirect = 'tickets.php';
if ($ticket)
$redirect ='tickets.php?id='.$ticket->getId();
} else { } else {
if(!$errors['err']) if(!$errors['err'])
...@@ -414,7 +425,7 @@ if($_POST && !$errors): ...@@ -414,7 +425,7 @@ if($_POST && !$errors):
// Drop files from the response attachments widget // Drop files from the response attachments widget
$response_form->setSource(array()); $response_form->setSource(array());
$response_form->getField('attachments')->reset(); $response_form->getField('attachments')->reset();
unset($_SESSION[':form-data']); $_SESSION[':form-data'] = null;
} elseif(!$errors['err']) { } elseif(!$errors['err']) {
$errors['err']=sprintf('%s %s', $errors['err']=sprintf('%s %s',
__('Unable to create the ticket.'), __('Unable to create the ticket.'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment