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


PHP Ticket_User::add方法代码示例

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


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

示例1: TicketFollowup

 function post_addItem()
 {
     global $LANG, $CFG_GLPI;
     // Add document if needed
     $this->addFiles($this->fields['id']);
     if (isset($this->input["_followup"]) && is_array($this->input["_followup"]) && strlen($this->input["_followup"]['content']) > 0) {
         $fup = new TicketFollowup();
         $type = "new";
         if (isset($this->fields["status"]) && $this->fields["status"] == "solved") {
             $type = "solved";
         }
         $toadd = array("type" => $type, "tickets_id" => $this->fields['id']);
         if (isset($this->input["_followup"]['content']) && strlen($this->input["_followup"]['content']) > 0) {
             $toadd["content"] = $this->input["_followup"]['content'];
         }
         if (isset($this->input["_followup"]['is_private'])) {
             $toadd["is_private"] = $this->input["_followup"]['is_private'];
         }
         $toadd['_no_notif'] = true;
         $fup->add($toadd);
     }
     if (isset($this->input["plan"]) || isset($this->input["_hour"]) && isset($this->input["_minute"]) && isset($this->input["realtime"]) && $this->input["realtime"] > 0) {
         $task = new TicketTask();
         $type = "new";
         if (isset($this->fields["status"]) && $this->fields["status"] == "solved") {
             $type = "solved";
         }
         $toadd = array("type" => $type, "tickets_id" => $this->fields['id']);
         if (isset($this->input["_hour"])) {
             $toadd["hour"] = $this->input["_hour"];
         }
         if (isset($this->input["_minute"])) {
             $toadd["minute"] = $this->input["_minute"];
         }
         if (isset($this->input["plan"])) {
             $toadd["plan"] = $this->input["plan"];
         }
         $toadd['_no_notif'] = true;
         $task->add($toadd);
     }
     $ticket_ticket = new Ticket_Ticket();
     // From interface
     if (isset($this->input['_link'])) {
         $this->input['_link']['tickets_id_1'] = $this->fields['id'];
         if ($ticket_ticket->can(-1, 'w', $this->input['_link'])) {
             $ticket_ticket->add($this->input['_link']);
         }
     }
     // From mailcollector : do not check rights
     if (isset($this->input["_linkedto"])) {
         $input2['tickets_id_1'] = $this->fields['id'];
         $input2['tickets_id_2'] = $this->input["_linkedto"];
         $input2['link'] = Ticket_Ticket::LINK_TO;
         $ticket_ticket->add($input2);
     }
     // Manage SLA Level : add actions
     if (isset($this->input["slas_id"]) && $this->input["slas_id"] > 0 && isset($this->input["slalevels_id"]) && $this->input["slalevels_id"] > 0) {
         $sla = new SLA();
         if ($sla->getFromDB($this->input["slas_id"])) {
             // Add first level in working table
             if ($this->input["slalevels_id"] > 0) {
                 $sla->addLevelToDo($this);
             }
         }
     }
     // Add user groups linked to tickets
     $ticket_user = new Ticket_User();
     $group_ticket = new Group_Ticket();
     if (isset($this->input["_users_id_requester"]) && ($this->input["_users_id_requester"] > 0 || isset($this->input["_users_id_requester_notif"]['alternative_email']) && !empty($this->input["_users_id_requester_notif"]['alternative_email']))) {
         $input2 = array('tickets_id' => $this->fields['id'], 'users_id' => $this->input["_users_id_requester"], 'type' => self::REQUESTER);
         if (isset($this->input["_users_id_requester_notif"])) {
             foreach ($this->input["_users_id_requester_notif"] as $key => $val) {
                 $input2[$key] = $val;
             }
         }
         $ticket_user->add($input2);
     }
     if (isset($this->input["_users_id_observer"]) && ($this->input["_users_id_observer"] > 0 || isset($this->input["_users_id_observer_notif"]['alternative_email']) && !empty($this->input["_users_id_observer_notif"]['alternative_email']))) {
         $input2 = array('tickets_id' => $this->fields['id'], 'users_id' => $this->input["_users_id_observer"], 'type' => self::OBSERVER);
         if (isset($this->input["_users_id_observer_notif"])) {
             foreach ($this->input["_users_id_observer_notif"] as $key => $val) {
                 $input2[$key] = $val;
             }
         }
         $ticket_user->add($input2);
     }
     if (isset($this->input["_users_id_assign"]) && $this->input["_users_id_assign"] > 0) {
         $input2 = array('tickets_id' => $this->fields['id'], 'users_id' => $this->input["_users_id_assign"], 'type' => self::ASSIGN);
         if (isset($this->input["_users_id_assign_notif"])) {
             foreach ($this->input["_users_id_assign_notif"] as $key => $val) {
                 $input2[$key] = $val;
             }
         }
         $ticket_user->add($input2);
     }
     if (isset($this->input["_groups_id_requester"]) && $this->input["_groups_id_requester"] > 0) {
         $group_ticket->add(array('tickets_id' => $this->fields['id'], 'groups_id' => $this->input["_groups_id_requester"], 'type' => self::REQUESTER));
     }
     if (isset($this->input["_groups_id_assign"]) && $this->input["_groups_id_assign"] > 0) {
         $group_ticket->add(array('tickets_id' => $this->fields['id'], 'groups_id' => $this->input["_groups_id_assign"], 'type' => self::ASSIGN));
//.........这里部分代码省略.........
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:101,代码来源:ticket.class.php

示例2: sprintf

         Event::log($_POST["id"], "ticket", 4, "tracking", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
         Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $_POST["id"]);
     } else {
         if (isset($_POST['addme_observer'])) {
             $ticket_user = new Ticket_User();
             $track->check($_POST['tickets_id'], READ);
             $input = array('tickets_id' => $_POST['tickets_id'], 'users_id' => Session::getLoginUserID(), 'use_notification' => 1, 'type' => CommonITILActor::OBSERVER);
             $ticket_user->add($input);
             Event::log($_POST['tickets_id'], "ticket", 4, "tracking", sprintf(__('%s adds an actor'), $_SESSION["glpiname"]));
             Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $_POST['tickets_id']);
         } else {
             if (isset($_POST['addme_assign'])) {
                 $ticket_user = new Ticket_User();
                 $track->check($_POST['tickets_id'], READ);
                 $input = array('tickets_id' => $_POST['tickets_id'], 'users_id' => Session::getLoginUserID(), 'use_notification' => 1, 'type' => CommonITILActor::ASSIGN);
                 $ticket_user->add($input);
                 Event::log($_POST['tickets_id'], "ticket", 4, "tracking", sprintf(__('%s adds an actor'), $_SESSION["glpiname"]));
                 Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $_POST['tickets_id']);
             } else {
                 if (isset($_REQUEST['delete_document'])) {
                     $document_item = new Document_Item();
                     $found_document_items = $document_item->find("itemtype = 'Ticket' " . " AND items_id = " . intval($_REQUEST['tickets_id']) . " AND documents_id = " . intval($_REQUEST['documents_id']));
                     foreach ($found_document_items as $item) {
                         $document_item->delete($item, true);
                     }
                     Html::back();
                 }
             }
         }
     }
 }
