当前位置: 首页>>代码示例>>PHP>>正文


PHP Software::getFromDB方法代码示例

本文整理汇总了PHP中Software::getFromDB方法的典型用法代码示例。如果您正苦于以下问题:PHP Software::getFromDB方法的具体用法?PHP Software::getFromDB怎么用?PHP Software::getFromDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Software的用法示例。


在下文中一共展示了Software::getFromDB方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPreAdditionalInfosForName

 /**
  * @since version 0.84
  *
  * @see CommonDBTM::getPreAdditionalInfosForName
  **/
 function getPreAdditionalInfosForName()
 {
     $soft = new Software();
     if ($soft->getFromDB($this->fields['softwares_id'])) {
         return $soft->getName();
     }
     return '';
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:13,代码来源:softwareversion.class.php

示例2: SoftwareVersion

 function post_deleteFromDB()
 {
     $vers = new SoftwareVersion();
     if (!$vers->getFromDB($this->fields['softwareversions_id'])) {
         return false;
     }
     /// Could not be possible : because several computers may be linked to a version
     // Update affected licenses
     //       $lic = new SoftwareLicense();
     //       $query = "SELECT `id`
     //                 FROM `glpi_softwarelicenses`
     //                 WHERE `softwares_id` = '".$vers->fields['softwares_id']."'
     //                   AND `computers_id` = '".$this->fields['computers_id']."'
     //                   AND `softwareversions_id_use` = '".$this->fields['softwareversions_id']."'";
     //       foreach ($DB->request($query) as $data) {
     //          $data['softwareversions_id_use'] = 0;
     //          $lic->update($data);
     //       }
     if (isset($this->input['_no_history']) && $this->input['_no_history']) {
         return false;
     }
     $soft = new Software();
     if ($soft->getFromDB($vers->fields['softwares_id'])) {
         $changes[0] = '0';
         $changes[1] = addslashes($soft->fields["name"] . " " . $vers->fields["name"]);
         $changes[2] = "";
         // Log on Computer history
         Log::history($this->fields['computers_id'], 'Computer', $changes, 0, HISTORY_UNINSTALL_SOFTWARE);
     }
     $comp = new Computer();
     if ($comp->getFromDB($this->fields['computers_id'])) {
         $changes[0] = '0';
         $changes[1] = addslashes($comp->fields["name"]);
         $changes[2] = "";
         // Log on SoftwareVersion history
         Log::history($this->fields['softwareversions_id'], 'SoftwareVersion', $changes, 0, HISTORY_UNINSTALL_SOFTWARE);
     }
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:38,代码来源:computer_softwareversion.class.php

示例3: showForWebapplication


//.........这里部分代码省略.........
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     if ($canedit && $number) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . __('Type') . "</th>";
     echo "<th>" . __('Name') . "</th>";
     echo "<th>" . __('Entity') . "</th>";
     echo "<th>" . __('Serial number') . "</th>";
     echo "<th>" . __('Inventory number') . "</th>";
     echo "</tr>";
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         if ($item->canView()) {
             $column = "name";
             if ($itemtype == 'Ticket') {
                 $column = "id";
             }
             $itemtable = getTableForItemType($itemtype);
             $query = "SELECT `{$itemtable}`.*,\n                                 `glpi_plugin_webapplications_webapplications_items`.`id` AS IDD, ";
             if ($itemtype == 'KnowbaseItem') {
                 $query .= "-1 AS entity\n                          FROM `glpi_plugin_webapplications_webapplications_items`, `{$itemtable}`\n                          " . KnowbaseItem::addVisibilityJoins() . "\n                          WHERE `{$itemtable}`.`id` = `glpi_plugin_webapplications_webapplications_items`.`items_id`\n                                AND ";
             } else {
                 $query .= "`glpi_entities`.`id` AS entity\n                          FROM `glpi_plugin_webapplications_webapplications_items`, `{$itemtable}` ";
                 if ($itemtype != 'Entity') {
                     $query .= "LEFT JOIN `glpi_entities`\n                              ON (`glpi_entities`.`id` = `{$itemtable}`.`entities_id`) ";
                 }
                 $query .= "WHERE `{$itemtable}`.`id` = `glpi_plugin_webapplications_webapplications_items`.`items_id`\n                                AND ";
             }
             $query .= "`glpi_plugin_webapplications_webapplications_items`.`itemtype` = '{$itemtype}'\n                       AND `glpi_plugin_webapplications_webapplications_items`.`plugin_webapplications_webapplications_id` = '{$instID}' ";
             if ($itemtype == 'KnowbaseItem') {
                 if (Session::getLoginUserID()) {
                     $where = "AND " . KnowbaseItem::addVisibilityRestrict();
                 } else {
                     // Anonymous access
                     if (Session::isMultiEntitiesMode()) {
                         $where = " AND (`glpi_entities_knowbaseitems`.`entities_id` = '0'\n                                     AND `glpi_entities_knowbaseitems`.`is_recursive` = '1')";
                     }
                 }
             } else {
                 $query .= getEntitiesRestrictRequest(" AND ", $itemtable, '', '', $item->maybeRecursive());
             }
             if ($item->maybeTemplate()) {
                 $query .= " AND `{$itemtable}`.`is_template` = '0'";
             }
             if ($itemtype == 'KnowbaseItem') {
                 $query .= " ORDER BY `{$itemtable}`.`{$column}`";
             } else {
                 $query .= " ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`{$column}`";
             }
             if ($itemtype == 'SoftwareLicense') {
                 $soft = new Software();
             }
             if ($result_linked = $DB->query($query)) {
                 if ($DB->numrows($result_linked)) {
                     while ($data = $DB->fetch_assoc($result_linked)) {
                         if ($itemtype == 'Ticket') {
                             $data["name"] = sprintf(__('%1$s: %2$s'), __('Ticket'), $data["id"]);
                         }
                         if ($itemtype == 'SoftwareLicense') {
                             $soft->getFromDB($data['softwares_id']);
                             $data["name"] = sprintf(__('%1$s - %2$s'), $data["name"], $soft->fields['name']);
                         }
                         $linkname = $data["name"];
                         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                             $linkname = sprintf(__('%1$s (%2$s)'), $linkname, $data["id"]);
                         }
                         $link = Toolbox::getItemTypeFormURL($itemtype);
                         $name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $linkname . "</a>";
                         echo "<tr class='tab_bg_1'>";
                         if ($canedit) {
                             echo "<td width='10'>";
                             Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]);
                             echo "</td>";
                         }
                         echo "<td class='center'>" . $item->getTypeName(1) . "</td>";
                         echo "<td " . (isset($data['is_deleted']) && $data['is_deleted'] ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>";
                         echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entity']);
                         echo "</td>";
                         echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>";
                         echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>";
                         echo "</tr>";
                     }
                 }
             }
         }
     }
     echo "</table>";
     if ($canedit && $number) {
         $paramsma['ontop'] = false;
         Html::showMassiveActions($paramsma);
         Html::closeForm();
     }
     echo "</div>";
 }
