当前位置: 首页>>代码示例>>PHP>>正文


PHP Ticket_User::can方法代码示例

本文整理汇总了PHP中Ticket_User::can方法的典型用法代码示例。如果您正苦于以下问题:PHP Ticket_User::can方法的具体用法?PHP Ticket_User::can怎么用?PHP Ticket_User::can使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ticket_User的用法示例。


在下文中一共展示了Ticket_User::can方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepareInputForUpdate

 function prepareInputForUpdate($input)
 {
     global $LANG, $CFG_GLPI;
     // Get ticket : need for comparison
     $this->getFromDB($input['id']);
     if (isset($input["date"]) && empty($input["date"])) {
         unset($input["date"]);
     }
     if (isset($input["closedate"]) && empty($input["closedate"])) {
         unset($input["closedate"]);
     }
     if (isset($input["solvedate"]) && empty($input["solvedate"])) {
         unset($input["solvedate"]);
     }
     // check mandatory fields
     if ($CFG_GLPI["is_ticket_title_mandatory"] && isset($input['name'])) {
         $title = trim($input['name']);
         if (empty($title)) {
             addMessageAfterRedirect($LANG['tracking'][6], false, ERROR);
             unset($input['name']);
         }
     }
     if ($CFG_GLPI["is_ticket_content_mandatory"] && isset($input['content'])) {
         $content = trim($input['content']);
         if (empty($content)) {
             addMessageAfterRedirect($LANG['tracking'][7], false, ERROR);
             unset($input['content']);
         }
     }
     // Security checks
     if (is_numeric(getLoginUserID(false)) && !haveRight("assign_ticket", "1")) {
         if (isset($input["_ticket_assign"]) && isset($input['_ticket_assign']['_type']) && $input['_ticket_assign']['_type'] == 'user') {
             // must own_ticket to grab a non assign ticket
             if ($this->countUsers(self::ASSIGN) == 0) {
                 if (!haveRight("steal_ticket", "1") && !haveRight("own_ticket", "1") || !isset($input["_ticket_assign"]['users_id']) || $input["_ticket_assign"]['users_id'] != getLoginUserID()) {
                     unset($input["_ticket_assign"]);
                 }
             } else {
                 // Can not steal or can steal and not assign to me
                 if (!haveRight("steal_ticket", "1") || !isset($input["_ticket_assign"]['users_id']) || $input["_ticket_assign"]['users_id'] != getLoginUserID()) {
                     unset($input["_ticket_assign"]);
                 }
             }
         }
         // No supplier assign
         if (isset($input["suppliers_id_assign"])) {
             unset($input["suppliers_id_assign"]);
         }
         // No group
         if (isset($input["_ticket_assign"]) && isset($input['_ticket_assign']['_type']) && $input['_ticket_assign']['_type'] == 'group') {
             unset($input["_ticket_assign"]);
         }
     }
     if (is_numeric(getLoginUserID(false)) && !haveRight("update_ticket", "1")) {
         $allowed_fields = array('id');
         if ($this->canApprove() && isset($input["status"])) {
             $allowed_fields[] = 'status';
         }
         // for post-only with validate right
         $ticketval = new TicketValidation();
         if (TicketValidation::canValidate($this->fields['id']) || $ticketval->canCreate()) {
             $allowed_fields[] = 'global_validation';
         }
         // Manage assign and steal right
         if (haveRight('assign_ticket', 1) || haveRight('steal_ticket', 1)) {
             $allowed_fields[] = '_ticket_assign';
         }
         if (haveRight('assign_ticket', 1)) {
             $allowed_fields[] = 'suppliers_id_assign';
         }
         // Can only update initial fields if no followup or task already added
         if ($this->numberOfFollowups() == 0 && $this->numberOfTasks() == 0 && $this->isUser(self::REQUESTER, getLoginUserID())) {
             $allowed_fields[] = 'content';
             $allowed_fields[] = 'urgency';
             $allowed_fields[] = 'ticketcategories_id';
             $allowed_fields[] = 'itemtype';
             $allowed_fields[] = 'items_id';
             $allowed_fields[] = 'name';
         }
         if ($this->canSolve()) {
             $allowed_fields[] = 'ticketsolutiontypes_id';
             $allowed_fields[] = 'solution';
         }
         foreach ($allowed_fields as $field) {
             if (isset($input[$field])) {
                 $ret[$field] = $input[$field];
             }
         }
         $input = $ret;
     }
     // Manage fields from auto update : map rule actions to standard ones
     if (isset($input['_auto_update'])) {
         if (isset($input['_users_id_assign'])) {
             $input['_ticket_assign']['_type'] = 'user';
             $input['_ticket_assign']['users_id'] = $input['_users_id_assign'];
         }
         if (isset($input['_groups_id_assign'])) {
             $input['_ticket_assign']['_type'] = 'group';
             $input['_ticket_assign']['groups_id'] = $input['_groups_id_assign'];
         }
//.........这里部分代码省略.........
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:101,代码来源:ticket.class.php

示例2: methodsetTicketAssign

 /**
  * Assign and actor in a ticket for an authenticated user
  *
  * @param $params    array of options (ticket, id2name)
  * @param $protocol        the communication protocol used
  *
  * @return array of hashtable as glpi.getTicket
  **/
 static function methodsetTicketAssign($params, $protocol)
 {
     global $DB, $CFG_GLPI;
     if (isset($params['help'])) {
         return array('ticket' => 'integer,mandatory', 'user' => 'integer,optional', 'supplier' => 'integer,optional', 'group' => 'integer,optional', 'user_email' => 'string,optional', 'use_email_notification' => 'bool,optional', 'help' => 'bool,optional');
     }
     if (!Session::getLoginUserID()) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED);
     }
     if (!Session::haveRight("assign_ticket", "1")) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED);
     }
     if (!isset($params['user']) && !isset($params['group']) && !isset($params['supplier'])) {
         return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'user or group or supplier');
     }
     $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=' . $params['ticket']);
     }
     if (!$ticket->can($params['ticket'], 'r')) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND);
     }
     if (!$ticket->getFromDB($params['ticket'])) {
         return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND, '', 'ticket');
     }
     $ticket_user = new Ticket_User();
     $user = array('tickets_id' => $params['ticket'], 'type' => CommonITILActor::ASSIGN);
     // technician : optionnal,  default = none
     if (isset($params['user'])) {
         if (!is_numeric($params['user'])) {
             return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'user');
         }
         $user['users_id'] = $params['user'];
         if ($ticket->getFromDB($params['ticket'])) {
             $entity = $ticket->getField('entities_id');
         }
         if (!$ticket_user->can(-1, 'w', $user) || !self::checkUserRights($params['user'], "own_ticket", 1, $entity)) {
             return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED);
         }
         if ($ticket->isUser(CommonITILActor::ASSIGN, $user['users_id'])) {
             return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'User already assign for this ticket');
         }
         if (isset($params['user_email'])) {
             if (!NotificationMail::isUserAddressValid($params['user_email'])) {
                 return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'user_email');
             }
             $user['alternative_email'] = $params['user_email'];
             $user['use_notification'] = 1;
         } else {
             if (isset($params['use_email_notification']) && $params['use_email_notification']) {
                 $user['_additional_assigns'][] = array('users_id' => $params['user'], 'use_notification' => 1);
             } else {
                 if (isset($params['use_email_notification']) && !$params['use_email_notification']) {
                     $user['_additional_assigns'][] = array('users_id' => $params['user'], 'use_notification' => 0);
                 }
             }
         }
         if (!$ticket_user->add($user)) {
             return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'user not assign');
         }
     }
     // group (technicians group) : optionnal,  default = none
     $group_ticket = new Group_Ticket();
     $group = array('tickets_id' => $params['ticket'], 'type' => CommonITILActor::ASSIGN);
     if (isset($params['group'])) {
         if (!is_numeric($params['group'])) {
             return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'group');
         }
         $group['groups_id'] = $params['group'];
         if (!$group_ticket->can(-1, 'w', $group)) {
             return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED);
         }
         if ($ticket->isGroup(CommonITILActor::ASSIGN, $params['group'])) {
             return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'Group already assign for this ticket');
         }
         if (!$group_ticket->add($group)) {
             return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', 'group not assign');
         }
     }
     // supplier to assign : optionnal,  default = none
     $supplier_ticket = new Supplier_Ticket();
     $supplier = array('tickets_id' => $params['ticket'], 'type' => CommonITILActor::ASSIGN);
     if (isset($params['supplier'])) {
         if (!is_numeric($params['supplier'])) {
             return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'supplier');
         }
         $supplier['suppliers_id'] = $params['supplier'];
         if (!$supplier_ticket->can(-1, 'w', $supplier)) {
             return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED);
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:methodhelpdesk.class.php


注:本文中的Ticket_User::can方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。