本文整理汇总了PHP中Ticket::canView方法的典型用法代码示例。如果您正苦于以下问题:PHP Ticket::canView方法的具体用法?PHP Ticket::canView怎么用?PHP Ticket::canView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ticket
的用法示例。
在下文中一共展示了Ticket::canView方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: view
/**
* View the ticket
*
*/
function view()
{
if ($this->active_ticket->isNew()) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
if (!$this->active_ticket->canView($this->logged_user)) {
$this->httpError(HTTP_ERR_FORBIDDEN);
}
// if
ProjectObjectViews::log($this->active_ticket, $this->logged_user);
$this->smarty->assign(array('page_back_url' => assemble_url('mobile_access_view_tickets', array('project_id' => $this->active_project->getId()))));
$this->addBreadcrumb(str_excerpt(clean($this->active_ticket->getName()), 10), mobile_access_module_get_view_url($this->active_ticket));
$this->addBreadcrumb(lang('View'));
}
示例2: changes
/**
* Show ticket changes
*
* @param void
* @return null
*/
function changes()
{
if ($this->active_ticket->isNew()) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
if (!$this->active_ticket->canView($this->logged_user)) {
$this->httpError(HTTP_ERR_FORBIDDEN);
}
// if
$this->skip_layout = $this->request->isApiCall() || $this->request->isAsyncCall();
$this->smarty->assign('changes', $this->active_ticket->getChanges());
}
示例3: getItem
/**
* Return the instance fields of itemtype identified by id
*
* @param $itemtype string itemtype (class) of object
* @param $id integer identifier of object
* @param $params array with theses options :
* - 'expand_dropdowns': Show dropdown's names instead of id. default: false. Optionnal
* - 'get_hateoas': Show relation of current item in a links attribute. default: true. Optionnal
* - 'get_sha1': Get a sha1 signature instead of the full answer. default: false. Optionnal
* - 'with_components': Only for [Computer, NetworkEquipment, Peripheral, Phone, Printer], Optionnal.
* - 'with_disks': Only for Computer, retrieve the associated filesystems. Optionnal.
* - 'with_softwares': Only for Computer, retrieve the associated softwares installations. Optionnal.
* - 'with_connections': Only for Computer, retrieve the associated direct connections (like peripherals and printers) .Optionnal.
* - 'with_networkports':Retrieve all network connections and advanced network informations. Optionnal.
* - 'with_infocoms': Retrieve financial and administrative informations. Optionnal.
* - 'with_contracts': Retrieve associated contracts. Optionnal.
* - 'with_documents': Retrieve associated external documents. Optionnal.
* - 'with_tickets': Retrieve associated itil tickets. Optionnal.
* - 'with_problems': Retrieve associated itil problems. Optionnal.
* - 'with_changes': Retrieve associated itil changes. Optionnal.
* - 'with_notes': Retrieve Notes (if exists, not all itemtypes have notes). Optionnal.
* - 'with_logs': Retrieve historical. Optionnal.
*
* @return array fields of found object
**/
protected function getItem($itemtype, $id, $params = array())
{
global $CFG_GLPI, $DB;
$this->initEndpoint();
// default params
$default = array('expand_dropdowns' => false, 'get_hateoas' => true, 'get_sha1' => false, 'with_components' => false, 'with_disks' => false, 'with_softwares' => false, 'with_connections' => false, 'with_networkports' => false, 'with_infocoms' => false, 'with_contracts' => false, 'with_documents' => false, 'with_tickets' => false, 'with_problems' => false, 'with_changes' => false, 'with_notes' => false, 'with_logs' => false);
$params = array_merge($default, $params);
$item = new $itemtype();
if (!$item->getFromDB($id)) {
return $this->messageNotfoundError();
}
if (!$item->can($id, READ)) {
return $this->messageRightError();
}
$fields = $item->fields;
// avoid disclosure of critical fields
$item::unsetUndisclosedFields($fields);
// retrieve devices
if (isset($params['with_devices']) && $params['with_devices'] && in_array($itemtype, Item_Devices::getConcernedItems())) {
$all_devices = array();
foreach (Item_Devices::getItemAffinities($item->getType()) as $device_type) {
$found_devices = getAllDatasFromTable($device_type::getTable(), "`items_id` = '" . $item->getID() . "'\n AND `itemtype` = '" . $item->getType() . "'\n AND `is_deleted` = '0'", true);
foreach ($found_devices as $devices_id => &$device) {
unset($device['items_id']);
unset($device['itemtype']);
unset($device['is_deleted']);
}
if (!empty($found_devices)) {
$all_devices[$device_type] = $found_devices;
}
}
$fields['_devices'] = $all_devices;
}
// retrieve computer disks
if (isset($params['with_disks']) && $params['with_disks'] && $itemtype == "Computer") {
// build query to retrive filesystems
$query = "SELECT `glpi_filesystems`.`name` AS fsname,\n `glpi_computerdisks`.*\n FROM `glpi_computerdisks`\n LEFT JOIN `glpi_filesystems`\n ON (`glpi_computerdisks`.`filesystems_id` = `glpi_filesystems`.`id`)\n WHERE `computers_id` = '{$id}'\n AND `is_deleted` = '0'";
$fields['_disks'] = array();
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
unset($data['computers_id']);
unset($data['is_deleted']);
$fields['_disks'][] = array('name' => $data);
}
}
}
// retrieve computer softwares
if (isset($params['with_softwares']) && $params['with_softwares'] && $itemtype == "Computer") {
$fields['_softwares'] = array();
if (!Software::canView()) {
$fields['_softwares'] = self::arrayRightError();
} else {
$query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n `glpi_softwares`.`id` AS softwares_id,\n `glpi_softwareversions`.`id` AS softwareversions_id,\n `glpi_computers_softwareversions`.`is_dynamic`,\n `glpi_softwareversions`.`states_id`,\n `glpi_softwares`.`is_valid`\n FROM `glpi_computers_softwareversions`\n LEFT JOIN `glpi_softwareversions`\n ON (`glpi_computers_softwareversions`.`softwareversions_id`\n = `glpi_softwareversions`.`id`)\n LEFT JOIN `glpi_softwares`\n ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n WHERE `glpi_computers_softwareversions`.`computers_id` = '{$id}'\n AND `glpi_computers_softwareversions`.`is_deleted` = '0'\n ORDER BY `glpi_softwares`.`name`, `glpi_softwareversions`.`name`";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$fields['_softwares'][] = $data;
}
}
}
}
// retrieve item connections
if (isset($params['with_connections']) && $params['with_connections'] && $itemtype == "Computer") {
$fields['_connections'] = array();
foreach ($CFG_GLPI["directconnect_types"] as $connect_type) {
$connect_item = new $connect_type();
if ($connect_item->canView()) {
$query = "SELECT `glpi_computers_items`.`id` AS assoc_id,\n `glpi_computers_items`.`computers_id` AS assoc_computers_id,\n `glpi_computers_items`.`itemtype` AS assoc_itemtype,\n `glpi_computers_items`.`items_id` AS assoc_items_id,\n `glpi_computers_items`.`is_dynamic` AS assoc_is_dynamic,\n " . getTableForItemType($connect_type) . ".*\n FROM `glpi_computers_items`\n LEFT JOIN `" . getTableForItemType($connect_type) . "`\n ON (`" . getTableForItemType($connect_type) . "`.`id`\n = `glpi_computers_items`.`items_id`)\n WHERE `computers_id` = '{$id}'\n AND `itemtype` = '" . $connect_type . "'\n AND `glpi_computers_items`.`is_deleted` = '0'";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$fields['_connections'][$connect_type][] = $data;
}
}
}
}
}
//.........这里部分代码省略.........
示例4: showForm
//.........这里部分代码省略.........
$a_duration_type = array();
$a_duration_type['seconds'] = __('Second(s)', 'monitoring');
$a_duration_type['minutes'] = __('Minute(s)', 'monitoring');
$a_duration_type['hours'] = __('Hour(s)', 'monitoring');
$a_duration_type['days'] = __('Day(s)', 'monitoring');
if ($createDowntime) {
Dropdown::showFromArray("duration_type", $a_duration_type, array('value' => $this->fields['duration_type']));
} else {
echo " " . $this->fields['duration_type'];
}
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Comment', 'monitoring') . "</td>";
echo "<td >";
if ($createDowntime) {
echo "<textarea cols='80' rows='4' name='comment' >" . $this->fields['comment'] . "</textarea>";
} else {
echo "<textarea cols='80' rows='4' name='comment' readonly='1' disabled='1' >" . $this->fields['comment'] . "</textarea>";
}
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('User', 'monitoring') . "</td>";
echo "<td>";
echo "<input type='hidden' name='users_id' value='" . $this->fields['users_id'] . "' />";
echo $this->getUsername();
echo "</td>";
echo "<td>" . __('Expired ?', 'monitoring') . "</td>";
echo "<td>";
echo Dropdown::getYesNo($this->fields['expired']);
echo "</td>";
echo "</tr>";
if (Ticket::canView()) {
echo "<tr class='tab_bg_1'>";
echo "<td colspan='4'> </td>";
echo "</tr>";
if ($this->isAssociatedTicket()) {
echo "<tr class='tab_bg_3'>";
echo "<td colspan='4'>" . __('Downtime associated ticket', 'monitoring') . "</td>";
echo "</tr>";
// Find ticket in DB ...
$track = new Ticket();
$track->getFromDB($this->getField("tickets_id"));
// Display ticket id, name and tracking ...
$bgcolor = $_SESSION["glpipriority_" . $track->fields["priority"]];
echo "<tr class='tab_bg_2'>";
echo "<td class='center' bgcolor='{$bgcolor}'>" . sprintf(__('%1$s: %2$s'), __('ID'), $track->fields["id"]) . "</td>";
echo "<td class='center'>";
$showprivate = Session::haveRight("show_full_ticket", 1);
$link = "<a id='ticket" . $track->fields["id"] . "' href='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $track->fields["id"];
$link .= "'>";
$link .= "<span class='b'>" . $track->getNameID() . "</span></a>";
$link = sprintf(__('%1$s (%2$s)'), $link, sprintf(__('%1$s - %2$s'), $track->numberOfFollowups($showprivate), $track->numberOfTasks($showprivate)));
$link = printf(__('%1$s %2$s'), $link, Html::showToolTip($track->fields['content'], array('applyto' => 'ticket' . $track->fields["id"], 'display' => false)));
echo "</td>";
echo "</tr>";
} else {
if ($createDowntime && Ticket::canCreate()) {
echo "<tr class='tab_bg_3'>";
echo "<td colspan='4'>" . __('Associated ticket (no declared category implies no ticket created):', 'monitoring') . "</td>";
echo "</tr>";
echo "<input type='hidden' name='redirect' value='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php' />";
echo "<input type='hidden' name='itemtype' value='" . $pmHost->getField("itemtype") . "' />";
echo "<input type='hidden' name='items_id' value='" . $pmHost->getField("items_id") . "' />";
echo '<input type="hidden" name="entities_id" value="' . $item->fields['entities_id'] . '" />';
示例5: getItem
/**
* Return the instance fields of itemtype identified by id
*
* @since version 9.1
*
* @param string $itemtype itemtype (class) of object
* @param integer $id identifier of object
* @param array $params array with theses options :
* - 'expand_dropdowns' : show dropdown's names instead of id. default: false. Optionnal
* - 'get_hateoas' : show relation of current item in a links attribute. default: true. Optionnal
* - 'with_components' : Only for [Computer, NetworkEquipment, Peripheral, Phone, Printer], Optionnal.
* - 'with_disks' : Only for Computer, retrieve the associated filesystems. Optionnal.
* - 'with_softwares' : Only for Computer, retrieve the associated softwares installations. Optionnal.
* - 'with_connections' : Only for Computer, retrieve the associated direct connections (like peripherals and printers) .Optionnal.
* - 'with_networkports' :Retrieve all network connections and advanced network informations. Optionnal.
* - 'with_infocoms' : Retrieve financial and administrative informations. Optionnal.
* - 'with_contracts' : Retrieve associated contracts. Optionnal.
* - 'with_documents' : Retrieve associated external documents. Optionnal.
* - 'with_tickets' : Retrieve associated itil tickets. Optionnal.
* - 'with_problems' : Retrieve associated itil problems. Optionnal.
* - 'with_changes' : Retrieve associated itil changes. Optionnal.
* - 'with_notes' : Retrieve Notes (if exists, not all itemtypes have notes). Optionnal.
* - 'with_logs' : Retrieve historical. Optionnal.
*
* @return array fields of found object
*/
protected function getItem($itemtype, $id, $params = array())
{
global $CFG_GLPI, $DB;
$this->initEndpoint();
// default params
$default = array('expand_dropdowns' => false, 'get_hateoas' => true, 'with_components' => false, 'with_disks' => false, 'with_softwares' => false, 'with_connections' => false, 'with_networkports' => false, 'with_infocoms' => false, 'with_contracts' => false, 'with_documents' => false, 'with_tickets' => false, 'with_problems' => false, 'with_changes' => false, 'with_notes' => false, 'with_logs' => false);
$params = array_merge($default, $params);
$item = new $itemtype();
if (!$item->getFromDB($id)) {
return $this->messageNotfoundError();
}
if (!$item->can($id, READ)) {
return $this->messageRightError();
}
$fields = $item->fields;
// retrieve devices
if (isset($params['with_devices']) && $params['with_devices'] && in_array($itemtype, Item_Devices::getConcernedItems())) {
$all_devices = array();
foreach (Item_Devices::getItemAffinities($item->getType()) as $device_type) {
$found_devices = getAllDatasFromTable($device_type::getTable(), "`items_id` = '" . $item->getID() . "'\n AND `itemtype` = '" . $item->getType() . "'\n AND `is_deleted` = '0'", true);
foreach ($found_devices as $devices_id => &$device) {
unset($device['items_id']);
unset($device['itemtype']);
unset($device['is_deleted']);
}
if (!empty($found_devices)) {
$all_devices[$device_type] = $found_devices;
}
}
$fields['_devices'] = $all_devices;
}
// retrieve computer disks
if (isset($params['with_disks']) && $params['with_disks'] && $itemtype == "Computer") {
// build query to retrive filesystems
$query = "SELECT `glpi_filesystems`.`name` AS fsname,\n `glpi_computerdisks`.*\n FROM `glpi_computerdisks`\n LEFT JOIN `glpi_filesystems`\n ON (`glpi_computerdisks`.`filesystems_id` = `glpi_filesystems`.`id`)\n WHERE `computers_id` = '{$id}'\n AND `is_deleted` = '0'";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
unset($data['computers_id']);
unset($data['is_deleted']);
$fields['_disks'][] = array('name' => $data);
}
}
}
// retrieve computer softwares
if (isset($params['with_softwares']) && $params['with_softwares'] && $itemtype == "Computer") {
$fields['_softwares'] = array();
if (!Software::canView()) {
$fields['_softwares'] = self::arrayRightError();
} else {
$query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n `glpi_softwares`.`id` AS softwares_id,\n `glpi_softwareversions`.`id` AS softwareversions_id,\n `glpi_computers_softwareversions`.`is_dynamic`,\n `glpi_softwareversions`.`states_id`,\n `glpi_softwares`.`is_valid`\n FROM `glpi_computers_softwareversions`\n LEFT JOIN `glpi_softwareversions`\n ON (`glpi_computers_softwareversions`.`softwareversions_id`\n = `glpi_softwareversions`.`id`)\n LEFT JOIN `glpi_softwares`\n ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n WHERE `glpi_computers_softwareversions`.`computers_id` = '{$id}'\n AND `glpi_computers_softwareversions`.`is_deleted` = '0'\n ORDER BY `glpi_softwares`.`name`, `glpi_softwareversions`.`name`";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$fields['_softwares'][] = $data;
}
}
}
}
// retrieve item connections
if (isset($params['with_connections']) && $params['with_connections'] && $itemtype == "Computer") {
$fields['_connections'] = array();
foreach ($CFG_GLPI["directconnect_types"] as $connect_type) {
$connect_item = new $connect_type();
if ($connect_item->canView()) {
$query = "SELECT `glpi_computers_items`.`id` AS assoc_id,\n `glpi_computers_items`.`computers_id` AS assoc_computers_id,\n `glpi_computers_items`.`itemtype` AS assoc_itemtype,\n `glpi_computers_items`.`items_id` AS assoc_items_id,\n `glpi_computers_items`.`is_dynamic` AS assoc_is_dynamic,\n " . getTableForItemType($connect_type) . ".*\n FROM `glpi_computers_items`\n LEFT JOIN `" . getTableForItemType($connect_type) . "`\n ON (`" . getTableForItemType($connect_type) . "`.`id`\n = `glpi_computers_items`.`items_id`)\n WHERE `computers_id` = '{$id}'\n AND `itemtype` = '" . $connect_type . "'\n AND `glpi_computers_items`.`is_deleted` = '0'";
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$fields['_connections'][$connect_type][] = $data;
}
}
}
}
}
// retrieve item networkports
if (isset($params['with_networkports']) && $params['with_networkports']) {
//.........这里部分代码省略.........