开发者ID:stweil,项目名称:glpi,代码行数:31,代码来源:ticket.form.php

示例3: 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

示例4: save

 /**
  * Save form datas to the target
  *
  * @param  PluginFormcreatorFormanswer $formanswer    Answers previously saved
  */
 public function save(PluginFormcreatorFormanswer $formanswer)
 {
     $datas = array();
     $ticket = new Ticket();
     $docItem = new Document_Item();
     $form = new PluginFormcreatorForm();
     $form->getFromDB($formanswer->fields['plugin_formcreator_forms_id']);
     // Get default request type
     $query = "SELECT id FROM `glpi_requesttypes` WHERE `name` LIKE 'Formcreator';";
     $result = $GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error());
     list($requesttypes_id) = $GLOBALS['DB']->fetch_array($result);
     $datas['requesttypes_id'] = $requesttypes_id;
     // Get predefined Fields
     $ttp = new TicketTemplatePredefinedField();
     $predefined_fields = $ttp->getPredefinedFields($this->fields['tickettemplates_id'], true);
     $datas = array_merge($datas, $predefined_fields);
     // Parse datas and tags
     $datas['name'] = addslashes($this->parseTags($this->fields['name'], $formanswer));
     $datas['content'] = htmlentities($this->parseTags($this->fields['comment'], $formanswer));
     $datas['entities_id'] = isset($_SESSION['glpiactive_entity']) ? $_SESSION['glpiactive_entity'] : $form->fields['entities_id'];
     $datas['_users_id_requester'] = 0;
     $datas['_users_id_recipient'] = $_SESSION['glpiID'];
     $datas['_tickettemplates_id'] = $this->fields['tickettemplates_id'];
     // Define due date
     $answer = new PluginFormcreatorAnswer();
     $found = $answer->find('plugin_formcreator_formanwers_id = ' . (int) $formanswer->fields['id'] . ' AND plugin_formcreator_question_id = ' . (int) $this->fields['due_date_question']);
     $date = array_shift($found);
     $str = "+" . $this->fields['due_date_value'] . " " . $this->fields['due_date_period'];
     switch ($this->fields['due_date_rule']) {
         case 'answer':
             $due_date = $date['answer'];
             break;
         case 'ticket':
             $due_date = date('Y-m-d H:i:s', strtotime($str));
             break;
         case 'calcul':
             $due_date = date('Y-m-d H:i:s', strtotime($date['answer'] . " " . $str));
             break;
         default:
             $due_date = null;
             break;
     }
     if (!is_null($due_date)) {
         $datas['due_date'] = $due_date;
     }
     // Select ticket actors
     $query = "SELECT id, actor_type, actor_value, use_notification\n                FROM glpi_plugin_formcreator_targettickets_actors\n                WHERE plugin_formcreator_targettickets_id = " . $this->getID() . "\n                AND actor_role = 'requester'";
     $result = $GLOBALS['DB']->query($query);
     // If there is only one requester add it on creation, otherwize we will add them later
     if ($GLOBALS['DB']->numrows($result) == 1) {
         $actor = $GLOBALS['DB']->fetch_array($result);
         switch ($actor['actor_type']) {
             case 'creator':
                 $user_id = $formanswer->fields['requester_id'];
                 break;
             case 'validator':
                 $user_id = $formanswer->fields['validator_id'];
                 break;
             case 'person':
             case 'group':
             case 'supplier':
                 $user_id = $actor['actor_value'];
                 break;
             case 'question_person':
             case 'question_group':
             case 'question_supplier':
                 $answer = new PluginFormcreatorAnswer();
                 $found = $answer->find('`plugin_formcreator_question_id` = ' . (int) $actor['actor_value'] . ' AND `plugin_formcreator_formanwers_id` = ' . (int) $formanswer->fields['id']);
                 $found = array_shift($found);
                 if (empty($found['answer'])) {
                     continue;
                 } else {
                     $user_id = (int) $found['answer'];
                 }
                 break;
         }
         $datas['_users_id_requester'] = $user_id;
     }
     // Create the target ticket
     if (!($ticketID = $ticket->add($datas))) {
         return false;
     }
     // Add link between Ticket and FormAnswer
     $itemlink = new Item_Ticket();
     $itemlink->add(array('itemtype' => 'PluginFormcreatorFormanswer', 'items_id' => $formanswer->fields['id'], 'tickets_id' => $ticketID));
     // Add actors to ticket
     $query = "SELECT id, actor_role, actor_type, actor_value, use_notification\n                FROM glpi_plugin_formcreator_targettickets_actors\n                WHERE plugin_formcreator_targettickets_id = " . $this->getID();
     $result = $GLOBALS['DB']->query($query);
     while ($actor = $GLOBALS['DB']->fetch_array($result)) {
         // If actor type is validator and if the form doesn't have a validator, continue to other actors
         if ($actor['actor_type'] == 'validator' && !$form->fields['validation_required']) {
             continue;
         }
         switch ($actor['actor_role']) {
             case 'requester':
//.........这里部分代码省略.........
开发者ID:ChristopheG77,项目名称:formcreator,代码行数:101,代码来源:targetticket.class.php

示例5: qualification

 /**
  * On ticket category change, add ticket category group and user
  * @param  CommonDBTM $item
  * @return nothing
  */
 static function qualification(CommonDBTM $item)
 {
     global $DB;
     //get auto-assign mode (config in entity)
     $auto_assign_mode = Entity::getUsedConfig('auto_assign_mode', $_SESSION['glpiactive_entity']);
     if ($auto_assign_mode == Entity::CONFIG_NEVER) {
         return true;
     }
     //get category
     $category = new ITILCategory();
     $category->getFromDB($item->input['itilcategories_id']);
     //category group
     if (!empty($category->fields['groups_id']) && $_SESSION['plugins']['escalade']['config']['reassign_group_from_cat']) {
         $group_ticket = new Group_Ticket();
         //check if group is not already present
         $group_found = $group_ticket->find("tickets_id = '" . $item->fields['id'] . "' AND groups_id = '" . $category->fields['groups_id'] . "' AND type = 2");
         if (empty($group_found)) {
             //add group to ticket
             $group_ticket->add(array('tickets_id' => $item->fields['id'], 'groups_id' => $category->fields['groups_id'], 'type' => CommonITILActor::ASSIGN));
         }
     }
     //category user
     if (!empty($category->fields['users_id']) && $_SESSION['plugins']['escalade']['config']['reassign_tech_from_cat']) {
         $ticket_user = new Ticket_User();
         //check if user is not already present
         $user_found = $ticket_user->find("tickets_id = '" . $item->fields['id'] . "' AND users_id = '" . $category->fields['users_id'] . "' AND type = 2");
         if (empty($user_found)) {
             //add user to ticket
             $ticket_user->add(array('tickets_id' => $item->fields['id'], 'users_id' => $category->fields['users_id'], 'type' => CommonITILActor::ASSIGN));
         }
     }
 }
开发者ID:korial29,项目名称:escalade,代码行数:37,代码来源:ticket.class.php

示例6: createSubTicket

 /**
  * 
  * @param type $items_id id of the ticket
  */
 static function createSubTicket($items_id)
 {
     global $CFG_GLPI;
     if ($_POST['slas_id'] == 0 || $_POST['groupsubticket'] == 0) {
         //         return;
     }
     $ticket = new Ticket();
     $ticketFollowup = new TicketFollowup();
     $ticketTask = new TicketTask();
     $document_Item = new Document_Item();
     $ticket_User = new Ticket_User();
     $group_Ticket = new Group_Ticket();
     // Disable send notification
     $use_mailing = $CFG_GLPI["use_mailing"];
     $CFG_GLPI["use_mailing"] = false;
     $ticket->getFromDB($items_id);
     unset($ticket->fields['id']);
     $ticket->fields['_link']['link'] = 1;
     $ticket->fields['_link']['tickets_id_1'] = 0;
     $ticket->fields['_link']['tickets_id_2'] = $items_id;
     $ticket->fields['bypassgrouponadd'] = true;
     $ticket->fields['slas_id'] = $_POST['slas_id'];
     $ticket->fields['date'] = date("Y-m-d H:i:s");
     $ticket->fields = Toolbox::addslashes_deep($ticket->fields);
     foreach ($ticket->fields as $key => $value) {
         if ($value == '') {
             unset($ticket->fields[$key]);
         }
     }
     $new_tickets_id = $ticket->add($ticket->fields);
     $a_followups = $ticketFollowup->find("`tickets_id`='" . $items_id . "'", "`id`");
     foreach ($a_followups as $data) {
         unset($data['id']);
         $data = Toolbox::addslashes_deep($data);
         $data['tickets_id'] = $new_tickets_id;
         $ticketFollowup->add($data);
     }
     $a_tasks = $ticketTask->find("`tickets_id`='" . $items_id . "'", "`id`");
     foreach ($a_tasks as $data) {
         unset($data['id']);
         $data = Toolbox::addslashes_deep($data);
         $data['tickets_id'] = $new_tickets_id;
         foreach ($data as $key => $value) {
             if ($value == '') {
                 unset($data[$key]);
             }
         }
         $ticketTask->add($data);
     }
     $a_documents = $document_Item->find("`items_id`='" . $items_id . "'\n         AND `itemtype`='Ticket'", "`id`");
     foreach ($a_documents as $data) {
         unset($data['id']);
         $data = Toolbox::addslashes_deep($data);
         $data['items_id'] = $new_tickets_id;
         $document_Item->add($data);
     }
     $a_ticketusers = $ticket_User->find("`tickets_id`='" . $items_id . "'\n         AND `type`='1'", "`id`");
     foreach ($a_ticketusers as $data) {
         unset($data['id']);
         $data = Toolbox::addslashes_deep($data);
         $data['tickets_id'] = $new_tickets_id;
         $ticket_User->add($data);
     }
     $a_ticketgroups = $group_Ticket->find("`tickets_id`='" . $items_id . "'\n         AND `type`='1'", "`id`");
     foreach ($a_ticketgroups as $data) {
         unset($data['id']);
         $data = Toolbox::addslashes_deep($data);
         $data['tickets_id'] = $new_tickets_id;
         $group_Ticket->add($data);
     }
     $CFG_GLPI["use_mailing"] = $use_mailing;
     $input = array();
     $input['tickets_id'] = $new_tickets_id;
     $input['groups_id'] = $_POST['groupsubticket'];
     $input['type'] = 2;
     $group_Ticket->add($input);
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:81,代码来源:ticketcopy.class.php


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