/** * Print the HTML array for device on link * * Print the HTML array for device on link for link $instID * *@param $links_id array : Link identifier. * *@return Nothing (display) * **/ static function showForItem($links_id) { global $DB, $CFG_GLPI, $LANG; $link = new Link(); if ($links_id > 0) { $link->check($links_id, 'r'); } else { // Create item $link->check(-1, 'w'); $link->getEmpty(); } $canedit = $link->can($links_id, 'w'); $canrecu = $link->can($links_id, 'recursive'); if (!haveRight("link", "r")) { return false; } //$canedit= haveRight("link","w"); $query = "SELECT *\n FROM `glpi_links_itemtypes`\n WHERE `links_id`='{$links_id}'\n ORDER BY `itemtype`"; $result = $DB->query($query); $number = $DB->numrows($result); $i = 0; $used = array(); echo "<form method='post' action=\"" . $CFG_GLPI["root_doc"] . "/front/link_itemtype.form.php\">"; echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr><th colspan='2'>" . $LANG['links'][4] . " :</th></tr>"; echo "<tr><th>" . $LANG['common'][17] . "</th>"; echo "<th> </th></tr>"; while ($i < $number) { $ID = $DB->result($result, $i, "id"); $itemtype = $DB->result($result, $i, "itemtype"); $typename = NOT_AVAILABLE; if (class_exists($itemtype)) { $item = new $itemtype(); $typename = $item->getTypeName(); } echo "<tr class='tab_bg_1'>"; echo "<td class='center'>{$typename}</td>"; echo "<td class='center'>"; echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/link_itemtype.form.php?delete=deletedevice&id={$ID}&links_id={$links_id}'>\n <strong>" . $LANG['buttons'][6] . "</strong></a></td></tr>"; $used[$itemtype] = $itemtype; $i++; } if ($canedit) { echo "<tr class='tab_bg_1'><td> </td><td class='center'>"; echo "<input type='hidden' name='links_id' value='{$links_id}'>"; Dropdown::dropdownTypes("itemtype", '', $CFG_GLPI["link_types"], $used); echo " <input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>"; echo "</td></tr>"; } echo "</table></div></form>"; }
/** * Add a single link to the links collection * * @param string $rel The relation of the link to the document. See RFC 5988 * http://tools.ietf.org/html/rfc5988#section-6.2.2 A document * MUST always have a "self" link. * @param Link $link The actual link object * @param boolean $overwrite When false and a link of $rel relation exists, an array of * links is created. Otherwise the existing link is overwriten * with the new one * * @return boolean True if the link was added to the collection */ public function addLink($rel, Link $link, $overwrite = true) { if (!$link->check()) { return false; } if (!array_key_exists($rel, $this->_links) || $overwrite) { $this->_links[$rel] = $link; } else { if (!is_array($this->_links[$rel])) { $this->_links[$rel] = array($this->_links[$rel]); } $this->_links[$rel][] = $link; } }
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: Julien Dombre // Purpose of file: // ---------------------------------------------------------------------- define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; if (empty($_GET["id"])) { $_GET["id"] = ""; } $link = new Link(); $link_itemtype = new Link_ItemType(); if (isset($_POST["add"])) { $link->check($_GET["id"], 'w'); if ($link_itemtype->add($_POST)) { Event::log($_POST["links_id"], "links", 4, "setup", $_SESSION["glpiname"] . " " . $LANG['log'][32]); } glpi_header($CFG_GLPI["root_doc"] . "/front/link.form.php?id=" . $_POST["links_id"]); } else { if (isset($_GET["delete"])) { $link->check($_GET["links_id"], 'w'); $link_itemtype->delete($_GET); Event::log($_GET["links_id"], "links", 4, "setup", $_SESSION["glpiname"] . " " . $LANG['log'][33]); glpi_header($_SERVER['HTTP_REFERER']); } }
This file is part of GLPI. GLPI is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPI 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 General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; Session::checkCentralAccess(); $link = new Link(); $link_itemtype = new Link_ItemType(); if (isset($_POST["add"])) { $link->check(-1, CREATE, $_POST); if ($link_itemtype->add($_POST)) { Event::log($_POST["links_id"], "links", 4, "setup", sprintf(__('%s adds a link with an item'), $_SESSION["glpiname"])); } Html::redirect($CFG_GLPI["root_doc"] . "/front/link.form.php?id=" . $_POST["links_id"]); }
You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; Session::checkRight("link", READ); if (empty($_GET["id"])) { $_GET["id"] = ""; } $link = new Link(); if (isset($_POST["add"])) { $link->check(-1, CREATE); $newID = $link->add($_POST); Event::log($newID, "links", 4, "setup", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"])); Html::redirect(Toolbox::getItemTypeFormURL('Link') . "?id=" . $newID); } else { if (isset($_POST["purge"])) { $link->check($_POST["id"], PURGE); $link->delete($_POST, 1); Event::log($_POST["id"], "links", 4, "setup", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); $link->redirectToList(); } else { if (isset($_POST["update"])) { $link->check($_POST["id"], UPDATE); $link->update($_POST); Event::log($_POST["id"], "links", 4, "setup", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); Html::back();
You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; Session::checkRight("link", "r"); if (empty($_GET["id"])) { $_GET["id"] = ""; } $link = new Link(); if (isset($_POST["add"])) { $link->check(-1, 'w'); $newID = $link->add($_POST); Event::log($newID, "links", 4, "setup", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"])); Html::redirect(Toolbox::getItemTypeFormURL('Link') . "?id=" . $newID); } else { if (isset($_POST["delete"])) { $link->check($_POST["id"], 'd'); $link->delete($_POST); Event::log($_POST["id"], "links", 4, "setup", sprintf(__('%s purges an item'), $_SESSION["glpiname"])); $link->redirectToList(); } else { if (isset($_POST["update"])) { $link->check($_POST["id"], 'w'); $link->update($_POST); Event::log($_POST["id"], "links", 4, "setup", sprintf(__('%s updates an item'), $_SESSION["glpiname"])); Html::back();
This file is part of GLPI. GLPI is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPI 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 General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; Session::checkCentralAccess(); $link = new Link(); $link_itemtype = new Link_ItemType(); if (isset($_POST["add"])) { $link->check(-1, 'w', $_POST); if ($link_itemtype->add($_POST)) { Event::log($_POST["links_id"], "links", 4, "setup", sprintf(__('%s adds a link with an item'), $_SESSION["glpiname"])); } Html::redirect($CFG_GLPI["root_doc"] . "/front/link.form.php?id=" . $_POST["links_id"]); }
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: Julien Dombre // Purpose of file: // ---------------------------------------------------------------------- define('GLPI_ROOT', '..'); include GLPI_ROOT . "/inc/includes.php"; if (empty($_GET["id"])) { $_GET["id"] = ""; } $link = new Link(); if (isset($_POST["add"])) { $link->check(-1, 'w'); $newID = $link->add($_POST); Event::log($newID, "links", 4, "setup", $_SESSION["glpiname"] . " " . $LANG['log'][20] . " " . $_POST["name"] . "."); glpi_header(getItemTypeFormURL('Link') . "?id=" . $newID); } else { if (isset($_POST["delete"])) { $link->check($_GET["id"], 'w'); $link->delete($_POST); Event::log($_GET["id"], "links", 4, "setup", $_SESSION["glpiname"] . " " . $LANG['log'][22]); $link->redirectToList(); } else { if (isset($_POST["update"])) { $link->check($_GET["id"], 'w'); $link->update($_POST); Event::log($_GET["id"], "links", 4, "setup", $_SESSION["glpiname"] . " " . $LANG['log'][21]); glpi_header($_SERVER['HTTP_REFERER']);