本文整理汇总了PHP中Ticket::canSolve方法的典型用法代码示例。如果您正苦于以下问题:PHP Ticket::canSolve方法的具体用法?PHP Ticket::canSolve怎么用?PHP Ticket::canSolve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ticket
的用法示例。
在下文中一共展示了Ticket::canSolve方法的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: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'solveticket':
$input = $ma->getInput();
$ticket = new Ticket();
foreach ($ids as $id) {
if ($item->can($id, READ)) {
if ($ticket->getFromDB($item->fields['tickets_id']) && $ticket->canSolve()) {
$toupdate = array();
$toupdate['id'] = $ticket->getID();
$toupdate['solutiontypes_id'] = $input['solutiontypes_id'];
$toupdate['solution'] = $input['solution'];
if ($ticket->update($toupdate)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($ticket->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($ticket->getErrorMessage(ERROR_RIGHT));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($ticket->getErrorMessage(ERROR_RIGHT));
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例3: processMassiveActionsForOneItemtype
/**
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
switch ($ma->getAction()) {
case 'add_task':
if (!($task = getItemForItemtype('TicketTask'))) {
$ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
break;
}
$ticket = new Ticket();
$field = $ticket->getForeignKeyField();
$input = $ma->getInput();
foreach ($ids as $id) {
if ($item->can($id, READ)) {
if ($ticket->getFromDB($item->fields['tickets_id'])) {
$input2 = array($field => $item->fields['tickets_id'], 'taskcategories_id' => $input['taskcategories_id'], 'actiontime' => $input['actiontime'], 'content' => $input['content']);
if ($task->can(-1, CREATE, $input2)) {
if ($task->add($input2)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
}
}
}
return;
case 'solveticket':
$input = $ma->getInput();
$ticket = new Ticket();
foreach ($ids as $id) {
if ($item->can($id, READ)) {
if ($ticket->getFromDB($item->fields['tickets_id']) && $ticket->canSolve()) {
$toupdate = array();
$toupdate['id'] = $ticket->getID();
$toupdate['solutiontypes_id'] = $input['solutiontypes_id'];
$toupdate['solution'] = $input['solution'];
if ($ticket->update($toupdate)) {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
$ma->addMessage($ticket->getErrorMessage(ERROR_ON_ACTION));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($ticket->getErrorMessage(ERROR_RIGHT));
}
} else {
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
$ma->addMessage($ticket->getErrorMessage(ERROR_RIGHT));
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例4: doSpecificMassiveActions
/**
* @see CommonDBTM::doSpecificMassiveActions()
*
* @since version 0.84
**/
function doSpecificMassiveActions($input = array())
{
$res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
switch ($input['action']) {
case "solveticket":
$ticket = new Ticket();
foreach ($input["item"] as $key => $val) {
if ($val == 1) {
if ($this->can($key, 'r')) {
if ($ticket->getFromDB($this->fields['tickets_id']) && $ticket->canSolve()) {
$toupdate = array();
$toupdate['id'] = $ticket->getID();
$toupdate['solutiontypes_id'] = $input['solutiontypes_id'];
$toupdate['solution'] = $input['solution'];
if ($ticket->update($toupdate)) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
} else {
$res['noright']++;
}
}
}
break;
default:
return parent::doSpecificMassiveActions($input);
}
return $res;
}
示例5: methodsetTicketSolution
/**
* Solution of 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 methodsetTicketSolution($params, $protocol)
{
global $DB, $CFG_GLPI;
if (isset($params['help'])) {
return array('ticket' => 'integer,mandatory', 'id2name' => 'bool,optional', 'type' => 'integer,optional', 'solution' => 'text,mandatory', '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 (!isset($params['solution'])) {
return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'solution');
}
if (isset($params['type']) && !is_numeric($params['type'])) {
return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'type=' . $params['type']);
}
if (!$ticket->can($params['ticket'], 'r')) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND, '', 'ticket');
}
if (!$ticket->getFromDB($params['ticket'])) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND, '', 'solution');
}
$input = array('id' => $ticket->getField('id'), 'solution' => addslashes(Toolbox::clean_cross_side_scripting_deep($params['solution'])), 'status' => Ticket::SOLVED);
if (isset($params['type'])) {
$input['solutiontypes_id'] = $params['type'];
}
if (!$ticket->canSolve($params['ticket'], 'w')) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED);
}
if ($ticket->update($input)) {
unset($params['solution'], $params['type']);
return self::methodGetTicket($params, $protocol);
}
return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', self::getDisplayError());
}