本文整理汇总了PHP中Ticket::can方法的典型用法代码示例。如果您正苦于以下问题:PHP Ticket::can方法的具体用法?PHP Ticket::can怎么用?PHP Ticket::can使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ticket
的用法示例。
在下文中一共展示了Ticket::can方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sprintf
$_GET['id'] = "";
}
if (isset($_POST["add"])) {
$track->check(-1, CREATE, $_POST);
if ($id = $track->add($_POST)) {
if ($_SESSION['glpibackcreated']) {
Html::redirect($track->getFormURL() . "?id=" . $id);
}
}
Html::back();
} else {
if (isset($_POST['update'])) {
$track->check($_POST['id'], UPDATE);
$track->update($_POST);
Event::log($_POST["id"], "ticket", 4, "tracking", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
if ($track->can($_POST["id"], READ)) {
$toadd = '';
// Copy solution to KB redirect to KB
if (isset($_POST['_sol_to_kb']) && $_POST['_sol_to_kb']) {
$toadd = "&_sol_to_kb=1";
}
Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $_POST["id"] . $toadd);
}
Session::addMessageAfterRedirect(__('You have been redirected because you no longer have access to this ticket'), true, ERROR);
Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.php");
} else {
if (isset($_POST['delete'])) {
$track->check($_POST['id'], DELETE);
if ($track->delete($_POST)) {
Event::log($_POST["id"], "ticket", 4, "tracking", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
}
示例2: canViewFile
/**
* Check is the curent user is allowed to see the file
*
* @param $options array of options (only 'tickets_id' used)
*
* @return boolean
**/
function canViewFile($options)
{
global $DB, $CFG_GLPI;
if (isset($_SESSION["glpiactiveprofile"]["interface"]) && $_SESSION["glpiactiveprofile"]["interface"] == "central") {
// My doc Check and Common doc right access
if ($this->can($this->fields["id"], READ) || $this->fields["users_id"] === Session::getLoginUserID()) {
return true;
}
// Reminder Case
$query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_reminders`\n ON (`glpi_reminders`.`id` = `glpi_documents_items`.`items_id`\n AND `glpi_documents_items`.`itemtype` = 'Reminder')\n " . Reminder::addVisibilityJoins() . "\n WHERE `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n AND " . Reminder::addVisibilityRestrict();
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
return true;
}
// Knowbase Case
if (Session::haveRight("knowbase", READ)) {
$query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_knowbaseitems`\n ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`\n AND `glpi_documents_items`.`itemtype` = 'KnowbaseItem')\n " . KnowbaseItem::addVisibilityJoins() . "\n WHERE `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n AND " . KnowbaseItem::addVisibilityRestrict();
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
return true;
}
}
if (Session::haveRight('knowbase', KnowbaseItem::READFAQ)) {
$query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_knowbaseitems`\n ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`\n AND `glpi_documents_items`.`itemtype` = 'KnowbaseItem')\n " . KnowbaseItem::addVisibilityJoins() . "\n WHERE `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n AND `glpi_knowbaseitems`.`is_faq` = '1'\n AND " . KnowbaseItem::addVisibilityRestrict();
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
return true;
}
}
// Tracking Case
if (isset($options["tickets_id"])) {
$job = new Ticket();
if ($job->can($options["tickets_id"], READ)) {
$query = "SELECT *\n FROM `glpi_documents_items`\n WHERE `glpi_documents_items`.`items_id` = '" . $options["tickets_id"] . "'\n AND `glpi_documents_items`.`itemtype` = 'Ticket'\n AND `documents_id`='" . $this->fields["id"] . "'";
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
return true;
}
}
}
} else {
if (Session::getLoginUserID()) {
// ! central
// Check if it is my doc
if ($this->fields["users_id"] === Session::getLoginUserID()) {
return true;
}
// Reminder Case
$query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_reminders`\n ON (`glpi_reminders`.`id` = `glpi_documents_items`.`items_id`\n AND `glpi_documents_items`.`itemtype` = 'Reminder')\n " . Reminder::addVisibilityJoins() . "\n WHERE `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n AND " . Reminder::addVisibilityRestrict();
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
return true;
}
if (Session::haveRight('knowbase', KnowbaseItem::READFAQ)) {
// Check if it is a FAQ document
$query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_knowbaseitems`\n ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`)\n " . KnowbaseItem::addVisibilityJoins() . "\n WHERE `glpi_documents_items`.`itemtype` = 'KnowbaseItem'\n AND `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n AND `glpi_knowbaseitems`.`is_faq` = '1'\n AND " . KnowbaseItem::addVisibilityRestrict();
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
return true;
}
}
// Tracking Case
if (isset($options["tickets_id"])) {
$job = new Ticket();
if ($job->can($options["tickets_id"], READ)) {
$query = "SELECT *\n FROM `glpi_documents_items`\n WHERE `glpi_documents_items`.`items_id` = '" . $options["tickets_id"] . "'\n AND `glpi_documents_items`.`itemtype` = 'Ticket'\n AND `documents_id` = '" . $this->fields["id"] . "'";
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
return true;
}
}
}
}
}
// Public FAQ for not connected user
if ($CFG_GLPI["use_public_faq"]) {
$query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_knowbaseitems`\n ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`)\n LEFT JOIN `glpi_entities_knowbaseitems`\n ON (`glpi_knowbaseitems`.`id` = `glpi_entities_knowbaseitems`.`knowbaseitems_id`)\n WHERE `glpi_documents_items`.`itemtype` = 'KnowbaseItem'\n AND `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n AND `glpi_knowbaseitems`.`is_faq` = '1'\n AND `glpi_entities_knowbaseitems`.`entities_id` = '0'\n AND `glpi_entities_knowbaseitems`.`is_recursive` = '1'";
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
return true;
}
}
return false;
}
示例3: showForTicket
/**
* Show changes for a ticket
*
* @param $ticket Ticket object
**/
static function showForTicket(Ticket $ticket)
{
global $DB, $CFG_GLPI;
$ID = $ticket->getField('id');
if (!$ticket->can($ID, READ)) {
return false;
}
$canedit = $ticket->canEdit($ID);
$rand = mt_rand();
$query = "SELECT DISTINCT `glpi_changes_tickets`.`id` AS linkID,\n `glpi_changes`.*\n FROM `glpi_changes_tickets`\n LEFT JOIN `glpi_changes`\n ON (`glpi_changes_tickets`.`changes_id` = `glpi_changes`.`id`)\n WHERE `glpi_changes_tickets`.`tickets_id` = '{$ID}'\n ORDER BY `glpi_changes`.`name`";
$result = $DB->query($query);
$changes = array();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$changes[$data['id']] = $data;
$used[$data['id']] = $data['id'];
}
}
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='changeticket_form{$rand}' id='changeticket_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='3'>" . __('Add a change') . "</th></tr>";
echo "<tr class='tab_bg_2'><td>";
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
Change::dropdown(array('used' => $used, 'entity' => $ticket->getEntityID()));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td><td>";
if (Session::haveRight('change', CREATE)) {
echo "<a href='" . Toolbox::getItemTypeFormURL('Change') . "?tickets_id={$ID}'>";
_e('Create a change from this ticket');
echo "</a>";
}
echo "</td></tr></table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $numrows) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
echo "<tr class='noHover'><th colspan='12'>" . Change::getTypeName($numrows) . "</th>";
echo "</tr>";
if ($numrows) {
Change::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
Session::initNavigateListItems('Change', sprintf(__('%1$s = %2$s'), Ticket::getTypeName(1), $ticket->fields["name"]));
$i = 0;
foreach ($changes as $data) {
Session::addToNavigateListItems('Change', $data["id"]);
Change::showShort($data['id'], array('row_num' => $i, 'type_for_massiveaction' => __CLASS__, 'id_for_massiveaction' => $data['linkID']));
$i++;
}
Change::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand);
}
echo "</table>";
if ($canedit && $numrows) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
echo "</div>";
}
示例4: manageLinkedTicketsOnSolved
/**
* Affect the same solution for duplicates tickets
*
* @param $ID ID of the ticket id
*
* @return nothing do the change
**/
static function manageLinkedTicketsOnSolved($ID)
{
$ticket = new Ticket();
if ($ticket->getfromDB($ID)) {
$input['solution'] = addslashes($ticket->fields['solution']);
$input['solutiontypes_id'] = addslashes($ticket->fields['solutiontypes_id']);
$tickets = self::getLinkedTicketsTo($ID);
if (count($tickets)) {
foreach ($tickets as $data) {
$input['id'] = $data['tickets_id'];
if ($ticket->can($input['id'], UPDATE) && $data['link'] == self::DUPLICATE_WITH && $ticket->fields['status'] != CommonITILObject::SOLVED && $ticket->fields['status'] != CommonITILObject::CLOSED) {
$ticket->update($input);
}
}
}
}
}
示例5: explode
if (isset($_POST['update'])) {
$track->check($_POST['id'], 'w');
if (isset($_POST["_my_items"]) && !empty($_POST["_my_items"])) {
$splitter = explode("_", $_POST["_my_items"]);
if (count($splitter) == 2) {
$_POST["itemtype"] = $splitter[0];
$_POST["items_id"] = $splitter[1];
}
}
$track->update($_POST);
Event::log($_POST["id"], "ticket", 4, "tracking", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
// Copy solution to KB redirect to KB
if (isset($_POST['_sol_to_kb']) && $_POST['_sol_to_kb']) {
Html::redirect($CFG_GLPI["root_doc"] . "/front/knowbaseitem.form.php?id=new&item_itemtype=Ticket&item_items_id=" . $_POST["id"]);
} else {
if ($track->can($_POST["id"], 'r')) {
Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $_POST["id"]);
}
Session::addMessageAfterRedirect(__('You have been redirected because you no longer have access to this ticket'), true, ERROR);
Html::redirect($CFG_GLPI["root_doc"] . "/front/ticket.php");
}
} else {
if (isset($_POST['delete'])) {
$track->check($_POST['id'], 'd');
if ($track->delete($_POST)) {
Event::log($_POST["id"], "ticket", 4, "tracking", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
}
$track->redirectToList();
} else {
if (isset($_POST['purge'])) {
$track->check($_POST['id'], 'd');
示例6: canUpdateItem
/**
* Is the current user have right to update the current followup ?
*
* @return boolean
**/
function canUpdateItem()
{
if ($this->fields["users_id"] != Session::getLoginUserID() && !Session::haveRight(self::$rightname, self::UPDATEALL)) {
return false;
}
$ticket = new Ticket();
if (!$ticket->can($this->getField('tickets_id'), READ)) {
return false;
}
if ($this->fields["users_id"] === Session::getLoginUserID() && Session::haveRight(self::$rightname, self::UPDATEMY)) {
return true;
}
// Only the technician
return Session::haveRight(self::$rightname, self::UPDATEALL) || $ticket->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) || isset($_SESSION["glpigroups"]) && $ticket->haveAGroup(CommonITILActor::ASSIGN, $_SESSION['glpigroups']);
}
示例7: 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);
//.........这里部分代码省略.........
示例8: showForTicket
/**
* Print the HTML array for Items linked to a ticket
*
* @param $ticket Ticket object
*
* @return Nothing (display)
**/
static function showForTicket(Ticket $ticket)
{
global $DB, $CFG_GLPI;
$instID = $ticket->fields['id'];
if (!$ticket->can($instID, READ)) {
return false;
}
$canedit = $ticket->canEdit($instID) && isset($_SESSION["glpiactiveprofile"]) && $_SESSION["glpiactiveprofile"]["interface"] == "central";
$rand = mt_rand();
$query = "SELECT DISTINCT `itemtype`\n FROM `glpi_items_tickets`\n WHERE `glpi_items_tickets`.`tickets_id` = '{$instID}'\n ORDER BY `itemtype`";
$result = $DB->query($query);
$number = $DB->numrows($result);
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='ticketitem_form{$rand}' id='ticketitem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>";
echo "<tr class='tab_bg_1'><td>";
// Select hardware on creation or if have update right
$class = new $ticket->userlinkclass();
$tickets_user = $class->getActors($instID);
$dev_user_id = 0;
if (isset($tickets_user[CommonITILActor::REQUESTER]) && count($tickets_user[CommonITILActor::REQUESTER]) == 1) {
foreach ($tickets_user[CommonITILActor::REQUESTER] as $user_id_single) {
$dev_user_id = $user_id_single['users_id'];
}
}
if ($dev_user_id > 0) {
self::dropdownMyDevices($dev_user_id, $ticket->fields["entities_id"], null, 0, array('tickets_id' => $instID));
}
$data = array_keys(getAllDatasFromTable('glpi_items_tickets'));
$used = array();
if (!empty($data)) {
foreach ($data as $val) {
$used[$val['itemtype']] = $val['id'];
}
}
self::dropdownAllDevices("itemtype", null, 0, 1, $dev_user_id, $ticket->fields["entities_id"], array('tickets_id' => $instID));
echo "<span id='item_ticket_selection_information'></span>";
echo "</td><td class='center' width='30%'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "<input type='hidden' name='tickets_id' value='{$instID}'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && $number) {
$header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_top .= "</th>";
$header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= "</th>";
}
$header_end .= "<th>" . __('Type') . "</th>";
$header_end .= "<th>" . __('Entity') . "</th>";
$header_end .= "<th>" . __('Name') . "</th>";
$header_end .= "<th>" . __('Serial number') . "</th>";
$header_end .= "<th>" . __('Inventory number') . "</th></tr>";
echo $header_begin . $header_top . $header_end;
$totalnb = 0;
for ($i = 0; $i < $number; $i++) {
$itemtype = $DB->result($result, $i, "itemtype");
if (!($item = getItemForItemtype($itemtype))) {
continue;
}
if (in_array($itemtype, $_SESSION["glpiactiveprofile"]["helpdesk_item_type"])) {
$itemtable = getTableForItemType($itemtype);
$query = "SELECT `{$itemtable}`.*,\n `glpi_items_tickets`.`id` AS IDD,\n `glpi_entities`.`id` AS entity\n FROM `glpi_items_tickets`,\n `{$itemtable}`";
if ($itemtype != 'Entity') {
$query .= " LEFT JOIN `glpi_entities`\n ON (`{$itemtable}`.`entities_id`=`glpi_entities`.`id`) ";
}
$query .= " WHERE `{$itemtable}`.`id` = `glpi_items_tickets`.`items_id`\n AND `glpi_items_tickets`.`itemtype` = '{$itemtype}'\n AND `glpi_items_tickets`.`tickets_id` = '{$instID}'";
if ($item->maybeTemplate()) {
$query .= " AND `{$itemtable}`.`is_template` = '0'";
}
$query .= getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive()) . "\n ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`name`";
$result_linked = $DB->query($query);
$nb = $DB->numrows($result_linked);
for ($prem = true; $data = $DB->fetch_assoc($result_linked); $prem = false) {
$name = $data["name"];
if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
$name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]);
//.........这里部分代码省略.........
示例9: canUpdateItem
/**
* Is the current user have right to update the current task ?
*
* @return boolean
**/
function canUpdateItem()
{
if ($this->fields["users_id"] != getLoginUserID() && !haveRight('update_tasks', 1)) {
return false;
}
$ticket = new Ticket();
if (!$ticket->can($this->getField('tickets_id'), 'r')) {
return false;
}
return true;
}
示例10: Ticket
$ticket->update($input);
}
}
}
break;
case "link_ticket":
$ticket = new Ticket();
if (isset($_POST['link']) && isset($_POST['tickets_id_1'])) {
if ($ticket->getFromDB($_POST['tickets_id_1'])) {
foreach ($_POST["item"] as $key => $val) {
if ($val == 1) {
$input['id'] = $_POST['tickets_id_1'];
$input['_link']['tickets_id_1'] = $_POST['tickets_id_1'];
$input['_link']['link'] = $_POST['link'];
$input['_link']['tickets_id_2'] = $key;
if ($ticket->can($_POST['tickets_id_1'], 'w')) {
$ticket->update($input);
}
}
}
}
}
break;
case 'reset':
if ($_POST["itemtype"] == 'CronTask') {
checkRight('config', 'w');
$crontask = new CronTask();
foreach ($_POST["item"] as $key => $val) {
if ($val == 1 && $crontask->getFromDB($key)) {
$crontask->resetDate();
}
示例11: canViewFile
/**
* Check is the curent user is allowed to see the file
*
* @param $options array of options (only 'tickets_id' used)
*
* @return boolean
**/
function canViewFile($options)
{
global $DB, $CFG_GLPI;
if (isset($_SESSION["glpiactiveprofile"]["interface"]) && $_SESSION["glpiactiveprofile"]["interface"] == "central") {
// My doc Check and Common doc right access
if ($this->can($this->fields["id"], 'r') || $this->fields["users_id"] === getLoginUserID()) {
return true;
}
// Knowbase Case
if (haveRight("knowbase", "r")) {
$query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_knowbaseitems`\n ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`)\n WHERE `glpi_documents_items`.`itemtype` = 'KnowbaseItem'\n AND `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'" . getEntitiesRestrictRequest(' AND', 'glpi_knowbaseitems', '', '', true);
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
return true;
}
}
if (haveRight("faq", "r")) {
$query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_knowbaseitems`\n ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`)\n WHERE `glpi_documents_items`.`itemtype` = 'KnowbaseItem'\n AND `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n AND `glpi_knowbaseitems`.`is_faq` = '1'" . getEntitiesRestrictRequest(' AND', 'glpi_knowbaseitems', '', '', true);
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
return true;
}
}
// Tracking Case
if (isset($options["tickets_id"])) {
$job = new Ticket();
if ($job->can($options["tickets_id"], 'r')) {
$query = "SELECT *\n FROM `glpi_documents_items`\n WHERE `glpi_documents_items`.`items_id` = '" . $options["tickets_id"] . "'\n AND `glpi_documents_items`.`itemtype` = 'Ticket'\n AND `documents_id`='" . $this->fields["id"] . "'";
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
return true;
}
}
}
} else {
if (getLoginUserID()) {
// ! central
// Check if it is my doc
if ($this->fields["users_id"] === getLoginUserID()) {
return true;
}
if (haveRight("faq", "r")) {
// Check if it is a FAQ document
$query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_knowbaseitems`\n ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`)\n WHERE `glpi_documents_items`.`itemtype` = 'KnowbaseItem'\n AND `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n AND `glpi_knowbaseitems`.`is_faq` = '1'" . getEntitiesRestrictRequest(' AND', 'glpi_knowbaseitems', '', '', true);
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
return true;
}
}
// Tracking Case
if (isset($options["tickets_id"])) {
$job = new Ticket();
if ($job->can($options["tickets_id"], 'r')) {
$query = "SELECT *\n FROM `glpi_documents_items`\n WHERE `glpi_documents_items`.`items_id` = '" . $options["tickets_id"] . "'\n AND `glpi_documents_items`.`itemtype` = 'Ticket'\n AND `documents_id` = '" . $this->fields["id"] . "'";
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
return true;
}
}
}
}
}
// Public FAQ for not connected user
if ($CFG_GLPI["use_public_faq"]) {
$query = "SELECT *\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_knowbaseitems`\n ON (`glpi_knowbaseitems`.`id` = `glpi_documents_items`.`items_id`)\n WHERE `glpi_documents_items`.`itemtype` = 'KnowbaseItem'\n AND `glpi_documents_items`.`documents_id` = '" . $this->fields["id"] . "'\n AND `glpi_knowbaseitems`.`is_faq` = '1'\n AND `glpi_knowbaseitems`.`entities_id` = '0'\n AND `glpi_knowbaseitems`.`is_recursive` = '1'";
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
return true;
}
}
return false;
}
示例12: showForTicket
/**
* Print the ticket costs
*
* @param $ticket Ticket object
* @param $withtemplate boolean Template or basic item (default '')
*
* @return Nothing (call to classes members)
**/
static function showForTicket(Ticket $ticket, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $ticket->fields['id'];
if (!$ticket->getFromDB($ID) || !$ticket->can($ID, "r") || !Session::haveRight('ticketcost', 'r')) {
return false;
}
$canedit = Session::haveRight('ticketcost', 'w');
echo "<div class='center'>";
$query = "SELECT *\n FROM `glpi_ticketcosts`\n WHERE `tickets_id` = '{$ID}'\n ORDER BY `begin_date`";
$rand = mt_rand();
if ($canedit) {
echo "<div id='viewcost" . $ID . "_{$rand}'></div>\n";
echo "<script type='text/javascript' >\n";
echo "function viewAddCost" . $ID . "_{$rand}() {\n";
$params = array('type' => __CLASS__, 'parenttype' => 'Ticket', 'tickets_id' => $ID, 'id' => -1);
Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
echo "};";
echo "</script>\n";
echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddCost" . $ID . "_{$rand}();'>";
echo __('Add a new cost') . "</a></div>\n";
}
if ($result = $DB->query($query)) {
echo "<table class='tab_cadre_fixehov'>";
echo "<tr><th colspan='7'>" . self::getTypeName($DB->numrows($result)) . "</th>";
echo "<th>" . __('Ticket duration') . "</th>";
echo "<th>" . CommonITILObject::getActionTime($ticket->fields['actiontime']) . "</th>";
echo "</tr>";
if ($DB->numrows($result)) {
echo "<tr><th>" . __('Name') . "</th>";
echo "<th>" . __('Begin date') . "</th>";
echo "<th>" . __('End date') . "</th>";
echo "<th>" . __('Budget') . "</th>";
echo "<th>" . __('Duration') . "</th>";
echo "<th>" . __('Time cost') . "</th>";
echo "<th>" . __('Fixed cost') . "</th>";
echo "<th>" . __('Material cost') . "</th>";
echo "<th>" . __('Total cost') . "</th>";
echo "</tr>";
Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), Ticket::getTypeName(1), $ticket->getName()));
$total = 0;
$total_time = 0;
$total_costtime = 0;
$total_fixed = 0;
$total_material = 0;
while ($data = $DB->fetch_assoc($result)) {
echo "<tr class='tab_bg_2' " . ($canedit ? "style='cursor:pointer' onClick=\"viewEditCost" . $data['tickets_id'] . "_" . $data['id'] . "_{$rand}();\"" : '') . ">";
$name = empty($data['name']) ? sprintf(__('%1$s (%2$s)'), $data['name'], $data['id']) : $data['name'];
echo "<td>";
printf(__('%1$s %2$s'), $name, Html::showToolTip($data['comment'], array('display' => false)));
if ($canedit) {
echo "\n<script type='text/javascript' >\n";
echo "function viewEditCost" . $data['tickets_id'] . "_" . $data["id"] . "_{$rand}() {\n";
$params = array('type' => __CLASS__, 'parenttype' => 'Ticket', 'tickets_id' => $data["tickets_id"], 'id' => $data["id"]);
Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
echo "};";
echo "</script>\n";
}
echo "</td>";
echo "<td>" . Html::convDate($data['begin_date']) . "</td>";
echo "<td>" . Html::convDate($data['end_date']) . "</td>";
echo "<td>" . Dropdown::getDropdownName('glpi_budgets', $data['budgets_id']) . "</td>";
echo "<td>" . CommonITILObject::getActionTime($data['actiontime']) . "</td>";
$total_time += $data['actiontime'];
echo "<td class='numeric'>" . Html::formatNumber($data['cost_time']) . "</td>";
$total_costtime += $data['actiontime'] * $data['cost_time'] / HOUR_TIMESTAMP;
echo "<td class='numeric'>" . Html::formatNumber($data['cost_fixed']) . "</td>";
$total_fixed += $data['cost_fixed'];
echo "<td class='numeric'>" . Html::formatNumber($data['cost_material']) . "</td>";
$total_material += $data['cost_material'];
$cost = self::computeTotalCost($data['actiontime'], $data['cost_time'], $data['cost_fixed'], $data['cost_material']);
echo "<td class='numeric'>" . Html::formatNumber($cost) . "</td>";
$total += $cost;
echo "</tr>";
Session::addToNavigateListItems(__CLASS__, $data['id']);
}
echo "<tr class='b'><td colspan='4' class='right'>" . __('Total') . '</td>';
echo "<td>" . CommonITILObject::getActionTime($total_time) . "</td>";
echo "<td class='numeric'>" . Html::formatNumber($total_costtime) . "</td>";
echo "<td class='numeric'>" . Html::formatNumber($total_fixed) . '</td>';
echo "<td class='numeric'>" . Html::formatNumber($total_material) . '</td>';
echo "<td class='numeric'>" . Html::formatNumber($total) . '</td></tr>';
} else {
echo "<tr><th colspan='9'>" . __('No item found') . "</th></tr>";
}
echo "</table>";
}
echo "</div><br>";
}
示例13: manageLinkedTicketsOnSolved
/**
* Affect the same solution for duplicates tickets
*
* @param $ID ID of the ticket id
*
* @return nothing do the change
**/
static function manageLinkedTicketsOnSolved($ID)
{
$ticket = new Ticket();
if ($ticket->getfromDB($ID)) {
$input['solution'] = addslashes($ticket->fields['solution']);
$input['ticketsolutiontypes_id'] = addslashes($ticket->fields['ticketsolutiontypes_id']);
$tickets = self::getLinkedTicketsTo($ID);
if (count($tickets)) {
foreach ($tickets as $data) {
$input['id'] = $data['tickets_id'];
if ($ticket->can($input['id'], 'w') && $data['link'] == self::DUPLICATE_WITH && $ticket->fields['status'] != 'solved' && $ticket->fields['status'] != 'closed') {
$ticket->update($input);
}
}
}
}
}
示例14: pdfMain
static function pdfMain(PluginPdfSimplePDF $pdf, Ticket $job)
{
global $CFG_GLPI, $DB;
$ID = $job->getField('id');
if (!$job->can($ID, 'r')) {
return false;
}
$pdf->setColumnsSize(100);
$pdf->displayTitle('<b>' . (empty($job->fields["name"]) ? __('Without title') : ($name = $job->fields["name"])) . '</b>');
if (count($_SESSION['glpiactiveentities']) > 1) {
$entity = " (" . Dropdown::getDropdownName("glpi_entities", $job->fields["entities_id"]) . ")";
} else {
$entity = '';
}
$pdf->setColumnsSize(50, 50);
$recipient_name = '';
if ($job->fields["users_id_recipient"]) {
$recipient = new User();
$recipient->getFromDB($job->fields["users_id_recipient"]);
$recipient_name = $recipient->getName();
}
$sla = $due = $commentsla = '';
if ($job->fields['due_date']) {
$due = "<b><i>" . sprintf(__('%1$s: %2$s'), __('Due date') . "</b></i>", Html::convDateTime($job->fields['due_date']));
}
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Opening date') . "</i></b>", Html::convDateTime($job->fields["date"])), $due);
$pdf->setColumnsSize(100);
if ($job->fields["slas_id"] > 0) {
$sla = "<b><i>" . sprintf(__('%1$s: %2$s'), __('SLA') . "</b></i>", Html::clean(Dropdown::getDropdownName("glpi_slas", $job->fields["slas_id"])));
$slalevel = new SlaLevel();
if ($slalevel->getFromDB($job->fields['slalevels_id'])) {
$commentsla = "<b><i>" . sprintf(__('%1$s: %2$s'), __('Escalation level') . "</b></i>", $slalevel->getName());
}
$nextaction = new SlaLevel_Ticket();
if ($nextaction->getFromDBForTicket($job->fields["id"])) {
$commentsla .= " <b><i>" . sprintf(__('Next escalation: %s') . "</b></i>", Html::convDateTime($nextaction->fields['date']));
if ($slalevel->getFromDB($nextaction->fields['slalevels_id'])) {
$commentsla .= " <b><i>" . sprintf(__('%1$s: %2$s'), __('Escalation level'), $slalevel->getName());
}
}
$pdf->displayText($sla, $commentsla, 1);
}
$pdf->setColumnsSize(50, 50);
$lastupdate = Html::convDateTime($job->fields["date_mod"]);
if ($job->fields['users_id_lastupdater'] > 0) {
$lastupdate = sprintf(__('%1$s by %2$s'), $lastupdate, getUserName($job->fields["users_id_lastupdater"]));
}
$pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('By') . "</i></b>", $recipient_name), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Last update') . '</i></b>', $lastupdate));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Type') . "</i></b>", Html::clean(Ticket::getTicketTypeName($job->fields["type"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Category') . "</i></b>", Html::clean(Dropdown::getDropdownName("glpi_itilcategories", $job->fields["itilcategories_id"]))));
$status = '';
if (in_array($job->fields["status"], $job->getSolvedStatusArray()) || in_array($job->fields["status"], $job->getClosedStatusArray())) {
$status = sprintf(__('%1$s %2$s'), '-', Html::convDateTime($job->fields["solvedate"]));
}
if (in_array($job->fields["status"], $job->getClosedStatusArray())) {
$status = sprintf(__('%1$s %2$s'), '-', Html::convDateTime($job->fields["closedate"]));
}
if ($job->fields["status"] == Ticket::WAITING) {
$status = sprintf(__('%1$s %2$s'), '-', Html::convDateTime($job->fields['begin_waiting_date']));
}
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Status') . "</i></b>", Html::clean($job->getStatus($job->fields["status"])) . $status), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Request source') . "</i></b>", Html::clean(Dropdown::getDropdownName('glpi_requesttypes', $job->fields['requesttypes_id']))));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Urgency') . "</i></b>", Html::clean($job->getUrgencyName($job->fields["urgency"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Approval') . "</i></b>", TicketValidation::getStatus($job->fields['global_validation'])));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Impact') . "</i></b>", Html::clean($job->getImpactName($job->fields["impact"]))));
$pdf->displayLine("<b><i>" . sprintf(__('%1$s: %2$s'), __('Priority') . "</i></b>", Html::clean($job->getPriorityName($job->fields["priority"]))), "<b><i>" . sprintf(__('%1$s: %2$s'), __('Location') . "</i></b>", Html::clean(Dropdown::getDropdownName("glpi_locations", $job->fields["locations_id"]))));
// Item
$name = "<b><i>" . sprintf(__('%1$s: %2$s'), __('Associated element') . "</i></b>", '');
$commentitem = '';
$pdf->setColumnsSize(100);
if ($job->fields['itemtype'] && ($item = getItemForItemtype($job->fields['itemtype']))) {
if ($item->getFromDB($job->fields["items_id"])) {
$name = "<b><i>" . sprintf(__('%1$s: %2$s'), __('Associated element') . "</i></b>", $item->getNameID());
if (isset($item->fields["serial"])) {
$commentitem = ", <b><i>" . sprintf(__('%1$s: %2$s'), __('Serial number') . "</i></b>", Html::clean($item->fields["serial"]));
Html::clean($item->fields["serial"]);
}
if (isset($item->fields["otherserial"])) {
$commentitem .= ", <b><i>" . sprintf(__('%1$s: %2$s'), __('Inventory number') . "</i></b>", Html::clean($item->fields["otherserial"]));
}
if (isset($item->fields["locations_id"])) {
$commentitem .= ", <b><i>" . sprintf(__('%1$s: %2$s'), __('Location') . "</i></b>", Html::clean(Dropdown::getDropdownName("glpi_locations", $item->fields["locations_id"])));
}
}
}
$pdf->displayText($name, $commentitem, 1);
$pdf->setColumnsSize(50, 50);
// Requester
$users = array();
$listusers = '';
$requester = '<b><i>' . sprintf(__('%1$s: %2$s') . "</i></b>", __('Requester'), $listusers);
foreach ($job->getUsers(CommonITILActor::REQUESTER) as $d) {
if ($d['users_id']) {
$tmp = Html::clean(getUserName($d['users_id']));
if ($d['alternative_email']) {
$tmp .= ' (' . $d['alternative_email'] . ')';
}
} else {
$tmp = $d['alternative_email'];
}
$users[] = $tmp;
}
if (count($users)) {
//.........这里部分代码省略.........
示例15: canUpdateItem
/**
* Is the current user have right to update the current followup ?
*
* @return boolean
**/
function canUpdateItem()
{
if ($this->fields["users_id"] != getLoginUserID() && !haveRight('update_followups', 1)) {
return false;
}
$ticket = new Ticket();
if (!$ticket->can($this->getField('tickets_id'), 'r')) {
return false;
}
if ($this->fields["users_id"] === getLoginUserID() && haveRight('update_own_followups', 1)) {
return true;
}
// Only the technician
return haveRight("update_followups", "1") || $ticket->isUser(Ticket::ASSIGN, getLoginUserID()) || isset($_SESSION["glpigroups"]) && $ticket->haveAGroup(Ticket::ASSIGN, $_SESSION['glpigroups']);
}