/**
  * Is the current user have right to update the current satisfaction
  *
  * @return boolean
  **/
 function canUpdateItem()
 {
     $ticket = new Ticket();
     if (!$ticket->getFromDB($this->fields['tickets_id'])) {
         return false;
     }
     // you can't change if your answer > 12h
     if (!is_null($this->fields['date_answered']) && strtotime("now") - strtotime($this->fields['date_answered']) > 12 * HOUR_TIMESTAMP) {
         return false;
     }
     if ($ticket->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID()) || $ticket->fields["users_id_recipient"] === Session::getLoginUserID() || isset($_SESSION["glpigroups"]) && $ticket->haveAGroup(CommonITILActor::REQUESTER, $_SESSION["glpigroups"])) {
         return true;
     }
     return false;
 }
 /**
  * Is the current user have right to update the current followup ?
  *
  * @return boolean
  **/
 function canUpdateItem()
 {
     if ($this->fields["users_id"] != Session::getLoginUserID() && !Session::haveRight(self::$rightname, self::UPDATEALL)) {
         return false;
     }
     $ticket = new Ticket();
     if (!$ticket->can($this->getField('tickets_id'), READ)) {
         return false;
     }
     if ($this->fields["users_id"] === Session::getLoginUserID() && Session::haveRight(self::$rightname, self::UPDATEMY)) {
         return true;
     }
     // Only the technician
     return Session::haveRight(self::$rightname, self::UPDATEALL) || $ticket->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) || isset($_SESSION["glpigroups"]) && $ticket->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups']);
 }
 /**
  * Is the current user have right to create the current task ?
  *
  * @return boolean
  **/
 function canCreateItem()
 {
     if (!parent::canReadITILItem()) {
         return false;
     }
     $ticket = new Ticket();
     if ($ticket->getFromDB($this->fields['tickets_id'])) {
         return Session::haveRight(self::$rightname, self::ADDALLTICKET) || $ticket->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) || isset($_SESSION["glpigroups"]) && $ticket->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups']);
     }
     return false;
 }
 /**
  * Is the current user have right to update the current followup ?
  *
  * @return boolean
  **/
 function canUpdateItem()
 {
     if ($this->fields["users_id"] != getLoginUserID() && !haveRight('update_followups', 1)) {
         return false;
     }
     $ticket = new Ticket();
     if (!$ticket->can($this->getField('tickets_id'), 'r')) {
         return false;
     }
     if ($this->fields["users_id"] === getLoginUserID() && haveRight('update_own_followups', 1)) {
         return true;
     }
     // Only the technician
     return haveRight("update_followups", "1") || $ticket->isUser(Ticket::ASSIGN, getLoginUserID()) || isset($_SESSION["glpigroups"]) && $ticket->haveAGroup(Ticket::ASSIGN, $_SESSION['glpigroups']);
 }
 /**
  * check right for Approve ticket Solution
  * for an authenticated user and a particular user
  *
  * @param $users_id  user id used for check ticket right
  * @param $ticket    ticket object
  *
  * @return array of hashtable
  **/
 static function checkApprobationSolution($users_id, Ticket $ticket)
 {
     if (!self::checkUserRights(Session::getLoginUserID(), 'update_ticket', 1, $ticket->getField('entities_id'))) {
         return false;
     }
     if (!($ticket->fields["users_id_recipient"] === $users_id || $ticket->isUser(CommonITILActor::REQUESTER, $users_id) || sizeof(Group_User::getUserGroups($users_id) > 0) && $ticket->haveAGroup(CommonITILActor::REQUESTER, Group_User::getUserGroups($users_id)))) {
         return false;
     }
     return true;
 }
 /**
  * Is the current user have right to create the current task ?
  *
  * @return boolean
  **/
 function canCreateItem()
 {
     $ticket = new Ticket();
     if (!$ticket->can($this->getField('tickets_id'), 'r')) {
         return false;
     }
     return haveRight("global_add_tasks", "1") || $ticket->isUser(Ticket::ASSIGN, getLoginUserID()) || isset($_SESSION["glpigroups"]) && $ticket->haveAGroup(Ticket::ASSIGN, $_SESSION['glpigroups']);
 }
 /**
  * check right for Approve ticket Solution
  * for an authenticated user and a particular user
  *
  * @param $users_id  user id used for check ticket right
  * @param $ticket    ticket object
  *
  * @return array of hashtable
  **/
 static function checkApprobationSolution($users_id, Ticket $ticket)
 {
     if (!($ticket->fields["users_id_recipient"] === $users_id || $ticket->isUser(CommonITILActor::REQUESTER, $users_id) || sizeof(Group_User::getUserGroups($users_id) > 0) && $ticket->haveAGroup(CommonITILActor::REQUESTER, Group_User::getUserGroups($users_id)))) {
         return false;
     }
     return true;
 }