开发者ID:wittwerch,项目名称:webapplications,代码行数:101,代码来源:webapplication_item.class.php

示例4: showForLicense

 /**
  * Show computers linked to a License
  *
  * @param $license SoftwareLicense object
  *
  * @return nothing
  **/
 static function showForLicense(SoftwareLicense $license)
 {
     global $DB, $CFG_GLPI;
     $searchID = $license->getField('id');
     if (!Software::canView() || !$searchID) {
         return false;
     }
     $canedit = Session::haveRightsOr("software", array(CREATE, UPDATE, DELETE, PURGE));
     $canshowcomputer = Computer::canView();
     if (isset($_GET["start"])) {
         $start = $_GET["start"];
     } else {
         $start = 0;
     }
     if (isset($_GET["order"]) && $_GET["order"] == "DESC") {
         $order = "DESC";
     } else {
         $order = "ASC";
     }
     if (isset($_GET["sort"]) && !empty($_GET["sort"])) {
         // manage several param like location,compname : order first
         $tmp = explode(",", $_GET["sort"]);
         $sort = "`" . implode("` {$order},`", $tmp) . "`";
     } else {
         $sort = "`entity` {$order}, `compname`";
     }
     //SoftwareLicense ID
     $query_number = "SELECT COUNT(*) AS cpt\n                       FROM `glpi_computers_softwarelicenses`\n                       INNER JOIN `glpi_computers`\n                           ON (`glpi_computers_softwarelicenses`.`computers_id`\n                                 = `glpi_computers`.`id`)\n                       WHERE `glpi_computers_softwarelicenses`.`softwarelicenses_id` = '{$searchID}'" . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n                             AND `glpi_computers`.`is_deleted` = '0'\n                             AND `glpi_computers`.`is_template` = '0'\n                             AND `glpi_computers_softwarelicenses`.`is_deleted` = '0'";
     $number = 0;
     if ($result = $DB->query($query_number)) {
         $number = $DB->result($result, 0, 0);
     }
     echo "<div class='center'>";
     if ($canedit) {
         echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwarelicense.form.php'>";
         echo "<input type='hidden' name='softwarelicenses_id' value='{$searchID}'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2 center'>";
         echo "<td>";
         Computer::dropdown(array('entity' => $license->fields['entities_id'], 'entity_sons' => $license->fields['is_recursive']));
         echo "</td>";
         echo "<td><input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
     }
     if ($number < 1) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . __('No item found') . "</th></tr>";
         echo "</table></div>\n";
         return;
     }
     // Display the pager
     Html::printAjaxPager(__('Affected computers'), $start, $number);
     $query = "SELECT `glpi_computers_softwarelicenses`.*,\n                       `glpi_computers`.`name` AS compname,\n                       `glpi_computers`.`id` AS cID,\n                       `glpi_computers`.`serial`,\n                       `glpi_computers`.`otherserial`,\n                       `glpi_users`.`name` AS username,\n                       `glpi_users`.`id` AS userid,\n                       `glpi_users`.`realname` AS userrealname,\n                       `glpi_users`.`firstname` AS userfirstname,\n                       `glpi_softwarelicenses`.`name` AS license,\n                       `glpi_softwarelicenses`.`id` AS vID,\n                       `glpi_softwarelicenses`.`name` AS vername,\n                       `glpi_entities`.`completename` AS entity,\n                       `glpi_locations`.`completename` AS location,\n                       `glpi_states`.`name` AS state,\n                       `glpi_groups`.`name` AS groupe,\n                       `glpi_softwarelicenses`.`name` AS lname,\n                       `glpi_softwarelicenses`.`id` AS lID,\n                       `glpi_softwarelicenses`.`softwares_id` AS softid\n                FROM `glpi_computers_softwarelicenses`\n                INNER JOIN `glpi_softwarelicenses`\n                     ON (`glpi_computers_softwarelicenses`.`softwarelicenses_id`\n                          = `glpi_softwarelicenses`.`id`)\n                INNER JOIN `glpi_computers`\n                     ON (`glpi_computers_softwarelicenses`.`computers_id` = `glpi_computers`.`id`)\n                LEFT JOIN `glpi_entities` ON (`glpi_computers`.`entities_id` = `glpi_entities`.`id`)\n                LEFT JOIN `glpi_locations`\n                     ON (`glpi_computers`.`locations_id` = `glpi_locations`.`id`)\n                LEFT JOIN `glpi_states` ON (`glpi_computers`.`states_id` = `glpi_states`.`id`)\n                LEFT JOIN `glpi_groups` ON (`glpi_computers`.`groups_id` = `glpi_groups`.`id`)\n                LEFT JOIN `glpi_users` ON (`glpi_computers`.`users_id` = `glpi_users`.`id`)\n                WHERE (`glpi_softwarelicenses`.`id` = '{$searchID}') " . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n                       AND `glpi_computers`.`is_deleted` = '0'\n                       AND `glpi_computers`.`is_template` = '0'\n                       AND `glpi_computers_softwarelicenses`.`is_deleted` = '0'\n                ORDER BY {$sort} {$order}\n                LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
     $rand = mt_rand();
     if ($result = $DB->query($query)) {
         if ($data = $DB->fetch_assoc($result)) {
             if ($canedit) {
                 $rand = mt_rand();
                 Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
                 $massiveactionparams = array('num_displayed' => $_SESSION['glpilist_limit'], 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('purge' => _x('button', 'Delete permanently')));
                 // show transfer only if multi licenses for this software
                 if (self::countLicenses($data['softid']) > 1) {
                     $massiveactionparams['specific_actions'][__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'move_license'] = _x('button', 'Move');
                 }
                 // Options to update license
                 $massiveactionparams['extraparams']['options']['move']['used'] = array($searchID);
                 $massiveactionparams['extraparams']['options']['move']['softwares_id'] = $license->fields['softwares_id'];
                 Html::showMassiveActions($massiveactionparams);
             }
             $soft = new Software();
             $soft->getFromDB($license->fields['softwares_id']);
             $showEntity = $license->isRecursive();
             $linkUser = User::canView();
             $text = sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $soft->fields["name"]);
             $text = sprintf(__('%1$s - %2$s'), $text, $data["vername"]);
             Session::initNavigateListItems('Computer', $text);
             $sort_img = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "' alt='' title=''>";
             echo "<table class='tab_cadre_fixehov'>";
             $columns = array('compname' => __('Name'), 'entity' => __('Entity'), 'serial' => __('Serial number'), 'otherserial' => __('Inventory number'), 'location,compname' => __('Location'), 'state,compname' => __('Status'), 'groupe,compname' => __('Group'), 'username,compname' => __('User'));
             if (!$showEntity) {
                 unset($columns['entity']);
             }
             $sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>";
             $header_begin = "<tr>";
             $header_top = '';
             $header_bottom = '';
             $header_end = '';
             if ($canedit) {
                 $header_begin .= "<th width='10'>";
                 $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
                 $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
//.........这里部分代码省略.........
开发者ID:pvasener,项目名称:glpi,代码行数:101,代码来源:computer_softwarelicense.class.php

示例5: showInstallations

 /**
  * Show installations of a software
  *
  * @param $searchID  value of the ID to search
  * @param $crit      to search : softwares_id (software) or id (version)
  *
  * @return nothing
  **/
 private static function showInstallations($searchID, $crit)
 {
     global $DB, $CFG_GLPI;
     if (!Session::haveRight("software", "r") || !$searchID) {
         return false;
     }
     $canedit = Session::haveRight("software", "w");
     $canshowcomputer = Session::haveRight("computer", "r");
     if (isset($_POST["start"])) {
         $start = $_POST["start"];
     } else {
         $start = 0;
     }
     if (isset($_POST["order"]) && $_POST["order"] == "DESC") {
         $order = "DESC";
     } else {
         $order = "ASC";
     }
     if (isset($_POST["sort"]) && !empty($_POST["sort"])) {
         // manage several param like location,compname :  order first
         $tmp = explode(",", $_POST["sort"]);
         $sort = "`" . implode("` {$order},`", $tmp) . "`";
     } else {
         if ($crit == "softwares_id") {
             $sort = "`entity` {$order}, `version`, `compname`";
         } else {
             $sort = "`entity` {$order}, `compname`";
         }
     }
     // Total Number of events
     if ($crit == "softwares_id") {
         // Software ID
         $query_number = "SELECT COUNT(*) AS cpt\n                          FROM `glpi_computers_softwareversions`\n                          INNER JOIN `glpi_softwareversions`\n                              ON (`glpi_computers_softwareversions`.`softwareversions_id`\n                                    = `glpi_softwareversions`.`id`)\n                          INNER JOIN `glpi_computers`\n                              ON (`glpi_computers_softwareversions`.`computers_id`\n                                    = `glpi_computers`.`id`)\n                          WHERE `glpi_softwareversions`.`softwares_id` = '{$searchID}'" . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n                                AND `glpi_computers`.`is_deleted` = '0'\n                                AND `glpi_computers`.`is_template` = '0'\n                                AND `glpi_computers_softwareversions`.`is_deleted` = '0'";
     } else {
         //SoftwareVersion ID
         $query_number = "SELECT COUNT(*) AS cpt\n                          FROM `glpi_computers_softwareversions`\n                          INNER JOIN `glpi_computers`\n                              ON (`glpi_computers_softwareversions`.`computers_id`\n                                    = `glpi_computers`.`id`)\n                          WHERE `glpi_computers_softwareversions`.`softwareversions_id`\n                                       = '{$searchID}'" . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n                                AND `glpi_computers`.`is_deleted` = '0'\n                                AND `glpi_computers`.`is_template` = '0'\n                                AND `glpi_computers_softwareversions`.`is_deleted` = '0'";
     }
     $number = 0;
     if ($result = $DB->query($query_number)) {
         $number = $DB->result($result, 0, 0);
     }
     echo "<div class='center'>";
     if ($number < 1) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . __('No item found') . "</th></tr>";
         echo "</table></div>\n";
         return;
     }
     // Display the pager
     Html::printAjaxPager(self::getTypeName(2), $start, $number);
     $query = "SELECT DISTINCT `glpi_computers_softwareversions`.*,\n                       `glpi_computers`.`name` AS compname,\n                       `glpi_computers`.`id` AS cID,\n                       `glpi_computers`.`serial`,\n                       `glpi_computers`.`otherserial`,\n                       `glpi_users`.`name` AS username,\n                       `glpi_users`.`id` AS userid,\n                       `glpi_users`.`realname` AS userrealname,\n                       `glpi_users`.`firstname` AS userfirstname,\n                       `glpi_softwareversions`.`name` AS version,\n                       `glpi_softwareversions`.`id` AS vID,\n                       `glpi_softwareversions`.`softwares_id` AS sID,\n                       `glpi_softwareversions`.`name` AS vername,\n                       `glpi_entities`.`completename` AS entity,\n                       `glpi_locations`.`completename` AS location,\n                       `glpi_states`.`name` AS state,\n                       `glpi_groups`.`name` AS groupe\n                FROM `glpi_computers_softwareversions`\n                INNER JOIN `glpi_softwareversions`\n                     ON (`glpi_computers_softwareversions`.`softwareversions_id`\n                           = `glpi_softwareversions`.`id`)\n                INNER JOIN `glpi_computers`\n                     ON (`glpi_computers_softwareversions`.`computers_id` = `glpi_computers`.`id`)\n                LEFT JOIN `glpi_entities` ON (`glpi_computers`.`entities_id` = `glpi_entities`.`id`)\n                LEFT JOIN `glpi_locations`\n                     ON (`glpi_computers`.`locations_id` = `glpi_locations`.`id`)\n                LEFT JOIN `glpi_states` ON (`glpi_computers`.`states_id` = `glpi_states`.`id`)\n                LEFT JOIN `glpi_groups` ON (`glpi_computers`.`groups_id` = `glpi_groups`.`id`)\n                LEFT JOIN `glpi_users` ON (`glpi_computers`.`users_id` = `glpi_users`.`id`)\n                WHERE (`glpi_softwareversions`.`{$crit}` = '{$searchID}') " . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n                       AND `glpi_computers`.`is_deleted` = '0'\n                       AND `glpi_computers`.`is_template` = '0'\n                       AND `glpi_computers_softwareversions`.`is_deleted` = '0'\n                ORDER BY {$sort} {$order}\n                LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
     $rand = mt_rand();
     if ($result = $DB->query($query)) {
         if ($data = $DB->fetch_assoc($result)) {
             $softwares_id = $data['sID'];
             $soft = new Software();
             $showEntity = $soft->getFromDB($softwares_id) && $soft->isRecursive();
             $linkUser = Session::haveRight('user', 'r');
             $title = $soft->fields["name"];
             if ($crit == "id") {
                 $title = sprintf(__('%1$s - %2$s'), $title, $data["vername"]);
             }
             Session::initNavigateListItems('Computer', sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $title));
             $sort_img = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "' alt=''\n                          title=''>";
             if ($canedit) {
                 $rand = mt_rand();
                 Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
                 $paramsma = array('num_displayed' => $_SESSION['glpilist_limit'], 'specific_actions' => array('move_version' => _x('button', 'Move'), 'purge' => _x('button', 'Delete permanently')));
                 // Options to update version
                 $paramsma['extraparams']['options']['move']['softwares_id'] = $softwares_id;
                 if ($crit == 'softwares_id') {
                     $paramsma['extraparams']['options']['move']['used'] = array();
                 } else {
                     $paramsma['extraparams']['options']['move']['used'] = array($searchID);
                 }
                 Html::showMassiveActions(__CLASS__, $paramsma);
             }
             echo "<table class='tab_cadre_fixehov'><tr>";
             if ($canedit) {
                 echo "<th width='10'>";
                 Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
                 echo "</th>";
             }
             if ($crit == "softwares_id") {
                 echo "<th>" . ($sort == "`vername`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=vername&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . _n('Version', 'Versions', 2) . "</a></th>";
             }
             echo "<th>" . ($sort == "`compname`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=compname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Name') . "</a></th>";
             if ($showEntity) {
                 echo "<th>" . (strstr($sort, "entity") ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=entity,compname&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Entity') . "</a></th>";
             }
             echo "<th>" . ($sort == "`serial`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=serial&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Serial number') . "</a></th>";
             echo "<th>" . ($sort == "`otherserial`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort=otherserial&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>" . __('Inventory number') . "</a></th>";
//.........这里部分代码省略.........
开发者ID:gaforeror,项目名称:glpi,代码行数:101,代码来源:computer_softwareversion.class.php

示例6: SoftwareORBit2added

 /**
  * @test
  */
 public function SoftwareORBit2added()
 {
     global $DB;
     $DB->connect();
     $software = new Software();
     $software->getFromDB(3);
     unset($software->fields['date_mod']);
     $a_reference = array('id' => '3', 'name' => 'ORBit2', 'entities_id' => '0', 'is_recursive' => '0', 'comment' => NULL, 'locations_id' => '0', 'users_id_tech' => '0', 'groups_id_tech' => '0', 'is_update' => '0', 'softwares_id' => '0', 'manufacturers_id' => '3', 'is_deleted' => '0', 'is_template' => '0', 'template_name' => NULL, 'users_id' => '0', 'groups_id' => '0', 'ticket_tco' => '0.0000', 'is_helpdesk_visible' => '1', 'softwarecategories_id' => '0', 'is_valid' => '1');
     $this->assertEquals($a_reference, $software->fields);
 }
开发者ID:C-Duv,项目名称:fusioninventory-for-glpi,代码行数:13,代码来源:ComputerUpdateTest.php

示例7: testSoftwareCategory

 /**
  * Test software category Rule and putInTrash / removeFromTrash
  */
 public function testSoftwareCategory()
 {
     global $CFG_GLPI;
     $ent0 = $this->sharedFixture['entity'][0];
     // Clean preload rules
     $tmp = SingletonRuleList::getInstance('RuleSoftwareCategory');
     $tmp->load = 0;
     $this->assertArrayHasKey('softwarecategories_id_ondelete', $CFG_GLPI, "Fail: no softwarecategories_id_ondelete");
     $idcat[0] = Dropdown::import('SoftwareCategory', array('name' => 'Trashed'));
     $this->assertGreaterThan(0, $idcat[0], "Fail: can't create SoftwareCategory");
     $idcat[1] = Dropdown::import('SoftwareCategory', array('name' => 'OpenSource'));
     $this->assertGreaterThan(0, $idcat[1], "Fail: can't create SoftwareCategory");
     $rule = new RuleSoftwareCategory();
     $crit = new RuleCriteria();
     $acte = new RuleAction();
     $idr[0] = $rule->add(array('name' => 'OSS', 'sub_type' => 'RuleSoftwareCategory', 'match' => 'AND', 'is_active' => 1));
     $this->assertGreaterThan(0, $idr[0], "Fail: can't create rule 1");
     $this->assertTrue($rule->getFromDB($idr[0]));
     $this->assertEquals(1, $rule->fields['ranking'], "Fail: ranking not set");
     $idc[0] = $crit->add(array('rules_id' => $idr[0], 'criteria' => 'manufacturer', 'condition' => Rule::PATTERN_IS, 'pattern' => 'Indepnet'));
     $this->assertGreaterThan(0, $idc[0], "Fail: can't create rule 1 criteria");
     $ida[0] = $acte->add(array('rules_id' => $idr[0], 'action_type' => 'assign', 'field' => 'softwarecategories_id', 'value' => $idcat[1]));
     $this->assertGreaterThan(0, $ida[0], "Fail: can't create rule 1 action");
     // Createthe software
     $soft = new Software();
     $id[0] = $soft->addOrRestoreFromTrash('GLPI', 'Indepnet', $ent0);
     $this->assertGreaterThan(0, $id[0], "Fail: can't create software 1");
     // Check name
     $this->assertTrue($soft->getFromDB($id[0]), "Fail: can't read new soft");
     $this->assertEquals('GLPI', $soft->getField('name'), "Fail: name not set");
     // Check category
     $catid = $soft->getField('softwarecategories_id');
     $this->assertEquals($idcat[1], $catid, "Fail: category not set");
     // Change configuration
     $CFG_GLPI["softwarecategories_id_ondelete"] = $idcat[0];
     // Delete
     $this->assertTrue($soft->putInTrash($id[0]), "Fail: can't put soft in trash");
     $this->assertTrue($soft->getFromDB($id[0]), "Fail: can't read new soft");
     $catid = $soft->getField('softwarecategories_id');
     $this->assertEquals($idcat[0], $catid, "Fail: category not set");
     $this->assertEquals(1, $soft->getField('is_deleted'), "Fail: soft not deleted");
     // Restore
     $this->assertTrue($soft->removeFromTrash($id[0]), "Fail: can't put soft in trash");
     $this->assertTrue($soft->getFromDB($id[0]), "Fail: can't read new soft");
     $catid = $soft->getField('softwarecategories_id');
     $this->assertEquals($idcat[1], $catid, "Fail: category not set");
     $this->assertEquals(0, $soft->getField('is_deleted'), "Fail: soft not restored");
     // Clean
     $this->assertTrue($soft->delete(array('id' => $id[0]), true), "Fail: can't delete software 1)");
 }
开发者ID:btry,项目名称:glpi,代码行数:53,代码来源:Import.php

示例8: maybeRecursive

 /**
  * Is the license may be recursive
  *
  * @return boolean
  **/
 function maybeRecursive()
 {
     $soft = new Software();
     if (isset($this->fields["softwares_id"]) && $soft->getFromDB($this->fields["softwares_id"])) {
         return $soft->isRecursive();
     }
     return false;
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:13,代码来源:softwarelicense.class.php

示例9: unset

             glpi_header($_SERVER['PHP_SELF'] . '?multiple_actions=1');
         } else {
             $REDIRECT = $_SESSION['glpi_massiveaction']['REDIRECT'];
             unset($_SESSION['glpi_massiveaction']);
             glpi_header($REDIRECT);
         }
     }
     break;
 case "compute_software_category":
     $softcatrule = new RuleSoftwareCategoryCollection();
     $soft = new Software();
     foreach ($_POST["item"] as $key => $val) {
         if ($val == 1) {
             $params = array();
             //Get software name and manufacturer
             $soft->getFromDB($key);
             $params["name"] = $soft->fields["name"];
             $params["manufacturers_id"] = $soft->fields["manufacturers_id"];
             $params["comment"] = $soft->fields["comment"];
             //Process rules
             $soft->update($softcatrule->processAllRules(null, $soft->fields, $params));
         }
     }
     break;
 case "replay_dictionnary":
     $softdictionnayrule = new RuleDictionnarySoftwareCollection();
     $ids = array();
     foreach ($_POST["item"] as $key => $val) {
         if ($val == 1) {
             $ids[] = $key;
         }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:massiveaction.php

示例10: showForDocument


//.........这里部分代码省略.........
                     $column = "name";
                 }
             }
             if ($itemtype == 'Ticket') {
                 $column = "id";
             }
             $itemtable = getTableForItemType($itemtype);
             $query = "SELECT `{$itemtable}`.*,\n                                 `glpi_documents_items`.`id` AS IDD, ";
             if ($itemtype == 'KnowbaseItem') {
                 $query .= "-1 AS entity\n                          FROM `glpi_documents_items`, `{$itemtable}`\n                          " . KnowbaseItem::addVisibilityJoins() . "\n                          WHERE `{$itemtable}`.`id` = `glpi_documents_items`.`items_id`\n                                AND ";
             } else {
                 $query .= "`glpi_entities`.`id` AS entity\n                          FROM `glpi_documents_items`, `{$itemtable}`";
                 if ($itemtype != 'Entity') {
                     $query .= " LEFT JOIN `glpi_entities`\n                                 ON (`glpi_entities`.`id` = `{$itemtable}`.`entities_id`)";
                 }
                 $query .= " WHERE `{$itemtable}`.`id` = `glpi_documents_items`.`items_id`\n                                 AND ";
             }
             $query .= "`glpi_documents_items`.`itemtype` = '{$itemtype}'\n                       AND `glpi_documents_items`.`documents_id` = '{$instID}' ";
             if ($itemtype == 'KnowbaseItem') {
                 if (Session::getLoginUserID()) {
                     $where = "AND " . KnowbaseItem::addVisibilityRestrict();
                 } else {
                     // Anonymous access
                     if (Session::isMultiEntitiesMode()) {
                         $where = " AND (`glpi_entities_knowbaseitems`.`entities_id` = '0'\n                                     AND `glpi_entities_knowbaseitems`.`is_recursive` = '1')";
                     }
                 }
             } else {
                 $query .= getEntitiesRestrictRequest(" AND ", $itemtable, '', '', $item->maybeRecursive());
             }
             if ($item->maybeTemplate()) {
                 $query .= " AND `{$itemtable}`.`is_template` = '0'";
             }
             if ($itemtype == 'KnowbaseItem') {
                 $query .= " ORDER BY `{$itemtable}`.`{$column}`";
             } else {
                 $query .= " ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`{$column}`";
             }
             if ($itemtype == 'SoftwareLicense') {
                 $soft = new Software();
             }
             if ($result_linked = $DB->query($query)) {
                 if ($DB->numrows($result_linked)) {
                     while ($data = $DB->fetch_assoc($result_linked)) {
                         if ($itemtype == 'Ticket') {
                             $data["name"] = sprintf(__('%1$s: %2$s'), __('Ticket'), $data["id"]);
                         }
                         if ($itemtype == 'SoftwareLicense') {
                             $soft->getFromDB($data['softwares_id']);
                             $data["name"] = sprintf(__('%1$s - %2$s'), $data["name"], $soft->fields['name']);
                         }
                         if ($item instanceof CommonDevice) {
                             $linkname = $data["designation"];
                         } else {
                             if ($item instanceof Item_Devices) {
                                 $linkname = $data["itemtype"];
                             } else {
                                 $linkname = $data["name"];
                             }
                         }
                         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                             $linkname = sprintf(__('%1$s (%2$s)'), $linkname, $data["id"]);
                         }
                         if ($item instanceof Item_Devices) {
                             $tmpitem = new $item::$itemtype_2();
                             if ($tmpitem->getFromDB($data[$item::$items_id_2])) {
                                 $linkname = $tmpitem->getLink();
                             }
                         }
                         $link = Toolbox::getItemTypeFormURL($itemtype);
                         $name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $linkname . "</a>";
                         echo "<tr class='tab_bg_1'>";
                         if ($canedit) {
                             echo "<td width='10'>";
                             Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]);
                             echo "</td>";
                         }
                         echo "<td class='center'>" . $item->getTypeName(1) . "</td>";
                         echo "<td " . (isset($data['is_deleted']) && $data['is_deleted'] ? "class='tab_bg_2_2'" : "") . ">" . $name . "</td>";
                         echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entity']);
                         echo "</td>";
                         echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>";
                         echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>";
                         echo "</tr>";
                     }
                 }
             }
         }
     }
     if ($number) {
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $number) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
开发者ID:pvasener,项目名称:glpi,代码行数:101,代码来源:document_item.class.php

示例11: showForTag

 /**
  * 
  * Note : can separe code of view list
  * @param PluginTagTag $tag
  * @return boolean
  */
 static function showForTag(PluginTagTag $tag)
 {
     global $DB;
     $instID = $tag->fields['id'];
     if (!$tag->can($instID, READ)) {
         return false;
     }
     $canedit = $tag->can($instID, UPDATE);
     $table = getTableForItemType(__CLASS__);
     $result = $DB->query("SELECT DISTINCT `itemtype`\n         FROM `{$table}`\n         WHERE `plugin_tag_tags_id` = '{$instID}'");
     $result2 = $DB->query("SELECT `itemtype`, items_id\n            FROM `{$table}`\n            WHERE `plugin_tag_tags_id` = '{$instID}'");
     $number = $DB->numrows($result);
     $rand = mt_rand();
     if ($canedit) {
         echo "<div class='firstbloc'>";
         //can use standart GLPI function
         $target = Toolbox::getItemTypeFormURL('PluginTagTag');
         echo "<form name='tagitem_form{$rand}' id='tagitem_form{$rand}' method='post' action='" . $target . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td class='right'>";
         //Note : this function is deprecated (and replace by an other)
         $itemtypes_to_show = self::getItemtypes($tag->fields['type_menu']);
         Dropdown::showAllItems("items_id", 0, 0, $tag->fields['is_recursive'] ? -1 : $tag->fields['entities_id'], $itemtypes_to_show, false, true);
         echo "<style>.select2-container { text-align: left; } </style>";
         //minor
         echo "</td><td class='center'>";
         echo "<input type='hidden' name='plugin_tag_tags_id' value='{$instID}'>";
         //Note : can use standart GLPI method
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         Html::showMassiveActions();
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     if ($canedit && $number) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . __('Type') . "</th>";
     echo "<th>" . __('Name') . "</th>";
     echo "<th>" . __('Entity') . "</th>";
     echo "<th>" . __('Serial number') . "</th>";
     echo "<th>" . __('Inventory number') . "</th>";
     echo "</tr>";
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         $item_id = $DB->result($result2, $i, "items_id");
         if ($item->canView()) {
             $column = strtolower(substr($itemtype, 0, 6)) == "device" ? "designation" : "name";
             // For rules itemtypes (example : ruledictionnaryphonemodel)
             if (strtolower(substr($itemtype, 0, 4)) == 'rule' || $itemtype == "PluginResourcesRulechecklist") {
                 $itemtable = getTableForItemType('Rule');
             } else {
                 $itemtable = getTableForItemType($itemtype);
             }
             $obj = new $itemtype();
             $obj->getFromDB($item_id);
             $query = "SELECT `{$itemtable}`.*, `glpi_plugin_tag_tagitems`.`id` AS IDD, ";
             switch ($itemtype) {
                 case 'KnowbaseItem':
                     $query .= "-1 AS entity\n                  FROM `glpi_plugin_tag_tagitems`, `{$itemtable}`\n                  " . KnowbaseItem::addVisibilityJoins() . "\n                  WHERE `{$itemtable}`.`id` = `glpi_plugin_tag_tagitems`.`items_id`\n                  AND ";
                     break;
                 case 'Profile':
                 case 'RSSFeed':
                 case 'Reminder':
                 case 'Entity':
                     //Possible to add (in code) condition to visibility :
                     $query .= "-1 AS entity\n                  FROM `glpi_plugin_tag_tagitems`, `{$itemtable}`\n                  WHERE `{$itemtable}`.`id` = `glpi_plugin_tag_tagitems`.`items_id`\n                  AND ";
                     break;
                 default:
                     if (isset($obj->fields['entities_id'])) {
                         $query .= "`glpi_entities`.`id` AS entity\n                        FROM `glpi_plugin_tag_tagitems`, `{$itemtable}`\n                        LEFT JOIN `glpi_entities`\n                        ON (`glpi_entities`.`id` = `{$itemtable}`.`entities_id`)\n                        WHERE `{$itemtable}`.`id` = `glpi_plugin_tag_tagitems`.`items_id`\n                        AND ";
                     } else {
                         $query .= "-1 AS entity\n                        FROM `glpi_plugin_tag_tagitems`, `{$itemtable}`\n                        WHERE `{$itemtable}`.`id` = `glpi_plugin_tag_tagitems`.`items_id`\n                        AND ";
                     }
                     break;
             }
             $query .= "`glpi_plugin_tag_tagitems`.`itemtype` = '{$itemtype}'\n               AND `glpi_plugin_tag_tagitems`.`plugin_tag_tags_id` = '{$instID}' ";
             $query .= getEntitiesRestrictRequest(" AND ", $itemtable, '', '', $item->maybeRecursive());
             if ($item->maybeTemplate()) {
                 $query .= " AND `{$itemtable}`.`is_template` = '0'";
             }
             switch ($itemtype) {
                 case 'KnowbaseItem':
//.........这里部分代码省略.........
开发者ID:korial29,项目名称:tag,代码行数:101,代码来源:tagitem.class.php

示例12: showItems

 /**
  * Show items links to a document
  *
  * @return nothing (HTML display)
  **/
 function showItems()
 {
     global $DB, $CFG_GLPI, $LANG;
     $instID = $this->fields['id'];
     if (!$this->can($instID, "r")) {
         return false;
     }
     $canedit = $this->can($instID, 'w');
     // for a document,
     // don't show here others documents associated to this one,
     // it's done for both directions in self::showAssociated
     $query = "SELECT DISTINCT `itemtype`\n                FROM `glpi_documents_items`\n                WHERE `glpi_documents_items`.`documents_id` = '{$instID}'\n                      AND `glpi_documents_items`.`itemtype` != 'Document'\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $rand = mt_rand();
     echo "<form method='post' name='document_form{$rand}' id='document_form{$rand}' action='" . $CFG_GLPI["root_doc"] . "/front/document.form.php'>";
     echo "<div class='spaced'><table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='" . ($canedit ? 6 : 5) . "'>";
     if ($DB->numrows($result) == 0) {
         echo $LANG['document'][13];
     } else {
         if ($DB->numrows($result) == 1) {
             echo $LANG['document'][14];
         } else {
             echo $LANG['document'][19];
         }
     }
     echo "</th></tr><tr>";
     if ($canedit) {
         echo "<th>&nbsp;</th>";
     }
     echo "<th>" . $LANG['common'][17] . "</th>";
     echo "<th>" . $LANG['common'][16] . "</th>";
     echo "<th>" . $LANG['entity'][0] . "</th>";
     echo "<th>" . $LANG['common'][19] . "</th>";
     echo "<th>" . $LANG['common'][20] . "</th>";
     echo "</tr>";
     for ($i = 0; $i < $number; $i++) {
         $itemtype = $DB->result($result, $i, "itemtype");
         if (!class_exists($itemtype)) {
             continue;
         }
         $item = new $itemtype();
         if ($item->canView()) {
             $column = "name";
             if ($itemtype == 'Ticket') {
                 $column = "id";
             }
             if ($itemtype == 'KnowbaseItem') {
                 $column = "question";
             }
             $itemtable = getTableForItemType($itemtype);
             $query = "SELECT `{$itemtable}`.*,\n                             `glpi_documents_items`.`id` AS IDD, ";
             if ($itemtype == 'Entity') {
                 // Left join because root entity not storeed
                 $query .= "`glpi_documents_items`.`items_id` AS entity\n                          FROM `glpi_documents_items`\n                          LEFT JOIN `glpi_entities`\n                              ON (`glpi_entities`.`id` = `glpi_documents_items`.`items_id`)\n                          WHERE ";
             } else {
                 $query .= "`glpi_entities`.`id` AS entity\n                          FROM `glpi_documents_items`, `{$itemtable}`\n                          LEFT JOIN `glpi_entities`\n                              ON (`glpi_entities`.`id` = `{$itemtable}`.`entities_id`)\n                          WHERE `{$itemtable}`.`id` = `glpi_documents_items`.`items_id`\n                          AND ";
             }
             $query .= "`glpi_documents_items`.`itemtype` = '{$itemtype}'\n                       AND `glpi_documents_items`.`documents_id` = '{$instID}' " . getEntitiesRestrictRequest(" AND ", $itemtable, '', '', $item->maybeRecursive());
             if ($item->maybeTemplate()) {
                 $query .= " AND `{$itemtable}`.`is_template` = '0'";
             }
             $query .= " ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`{$column}`";
             if ($itemtype == 'SoftwareLicense') {
                 $soft = new Software();
             }
             if ($result_linked = $DB->query($query)) {
                 if ($DB->numrows($result_linked)) {
                     while ($data = $DB->fetch_assoc($result_linked)) {
                         $ID = "";
                         if ($itemtype == 'Entity' && !$data['entity']) {
                             $data['id'] = 0;
                             $data['name'] = $LANG['entity']['2'];
                         }
                         if ($itemtype == 'Ticket') {
                             $data["name"] = $LANG['job'][38] . " " . $data["id"];
                         }
                         if ($itemtype == 'KnowbaseItem') {
                             $data["name"] = $data["question"];
                         }
                         if ($itemtype == 'SoftwareLicense') {
                             $soft->getFromDB($data['softwares_id']);
                             $data["name"] = $data["name"] . ' - ' . $soft->fields['name'];
                         }
                         if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) {
                             $ID = " (" . $data["id"] . ")";
                         }
                         $link = getItemTypeFormURL($itemtype);
                         $name = "<a href=\"" . $link . "?id=" . $data["id"] . "\">" . $data["name"] . "{$ID}</a>";
                         echo "<tr class='tab_bg_1'>";
                         if ($canedit) {
                             echo "<td width='10'>";
                             $sel = "";
                             if (isset($_GET["select"]) && $_GET["select"] == "all") {
//.........这里部分代码省略.........
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:101,代码来源:document.class.php

示例13: showForLicense

 /**
  * Show users linked to a License
  *
  * @param $license SoftwareLicense object
  *
  * @return nothing
  **/
 static function showForLicense(SoftwareLicense $license)
 {
     global $DB, $CFG_GLPI;
     $searchID = $license->getField('id');
     if (!Software::canView() || !$searchID) {
         return false;
     }
     $canedit = PluginFpsoftwareVersionhelper::checkRights("software", array(CREATE, UPDATE, DELETE, PURGE), "Or");
     $canshowuser = User::canView();
     if (isset($_GET["start"])) {
         $start = $_GET["start"];
     } else {
         $start = 0;
     }
     if (isset($_GET["order"]) && $_GET["order"] == "DESC") {
         $order = "DESC";
     } else {
         $order = "ASC";
     }
     //SoftwareLicense ID
     $query_number = "SELECT COUNT(*) AS cpt\n                       FROM `glpi_users_softwarelicenses`\n                       INNER JOIN `glpi_users`\n                           ON (`glpi_users_softwarelicenses`.`users_id`\n                                 = `glpi_users`.`id`)\n                       WHERE `glpi_users_softwarelicenses`.`softwarelicenses_id` = '{$searchID}'";
     $number = 0;
     if ($result = $DB->query($query_number)) {
         $number = $DB->result($result, 0, 0);
     }
     echo "<div class='center'>";
     if ($canedit) {
         echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . self::$front_url . "/front/user_softwarelicense.form.php'>";
         echo "<input type='hidden' name='softwarelicenses_id' value='{$searchID}'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2 center'>";
         echo "<td>";
         //FOR NOW ALL USERS ARE SHOWN, DON'T KNOW IF THERE SHOULD BE ANY RESTRICTION.
         //ALSO IT CAUSES A POSSIBILITY TO ONE USER MANY TIMES.
         User::dropdown(array('right' => 'all'));
         echo "</td>";
         echo "<td><input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
     }
     if ($number < 1) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . __('No item found') . "</th></tr>";
         echo "</table></div>\n";
         return;
     }
     // Display the pager
     Html::printAjaxPager(__('Affected users'), $start, $number);
     $query = "SELECT `glpi_users_softwarelicenses`.*,\n                       `glpi_users`.`name` AS username,\n                       `glpi_users`.`id` AS userid,\n                       `glpi_users`.`realname` AS userrealname,\n                       `glpi_users`.`firstname` AS userfirstname,\n                       `glpi_softwarelicenses`.`name` AS license,\n                       `glpi_softwarelicenses`.`id` AS lID\n                FROM `glpi_users_softwarelicenses`\n                INNER JOIN `glpi_softwarelicenses`\n                     ON (`glpi_users_softwarelicenses`.`softwarelicenses_id`\n                          = `glpi_softwarelicenses`.`id`)\n                INNER JOIN `glpi_users`\n                     ON (`glpi_users_softwarelicenses`.`users_id` = `glpi_users`.`id`)\n                WHERE `glpi_softwarelicenses`.`id` = '{$searchID}'\n                LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
     $rand = mt_rand();
     if ($result = $DB->query($query)) {
         if ($data = $DB->fetch_assoc($result)) {
             if ($canedit) {
                 $rand = mt_rand();
                 Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
                 list($higher_version, $massiveactionparams) = PluginFpsoftwareVersionhelper::massiveActionParams($rand, __CLASS__);
                 // Options to update license
                 $massiveactionparams['extraparams']['options']['move']['used'] = array($searchID);
                 $massiveactionparams['extraparams']['options']['move']['softwares_id'] = $license->fields['softwares_id'];
                 Html::showMassiveActions($higher_version ? $massiveactionparams : __CLASS__, $massiveactionparams);
             }
             $soft = new Software();
             $soft->getFromDB($license->fields['softwares_id']);
             $text = sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $soft->fields["name"]);
             $text = sprintf(__('%1$s - ID %2$s'), $text, $license->fields['softwares_id']);
             Session::initNavigateListItems('User', $text);
             echo "<table class='tab_cadre_fixehov'>";
             $columns = array('username' => __('Username'), 'userrealname' => __('Surname'), 'userfirstname' => __('First name'), 'added' => __('Added'));
             $header_begin = "<tr>";
             $header_top = '';
             $header_bottom = '';
             $header_end = '';
             if ($canedit) {
                 $header_begin .= "<th width='10'>";
                 $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
                 $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
                 $header_end .= "</th>";
             }
             foreach ($columns as $key => $val) {
                 // Non order column
                 $header_end .= "<th>{$val}</th>";
             }
             $header_end .= "</tr>\n";
             echo $header_begin . $header_top . $header_end;
             do {
                 Session::addToNavigateListItems('User', $data["userid"]);
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
                 }
                 if ($canshowuser) {
                     echo "<td><a href='user.form.php?id=" . $data['userid'] . "'>" . $data['username'] . "</a></td>";
//.........这里部分代码省略.........
开发者ID:dawidplocki,项目名称:glpi-fpsoftware,代码行数:101,代码来源:common.class.php

示例14: AddComputerStep3

 /**
  * @test
  */
 public function AddComputerStep3()
 {
     global $DB;
     $this->mark_incomplete();
     return;
     // TODO: recode this test
     $DB->connect();
     $DB->query("UPDATE `glpi_entities`\n         SET `entities_id_software` = '-2'\n         WHERE `id`='1'");
     $_SESSION['glpiactive_entity'] = 0;
     $_SESSION['glpiactiveentities_string'] = 0;
     $_SESSION['glpishowallentities'] = 1;
     $_SESSION['glpiname'] = 'glpi';
     $pfiComputerInv = new PluginFusioninventoryInventoryComputerInventory();
     $computer = new Computer();
     $software = new Software();
     $input = array('id' => 1, 'is_recursive' => 0);
     $software->update($input);
     $computer->add(array('name' => 'pc2', 'entities_id' => 1));
     $a_inventory = array();
     $a_inventory['CONTENT']['HARDWARE'] = array('NAME' => 'pc2');
     $a_inventory['CONTENT']['SOFTWARES'][] = array('COMMENTS' => "Non-interactive tool to get files from FTP, GOPHER, HTTP(S)", 'NAME' => "curl", 'VERSION' => "7.24.0_1");
     // ** Add agent
     $pfAgent = new PluginFusioninventoryAgent();
     $a_agents_id = $pfAgent->add(array('name' => 'pc-2013-02-13', 'device_id' => 'pc-2013-02-13'));
     $_SESSION['plugin_fusioninventory_agents_id'] = $a_agents_id;
     // ** Add
     $pfiComputerInv->import("pc2-2013-02-13", "", $a_inventory);
     // creation
     $computer->getFromDB(2);
     $this->assertEquals(1, $computer->fields['entities_id'], 'Add computer');
     $nbSoftwares = countElementsInTable("glpi_softwares");
     $softs = getAllDatasFromTable("glpi_softwares");
     $this->assertEquals(2, $nbSoftwares, 'Nb softwares ' . print_r($softs, true));
     $software->getFromDB(2);
     $this->assertEquals(1, $software->fields['entities_id'], "May be on entity 1");
     // Software not in same entity as computer, may be recursive
     $this->assertEquals(0, $software->fields['is_recursive'], 'Software may have recursive = 0');
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:41,代码来源:SoftwareEntityCreationTest.php

示例15: getSoftwares

 static function getSoftwares($protocol, $params = array(), $original_params = array())
 {
     global $DB, $WEBSERVICE_LINKED_OBJECTS;
     if (!Session::haveRight("software", READ)) {
         return array();
     }
     $item = new $params['options']['itemtype']();
     $resp = array();
     $software = new Software();
     //Store softwares, versions and licenses
     $softwares = array();
     if ($item->can($params['data']['id'], READ) && $software->can(-1, READ)) {
         foreach (array('SoftwareVersion', 'SoftwareLicense') as $itemtype) {
             $link_table = "glpi_computers_" . Toolbox::addslashes_deep(strtolower($itemtype)) . "s";
             $table = getTableForItemType($itemtype);
             $query = "SELECT DISTINCT `gsv`.*\n                           FROM `" . Toolbox::addslashes_deep($link_table) . "` AS gcsv,\n                                `" . Toolbox::addslashes_deep($table) . "` AS gsv\n                           WHERE `gcsv`.`computers_id`\n                                       = '" . Toolbox::addslashes_deep($params['data']['id']) . "'\n                                 AND `gcsv`.`" . getForeignKeyFieldForTable($table) . "` = `gsv`.`id`\n                           GROUP BY `gsv`.`softwares_id`\n                           ORDER BY `gsv`.`softwares_id` ASC";
             foreach ($DB->request($query) as $version_or_license) {
                 //Software is not yet in the list
                 if (!isset($softwares['Software'][$version_or_license['softwares_id']])) {
                     $software->getFromDB($version_or_license['softwares_id']);
                     $toformat = array('data' => $software->fields, 'searchOptions' => Search::getOptions('Software'), 'options' => $params['options']);
                     $tmp = array();
                     parent::formatDataForOutput($toformat, $tmp);
                     $softwares['Software'][$version_or_license['softwares_id']] = $tmp;
                 }
                 $toformat2 = array('data' => $version_or_license, 'searchOptions' => Search::getOptions($itemtype), 'options' => $params['options']);
                 $tmp = array();
                 parent::formatDataForOutput($toformat2, $tmp);
                 $softwares['Software'][$version_or_license['softwares_id']][$itemtype][$version_or_license['id']] = $tmp;
             }
         }
     }
     return $softwares;
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:34,代码来源:methodinventaire.class.php


注:本文中的Software::getFromDB方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。