canAddFollowups() public method

Is the current user have right to add followups to the current ticket ?
public canAddFollowups ( ) : boolean
return boolean
Beispiel #1
0
 function canCreateItem()
 {
     // From Ticket Document Tab => check right to add followup.
     if (isset($this->fields['tickets_id']) && $this->fields['tickets_id'] > 0) {
         $ticket = new Ticket();
         if ($ticket->getFromDB($this->fields['tickets_id'])) {
             return $ticket->canAddFollowups();
         }
     }
     if (Session::haveRight('document', 'w')) {
         return parent::canCreateItem();
     }
     return false;
 }
Beispiel #2
0
 function canCreateItem()
 {
     if (isset($this->input['itemtype']) && isset($this->input['items_id'])) {
         if ($item = getItemForItemtype($this->input['itemtype'])) {
             if ($item->canAddItem('Document')) {
                 return true;
             }
         }
     }
     // From Ticket Document Tab => check right to add followup.
     if (isset($this->fields['tickets_id']) && $this->fields['tickets_id'] > 0) {
         $ticket = new Ticket();
         if ($ticket->getFromDB($this->fields['tickets_id'])) {
             return $ticket->canAddFollowups();
         }
     }
     if (Session::haveRight('document', 'w')) {
         return parent::canCreateItem();
     }
     return false;
 }
 /**
  * Is the current user have right to create the current followup ?
  *
  * @return boolean
  **/
 function canCreateItem()
 {
     $ticket = new Ticket();
     if (!$ticket->can($this->getField('tickets_id'), READ)) {
         return false;
     }
     return $ticket->canAddFollowups();
 }
 /**
  * Add a document to a existing ticket
  * for an authenticated user
  *
  * @param $params array of options (ticket, uri, name, base64, comment)
  *        only one of uri and base64 must be set
  *        name is mandatory when base64 set, for extension check (filename)
  * @param $protocol     the communication protocol used
  *
  * @return array of hashtable
  **/
 static function methodAddTicketDocument($params, $protocol)
 {
     global $DB, $CFG_GLPI;
     if (isset($params['help'])) {
         return array('ticket' => 'integer,mandatory', 'uri' => 'string,optional', 'base64' => 'string,optional', 'content' => 'string,optional', 'close' => 'bool,optional', 'reopen' => 'bool,optional', 'source' => 'string,optional', 'private' => 'bool,optional', 'help' => 'bool,optional');
     }
     if (!Session::getLoginUserID()) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED);
     }
     $ticket = new Ticket();
     if (!isset($params['ticket'])) {
         return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'ticket');
     }
     if (!is_numeric($params['ticket'])) {
         return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'ticket');
     }
     if (!$ticket->can($params['ticket'], 'r')) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND);
     }
     if (in_array($ticket->fields["status"], $ticket->getClosedStatusArray())) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED, '', 'closed ticket');
     }
     if (!$ticket->canAddFollowups()) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED, '', 'access denied');
     }
     if (isset($params['name']) && !empty($params['name'])) {
         $document_name = addslashes($params['name']);
     } else {
         $document_name = addslashes(sprintf(__('%1$s %2$s'), _x('phone', 'Number'), $ticket->fields['id']));
     }
     $filename = tempnam(GLPI_DOC_DIR . '/_tmp', 'PWS');
     $response = parent::uploadDocument($params, $protocol, $filename, $document_name);
     //An error occured during document upload
     if (parent::isError($protocol, $response)) {
         return $response;
     }
     $doc = new Document();
     $documentitem = new Document_Item();
     $docid = $doc->getFromDBbyContent($ticket->fields["entities_id"], $filename);
     if ($docid) {
         $input = array('itemtype' => $ticket->getType(), 'items_id' => $ticket->getID(), 'documents_id' => $doc->getID());
         if ($DB->request('glpi_documents_items', $input)->numrows()) {
             return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'document already associated to this ticket');
         }
         $new = $documentitem->add($input);
     } else {
         $input = array('itemtype' => $ticket->getType(), 'items_id' => $ticket->getID(), 'tickets_id' => $ticket->getID(), 'entities_id' => $ticket->getEntityID(), 'is_recursive' => $ticket->isRecursive(), 'documentcategories_id' => $CFG_GLPI["documentcategories_id_forticket"]);
         $new = $doc->add($input);
     }
     // to not add it twice during followup
     unset($_FILES['filename']);
     if (!$new) {
         return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', self::getDisplayError());
     }
     if (isset($params['comment']) && !empty($params['comment'])) {
         $params['content'] = $params['comment'];
         unset($params['comment']);
     }
     if (isset($params['content']) && !empty($params['content'])) {
         return self::methodAddTicketFollowup($params, $protocol);
     }
     return self::methodGetTicket(array('ticket' => $params['ticket']), $protocol);
 }
 /**
  * Is the current user have right to create the current followup ?
  *
  * @return boolean
  **/
 function canCreateItem()
 {
     $ticket = new Ticket();
     if (!$ticket->can($this->getField('tickets_id'), READ) || in_array($ticket->fields['status'], $ticket->getClosedStatusArray())) {
         return false;
     }
     return $ticket->canAddFollowups();
 }