Merge pull request #8 from mredigonda/patch-guillermo

Patch guillermo
This commit is contained in:
Guillermo Giuliana 2019-07-21 02:52:47 -03:00 committed by GitHub
commit 4c3049a4fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 33 deletions

View File

@ -444,6 +444,7 @@ class TicketViewer extends React.Component {
} }
}).then(this.onTicketModification.bind(this)); }).then(this.onTicketModification.bind(this));
} }
addTag(tag) { addTag(tag) {
API.call({ API.call({
path: '/ticket/add-tag', path: '/ticket/add-tag',
@ -463,6 +464,7 @@ class TicketViewer extends React.Component {
} }
}).then(this.onTicketModification.bind(this)) }).then(this.onTicketModification.bind(this))
} }
onCustomResponsesChanged({index}) { onCustomResponsesChanged({index}) {
let replaceContentWithCustomResponse = () => { let replaceContentWithCustomResponse = () => {
this.setState({ this.setState({
@ -523,6 +525,7 @@ class TicketViewer extends React.Component {
commentError: true commentError: true
}); });
} }
onSubmit(formState) { onSubmit(formState) {
this.setState({ this.setState({
loading: true loading: true

View File

@ -75,10 +75,7 @@ class AdminPanelViewTicket extends React.Component {
onChange: this.retrieveTicket.bind(this), onChange: this.retrieveTicket.bind(this),
assignmentAllowed: this.props.assignmentAllowed, assignmentAllowed: this.props.assignmentAllowed,
customResponses: this.props.customResponses, customResponses: this.props.customResponses,
editable: ( editable: true
(this.state.ticket.owner && this.state.ticket.owner.id == SessionStore.getSessionData().userId) ||
(this.state.ticket.author && this.state.ticket.author.staff && this.state.ticket.author.id == SessionStore.getSessionData().userId)
)
}; };
} }

View File

@ -50,26 +50,20 @@ class ChangePriorityController extends Controller {
$ticket = Ticket::getByTicketNumber($ticketNumber); $ticket = Ticket::getByTicketNumber($ticketNumber);
$user = Controller::getLoggedUser(); $user = Controller::getLoggedUser();
if (!$user->canManageTicket($ticket)) throw new RequestException(ERRORS::NO_PERMISSION); if(!$user->canManageTicket($ticket)) throw new RequestException(ERRORS::NO_PERMISSION);
$ticket->priority = $priority;
$ticket->unread = !$ticket->isAuthor($user);
$event = Ticketevent::getEvent(Ticketevent::PRIORITY_CHANGED);
$event->setProperties(array(
'authorStaff' => Controller::getLoggedUser(),
'content' => $ticket->priority,
'date' => Date::getCurrentDate()
));
$ticket->addEvent($event);
$ticket->store();
if($ticket->owner && $user->id === $ticket->owner->id) { Log::createLog('PRIORITY_CHANGED', $ticket->ticketNumber);
$ticket->priority = $priority; Response::respondSuccess();
$ticket->unread = !$ticket->isAuthor($user);
$event = Ticketevent::getEvent(Ticketevent::PRIORITY_CHANGED);
$event->setProperties(array(
'authorStaff' => Controller::getLoggedUser(),
'content' => $ticket->priority,
'date' => Date::getCurrentDate()
));
$ticket->addEvent($event);
$ticket->store();
Log::createLog('PRIORITY_CHANGED', $ticket->ticketNumber);
Response::respondSuccess();
} else {
throw new RequestException(ERRORS::NO_PERMISSION);
}
} }
} }

View File

@ -61,19 +61,15 @@ class CloseController extends Controller {
public function handler() { public function handler() {
$this->ticket = Ticket::getByTicketNumber(Controller::request('ticketNumber')); $this->ticket = Ticket::getByTicketNumber(Controller::request('ticketNumber'));
$user = Controller::getLoggedUser();
if( if(!Controller::isStaffLogged() && Controller::isUserSystemEnabled() &&
(Controller::isUserSystemEnabled() || Controller::isStaffLogged()) && !$this->ticket->isAuthor($user)){
!$this->ticket->isOwner(Controller::getLoggedUser()) &&
!$this->ticket->isAuthor(Controller::getLoggedUser())
) {
throw new RequestException(ERRORS::NO_PERMISSION); throw new RequestException(ERRORS::NO_PERMISSION);
} }
if(Controller::isStaffLogged()){ if(Controller::isStaffLogged() && (!$user->canManageTicket($this->ticket))){
$user = Controller::getLoggedUser(); throw new RequestException(ERRORS::NO_PERMISSION);
if (!$user->canManageTicket($this->ticket)) throw new RequestException(ERRORS::NO_PERMISSION);
} }
$this->markAsUnread(); $this->markAsUnread();

View File

@ -83,7 +83,7 @@ class CommentController extends Controller {
$isOwner = $this->ticket->isOwner(Controller::getLoggedUser()); $isOwner = $this->ticket->isOwner(Controller::getLoggedUser());
$user = Controller::getLoggedUser(); $user = Controller::getLoggedUser();
if((Controller::isUserSystemEnabled() || Controller::isStaffLogged()) && !$isOwner && !$isAuthor) { if(!Controller::isStaffLogged() && Controller::isUserSystemEnabled() && !$isAuthor){
throw new RequestException(ERRORS::NO_PERMISSION); throw new RequestException(ERRORS::NO_PERMISSION);
} }