本文整理汇总了PHP中Document_Item::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Document_Item::find方法的具体用法?PHP Document_Item::find怎么用?PHP Document_Item::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Document_Item
的用法示例。
在下文中一共展示了Document_Item::find方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: geTimelineItems
static function geTimelineItems(Ticket $ticket, $rand)
{
global $DB, $CFG_GLPI;
$timeline = array();
$user = new User();
$group = new Group();
$followup_obj = new TicketFollowup();
$task_obj = new TicketTask();
$document_item_obj = new Document_Item();
$ticket_valitation_obj = new TicketValidation();
//checks rights
$showpublic = Session::haveRightsOr("followup", array(TicketFollowup::SEEPUBLIC, TicketFollowup::SEEPRIVATE)) && Session::haveRightsOr("task", array(TicketTask::SEEPUBLIC, TicketTask::SEEPRIVATE));
$restrict_fup = $restrict_task = "";
if (!Session::haveRight("ticket", TicketFollowup::SEEPRIVATE)) {
$restrict_fup = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "') ";
}
if (!Session::haveRight("ticket", TicketTask::SEEPRIVATE)) {
$restrict_task = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "') ";
}
if (!$showpublic) {
$restrict = " AND 1 = 0";
}
//add ticket followups to timeline
$followups = $followup_obj->find("tickets_id = " . $ticket->getID() . " {$restrict_fup}", 'date DESC');
foreach ($followups as $followups_id => $followup) {
$followup_obj->getFromDB($followups_id);
$can_edit = $followup_obj->canUpdateItem();
$followup['can_edit'] = $can_edit;
$timeline[$followup['date'] . "_followup_" . $followups_id] = array('type' => 'TicketFollowup', 'item' => $followup);
}
//add ticket tasks to timeline
$tasks = $task_obj->find("tickets_id = " . $ticket->getID() . " {$restrict_task}", 'date DESC');
foreach ($tasks as $tasks_id => $task) {
$task_obj->getFromDB($tasks_id);
$can_edit = $task_obj->canUpdateItem();
$task['can_edit'] = $can_edit;
$timeline[$task['date'] . "_task_" . $tasks_id] = array('type' => 'TicketTask', 'item' => $task);
}
//add ticket documents to timeline
$document_obj = new Document();
$document_items = $document_item_obj->find("itemtype = 'Ticket' AND items_id = " . $ticket->getID());
foreach ($document_items as $document_item) {
$document_obj->getFromDB($document_item['documents_id']);
$timeline[$document_obj->fields['date_mod'] . "_document_" . $document_item['documents_id']] = array('type' => 'Document_Item', 'item' => $document_obj->fields);
}
//add assign changes
/*$log_obj = new Log;
$gassign_items = $log_obj->find("itemtype = 'Ticket' AND items_id = ".$ticket->getID()."
AND itemtype_link = 'Group' AND linked_action = '15'");
foreach ($gassign_items as $logs_id => $gassign) {
//find group
$group_name = preg_replace("#(.*)\s\([0-9]*\)#", "$1", $gassign['new_value']);
$groups = $group->find("name = '$group_name'");
$first_group = array_shift($groups);
$group->getFromDB($first_group['id']);
$content = __("Assigned to")." : ".
"<img src='".$CFG_GLPI['root_doc']."/plugins/talk/pics/group.png' class='group_assign' />".
" <strong>".$group->getLink()."</strong>";
//find user
$user_name = preg_replace("#(.*)\s\([0-9]*\)#", "$1", $gassign['user_name']);
$users = $user->find("CONCAT(firstname, ' ', realname) = '$user_name'");
$first_user = array_shift($users);
if ($first_user == NULL) {
$first_user['id'] = false;
}
$timeline[$gassign['date_mod']."_assign_".$logs_id] = array('type' => 'Assign',
'item' => array(
'date' => $gassign['date_mod'],
'content' => $content,
'can_edit' => false,
'users_id' => $first_user['id']
));
}*/
//add existing solution
if (!empty($ticket->fields['solution'])) {
$users_id = 0;
$solution_date = $ticket->fields['solvedate'];
//search date and user of last solution in glpi_logs
if ($res_solution = $DB->query("SELECT date_mod AS solution_date, user_name FROM glpi_logs\n WHERE itemtype = 'Ticket' \n AND items_id = " . $ticket->getID() . "\n AND id_search_option = 24\n ORDER BY id DESC\n LIMIT 1")) {
$data_solution = $DB->fetch_assoc($res_solution);
if (!empty($data_solution['solution_date'])) {
$solution_date = $data_solution['solution_date'];
}
// find user
if (!empty($data_solution['user_name'])) {
$users_id = addslashes(trim(preg_replace("/.*\\(([0-9]+)\\)/", "\$1", $data_solution['user_name'])));
}
}
// fix trouble with html_entity_decode who skip accented characters (on windows browser)
$solution_content = preg_replace_callback("/(&#[0-9]+;)/", function ($m) {
return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
}, $ticket->fields['solution']);
$timeline[$solution_date . "_solution"] = array('type' => 'Solution', 'item' => array('id' => 0, 'content' => Html::clean(html_entity_decode($solution_content)), 'date' => $solution_date, 'users_id' => $users_id, 'solutiontypes_id' => $ticket->fields['solutiontypes_id'], 'can_edit' => Ticket::canUpdate() && $ticket->canSolve()));
}
// add ticket validation to timeline
if ($ticket->fields['type'] == Ticket::DEMAND_TYPE && (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEREQUEST) || Session::haveRight('ticketvalidation', TicketValidation::CREATEREQUEST)) || $ticket->fields['type'] == Ticket::INCIDENT_TYPE && (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEINCIDENT) || Session::haveRight('ticketvalidation', TicketValidation::CREATEINCIDENT))) {
$ticket_validations = $ticket_valitation_obj->find('tickets_id = ' . $ticket->getID());
//.........这里部分代码省略.........
示例2: getTimelineItems
/**
* @since version 0.90
*
**/
function getTimelineItems()
{
global $DB, $CFG_GLPI;
$timeline = array();
$user = new User();
$group = new Group();
$followup_obj = new TicketFollowup();
$task_obj = new TicketTask();
$document_item_obj = new Document_Item();
$ticket_valitation_obj = new TicketValidation();
//checks rights
$showpublic = Session::haveRightsOr("followup", array(TicketFollowup::SEEPUBLIC, TicketFollowup::SEEPRIVATE)) || Session::haveRightsOr("task", array(TicketTask::SEEPUBLIC, TicketTask::SEEPRIVATE));
$restrict_fup = $restrict_task = "";
if (!Session::haveRight("followup", TicketFollowup::SEEPRIVATE)) {
$restrict_fup = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "') ";
}
if (!Session::haveRight("task", TicketTask::SEEPRIVATE)) {
$restrict_task = " AND (`is_private` = '0'\n OR `users_id` ='" . Session::getLoginUserID() . "') ";
}
if (!$showpublic) {
$restrict = " AND 1 = 0";
}
//add ticket followups to timeline
if ($followup_obj->canview()) {
$followups = $followup_obj->find("tickets_id = " . $this->getID() . " {$restrict_fup}", 'date DESC');
foreach ($followups as $followups_id => $followup) {
$followup_obj->getFromDB($followups_id);
$followup['can_edit'] = $followup_obj->canUpdateItem();
$timeline[$followup['date'] . "_followup_" . $followups_id] = array('type' => 'TicketFollowup', 'item' => $followup);
}
}
//add ticket tasks to timeline
if ($task_obj->canview()) {
$tasks = $task_obj->find("tickets_id = " . $this->getID() . " {$restrict_task}", 'date DESC');
foreach ($tasks as $tasks_id => $task) {
$task_obj->getFromDB($tasks_id);
$task['can_edit'] = $task_obj->canUpdateItem();
$timeline[$task['date'] . "_task_" . $tasks_id] = array('type' => 'TicketTask', 'item' => $task);
}
}
//add ticket documents to timeline
$document_obj = new Document();
$document_items = $document_item_obj->find("itemtype = 'Ticket' AND items_id = " . $this->getID());
foreach ($document_items as $document_item) {
$document_obj->getFromDB($document_item['documents_id']);
$timeline[$document_obj->fields['date_mod'] . "_document_" . $document_item['documents_id']] = array('type' => 'Document_Item', 'item' => $document_obj->fields);
}
//add existing solution
if (!empty($this->fields['solution']) || !empty($this->fields['solutiontypes_id'])) {
$users_id = 0;
$solution_date = $this->fields['solvedate'];
//search date and user of last solution in glpi_logs
if ($res_solution = $DB->query("SELECT `date_mod` AS solution_date, `user_name`, `id`\n FROM `glpi_logs`\n WHERE `itemtype` = 'Ticket'\n AND `items_id` = " . $this->getID() . "\n AND `id_search_option` = 24\n ORDER BY `id` DESC\n LIMIT 1")) {
$data_solution = $DB->fetch_assoc($res_solution);
if (!empty($data_solution['solution_date'])) {
$solution_date = $data_solution['solution_date'];
}
// find user
if (!empty($data_solution['user_name'])) {
$users_id = addslashes(trim(preg_replace("/.*\\(([0-9]+)\\)/", "\$1", $data_solution['user_name'])));
}
}
// fix trouble with html_entity_decode who skip accented characters (on windows browser)
$solution_content = preg_replace_callback("/(&#[0-9]+;)/", function ($m) {
return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES");
}, $this->fields['solution']);
$timeline[$solution_date . "_solution"] = array('type' => 'Solution', 'item' => array('id' => 0, 'content' => Toolbox::unclean_cross_side_scripting_deep($solution_content), 'date' => $solution_date, 'users_id' => $users_id, 'solutiontypes_id' => $this->fields['solutiontypes_id'], 'can_edit' => Ticket::canUpdate() && $this->canSolve()));
}
// add ticket validation to timeline
if ($this->fields['type'] == Ticket::DEMAND_TYPE && (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEREQUEST) || Session::haveRight('ticketvalidation', TicketValidation::CREATEREQUEST)) || $this->fields['type'] == Ticket::INCIDENT_TYPE && (Session::haveRight('ticketvalidation', TicketValidation::VALIDATEINCIDENT) || Session::haveRight('ticketvalidation', TicketValidation::CREATEINCIDENT))) {
$ticket_validations = $ticket_valitation_obj->find('tickets_id = ' . $this->getID());
foreach ($ticket_validations as $validations_id => $validation) {
$canedit = $ticket_valitation_obj->can($validations_id, UPDATE);
$user->getFromDB($validation['users_id_validate']);
$timeline[$validation['submission_date'] . "_validation_" . $validations_id] = array('type' => 'TicketValidation', 'item' => array('id' => $validations_id, 'date' => $validation['submission_date'], 'content' => __('Validation request') . " => " . $user->getlink() . "<br>" . $validation['comment_submission'], 'users_id' => $validation['users_id'], 'can_edit' => $canedit));
if (!empty($validation['validation_date'])) {
$timeline[$validation['validation_date'] . "_validation_" . $validations_id] = array('type' => 'TicketValidation', 'item' => array('id' => $validations_id, 'date' => $validation['validation_date'], 'content' => __('Validation request answer') . " : " . _sx('status', ucfirst(TicketValidation::getStatus($validation['status']))) . "<br>" . $validation['comment_validation'], 'users_id' => $validation['users_id_validate'], 'status' => "status_" . $validation['status'], 'can_edit' => $canedit));
}
}
}
//reverse sort timeline items by key (date)
krsort($timeline);
return $timeline;
}
示例3: array
$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();
}
}
}
}
}
}
}
}
}
if (isset($_GET["id"]) && $_GET["id"] > 0) {
if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") {
示例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':
//.........这里部分代码省略.........
示例5: 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);
}