/** * Check right on an item - overloaded to check user access to its datas * * @param $ID ID of the item (-1 if new item) * @param $right Right to check : r / w / recursive * @param $input array of input data (used for adding item) * * @return boolean **/ function can($ID, $right, &$input = NULL) { if ($ID > 0) { if ($this->fields['users_id'] === getLoginUserID()) { return true; } } return parent::can($ID, $right, $input); }
/** * Is the current user have right to update the current satisfaction * * @return boolean */ function canUpdateItem() { $ticket = new Ticket(); if (!$ticket->getFromDB($this->fields['tickets_id'])) { return false; } // you can't change if your answer > 12h if (!is_null($this->fields['date_answered']) && strtotime("now") - strtotime($this->fields['date_answered']) > 12 * HOUR_TIMESTAMP) { return false; } if ($ticket->isUser(Ticket::REQUESTER, getLoginUserID()) || $ticket->fields["users_id_recipient"] === getLoginUserID() || isset($_SESSION["glpigroups"]) && $ticket->haveAGroup(Ticket::REQUESTER, $_SESSION["glpigroups"])) { return true; } return false; }
static function countForItem(CommonDBTM $item) { $restrict = "`glpi_documents_items`.`documents_id` = `glpi_documents`.`id`\n AND `glpi_documents_items`.`items_id` = '" . $item->getField('id') . "'\n AND `glpi_documents_items`.`itemtype` = '" . $item->getType() . "'"; if (getLoginUserID()) { $restrict .= getEntitiesRestrictRequest(" AND ", "glpi_documents", '', '', true); } else { // Anonymous access from FAQ $restrict .= " AND `glpi_documents`.`entities_id` = '0' "; } $nb = countElementsInTable(array('glpi_documents_items', 'glpi_documents'), $restrict); // Document case : search in both if ($item->getType() == 'Document') { $restrict = "`glpi_documents_items`.`items_id` = `glpi_documents`.`id`\n AND `glpi_documents_items`.`documents_id` = '" . $item->getField('id') . "'\n AND `glpi_documents_items`.`itemtype` = '" . $item->getType() . "'"; if (getLoginUserID()) { $restrict .= getEntitiesRestrictRequest(" AND ", "glpi_documents", '', '', true); } else { // Anonymous access from FAQ $restrict .= " AND `glpi_documents`.`entities_id` = '0' "; } $nb += countElementsInTable(array('glpi_documents_items', 'glpi_documents'), $restrict); } return $nb; }
/** * Show bookmarks list * * @param $target target to use for links * @param $is_private show private of public bookmarks ? * * @return nothing **/ function showBookmarkList($target, $is_private = 1) { global $DB, $LANG, $CFG_GLPI; if (!$is_private && !haveRight('bookmark_public', 'r')) { return false; } $query = "SELECT `" . $this->getTable() . "`.*,\n `glpi_bookmarks_users`.`id` AS IS_DEFAULT\n FROM `" . $this->getTable() . "`\n LEFT JOIN `glpi_bookmarks_users`\n ON (`" . $this->getTable() . "`.`itemtype` = `glpi_bookmarks_users`.`itemtype`\n AND `" . $this->getTable() . "`.`id` = `glpi_bookmarks_users`.`bookmarks_id`)\n WHERE "; if ($is_private) { $query .= "(`" . $this->getTable() . "`.`is_private`='1'\n AND `" . $this->getTable() . "`.`users_id`='" . getLoginUserID() . "') "; } else { $query .= "(`" . $this->getTable() . "`.`is_private`='0' " . getEntitiesRestrictRequest("AND", $this->getTable(), "", "", true) . ")"; } $query .= " ORDER BY `itemtype`, `name`"; if ($result = $DB->query($query)) { $rand = mt_rand(); echo "<form method='post' id='form_load_bookmark{$rand}' action=\"{$target}\">"; echo "<div class='center' id='tabsbody' >"; echo "<table class='tab_cadrehov' width='" . self::WIDTH . "px'>"; echo "<tr>"; echo "<th class='center' colspan='3'>" . $LANG['buttons'][52] . " " . $LANG['bookmark'][1] . "</th>"; echo "<th width='20px'> </th>"; echo "<th>" . $LANG['bookmark'][6] . "</th></tr>"; if ($DB->numrows($result)) { $current_type = -1; $current_type_name = NOT_AVAILABLE; while ($this->fields = $DB->fetch_assoc($result)) { if ($current_type != $this->fields['itemtype']) { $current_type = $this->fields['itemtype']; $current_type_name = NOT_AVAILABLE; if ($current_type == "States") { $current_type_name = $LANG['state'][0]; } else { if (class_exists($current_type)) { $item = new $current_type(); $current_type_name = $item->getTypeName(); } } } $canedit = $this->can($this->fields["id"], "w"); echo "<tr class='tab_bg_1'>"; echo "<td width='10px'>"; if ($canedit) { $sel = ""; if (isset($_GET["select"]) && $_GET["select"] == "all") { $sel = "checked"; } echo "<input type='checkbox' name='bookmark[" . $this->fields["id"] . "]'" . $sel . ">"; } else { echo " "; } echo "</td>"; echo "<td>{$current_type_name}</td>"; echo "<td><a href=\"" . GLPI_ROOT . "/front/popup.php?popup=load_bookmark&id=" . $this->fields["id"] . "\">" . $this->fields["name"] . "</a></td>"; if ($canedit) { echo "<td><a href=\"" . GLPI_ROOT . "/front/popup.php?popup=edit_bookmark&id=" . $this->fields["id"] . "\">\n <img src='" . $CFG_GLPI["root_doc"] . "/pics/edit.png' alt='" . $LANG['buttons'][14] . "'></a></td>"; } else { echo "<td> </td>"; } echo "<td class='center'>"; if ($this->fields['type'] == BOOKMARK_SEARCH) { if (is_null($this->fields['IS_DEFAULT'])) { echo "<a href=\"" . GLPI_ROOT . "/front/popup.php?popup=edit_bookmark&\n mark_default=1&id=" . $this->fields["id"] . "\">" . $LANG['choice'][0] . "</a>"; } else { echo "<a href=\"" . GLPI_ROOT . "/front/popup.php?popup=edit_bookmark&\n mark_default=0&id=" . $this->fields["id"] . "\">" . $LANG['choice'][1] . "</a>"; } } echo "</td></tr>"; } echo "</table></div>"; openArrowMassive("form_load_bookmark{$rand}"); closeArrowMassive('delete_several', $LANG['buttons'][6]); } else { echo "<tr class='tab_bg_1'><td colspan='5'>" . $LANG['bookmark'][3] . "</td></tr></table>"; } echo '</form>'; } }
/** * Get tickets count * * @param $foruser boolean : only for current login user as requester */ static function showCentralCount($foruser = false) { global $DB, $CFG_GLPI, $LANG; // show a tab with count of jobs in the central and give link if (!haveRight("show_all_ticket", "1") && !haveRight("create_ticket", 1)) { return false; } if (!haveRight("show_all_ticket", "1")) { $foruser = true; } $query = "SELECT `status`,\n COUNT(*) AS COUNT\n FROM `glpi_tickets` "; if ($foruser) { $query .= " LEFT JOIN `glpi_tickets_users`\n ON (`glpi_tickets`.`id` = `glpi_tickets_users`.`tickets_id`)"; } $query .= getEntitiesRestrictRequest("WHERE", "glpi_tickets"); if ($foruser) { $query .= " AND `glpi_tickets_users`.`type` = '" . self::REQUESTER . "'\n AND `glpi_tickets_users`.`users_id` = '" . getLoginUserID() . "' "; } $query .= "GROUP BY `status`"; $result = $DB->query($query); $status = array('new' => 0, 'assign' => 0, 'plan' => 0, 'waiting' => 0, 'solved' => 0, 'closed' => 0); if ($DB->numrows($result) > 0) { while ($data = $DB->fetch_assoc($result)) { $status[$data["status"]] = $data["COUNT"]; } } $options['field'][0] = 12; $options['searchtype'][0] = 'equals'; $options['contains'][0] = 'process'; $options['link'][0] = 'AND'; $options['reset'] = 'reset'; echo "<table class='tab_cadrehov' >"; echo "<tr><th colspan='2'>"; if ($foruser) { echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php?create_ticket=1\">" . $LANG['profiles'][5] . " <img src='" . $CFG_GLPI["root_doc"] . "/pics/menu_add.png' title=\"" . $LANG['buttons'][8] . "\" alt=\"" . $LANG['buttons'][8] . "\"></a>"; } else { echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . append_params($options, '&') . "\">" . $LANG['title'][10] . "</a></th></tr>"; } echo "</th></tr>"; echo "<tr><th>" . $LANG['title'][28] . "</th><th>" . $LANG['tracking'][29] . "</th></tr>"; $options['contains'][0] = 'new'; echo "<tr class='tab_bg_2'>"; echo "<td><a href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . append_params($options, '&') . "\">" . $LANG['tracking'][30] . "</a></td>"; echo "<td>" . $status["new"] . "</td></tr>"; $options['contains'][0] = 'assign'; echo "<tr class='tab_bg_2'>"; echo "<td><a href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . append_params($options, '&') . "\">" . $LANG['tracking'][31] . "</a></td>"; echo "<td>" . $status["assign"] . "</td></tr>"; $options['contains'][0] = 'plan'; echo "<tr class='tab_bg_2'>"; echo "<td><a href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . append_params($options, '&') . "\">" . $LANG['tracking'][32] . "</a></td>"; echo "<td>" . $status["plan"] . "</td></tr>"; $options['contains'][0] = 'waiting'; echo "<tr class='tab_bg_2'>"; echo "<td><a href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . append_params($options, '&') . "\">" . $LANG['joblist'][26] . "</a></td>"; echo "<td>" . $status["waiting"] . "</td></tr>"; $options['contains'][0] = 'solved'; echo "<tr class='tab_bg_2'>"; echo "<td><a href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . append_params($options, '&') . "\">" . $LANG['job'][15] . "</a></td>"; echo "<td>" . $status["solved"] . "</td></tr>"; $options['contains'][0] = 'closed'; echo "<tr class='tab_bg_2'>"; echo "<td><a href=\"" . $CFG_GLPI["root_doc"] . "/front/ticket.php?" . append_params($options, '&') . "\">" . $LANG['joblist'][33] . "</a></td>"; echo "<td>" . $status["closed"] . "</td></tr>"; echo "</table><br>"; }
/** * Print the helpdesk * * @param $ID int : ID of the user who want to display the Helpdesk * @param $from_helpdesk int : is display from the helpdesk.php ? * * @return nothing (print the helpdesk) **/ function printHelpDesk($ID, $from_helpdesk) { global $DB, $CFG_GLPI, $LANG; if (!haveRight("create_ticket", "1")) { return false; } if (haveRight('validate_ticket', 1)) { $opt = array(); $opt['reset'] = 'reset'; $opt['field'][0] = 55; // validation status $opt['searchtype'][0] = 'equals'; $opt['contains'][0] = 'waiting'; $opt['link'][0] = 'AND'; $opt['field'][1] = 59; // validation aprobator $opt['searchtype'][1] = 'equals'; $opt['contains'][1] = getLoginUserID(); $opt['link'][1] = 'AND'; $url_validate = $CFG_GLPI["root_doc"] . "/front/ticket.php?" . append_params($opt, '&'); if (TicketValidation::getNumberTicketsToValidate(getLoginUserID()) > 0) { echo "<a href='{$url_validate}' title=\"" . $LANG['validation'][15] . "\"\n alt=\"" . $LANG['validation'][15] . "\">" . $LANG['validation'][33] . "</a><br><br>"; } } $query = "SELECT `email`, `realname`, `firstname`, `name`\n FROM `glpi_users`\n WHERE `id` = '{$ID}'"; $result = $DB->query($query); $email = $DB->result($result, 0, "email"); // Get saved data from a back system $use_email_notification = 1; if ($email == "") { $use_email_notification = 0; } $itemtype = 0; $items_id = ""; $content = ""; $title = ""; $ticketcategories_id = 0; $urgency = 3; $type = 0; if (isset($_SESSION["helpdeskSaved"]['_users_id_requester_notif']) && isset($_SESSION["helpdeskSaved"]['_users_id_requester_notif']['use_notification'])) { $use_email_notification = stripslashes($_SESSION["helpdeskSaved"]['_users_id_requester_notif']['use_notification']); } if (isset($_SESSION["helpdeskSaved"]["email"])) { $email = stripslashes($_SESSION["helpdeskSaved"]["user_email"]); } if (isset($_SESSION["helpdeskSaved"]["itemtype"])) { $itemtype = stripslashes($_SESSION["helpdeskSaved"]["itemtype"]); } if (isset($_SESSION["helpdeskSaved"]["items_id"])) { $items_id = stripslashes($_SESSION["helpdeskSaved"]["items_id"]); } if (isset($_SESSION["helpdeskSaved"]["content"])) { $content = cleanPostForTextArea($_SESSION["helpdeskSaved"]["content"]); } if (isset($_SESSION["helpdeskSaved"]["name"])) { $title = stripslashes($_SESSION["helpdeskSaved"]["name"]); } if (isset($_SESSION["helpdeskSaved"]["ticketcategories_id"])) { $ticketcategories_id = stripslashes($_SESSION["helpdeskSaved"]["ticketcategories_id"]); } if (isset($_SESSION["helpdeskSaved"]["type"])) { $type = stripslashes($_SESSION["helpdeskSaved"]["type"]); } if (isset($_SESSION["helpdeskSaved"]["urgency"])) { $urgency = stripslashes($_SESSION["helpdeskSaved"]["urgency"]); } unset($_SESSION["helpdeskSaved"]); echo "<form method='post' name='helpdeskform' action='" . $CFG_GLPI["root_doc"] . "/front/tracking.injector.php' enctype='multipart/form-data'>"; echo "<input type='hidden' name='_from_helpdesk' value='{$from_helpdesk}'>"; echo "<input type='hidden' name='requesttypes_id' value='" . RequestType::getDefault('helpdesk') . "'>"; if ($CFG_GLPI['urgency_mask'] == 1 << 3) { // Dont show dropdown if only 1 value enabled echo "<input type='hidden' name='urgency' value='3'>"; } echo "<input type='hidden' name='entities_id' value='" . $_SESSION["glpiactive_entity"] . "'>"; echo "<div class='center'><table class='tab_cadre'>"; echo "<tr><th colspan='2'>" . $LANG['job'][11] . " : "; if (isMultiEntitiesMode()) { echo " (" . Dropdown::getDropdownName("glpi_entities", $_SESSION["glpiactive_entity"]) . ")"; } echo "</th></tr>"; if ($CFG_GLPI['urgency_mask'] != 1 << 3) { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['joblist'][29] . " : </td>"; echo "<td>"; Ticket::dropdownUrgency("urgency", $urgency); echo "</td></tr>"; } if (NotificationTargetTicket::isAuthorMailingActivatedForHelpdesk()) { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['help'][8] . " : </td>"; echo "<td>"; $_REQUEST['value'] = getLoginUserID(); $_REQUEST['field'] = '_users_id_requester_notif'; $_REQUEST['use_notification'] = $use_email_notification; include GLPI_ROOT . "/ajax/uemailUpdate.php"; echo "</td></tr>"; } if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] != 0) { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['help'][24] . " : </td>"; echo "<td>"; Ticket::dropdownMyDevices(getLoginUserID(), $_SESSION["glpiactive_entity"]); Ticket::dropdownAllDevices("itemtype", $itemtype, $items_id, 0, $_SESSION["glpiactive_entity"]); echo "</td></tr>"; } echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][17] . " : </td><td>"; Ticket::dropdownType('type', $type); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][36] . " : </td><td>"; Dropdown::show('TicketCategory', array('value' => $ticketcategories_id, 'condition' => '`is_helpdeskvisible`=1')); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][57] . " : </td>"; echo "<td><input type='text' maxlength='250' size='50' name='name' value='{$title}'></td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='2'><textarea name='content' cols='78' rows='14'>{$content}</textarea>"; echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['document'][2] . " (" . Document::getMaxUploadSize() . ") : "; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/aide.png' class='pointer' alt='" . $LANG['central'][7] . "' onclick=\"window.open('" . $CFG_GLPI["root_doc"] . "/front/documenttype.list.php','Help','scrollbars=1,resizable=1,width=1000,height=800')\">"; echo "</td>"; echo "<td><input type='file' name='filename' value='' size='25'></td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='2' class='center'>"; echo "<input type='submit' value=\"" . $LANG['help'][14] . "\" class='submit'>"; echo "</td></tr>"; echo "</table></div></form>"; }
foreach ($_POST['items'] as $reservationitems_id) { $_POST['reservationitems_id'] = $reservationitems_id; $times = $_POST["periodicity_times"]; $begin = $_POST["begin"]; list($begin_year, $begin_month, $begin_day) = explode("-", $_POST["begin"]); $end = $_POST["end"]; $to_add = 1; if ($_POST["periodicity"] == "week") { $to_add = 7; } $_POST['_target'] = $_SERVER['PHP_SELF']; $_POST['_ok'] = true; for ($i = 0; $i < $times && $_POST['_ok']; $i++) { $_POST["begin"] = date('Y-m-d H:i:s', strtotime($begin) + $i * $to_add * DAY_TIMESTAMP); $_POST["end"] = date('Y-m-d H:i:s', strtotime($end) + $i * $to_add * DAY_TIMESTAMP); if (haveRight("reservation_central", "w") || getLoginUserID() === $_POST["users_id"]) { unset($rr->fields["id"]); $_POST['_ok'] = $rr->add($_POST); } } // Positionnement du calendrier au mois de debut $_GET["mois_courant"] = $begin_month; $_GET["annee_courant"] = $begin_year; if ($_POST['_ok']) { Event::log($_POST["reservationitems_id"], "reservation", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][20]); } else { $all_ok = false; } } if ($all_ok) { $toadd = "";
// ---------------------------------------------------------------------- // Original Author of file: // Purpose of file: // ---------------------------------------------------------------------- define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; // Redirect management if (isset($_GET["redirect"])) { manageRedirect($_GET["redirect"]); } //******************* // Affichage Module FAQ //****************** $name = ""; checkFaqAccess(); if (getLoginUserID()) { helpHeader($LANG['Menu'][20], $_SERVER['PHP_SELF'], $_SESSION["glpiname"]); } else { $_SESSION["glpilanguage"] = $CFG_GLPI['language']; // Anonymous FAQ simpleHeader($LANG['Menu'][20], array($LANG['Menu'][20] => $_SERVER['PHP_SELF'])); } if (!isset($_GET["contains"])) { $_GET["contains"] = ""; } if (!isset($_GET["knowbaseitemcategories_id"])) { $_GET["knowbaseitemcategories_id"] = 0; } if (isset($_GET["id"])) { $kb = new KnowbaseItem(); if ($kb->getFromDB($_GET["id"])) {
/** * Print the search config form * * @param $target form target * @param $itemtype item type * * @return nothing **/ function showFormPerso($target, $itemtype) { global $CFG_GLPI, $LANG, $DB; $searchopt = Search::getCleanedOptions($itemtype); if (!is_array($searchopt)) { return false; } $item = NULL; if ($itemtype != 'States' && class_exists($itemtype)) { $item = new $itemtype(); } $IDuser = getLoginUserID(); echo "<div class='center' id='tabsbody' >"; // Defined items $query = "SELECT *\n FROM `" . $this->getTable() . "`\n WHERE `itemtype` = '{$itemtype}'\n AND `users_id` = '{$IDuser}'\n ORDER BY `rank`"; $result = $DB->query($query); $numrows = 0; $numrows = $DB->numrows($result); if ($numrows == 0) { checkRight("search_config", "w"); echo "<table class='tab_cadre_fixe'><tr><th colspan='4'>"; echo "<form method='post' action='{$target}'>"; echo "<input type='hidden' name='itemtype' value='{$itemtype}'>"; echo "<input type='hidden' name='users_id' value='{$IDuser}'>"; echo $LANG['setup'][241] . "<span class='small_space'>"; echo "<input type='submit' name='activate' value=\"" . $LANG['buttons'][2] . "\" class='submit'>"; echo "</span></form></th></tr></table>\n"; } else { $already_added = self::getForTypeUser($itemtype, $IDuser); echo "<table class='tab_cadre_fixe'><tr><th colspan='4'>"; echo $LANG['setup'][252] . " : </th></tr>"; echo "<tr class='tab_bg_1'><td colspan='4' class='center'>"; echo "<form method='post' action=\"{$target}\">"; echo "<input type='hidden' name='itemtype' value='{$itemtype}'>"; echo "<input type='hidden' name='users_id' value='{$IDuser}'>"; echo "<select name='num'>"; $first_group = true; foreach ($searchopt as $key => $val) { if (!is_array($val)) { if (!$first_group) { echo "</optgroup>\n"; } else { $first_group = false; } echo "<optgroup label=\"{$val}\">"; } else { if ($key != 1 && !in_array($key, $already_added)) { echo "<option value='{$key}'>" . $val["name"] . "</option>\n"; } } } if (!$first_group) { echo "</optgroup>\n"; } echo "</select><span class='small_space'>"; echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>"; echo "</span></form>"; echo "</td></tr>\n"; // print first element echo "<tr class='tab_bg_2'>"; echo "<td class='center' width='50%'>" . $searchopt[1]["name"] . "</td>"; echo "<td colspan='3'> </td>"; echo "</tr>"; // print entity if (isMultiEntitiesMode() && (isset($CFG_GLPI["union_search_type"][$itemtype]) || $item && $item->maybeRecursive() || count($_SESSION["glpiactiveentities"]) > 1) && isset($searchopt[80])) { echo "<tr class='tab_bg_2'>"; echo "<td class='center' width='50%'>" . $searchopt[80]["name"] . "</td>"; echo "<td colspan='3'> </td>"; echo "</tr>"; } $i = 0; if ($numrows) { while ($data = $DB->fetch_array($result)) { if ($data["num"] != 1 && isset($searchopt[$data["num"]])) { echo "<tr class='tab_bg_2'>"; echo "<td class='center' width='50%' >"; echo $searchopt[$data["num"]]["name"] . "</td>"; if ($i != 0) { echo "<td class='center middle'>"; echo "<form method='post' action='{$target}'>"; echo "<input type='hidden' name='id' value='" . $data["id"] . "'>"; echo "<input type='hidden' name='users_id' value='{$IDuser}'>"; echo "<input type='hidden' name='itemtype' value='{$itemtype}'>"; echo "<input type='image' name='up' value=\"" . $LANG['buttons'][24] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-up2.png' alt=\"" . $LANG['buttons'][24] . "\" title=\"" . $LANG['buttons'][24] . "\">"; echo "</form></td>\n"; } else { echo "<td> </td>"; } if ($i != $numrows - 1) { echo "<td class='center middle'>"; echo "<form method='post' action='{$target}'>"; echo "<input type='hidden' name='id' value='" . $data["id"] . "'>"; echo "<input type='hidden' name='users_id' value='{$IDuser}'>"; echo "<input type='hidden' name='itemtype' value='{$itemtype}'>"; echo "<input type='image' name='down' value=\"" . $LANG['buttons'][25] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-down2.png' alt=\"" . $LANG['buttons'][25] . "\" title=\"" . $LANG['buttons'][25] . "\">"; echo "</form></td>\n"; } else { echo "<td> </td>"; } echo "<td class='center middle'>"; echo "<form method='post' action='{$target}'>"; echo "<input type='hidden' name='id' value='" . $data["id"] . "'>"; echo "<input type='hidden' name='users_id' value='{$IDuser}'>"; echo "<input type='hidden' name='itemtype' value='{$itemtype}'>"; echo "<input type='image' name='delete' value=\"" . $LANG['buttons'][6] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-delete2.png' alt=\"" . $LANG['buttons'][6] . "\" title=\"" . $LANG['buttons'][6] . "\">"; echo "</form></td>\n"; echo "</tr>"; $i++; } } } echo "</table>"; } echo "</div>"; }
/** * Show the current tickettask sumnary **/ function showSummary($ticket) { global $DB, $LANG, $CFG_GLPI; if (!haveRight("observe_ticket", "1") && !haveRight("show_full_ticket", "1")) { return false; } $tID = $ticket->fields['id']; // Display existing Followups $showprivate = haveRight("show_full_ticket", "1"); $caneditall = haveRight("update_tasks", "1"); $tmp = array('tickets_id' => $tID); $canadd = $this->can(-1, 'w', $tmp); $RESTRICT = ""; if (!$showprivate) { $RESTRICT = " AND (`is_private` = '0'\n OR `users_id` ='" . getLoginUserID() . "') "; } $query = "SELECT `id`, `date`\n FROM `glpi_tickettasks`\n WHERE `tickets_id` = '{$tID}'\n {$RESTRICT}\n ORDER BY `date` DESC"; $result = $DB->query($query); $rand = mt_rand(); if ($caneditall || $canadd) { echo "<div id='viewfollowup" . $tID . "{$rand}'></div>\n"; } if ($canadd) { echo "<script type='text/javascript' >\n"; echo "function viewAddFollowup" . $ticket->fields['id'] . "{$rand}() {\n"; $params = array('type' => __CLASS__, 'tickets_id' => $ticket->fields['id'], 'id' => -1); ajaxUpdateItemJsCode("viewfollowup" . $ticket->fields['id'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewfollowup.php", $params, false); echo "};"; echo "</script>\n"; if ($ticket->fields["status"] != 'solved' && $ticket->fields["status"] != 'closed') { echo "<div class='center'>" . "<a href='javascript:viewAddFollowup" . $ticket->fields['id'] . "{$rand}();'>"; echo $LANG['job'][30] . "</a></div></p><br>\n"; } } //echo "<h3>" . $LANG['job'][37] . "</h3>"; if ($DB->numrows($result) == 0) { echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'><th class='b'>" . $LANG['job'][50]; echo "</th></tr></table>"; } else { echo "<table class='tab_cadre_fixehov'>"; echo "<tr><th>" . $LANG['common'][17] . "</th><th>" . $LANG['common'][27] . "</th>"; echo "<th>" . $LANG['joblist'][6] . "</th><th>" . $LANG['job'][31] . "</th>"; echo "<th>" . $LANG['common'][37] . "</th>"; if ($showprivate) { echo "<th>" . $LANG['common'][77] . "</th>"; } echo "<th>" . $LANG['job'][35] . "</th></tr>\n"; while ($data = $DB->fetch_array($result)) { if ($this->getFromDB($data['id'])) { $this->showInTicketSumnary($ticket, $rand, $showprivate); } } echo "</table>"; } }
/** * Log a message in log file * * @param $name string: name of the log file * @param $text string: text to log * @param $force boolean: force log in file not seeing use_log_in_files config **/ function logInFile($name, $text, $force = false) { global $CFG_GLPI; $user = ''; if (function_exists('getLoginUserID')) { $user = "******" . getLoginUserID() . '@' . php_uname('n') . "]"; } if (isset($CFG_GLPI["use_log_in_files"]) && $CFG_GLPI["use_log_in_files"] || $force) { error_log(convDateTime(date("Y-m-d H:i:s")) . "{$user}\n" . $text, 3, GLPI_LOG_DIR . "/" . $name . ".log"); } }
FusionInventory is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with FusionInventory. If not, see <http://www.gnu.org/licenses/>. ------------------------------------------------------------------------ @package FusionInventory @author Kevin Roy @co-author @copyright Copyright (c) 2010-2014 FusionInventory team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link http://www.fusioninventory.org/ @link http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/ @since 2010 ------------------------------------------------------------------------ */ include "../../../inc/includes.php"; $loggedin = array(); $loggedin['result'] = 1; if (!isset($_SESSION["glpiname"])) { if (!getLoginUserID()) { $loggedin['result'] = 0; } } echo json_encode($loggedin);
/** * Display debug information for reservation of current object **/ function showDebug() { $resa = new Reservation(); $resa->fields['id'] = '1'; $resa->fields['reservationitems_id'] = $this->getField('id'); $resa->fields['begin'] = $_SESSION['glpi_currenttime']; $resa->fields['end'] = $_SESSION['glpi_currenttime']; $resa->fields['users_id'] = getLoginUserID(); $resa->fields['comment'] = ''; NotificationEvent::debugEvent($resa); }
/** Get groups assigned to tickets between 2 dates * * @param $entrees array : array containing data to displayed * @param $options array : options * - title string title displayed (default empty) * - showtotal boolean show total in title (default false) * - width integer width of the graph (default 700) * - height integer height of the graph (default 300) * - unit integer height of the graph (default empty) * - type integer height of the graph (default line) : line bar pie * - csv boolean export to CSV (default true) * - datatype string datatype (count or average / default is count) * * @return array contains the distinct groups assigned to a tickets **/ static function showGraph($entrees, $options = array()) { global $CFG_GLPI, $LANG; if ($uid = getLoginUserID(false)) { if (!isset($_SESSION['glpigraphtype'])) { $_SESSION['glpigraphtype'] = $CFG_GLPI['default_graphtype']; } $param['showtotal'] = false; $param['title'] = ''; $param['width'] = 900; $param['height'] = 300; $param['unit'] = ''; $param['type'] = 'line'; $param['csv'] = true; $param['datatype'] = 'count'; if (is_array($options) && count($options)) { foreach ($options as $key => $val) { $param[$key] = $val; } } // Clean data if (is_array($entrees) && count($entrees)) { foreach ($entrees as $key => $val) { if (!is_array($val) || count($val) == 0) { unset($entrees[$key]); } } } if (!is_array($entrees) || count($entrees) == 0) { if (!empty($param['title'])) { echo "<div class='center'>" . $param['title'] . " : " . $LANG['stats'][2] . "</div>"; } return false; } echo "<div class='center-h' style='width:" . $param['width'] . "px'>"; echo "<div>"; switch ($param['type']) { case 'pie': // Check datas : sum must be > 0 reset($entrees); $sum = array_sum(current($entrees)); while ($sum == 0 && ($data = next($entrees))) { $sum += array_sum($data); } if ($sum == 0) { return false; } $graph = new ezcGraphPieChart(); $graph->palette = new GraphPalette(); $graph->options->font->maxFontSize = 15; $graph->title->background = '#EEEEEC'; $graph->renderer = new ezcGraphRenderer3d(); $graph->renderer->options->pieChartHeight = 20; $graph->renderer->options->moveOut = 0.2; $graph->renderer->options->pieChartOffset = 63; $graph->renderer->options->pieChartGleam = 0.3; $graph->renderer->options->pieChartGleamColor = '#FFFFFF'; $graph->renderer->options->pieChartGleamBorder = 2; $graph->renderer->options->pieChartShadowSize = 5; $graph->renderer->options->pieChartShadowColor = '#BABDB6'; if (count($entrees) == 1) { $graph->legend = false; } break; case 'bar': $graph = new ezcGraphBarChart(); $graph->options->fillLines = 210; $graph->xAxis->axisLabelRenderer = new ezcGraphAxisRotatedBoxedLabelRenderer(); $graph->xAxis->axisLabelRenderer->angle = 45; $graph->xAxis->axisSpace = 0.2; $graph->yAxis->min = 0; $graph->palette = new GraphPalette(); $graph->options->font->maxFontSize = 15; $graph->title->background = '#EEEEEC'; $graph->renderer = new ezcGraphRenderer3d(); $graph->renderer->options->legendSymbolGleam = 0.5; $graph->renderer->options->barChartGleam = 0.5; $max = 0; foreach ($entrees as $key => $val) { if (count($val) > $max) { $max = count($val); } } $graph->xAxis->labelCount = $max; break; case 'line': // No break default case // No break default case default: $graph = new ezcGraphLineChart(); $graph->options->fillLines = 210; $graph->xAxis->axisLabelRenderer = new ezcGraphAxisRotatedLabelRenderer(); $graph->xAxis->axisLabelRenderer->angle = 45; $graph->xAxis->axisSpace = 0.2; $graph->yAxis->min = 0; $graph->palette = new GraphPalette(); $graph->options->font->maxFontSize = 15; $graph->title->background = '#EEEEEC'; $graph->renderer = new ezcGraphRenderer3d(); $graph->renderer->options->legendSymbolGleam = 0.5; $graph->renderer->options->barChartGleam = 0.5; $graph->renderer->options->depth = 0.07000000000000001; break; } if (!empty($param['title'])) { $pretoadd = ""; $posttoadd = ""; if (!empty($param['unit'])) { $posttoadd = " " . $param['unit']; $pretoadd = " - "; } // Add to title if (count($entrees) == 1) { $param['title'] .= $pretoadd; if ($param['showtotal'] == 1) { reset($entrees); $param['title'] .= round(array_sum(current($entrees)), 2); } $param['title'] .= $posttoadd; } else { // add sum to legend and unit to title $param['title'] .= $pretoadd . $posttoadd; // Cannot display totals of already average values if ($param['showtotal'] == 1 && $param['datatype'] != 'average') { $entree_tmp = $entrees; $entrees = array(); foreach ($entree_tmp as $key => $data) { $sum = round(array_sum($data)); $entrees[$key . " ({$sum})"] = $data; } } } $graph->title = $param['title']; } switch ($_SESSION['glpigraphtype']) { case "png": $extension = "png"; $graph->driver = new ezcGraphGdDriver(); $graph->options->font = GLPI_FONT_FREESANS; break; default: $extension = "svg"; break; } $filename = $uid . '_' . mt_rand(); $csvfilename = $filename . '.csv'; $filename .= '.' . $extension; foreach ($entrees as $label => $data) { $graph->data[$label] = new ezcGraphArrayDataSet($data); $graph->data[$label]->symbol = ezcGraph::NO_SYMBOL; } switch ($_SESSION['glpigraphtype']) { case "png": $graph->render($param['width'], $param['height'], GLPI_GRAPH_DIR . '/' . $filename); echo "<img src='" . $CFG_GLPI['root_doc'] . "/front/graph.send.php?file={$filename}'>"; break; default: $graph->render($param['width'], $param['height'], GLPI_GRAPH_DIR . '/' . $filename); echo "<object data='" . $CFG_GLPI['root_doc'] . "/front/graph.send.php?file={$filename}'\n type='image/svg+xml' width='" . $param['width'] . "' height='" . $param['height'] . "'>\n <param name='src' value='" . $CFG_GLPI['root_doc'] . "/front/graph.send.php?file={$filename}'>\n You need a browser capeable of SVG to display this image.\n </object> "; break; } // Render CSV if ($param['csv']) { if ($fp = fopen(GLPI_GRAPH_DIR . '/' . $csvfilename, 'w')) { // reformat datas $values = array(); $labels = array(); $row_num = 0; foreach ($entrees as $label => $data) { $labels[$row_num] = $label; if (is_array($data) && count($data)) { foreach ($data as $key => $val) { if (!isset($values[$key])) { $values[$key] = array(); } if ($param['datatype'] == 'average') { $val = round($val, 2); } $values[$key][$row_num] = $val; } } $row_num++; } ksort($values); // Print labels fwrite($fp, $_SESSION["glpicsv_delimiter"]); foreach ($labels as $val) { fwrite($fp, $val . $_SESSION["glpicsv_delimiter"]); } fwrite($fp, "\n"); foreach ($values as $key => $data) { fwrite($fp, $key . $_SESSION["glpicsv_delimiter"]); foreach ($data as $value) { fwrite($fp, $value . $_SESSION["glpicsv_delimiter"]); } fwrite($fp, "\n"); } fclose($fp); } } echo "</div>"; echo "<div class='right' style='width:" . $param['width'] . "px'>"; if ($_SESSION['glpigraphtype'] != 'svg') { echo " <a href='" . $CFG_GLPI['root_doc'] . "/front/graph.send.php?switchto=svg'>SVG" . "</a>"; } if ($_SESSION['glpigraphtype'] != 'png') { echo " <a href='" . $CFG_GLPI['root_doc'] . "/front/graph.send.php?switchto=png'>PNG" . "</a>"; } if ($param['csv']) { echo " / <a href='" . $CFG_GLPI['root_doc'] . "/front/graph.send.php?file={$csvfilename}'>CSV" . "</a>"; } echo "</div>"; echo '</div>'; } }
/** * Get the SEARCH_OPTION array * * @param $itemtype * @param $withplugins boolean get search options from plugins * * @return the reference to array of search options for the given item type **/ static function &getOptions($itemtype, $withplugins = true) { global $LANG, $CFG_GLPI; static $search = array(); if (!isset($search[$itemtype])) { // standard type first if ($itemtype == 'States') { $search[$itemtype]['common'] = $LANG['common'][32]; $search['States'][1]['table'] = 'state_types'; $search['States'][1]['field'] = 'name'; $search['States'][1]['name'] = $LANG['common'][16]; $search['States'][1]['datatype'] = 'itemlink'; $search['States'][1]['searchtype'] = 'contains'; $search['States'][2]['table'] = 'state_types'; $search['States'][2]['field'] = 'id'; $search['States'][2]['name'] = $LANG['common'][2]; $search['States'][2]['searchtype'] = 'contains'; $search['States'][31]['table'] = 'glpi_states'; $search['States'][31]['field'] = 'name'; $search['States'][31]['name'] = $LANG['state'][0]; $search['States'] += Location::getSearchOptionsToAdd(); $search['States'][5]['table'] = 'state_types'; $search['States'][5]['field'] = 'serial'; $search['States'][5]['name'] = $LANG['common'][19]; $search['States'][6]['table'] = 'state_types'; $search['States'][6]['field'] = 'otherserial'; $search['States'][6]['name'] = $LANG['common'][20]; $search['States'][16]['table'] = 'state_types'; $search['States'][16]['field'] = 'comment'; $search['States'][16]['name'] = $LANG['common'][25]; $search['States'][16]['datatype'] = 'text'; $search['States'][70]['table'] = 'glpi_users'; $search['States'][70]['field'] = 'name'; $search['States'][70]['name'] = $LANG['common'][34]; $search['States'][71]['table'] = 'glpi_groups'; $search['States'][71]['field'] = 'name'; $search['States'][71]['name'] = $LANG['common'][35]; $search['States'][19]['table'] = 'state_types'; $search['States'][19]['field'] = 'date_mod'; $search['States'][19]['name'] = $LANG['common'][26]; $search['States'][19]['datatype'] = 'datetime'; $search['States'][19]['massiveaction'] = false; $search['States'][23]['table'] = 'glpi_manufacturers'; $search['States'][23]['field'] = 'name'; $search['States'][23]['name'] = $LANG['common'][5]; $search['States'][24]['table'] = 'glpi_users'; $search['States'][24]['field'] = 'name'; $search['States'][24]['name'] = $LANG['common'][10]; $search['States'][80]['table'] = 'glpi_entities'; $search['States'][80]['field'] = 'completename'; $search['States'][80]['name'] = $LANG['entity'][0]; } else { if (class_exists($itemtype)) { $item = new $itemtype(); $search[$itemtype] = $item->getSearchOptions(); } } if (getLoginUserID() && in_array($itemtype, $CFG_GLPI["ticket_types"])) { $search[$itemtype]['tracking'] = $LANG['title'][24]; $search[$itemtype][60]['table'] = 'glpi_tickets'; $search[$itemtype][60]['linkfield'] = 'items_id'; $search[$itemtype][60]['field'] = 'count'; $search[$itemtype][60]['name'] = $LANG['stats'][13]; $search[$itemtype][60]['forcegroupby'] = true; $search[$itemtype][60]['usehaving'] = true; $search[$itemtype][60]['datatype'] = 'number'; $search[$itemtype][60]['massiveaction'] = false; $search[$itemtype][60]['joinparams'] = array('jointype' => "itemtype_item", 'condition' => getEntitiesRestrictRequest('AND', 'NEWTABLE')); } if (in_array($itemtype, $CFG_GLPI["networkport_types"])) { $search[$itemtype] += NetworkPort::getSearchOptionsToAdd($itemtype); } if (in_array($itemtype, $CFG_GLPI["contract_types"])) { $search[$itemtype] += Contract::getSearchOptionsToAdd(); } if (in_array($itemtype, $CFG_GLPI["infocom_types"])) { $search[$itemtype] += Infocom::getSearchOptionsToAdd($itemtype); } if ($withplugins) { // Search options added by plugins $plugsearch = getPluginSearchOptions($itemtype); if (count($plugsearch)) { $search[$itemtype] += array('plugins' => $LANG['common'][29]); $search[$itemtype] += $plugsearch; } } // Complete linkfield if not define if ($itemtype === 'States') { $itemtable = 'states_types'; } else { $itemtable = $item->getTable(); } foreach ($search[$itemtype] as $key => $val) { // Compatibility before 0.80 : Force massive action to false if linkfield is empty : if (isset($val['linkfield']) && empty($val['linkfield'])) { $search[$itemtype][$key]['massiveaction'] = false; } if (!isset($val['linkfield']) || empty($val['linkfield'])) { if (strcmp($itemtable, $val['table']) == 0 && (!isset($val['joinparams']) || count($val['joinparams']) == 0)) { $search[$itemtype][$key]['linkfield'] = $val['field']; } else { $search[$itemtype][$key]['linkfield'] = getForeignKeyFieldForTable($val['table']); } } // Add default joinparams if (!isset($val['joinparams'])) { $search[$itemtype][$key]['joinparams'] = array(); } } } return $search[$itemtype]; }
/** * Display a reservation * * @param $ID ID a the reservation item * @param $date date to display **/ static function displayReservationsForAnItem($ID, $date) { global $DB, $LANG; $users_id = getLoginUserID(); $resa = new self(); $user = new User(); list($year, $month, $day) = explode("-", $date); $debut = $date . " 00:00:00"; $fin = $date . " 23:59:59"; $query = "SELECT *\n FROM `glpi_reservations`\n WHERE '{$debut}' < `end`\n AND '{$fin}' > `begin`\n AND `reservationitems_id` = '{$ID}'\n ORDER BY `begin`"; if ($result = $DB->query($query)) { if ($DB->numrows($result) > 0) { echo "<table width='100%'>"; while ($row = $DB->fetch_array($result)) { echo "<tr>"; $user->getFromDB($row["users_id"]); $display = ""; if ($debut > $row['begin']) { $heure_debut = "00:00"; } else { $heure_debut = get_hour_from_sql($row['begin']); } if ($fin < $row['end']) { $heure_fin = "24:00"; } else { $heure_fin = get_hour_from_sql($row['end']); } if (strcmp($heure_debut, "00:00") == 0 && strcmp($heure_fin, "24:00") == 0) { $display = $LANG['planning'][5]; } else { if (strcmp($heure_debut, "00:00") == 0) { $display = $LANG['reservation'][16] . " " . $heure_fin; } else { if (strcmp($heure_fin, "24:00") == 0) { $display = $LANG['reservation'][17] . " " . $heure_debut; } else { $display = $heure_debut . "-" . $heure_fin; } } } $rand = mt_rand(); $modif = $modif_end = ""; if ($resa->can($row['id'], "w")) { $modif = "<a id='content_" . $ID . $rand . "'\n href='reservation.form.php?id=" . $row['id'] . "'>"; $modif_end = "</a>"; $modif_end .= showToolTip($row["comment"], array('applyto' => "content_" . $ID . $rand, 'display' => false)); } echo "<td class='tab_resa center'>" . $modif . "<span>" . $display . "<br><strong>" . formatUserName($user->fields["id"], $user->fields["name"], $user->fields["realname"], $user->fields["firstname"]); echo "</strong></span>"; echo $modif_end; echo "</td></tr>\n"; } echo "</table>\n"; } } }
/** * Print the config form for default user prefs * * @param $data array containing datas * (CFG_GLPI for global config / glpi_users fields for user prefs) * * @return Nothing (display) **/ function showFormUserPrefs($data = array()) { global $DB, $LANG, $CFG_GLPI; $oncentral = $_SESSION["glpiactiveprofile"]["interface"] == "central"; $userpref = false; $url = getItemTypeFormURL(__CLASS__); if (array_key_exists('last_login', $data)) { $userpref = true; if ($data["id"] === getLoginUserID()) { $url = $CFG_GLPI['root_doc'] . "/front/preference.php"; } else { $url = $CFG_GLPI['root_doc'] . "/front/user.form.php"; } } echo "<form name='form' action='{$url}' method='post'>"; echo "<div class='center' id='tabsbody'>"; echo "<input type='hidden' name='id' value='" . $data["id"] . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . $LANG['setup'][6] . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['setup'][111] . " :</td><td>"; // Limit using global config Dropdown::showInteger('list_limit', $data['list_limit'] < $CFG_GLPI['list_limit_max'] ? $data['list_limit'] : $CFG_GLPI['list_limit_max'], 5, $CFG_GLPI['list_limit_max'], 5); echo "</td><td>" . $LANG['setup'][128] . " :</td>"; echo "<td>"; $date_formats = array(0 => $LANG['calendar'][0], 1 => $LANG['calendar'][1], 2 => $LANG['calendar'][2]); Dropdown::showFromArray('date_format', $date_formats, array('value' => $data["date_format"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; if ($oncentral) { echo "<td>" . $LANG['setup'][112] . " :</td><td>"; Dropdown::showInteger('dropdown_chars_limit', $data["dropdown_chars_limit"], 20, 100); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "<td>" . $LANG['setup'][150] . " :</td>"; $values = array(0 => '1 234.56', 1 => '1,234.56', 2 => '1 234,56'); echo "<td>"; Dropdown::showFromArray('number_format', $values, array('value' => $data["number_format"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; if ($oncentral) { echo "<td>" . $LANG['setup'][132] . " :</td><td>"; Dropdown::showYesNo('use_flat_dropdowntree', $data["use_flat_dropdowntree"]); echo "</td>"; } else { echo "<td colspan='2'> </td>"; } echo "<td>" . $LANG['setup'][10] . " :</td><td>"; $values = array(REALNAME_BEFORE => $LANG['common'][48] . " " . $LANG['common'][43], FIRSTNAME_BEFORE => $LANG['common'][43] . " " . $LANG['common'][48]); Dropdown::showFromArray('names_format', $values, array('value' => $data["names_format"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td colspan='2'></td>"; echo "<td>" . $LANG['setup'][7] . " :</td><td>"; $values = array(';' => ';', ',' => ','); Dropdown::showFromArray('csv_delimiter', $values, array('value' => $data["csv_delimiter"])); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; if ($oncentral) { echo "<td>" . $LANG['setup'][129] . " :</td><td>"; Dropdown::showYesNo("is_ids_visible", $data["is_ids_visible"]); echo "</td>"; } else { echo "<td colspan='2'></td>"; } echo "<td>" . ($userpref ? $LANG['setup'][41] : $LANG['setup'][113]) . " :</td><td>"; if (haveRight("config", "w") || !GLPI_DEMO_MODE) { Dropdown::showLanguages("language", array('value' => $data["language"])); } else { echo " "; } echo "</td></tr>"; if ($oncentral) { echo "<tr class='tab_bg_1'><th colspan='4'>" . $LANG['title'][24] . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['setup'][39] . " :</td><td>"; Dropdown::showYesNo("followup_private", $data["followup_private"]); echo "</td><td> " . $LANG['setup'][110] . " :</td><td>"; Dropdown::showYesNo("show_jobs_at_login", $data["show_jobs_at_login"]); echo " </td></tr>"; echo "<tr class='tab_bg_2'><td>" . $LANG['setup'][40] . " :</td><td>"; Dropdown::showYesNo("task_private", $data["task_private"]); echo "</td><td> " . $LANG['job'][44] . " :</td><td>"; Dropdown::show('RequestType', array('value' => $data["default_requesttypes_id"], 'name' => "default_requesttypes_id")); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['setup'][114] . " :</td>"; echo "<td colspan='3'>"; echo "<table><tr>"; echo "<td bgcolor='" . $data["priority_1"] . "'>1 : "; echo "<input type='text' name='priority_1' size='7' value='" . $data["priority_1"] . "'></td>"; echo "<td bgcolor='" . $data["priority_2"] . "'>2 : "; echo "<input type='text' name='priority_2' size='7' value='" . $data["priority_2"] . "'></td>"; echo "<td bgcolor='" . $data["priority_3"] . "'>3 : "; echo "<input type='text' name='priority_3' size='7' value='" . $data["priority_3"] . "'></td>"; echo "<td bgcolor='" . $data["priority_4"] . "'>4 : "; echo "<input type='text' name='priority_4' size='7' value='" . $data["priority_4"] . "'></td>"; echo "<td bgcolor='" . $data["priority_5"] . "'>5 : "; echo "<input type='text' name='priority_5' size='7' value='" . $data["priority_5"] . "'></td>"; echo "<td bgcolor='" . $data["priority_6"] . "'>6 : "; echo "<input type='text' name='priority_6' size='7' value='" . $data["priority_6"] . "'></td>"; echo "</tr></table>"; echo "</td></tr>"; echo "<tr class='tab_bg_1'><th colspan='4'>" . $LANG['softwarecategories'][5] . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . $LANG['softwarecategories'][4] . " :</td><td>"; Dropdown::showYesNo("is_categorized_soft_expanded", $data["is_categorized_soft_expanded"]); echo "</td><td>" . $LANG['softwarecategories'][3] . " :</td><td>"; Dropdown::showYesNo("is_not_categorized_soft_expanded", $data["is_not_categorized_soft_expanded"]); echo "</td></tr>"; } echo "<tr class='tab_bg_2'>"; echo "<td colspan='4' class='center'>"; echo "<input type='submit' name='update' class='submit' value=\"" . $LANG['buttons'][2] . "\">"; echo "</td></tr>"; echo "</table></div>"; echo "</form>"; }
/** * Display debug information for current object **/ function showDebug() { $params = array('message' => '', 'action_type' => true, 'action_user' => getUserName(getLoginUserID()), 'entities_id' => $_SESSION['glpiactive_entity'], 'itemtype' => get_class($this), 'date' => $_SESSION['glpi_currenttime'], 'refuse' => true); NotificationEvent::debugEvent($this, $params); }
/** * Check field unicity before insert or update * * @param add true for insert, false for update * @param $options array * * @return true if item can be written in DB, false if not **/ function checkUnicity($add = false, $options = array()) { global $LANG, $DB, $CFG_GLPI; $p['unicity_error_message'] = true; $p['add_event_on_duplicate'] = true; $p['disable_unicity_check'] = false; if (is_array($options) && count($options)) { foreach ($options as $key => $value) { $p[$key] = $value; } } $result = true; //Do not check unicity when creating infocoms or if checking is expliclty disabled if ($p['disable_unicity_check']) { return $result; } //Get all checks for this itemtype and this entity if (in_array(get_class($this), $CFG_GLPI["unicity_types"])) { // Get input entities if set / else get object one if (isset($this->input['entities_id'])) { $entities_id = $this->input['entities_id']; } else { $entities_id = $this->fields['entities_id']; } $all_fields = FieldUnicity::getUnicityFieldsConfig(get_class($this), $entities_id); foreach ($all_fields as $key => $fields) { //If there's fields to check if (!empty($fields) && !empty($fields['fields'])) { $where = ""; $continue = true; foreach (explode(',', $fields['fields']) as $field) { if (isset($this->input[$field]) && (getTableNameForForeignKeyField($field) == '' && $this->input[$field] != '' || getTableNameForForeignKeyField($field) != '' && $this->input[$field] > 0) && !Fieldblacklist::isFieldBlacklisted(get_class($this), $entities_id, $field, $this->input[$field])) { $where .= " AND `" . $this->getTable() . "`.`{$field}` = '" . $this->input[$field] . "'"; } else { $continue = false; } } if ($continue && $where != '') { $entities = $fields['entities_id']; if ($fields['is_recursive']) { $entities = getSonsOf('glpi_entities', $fields['entities_id']); } $where_global = getEntitiesRestrictRequest(" AND", $this->getTable(), '', $entities); //If update, exclude ID of the current object if (!$add) { $where .= " AND `" . $this->getTable() . "`.`id` NOT IN (" . $this->input['id'] . ") "; } if (countElementsInTable($this->table, "1 {$where} {$where_global}") > 0) { if ($p['unicity_error_message'] || $p['add_event_on_duplicate']) { $message = array(); foreach (explode(',', $fields['fields']) as $field) { $table = getTableNameForForeignKeyField($field); if ($table != '') { $searchOption = $this->getSearchOptionByField('field', 'name', $table); } else { $searchOption = $this->getSearchOptionByField('field', $field); } $message[] = $searchOption['name'] . '=' . $this->input[$field]; } $doubles = getAllDatasFromTable($this->table, "1 {$where} {$where_global}"); $message_text = $this->getUncityErrorMessage($message, $fields, $doubles); if ($p['unicity_error_message']) { if (!$fields['action_refuse']) { $show_other_messages = $fields['action_refuse'] ? true : false; } else { $show_other_messages = true; } addMessageAfterRedirect($message_text, true, $show_other_messages, $show_other_messages); } if ($p['add_event_on_duplicate']) { Event::log(!$add ? $this->fields['id'] : 0, get_class($this), 4, 'inventory', $_SESSION["glpiname"] . " " . $LANG['log'][123] . ' : ' . $message_text); } } if ($fields['action_refuse']) { $result = false; } if ($fields['action_notify']) { $params = array('message' => html_clean($message_text), 'action_type' => $add, 'action_user' => getUserName(getLoginUserID()), 'entities_id' => $entities_id, 'itemtype' => get_class($this), 'date' => $_SESSION['glpi_currenttime'], 'refuse' => $fields['action_refuse']); NotificationEvent::raiseEvent('refuse', new FieldUnicity(), $params); } } } } } } return $result; }
*/ // ---------------------------------------------------------------------- // Original Author of file: // Purpose of file: // ---------------------------------------------------------------------- define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; header("Content-Type: text/html; charset=UTF-8"); header_nocache(); if (!isset($_REQUEST['glpi_tab'])) { exit; } checkLoginUser(); $user = new User(); switch ($_REQUEST['glpi_tab']) { case 2: $config = new Config(); $user->getFromDB(getLoginUserID()); $user->computePreferences(); $config->showFormUserPrefs($user->fields); break; case 3: DisplayPreference::showForUser(getLoginUserID()); break; default: $pref = new Preference(); if (!Plugin::displayAction($pref, $_REQUEST['glpi_tab'])) { $user->showMyForm($CFG_GLPI['root_doc'] . "/front/preference.php", getLoginUserID()); } } ajaxFooter();
static function showShortForTicket($ID) { global $DB, $CFG_GLPI, $LANG; // Print Followups for a job $showprivate = haveRight("show_full_ticket", "1"); $RESTRICT = ""; if (!$showprivate) { $RESTRICT = " AND (`is_private` = '0'\n OR `users_id` ='" . getLoginUserID() . "') "; } // Get Number of Followups $query = "SELECT *\n FROM `glpi_ticketfollowups`\n WHERE `tickets_id` = '{$ID}'\n {$RESTRICT}\n ORDER BY `date` DESC"; $result = $DB->query($query); $out = ""; if ($DB->numrows($result) > 0) { $out .= "<div class='center'><table class='tab_cadre' width='100%'>\n\n <tr><th>" . $LANG['common'][27] . "</th><th>" . $LANG['job'][4] . "</th>\n <th>" . $LANG['joblist'][6] . "</th></tr>\n"; while ($data = $DB->fetch_array($result)) { $out .= "<tr class='tab_bg_3'>\n <td class='center'>" . convDateTime($data["date"]) . "</td>\n <td class='center'>" . getUserName($data["users_id"], 1) . "</td>\n <td width='70%' class='b'>" . resume_text($data["content"], $CFG_GLPI["cut"]) . "\n </td></tr>"; } $out .= "</table></div>"; } return $out; }
/** * Log history * * @param $items_id * @param $itemtype * @param $changes * @param $itemtype_link * @param $linked_action * * @return boolean success **/ static function history($items_id, $itemtype, $changes, $itemtype_link = '', $linked_action = '0') { global $DB; $date_mod = $_SESSION["glpi_currenttime"]; if (empty($changes)) { return false; } // create a query to insert history $id_search_option = $changes[0]; $old_value = $changes[1]; $new_value = $changes[2]; if ($uid = getLoginUserID(false)) { if (is_numeric($uid)) { $username = getUserName($uid, $link = 0); } else { // For cron management $username = $uid; } } else { $username = ""; } $old_value = mysql_real_escape_string(utf8_substr(stripslashes($old_value), 0, 180)); $new_value = mysql_real_escape_string(utf8_substr(stripslashes($new_value), 0, 180)); // Security to be sure that values do not pass over the max length if (utf8_strlen($old_value) > 255) { $old_value = utf8_substr($old_value, 0, 250); } if (utf8_strlen($new_value) > 255) { $new_value = utf8_substr($new_value, 0, 250); } // Build query $query = "INSERT INTO `glpi_logs`\n (`items_id`, `itemtype`, `itemtype_link`, `linked_action`, `user_name`,\n `date_mod`, `id_search_option`, `old_value`, `new_value`)\n VALUES ('{$items_id}', '{$itemtype}', '{$itemtype_link}', '{$linked_action}',\n '" . addslashes($username) . "', '{$date_mod}', '{$id_search_option}',\n '{$old_value}', '{$new_value}')"; if ($DB->query($query)) { return $DB->insert_id(); } return false; }
if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") { helpHeader($LANG['Menu'][5], '', $_SESSION["glpiname"]); } else { commonHeader($LANG['Menu'][5], '', "maintain", "ticket"); } $available_options = array('load_kb_sol'); $options = array(); foreach ($available_options as $key) { if (isset($_GET[$key])) { $options[$key] = $_GET[$key]; } } $track->showForm($_GET["id"], $options); } else { commonHeader($LANG['job'][13], '', "maintain", "ticket"); $users_id_requester = getLoginUserID(); // No default requester if own ticket right = tech and update_ticket right to update requester if (haveRight('own_ticket', 1) && haveRight('update_ticket', 1)) { $users_id_requester = 0; } // Set default value... $values = array('_users_id_requester' => $users_id_requester, '_users_id_requester_notif' => array('use_notification' => 1), '_groups_id_requester' => 0, '_users_id_assign' => 0, '_users_id_assign_notif' => array('use_notification' => 1), '_groups_id_assign' => 0, '_users_id_observer' => 0, '_users_id_observer_notif' => array('use_notification' => 1), '_groups_id_observer' => 0, 'suppliers_id_assign' => 0, 'name' => '', 'content' => '', 'ticketcategories_id' => 0, 'urgency' => 3, 'impact' => 3, 'priority' => Ticket::computePriority(3, 3), 'requesttypes_id' => $_SESSION["glpidefault_requesttypes_id"], 'hour' => 0, 'minute' => 0, 'date' => $_SESSION["glpi_currenttime"], 'entities_id' => $_SESSION["glpiactive_entity"], 'status' => 'new', 'followup' => array(), 'itemtype' => '', 'items_id' => 0, 'plan' => array(), 'global_validation' => 'none', 'due_date' => '', 'slas_id' => 0, '_add_validation' => 0, 'type' => -1); // Restore saved value or override with page parameter foreach ($values as $name => $value) { if (isset($_REQUEST[$name])) { $values[$name] = $_REQUEST[$name]; } else { if (isset($_SESSION["helpdeskSaved"][$name])) { $values[$name] = $_SESSION["helpdeskSaved"]["{$name}"]; } }
/** * Show the central personal view * * **/ static function showMyView() { global $LANG, $DB; $showticket = haveRight("show_all_ticket", "1") || haveRight("show_assign_ticket", "1"); echo "<table class='tab_cadre_central'>"; if ($DB->isSlave() && !$DB->first_connection) { echo "<tr><th colspan='2'><br>"; displayTitle(GLPI_ROOT . "/pics/warning.png", $LANG['setup'][809], $LANG['setup'][809]); echo "</th></tr>"; } echo "<tr><td class='top'><table>"; if (haveRight('validate_ticket', 1)) { echo "<tr><td class='top' width='450px'><br>"; Ticket::showCentralList(0, "tovalidate", false); echo "</td></tr>"; } echo "<tr><td class='top' width='450px'>"; Ticket::showCentralList(0, "toapprove", false); echo "</td></tr>"; echo "<tr><td class='top' width='450px'>"; Ticket::showCentralList(0, "requestbyself", false); echo "</td></tr>"; if ($showticket) { echo "<tr><td class='top' width='450px'>"; Ticket::showCentralList(0, "process", false); echo "</td></tr>"; echo "<tr><td class='top' width='450px'>"; Ticket::showCentralList(0, "waiting", false); echo "</td></tr>"; } echo "</table></td>"; echo "<td class='top'><table><tr>"; echo "<td class='top' width='450px'><br>"; Planning::showCentral(getLoginUserID()); echo "</td></tr>"; echo "<tr><td class='top' width='450px'>"; Reminder::showListForCentral(); echo "</td></tr>"; if (haveRight("reminder_public", "r")) { echo "<tr><td class='top' width='450px'>"; Reminder::showListForCentral($_SESSION["glpiactive_entity"]); $entities = array_reverse(getAncestorsOf("glpi_entities", $_SESSION["glpiactive_entity"])); foreach ($entities as $entity) { Reminder::showListForCentral($entity, true); } foreach ($_SESSION["glpiactiveentities"] as $entity) { if ($entity != $_SESSION["glpiactive_entity"]) { Reminder::showListForCentral($entity, false); } } echo "</td></tr>"; } echo "</table></td></tr></table>"; }
/** * Print the validation form * * @param $ID integer ID of the item * @param $options array options used * **/ function showForm($ID, $options = array()) { global $LANG; $this->check($ID, 'w'); if ($ID > 0) { $tickets_id = $this->fields["tickets_id"]; } else { $tickets_id = $options['ticket']->fields["id"]; } $ticket = new Ticket(); if (!$ticket->getFromDB($tickets_id)) { return false; } // No update validation is answer set $validation_admin = $this->fields["users_id"] == getLoginUserID() && $this->canCreate() && $this->fields['status'] == 'waiting'; $validator = $this->fields["users_id_validate"] == getLoginUserID(); $options['colspan'] = 1; $this->showFormHeader($options); if ($validation_admin) { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['validation'][18] . " : </td>"; echo "<td>"; echo "<input type='hidden' name='tickets_id' value='" . $ticket->fields['id'] . "'>"; echo "<input type='hidden' name='entities_id' value='" . $ticket->fields['entities_id'] . "'>"; echo getUserName($this->fields["users_id"]); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['validation'][21] . " : </td>"; echo "<td>"; echo "<input type='hidden' name='tickets_id' value='" . $ticket->fields['id'] . "'>"; echo "<input type='hidden' name='entities_id' value='" . $ticket->fields['entities_id'] . "'>"; User::dropdown(array('name' => "users_id_validate", 'entity' => $ticket->fields['entities_id'], 'right' => 'validate_ticket', 'value' => $this->fields["users_id_validate"])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][25] . " : </td>"; echo "<td><textarea cols='60' rows='3' name='comment_submission'>" . $this->fields["comment_submission"] . "</textarea></td></tr>"; } else { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['validation'][18] . " : </td>"; echo "<td>" . getUserName($this->fields["users_id"]) . "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . $LANG['validation'][21] . " : </td>"; echo "<td>" . getUserName($this->fields["users_id_validate"]) . "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][25] . " : </td>"; echo "<td>" . $this->fields["comment_submission"] . "</td></tr>"; } if ($ID > 0) { echo "<tr class='tab_bg_2'><td colspan='2'> </td></tr>"; if ($validator) { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['validation'][28] . " : </td>"; echo "<td>"; self::dropdownStatus("status", array('value' => $this->fields["status"])); echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['validation'][6] . " (" . $LANG['validation'][16] . ") : </td>"; echo "<td><textarea cols='60' rows='3' name='comment_validation'>" . $this->fields["comment_validation"] . "</textarea>"; echo "</td></tr>"; } else { echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['validation'][28] . " : </td>"; echo "<td>" . self::getStatus($this->fields["status"]) . "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . $LANG['common'][25] . " : </td>"; echo "<td>" . $this->fields["comment_validation"] . "</td></tr>"; } } $this->showFormButtons($options); return true; }
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -------------------------------------------------------------------------- */ // ---------------------------------------------------------------------- // Original Author of file: // Purpose of file: // ---------------------------------------------------------------------- define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; if (!isset($_GET["uID"])) { if (($uid = getLoginUserID()) && !haveRight("show_all_planning", "1")) { $_GET["uID"] = $uid; } else { $_GET["uID"] = 0; } } if (!isset($_GET["gID"])) { $_GET["gID"] = 0; } if (!isset($_GET["usertype"])) { $_GET["usertype"] = "user"; } switch ($_GET["usertype"]) { case "user": $_GET['gID'] = 0; break;
/** * Load groups where I am in the active entity. * * @return Nothing **/ function loadGroups() { global $DB; $_SESSION["glpigroups"] = array(); $query_gp = "SELECT `groups_id`\n FROM `glpi_groups_users`\n LEFT JOIN `glpi_groups` ON (`glpi_groups_users`.`groups_id` = `glpi_groups`.`id`)\n WHERE `glpi_groups_users`.`users_id`='" . getLoginUserID() . "' " . getEntitiesRestrictRequest(" AND ", "glpi_groups", "entities_id", $_SESSION['glpiactiveentities'], true); $result_gp = $DB->query($query_gp); if ($DB->numrows($result_gp)) { while ($data = $DB->fetch_array($result_gp)) { $_SESSION["glpigroups"][] = $data["groups_id"]; } } }
define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; $user = new User(); // Manage lost password if (isset($_GET['lostpassword'])) { nullHeader(); if (isset($_GET['token'])) { User::showPasswordForgetChangeForm($_GET['token']); } else { User::showPasswordForgetRequestForm(); } nullFooter(); exit; } checkLoginUser(); if (isset($_POST["update"]) && $_POST["id"] === getLoginUserID()) { $user->update($_POST); Event::log(0, "users", 5, "setup", $_SESSION["glpiname"] . " " . $LANG['log'][21] . " " . $_SESSION["glpiname"] . "."); glpi_header($_SERVER['HTTP_REFERER']); } else { if ($_SESSION["glpiactiveprofile"]["interface"] == "central") { commonHeader($LANG['title'][13], $_SERVER['PHP_SELF'], 'preference'); } else { helpHeader($LANG['title'][13], $_SERVER['PHP_SELF']); } $pref = new Preference(); $pref->show(); if ($_SESSION["glpiactiveprofile"]["interface"] == "central") { commonFooter(); } else { helpFooter();
function plugin_monitoring_addDefaultWhere($type) { switch ($type) { case "PluginMonitoringDisplayview": $who = getLoginUserID(); return " (`glpi_plugin_monitoring_displayviews`.`users_id` = '{$who}' \n OR `glpi_plugin_monitoring_displayviews`.`users_id` = '0') "; break; } return ""; }
/** * Show documents associated to an item * * @param $item CommonDBTM object for which associated documents must be displayed * @param $withtemplate **/ static function showAssociated(CommonDBTM $item, $withtemplate = '') { global $DB, $CFG_GLPI, $LANG; $ID = $item->getField('id'); if ($item->isNewID($ID)) { return false; } if ($item->getType() != 'Ticket' && $item->getType() != 'KnowbaseItem' && !haveRight('document', 'r')) { return false; } if (!$item->can($item->fields['id'], 'r')) { return false; } if (empty($withtemplate)) { $withtemplate = 0; } $linkparam = ''; if (get_class($item) == 'Ticket') { $linkparam = "&tickets_id=" . $item->fields['id']; } $canedit = $item->can($ID, 'w'); $is_recursive = $item->isRecursive(); $query = "SELECT `glpi_documents_items`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_documents`.`name` AS assocName,\n `glpi_documents`.*\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_documents`\n ON (`glpi_documents_items`.`documents_id`=`glpi_documents`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_documents`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_documents_items`.`items_id` = '{$ID}'\n AND `glpi_documents_items`.`itemtype` = '" . $item->getType() . "' "; if (getLoginUserID()) { $query .= getEntitiesRestrictRequest(" AND", "glpi_documents", '', '', true); } else { // Anonymous access from FAQ $query .= " AND `glpi_documents`.`entities_id`= '0' "; } // Document : search links in both order using union if ($item->getType() == 'Document') { $query .= "UNION\n SELECT `glpi_documents_items`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_documents`.`name` AS assocName,\n `glpi_documents`.*\n FROM `glpi_documents_items`\n LEFT JOIN `glpi_documents`\n ON (`glpi_documents_items`.`items_id`=`glpi_documents`.`id`)\n LEFT JOIN `glpi_entities`\n ON (`glpi_documents`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_documents_items`.`documents_id` = '{$ID}'\n AND `glpi_documents_items`.`itemtype` = '" . $item->getType() . "' "; if (getLoginUserID()) { $query .= getEntitiesRestrictRequest(" AND", "glpi_documents", '', '', true); } else { // Anonymous access from FAQ $query .= " AND `glpi_documents`.`entities_id`='0' "; } } $query .= " ORDER BY `assocName`"; $result = $DB->query($query); $number = $DB->numrows($result); $i = 0; if ($withtemplate != 2) { echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/front/document.form.php\" enctype=\"multipart/form-data\">"; } echo "<div class='spaced'><table class='tab_cadre_fixe'>"; echo "<tr><th colspan='7'>"; if ($DB->numrows($result) == 0) { echo $LANG['document'][17]; } else { if ($DB->numrows($result) == 1) { echo $LANG['document'][21]; } else { echo $LANG['document'][20]; } } echo "</th></tr>"; echo "<tr><th>" . $LANG['common'][16] . "</th>"; echo "<th>" . $LANG['entity'][0] . "</th>"; echo "<th>" . $LANG['document'][2] . "</th>"; echo "<th>" . $LANG['document'][33] . "</th>"; echo "<th>" . $LANG['document'][3] . "</th>"; echo "<th>" . $LANG['document'][4] . "</th>"; if ($withtemplate < 2) { echo "<th> </th>"; } echo "</tr>"; $used = array(); if ($number) { // Don't use this for document associated to document // To not loose navigation list for current document if ($item->getType() != 'Document') { initNavigateListItems('Document', $item->getTypeName() . " = " . $item->getName()); } $document = new Document(); while ($data = $DB->fetch_assoc($result)) { $docID = $data["id"]; $link = NOT_AVAILABLE; $downloadlink = NOT_AVAILABLE; if ($document->getFromDB($docID)) { $link = $document->getLink(); $downloadlink = $document->getDownloadLink($linkparam); } if ($item->getType() != 'Document') { addToNavigateListItems('Document', $docID); } $used[$docID] = $docID; $assocID = $data["assocID"]; echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>"; echo "<td class='center'>{$link}</td>"; echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entity']); echo "</td>"; echo "<td class='center'>{$downloadlink}</td>"; echo "<td class='center'>"; if (!empty($data["link"])) { echo "<a target=_blank href='" . formatOutputWebLink($data["link"]) . "'>" . $data["link"]; echo "</a>"; } else { echo " "; } echo "</td>"; echo "<td class='center'>" . Dropdown::getDropdownName("glpi_documentcategories", $data["documentcategories_id"]); echo "</td>"; echo "<td class='center'>" . $data["mime"] . "</td>"; if ($withtemplate < 2) { echo "<td class='tab_bg_2 center b'>"; if ($canedit && $_SESSION["glpiactiveprofile"]["interface"] != 'helpdesk') { echo "<a href='" . $CFG_GLPI["root_doc"]; echo "/front/document.form.php?deletedocumentitem=1&id={$assocID}"; echo "&itemtype=" . $item->getType() . "&items_id={$ID}&documents_id={$docID}'>"; echo $LANG['buttons'][6] . "</a>"; } else { echo " "; } echo "</td>"; } echo "</tr>"; $i++; } } if ($canedit) { // hack for ticket || get_class($item)=='Ticket') { // Restrict entity for knowbase $entities = ""; $entity = $_SESSION["glpiactive_entity"]; if ($item->isEntityAssign()) { $entity = $item->getEntityID(); if ($item->isRecursive()) { $entities = getSonsOf('glpi_entities', $entity); } else { $entities = $entity; } } if ($withtemplate < 2) { $limit = getEntitiesRestrictRequest(" AND ", "glpi_documents", '', $entities, true); $q = "SELECT count(*)\n FROM `glpi_documents`\n WHERE `is_deleted` = '0'\n {$limit}"; $result = $DB->query($q); $nb = $DB->result($result, 0, 0); echo "<tr class='tab_bg_1'><td class='center' colspan='3'>"; echo "<input type='hidden' name='entities_id' value='{$entity}'>"; echo "<input type='hidden' name='is_recursive' value='{$is_recursive}'>"; echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>"; echo "<input type='hidden' name='items_id' value='{$ID}'>"; if ($item->getType() == 'Ticket') { echo "<input type='hidden' name='documentcategories_id' value='" . $CFG_GLPI["documentcategories_id_forticket"] . "'>"; echo "<input type='hidden' name='tickets_id' value='{$ID}'>"; } echo "<input type='file' name='filename' size='25'> "; echo "(" . self::getMaxUploadSize() . ") "; echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>"; echo "</td>"; if ($item->getType() == 'Document') { $used[$ID] = $ID; } if (haveRight('document', 'r') && $nb > count($used)) { echo "<td class='left' colspan='2'>"; self::dropdown(array('entity' => $entities, 'used' => $used)); echo "</td><td class='center'>"; echo "<input type='submit' name='adddocumentitem' value=\"" . $LANG['buttons'][8] . "\" class='submit'>"; echo "</td><td> </td>"; } else { echo "<td colspan='4'> </td>"; } echo "</tr>"; } } echo "</table></form></div>"; }