showItemTypes() static public method

Make a select box for device type
static public showItemTypes ( $name, $types = [], $options = [] ) : nothing
$name name of the select box
$types array of types to display
$options Parameters which could be used in options array : - value : integer / preselected value (default '') - used : array / Already used items ID: not to display in dropdown (default empty) - emptylabel : Empty choice's label (default self::EMPTY_VALUE) - display : boolean if false get string - width : specific width needed (default not set) - emptylabel : empty label if empty displayed (default self::EMPTY_VALUE) - display_emptychoice : display empty choice (default false)
return nothing (print out an HTML select box)
コード例 #1
1
 static function showAllItems($myname, $value_type = 0, $value = 0, $entity_restrict = -1, $types, $locations_id = -1, $action = 'showItem')
 {
     global $DB, $CFG_GLPI;
     $rand = mt_rand();
     $plugin = new Plugin();
     echo "<table border='0'><tr><td>\n";
     if ($myname == 'type') {
         $newtypes = array_flip($types);
         unset($newtypes['Location']);
         unset($newtypes['Netpoint']);
         if ($plugin->isActivated("resources")) {
             unset($newtypes['PluginResourcesResource']);
         }
         $types = array_flip($newtypes);
     }
     $rand = Dropdown::showItemTypes($myname, $types, array('emptylabel' => Dropdown::EMPTY_VALUE, 'width' => 150));
     $params = array('type' => '__VALUE__', 'value' => $value, 'myname' => $myname, 'action' => $action, 'entity_restrict' => $entity_restrict, 'locations_id' => $locations_id);
     Ajax::updateItemOnSelectEvent("dropdown_{$myname}{$rand}", "show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params);
     echo "</td><td>\n";
     echo "<span id='show_{$myname}{$rand}'>&nbsp;</span>\n";
     echo "</td></tr></table>\n";
     if ($value > 0) {
         echo "<script type='text/javascript' >\n";
         echo "document.getElementById('item_type{$rand}').value='" . $value_type . "';";
         echo "</script>\n";
         $params["typetable"] = $value_type;
         Ajax::updateItem("show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params);
     }
     return $rand;
 }
コード例 #2
0
ファイル: rule.class.php プロジェクト: pvasener/glpi
 /**
  * Display item used to select a pattern for a criteria
  *
  * @param $name      criteria name
  * @param $ID        the given criteria
  * @param $condition condition used
  * @param $value     the pattern (default '')
  * @param $test      Is to test rule ? (false by default)
  **/
 function displayCriteriaSelectPattern($name, $ID, $condition, $value = "", $test = false)
 {
     $crit = $this->getCriteria($ID);
     $display = false;
     $tested = false;
     if (isset($crit['type']) && ($test || in_array($condition, array(self::PATTERN_IS, self::PATTERN_IS_NOT, self::PATTERN_NOT_UNDER, self::PATTERN_UNDER)))) {
         switch ($crit['type']) {
             case "yesonly":
                 Dropdown::showYesNo($name, $crit['table'], 0);
                 $display = true;
                 break;
             case "yesno":
                 Dropdown::showYesNo($name, $crit['table']);
                 $display = true;
                 break;
             case "dropdown":
                 $param = array('name' => $name, 'value' => $value);
                 if (isset($crit['condition'])) {
                     $param['condition'] = $crit['condition'];
                 }
                 Dropdown::show(getItemTypeForTable($crit['table']), $param);
                 $display = true;
                 break;
             case "dropdown_users":
                 User::dropdown(array('value' => $value, 'name' => $name, 'right' => 'all'));
                 $display = true;
                 break;
             case "dropdown_tracking_itemtype":
                 Dropdown::showItemTypes($name, array_keys(Ticket::getAllTypesForHelpdesk()));
                 $display = true;
                 break;
             case "dropdown_urgency":
                 Ticket::dropdownUrgency(array('name' => $name, 'value' => $value));
                 $display = true;
                 break;
             case "dropdown_impact":
                 Ticket::dropdownImpact(array('name' => $name, 'value' => $value));
                 $display = true;
                 break;
             case "dropdown_priority":
                 Ticket::dropdownPriority(array('name' => $name, 'value' => $value));
                 $display = true;
                 break;
             case "dropdown_status":
                 Ticket::dropdownStatus(array('name' => $name, 'value' => $value));
                 $display = true;
                 break;
             case "dropdown_tickettype":
                 Ticket::dropdownType($name, array('value' => $value));
                 $display = true;
                 break;
         }
         $tested = true;
     }
     //Not a standard condition
     if (!$tested) {
         $display = $this->displayAdditionalRuleCondition($condition, $crit, $name, $value, $test);
     }
     if ($condition == self::PATTERN_EXISTS || $condition == self::PATTERN_DOES_NOT_EXISTS) {
         echo "<input type='hidden' name='{$name}' value='1'>";
         $display = true;
     }
     if (!$display && ($rc = getItemForItemtype($this->rulecriteriaclass))) {
         Html::autocompletionTextField($rc, "pattern", array('name' => $name, 'value' => $value, 'size' => 70));
     }
 }
コード例 #3
0
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!Config::canUpdate()) {
         return false;
     }
     $spotted = false;
     if (empty($ID)) {
         if ($this->getEmpty()) {
             $spotted = true;
         }
     } else {
         if ($this->getFromDB($ID)) {
             $spotted = true;
         }
     }
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>";
     echo "<td colspan='3'>";
     Html::autocompletionTextField($this, "name");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Type') . "</td><td colspan='3'>";
     Dropdown::showItemTypes('itemtype', $CFG_GLPI["notificationtemplates_types"], array('value' => $this->fields['itemtype'] ? $this->fields['itemtype'] : 'Ticket'));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Comments') . "</td>";
     echo "<td colspan='3'>";
     echo "<textarea cols='60' rows='5' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('CSS') . "</td>";
     echo "<td colspan='3'>";
     echo "<textarea cols='60' rows='5' name='css' >" . $this->fields["css"] . "</textarea></td></tr>";
     $this->showFormButtons($options);
     return true;
 }
コード例 #4
0
ファイル: searchmetarow.php プロジェクト: kipman/glpi
    $value = '';
    if (isset($metacriteria["link"])) {
        $value = $metacriteria["link"];
    }
    Dropdown::showFromArray("metacriteria[" . $_POST["num"] . "][link]", Search::getLogicalOperators(), array('value' => $value, 'width' => '40%'));
    // Display select of the linked item type available
    foreach ($linked as $key) {
        if (!isset($metanames[$key])) {
            if ($linkitem = getItemForItemtype($key)) {
                $metanames[$key] = $linkitem->getTypeName();
            }
        }
    }
    $value = '';
    if (isset($metacriteria['itemtype']) && !empty($metacriteria['itemtype'])) {
        $value = $metacriteria['itemtype'];
    }
    $rand = Dropdown::showItemTypes("metacriteria[" . $_POST["num"] . "][itemtype]", $linked, array('width' => '50%', 'value' => $value));
    $field_id = Html::cleanId("dropdown_metacriteria[" . $_POST["num"] . "][itemtype]{$rand}");
    echo "</td><td>";
    // Ajax script for display search met& item
    echo "<span id='show_" . $_POST["itemtype"] . "_" . $_POST["num"] . "_{$rand}'>&nbsp;</span>\n";
    $params = array('itemtype' => '__VALUE__', 'num' => $_POST["num"], 'field' => isset($metacriteria['field']) ? $metacriteria['field'] : "", 'value' => isset($metacriteria['value']) ? stripslashes($metacriteria['value']) : "", 'searchtype' => isset($metacriteria['searchtype']) ? $metacriteria['searchtype'] : "");
    Ajax::updateItemOnSelectEvent($field_id, "show_" . $_POST["itemtype"] . "_" . $_POST["num"] . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params);
    if (isset($metacriteria['itemtype']) && !empty($metacriteria['itemtype'])) {
        $params['itemtype'] = $metacriteria['itemtype'];
        Ajax::updateItem("show_" . $_POST["itemtype"] . "_" . $_POST["num"] . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/updateMetaSearch.php", $params);
    }
    echo "</td></tr></table>";
    echo "</td></tr>\n";
}
コード例 #5
0
 /**
  * show  hardware to be identified, or identified and imported, or just the hardware with agents installed on them
  * @param type $hardware array
  * @param type $lim integer
  * @param int|type $start integer
  * @param type $ipAdress string
  * @param type $status string
  * @param $subnet
  * @param $action
  * @global type $CFG_GLPI
  */
 static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $subnet, $action)
 {
     global $CFG_GLPI, $DB;
     $output_type = Search::HTML_OUTPUT;
     //0
     $link = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php";
     $return = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.php";
     $returnargs = "subnetsChoice={$subnet}&action={$action}";
     $reload = "ip={$ipAdress}&status={$status}&action={$action}";
     $backValues = "?b[]={$ipAdress}&b[]={$status}";
     if ($status == "inventoried") {
         $status_name = __('Inventoried', 'ocsinventoryng');
     } elseif ($status == "imported") {
         $status_name = __('Imported / Linked', 'ocsinventoryng');
     } elseif ($status == "noninventoried") {
         $status_name = __('Non Inventoried', 'ocsinventoryng');
     } else {
         $status_name = __('Identified', 'ocsinventoryng');
     }
     $subnet_name = self::getSubnetNamebyIP($ipAdress);
     echo "<div class='center'>";
     echo "<h2>" . __('Subnet', 'ocsinventoryng') . " " . $subnet_name . " (" . $ipAdress . ") - " . $status_name;
     echo "&nbsp;";
     $refresh = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php?" . $reload;
     Html::showSimpleForm($refresh, 'refresh', _sx('button', 'Refresh'), array(), $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/pics/synchro.png");
     echo "</h2>";
     echo "</div>";
     if ($subnet >= 0) {
         $back = __('Back');
         echo "<div class='center'><a href='{$return}?{$returnargs}'>{$back}</div>";
     }
     echo Html::printPager($start, count($hardware), $link, $reload);
     echo Search::showNewLine($output_type, true);
     if (empty($hardware)) {
         echo "<div class='center b'><br>" . __('No new IPDiscover device to import', 'ocsinventoryng') . "</div>";
         Html::displayBackLink();
     } else {
         $header_num = 1;
         switch ($status) {
             case "inventoried":
                 echo "<table width='100%'class='tab_cadrehov'>\n";
                 echo Search::showHeaderItem($output_type, __('User'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Name'), $header_num);
                 echo Search::showHeaderItem($output_type, __('System'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Version of the operating system'), $header_num);
                 echo Search::showHeaderItem($output_type, __('IP address'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Last OCSNG inventory date', 'ocsinventoryng'), $header_num);
                 echo Search::showEndLine($output_type);
                 $row_num = 1;
                 for ($i = $start; $i < $lim + $start; $i++) {
                     if (isset($hardware[$i])) {
                         $row_num++;
                         $item_num = 1;
                         echo Search::showNewLine($output_type, $row_num % 2);
                         echo Search::showItem($output_type, $hardware[$i]["userid"], $item_num, $row_num);
                         echo Search::showItem($output_type, $hardware[$i]["name"], $item_num, $row_num);
                         echo Search::showItem($output_type, $hardware[$i]["osname"], $item_num, $row_num);
                         echo Search::showItem($output_type, $hardware[$i]["osversion"], $item_num, $row_num);
                         echo Search::showItem($output_type, $hardware[$i]["ipaddr"], $item_num, $row_num);
                         echo Search::showItem($output_type, Html::convDateTime($hardware[$i]["lastdate"]), $item_num, $row_num);
                         echo Search::showEndLine($output_type);
                     }
                 }
                 echo "</table>\n";
                 break;
             case "imported":
                 $target = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php" . $backValues;
                 self::checkBox($target);
                 echo "<form method='post' id='ipdiscover_form' name='ipdiscover_form' action='{$target}'>";
                 echo "<div class='center' style=\"width=100%\">";
                 echo "<input type='submit' class='submit' name='deletelink'  value=\"" . _sx('button', 'Delete link', 'ocsinventoryng') . "\"></div>";
                 echo "<table width='100%'class='tab_cadrehov'>\n";
                 echo Search::showHeaderItem($output_type, __('Item'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Item type'), $header_num);
                 echo Search::showHeaderItem($output_type, __('MAC address'), $header_num);
                 echo Search::showHeaderItem($output_type, __('IP address'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Location'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Import date in GLPI', 'ocsinventoryng'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Subnet'), $header_num);
                 echo Search::showHeaderItem($output_type, __('&nbsp;'), $header_num);
                 echo Search::showEndLine($output_type);
                 $row_num = 1;
                 for ($i = $start; $i < $lim + $start; $i++) {
                     if (isset($hardware[$i])) {
                         $row_num++;
                         $item_num = 1;
                         echo Search::showNewLine($output_type, $row_num % 2);
                         $class = getItemForItemtype($hardware[$i]["itemtype"]);
                         $class->getFromDB($hardware[$i]["items_id"]);
                         $iplist = "";
                         $ip = new IPAddress();
                         // Update IPAddress
                         foreach ($DB->request('glpi_networkports', array('itemtype' => $hardware[$i]["itemtype"], 'items_id' => $hardware[$i]["items_id"])) as $netname) {
                             foreach ($DB->request('glpi_networknames', array('itemtype' => 'NetworkPort', 'items_id' => $netname['id'])) as $dataname) {
                                 foreach ($DB->request('glpi_ipaddresses', array('itemtype' => 'NetworkName', 'items_id' => $dataname['id'])) as $data) {
                                     $ip->getFromDB($data['id']);
                                     $iplist .= $ip->getName() . "<br>";
                                 }
                             }
                         }
                         echo Search::showItem($output_type, $class->getLink(), $item_num, $row_num);
                         echo Search::showItem($output_type, $class->getTypeName(), $item_num, $row_num);
                         echo Search::showItem($output_type, $hardware[$i]["macaddress"], $item_num, $row_num);
                         echo Search::showItem($output_type, $iplist, $item_num, $row_num);
                         echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_locations", $class->fields["locations_id"]), $item_num, $row_num);
                         echo Search::showItem($output_type, Html::convDateTime($hardware[$i]["last_update"]), $item_num, $row_num);
                         echo Search::showItem($output_type, $hardware[$i]["subnet"], $item_num, $row_num);
                         echo self::showItem($hardware[$i]["id"], "", "", "", true, "", $i);
                         echo Search::showEndLine($output_type);
                     }
                 }
                 echo "<tbody style=\"display:none\">";
                 echo "<tr><td><input type=\"hidden\" name='subnet' value=\"{$ipAdress}\" ></td></tr>";
                 echo "</tbody>";
                 echo "</table>\n";
                 echo "<div class='center' style=\"width=100%\">";
                 echo "<input type='submit' class='submit' name='deletelink'  value=\"" . _sx('button', 'Delete link', 'ocsinventoryng') . "\"></div>";
                 Html::closeForm();
                 self::checkBox($target);
                 break;
             case "noninventoried":
                 $ocsTypes = array("id" => array(Dropdown::EMPTY_VALUE), "name" => array(Dropdown::EMPTY_VALUE));
                 $link = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.php";
                 $target = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php" . $backValues;
                 $macConstructor = "";
                 self::getOCSTypes($ocsTypes);
                 self::checkBox($target);
                 echo "<form method='post' id='ipdiscover_form' name='ipdiscover_form' action='{$target}'>";
                 echo "<div class='center' style=\"width=100%\">";
                 if ($action == "import") {
                     echo "<input type='submit' class='submit' name='IdentifyAndImport'  value=\"" . _sx('button', 'Import') . "\">";
                     echo "&nbsp;";
                 } else {
                     echo "<input type='submit' class='submit' name='IdentifyAndLink'  value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">";
                     echo "&nbsp;";
                 }
                 echo "<input type='submit' class='submit' name='delete'  value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>";
                 echo "<table width='100%'class='tab_cadrehov'>\n";
                 echo Search::showHeaderItem($output_type, __('Date'), $header_num);
                 echo Search::showHeaderItem($output_type, __('MAC address'), $header_num);
                 echo Search::showHeaderItem($output_type, __('IP address'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Subnet mask'), $header_num);
                 echo Search::showHeaderItem($output_type, __('DNS', 'ocsinventoryng'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Description') . "<span class='red'>*</span>", $header_num);
                 echo Search::showHeaderItem($output_type, __('OCS Type', 'ocsinventoryng') . "<span class='red'>*</span>", $header_num);
                 if ($action == "import") {
                     echo Search::showHeaderItem($output_type, __('Name'), $header_num);
                     if (Session::isMultiEntitiesMode()) {
                         echo Search::showHeaderItem($output_type, __('Entity'), $header_num);
                     }
                     echo Search::showHeaderItem($output_type, __('GLPI Type', 'ocsinventoryng') . "<span class='red'>*</span>", $header_num);
                 } else {
                     echo Search::showHeaderItem($output_type, __('Item to link', 'ocsinventoryng'), $header_num, "", 0, "", 'width=15%');
                 }
                 echo Search::showHeaderItem($output_type, __('&nbsp;'), $header_num);
                 echo Search::showEndLine($output_type);
                 $row_num = 1;
                 $ocstypes = array();
                 foreach ($ocsTypes["name"] as $items) {
                     $ocstypes[$items] = $items;
                 }
                 $itemstypes = array(Dropdown::EMPTY_VALUE);
                 foreach (self::$hardwareItemTypes as $items) {
                     $class = getItemForItemtype($items);
                     $itemstypes[$items] = $class->getTypeName();
                 }
                 for ($i = $start; $i < $lim + $start; $i++) {
                     if (isset($hardware[$i])) {
                         $row_num++;
                         echo Search::showNewLine($output_type, $row_num % 2);
                         echo self::showItem(Html::convDateTime($hardware[$i]["date"]));
                         if (isset($_SESSION["OCS"]["IpdiscoverMacConstructors"])) {
                             $macs = unserialize($_SESSION["OCS"]["IpdiscoverMacConstructors"]);
                             if (isset($macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))])) {
                                 $macConstructor = $macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))];
                             } else {
                                 $macConstructor = __("unknow");
                             }
                         }
                         $mac = $hardware[$i]["mac"] . "<small> ( " . $macConstructor . " )</small>";
                         echo self::showItem($mac);
                         echo self::showItem($ip = $hardware[$i]["ip"]);
                         echo self::showItem($hardware[$i]["mask"]);
                         echo self::showItem($hardware[$i]["DNS"]);
                         echo "<td><input type=\"text\" name='itemsdescription[" . $i . "]' value=\"\" ></td>";
                         echo "<td>";
                         Dropdown::showFromArray("ocsitemstype[{$i}]", $ocstypes);
                         echo "</td>";
                         if ($action == "import") {
                             echo "<td><input type=\"text\" name='itemsname[" . $i . "]' value=\"\"></td>";
                             if (Session::isMultiEntitiesMode()) {
                                 echo "<td>";
                                 Entity::dropdown(array('name' => "entities[{$i}]", 'entity' => $_SESSION["glpiactiveentities"]));
                                 echo "</td>";
                             }
                             echo "<td>";
                             Dropdown::showFromArray("glpiitemstype[{$i}]", $itemstypes);
                             echo "</td>";
                         } else {
                             echo "<td width='10'>";
                             $mtrand = mt_rand();
                             $mynamei = "itemtype";
                             $myname = "tolink_items[" . $i . "]";
                             $rand = Dropdown::showItemTypes($mynamei, self::$hardwareItemTypes, array('rand' => $mtrand));
                             $p = array('itemtype' => '__VALUE__', 'entity_restrict' => $_SESSION["glpiactiveentities"], 'id' => $i, 'rand' => $rand, 'myname' => $myname);
                             //print_r($p);
                             Ajax::updateItemOnSelectEvent("dropdown_{$mynamei}{$rand}", "results_{$mynamei}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/ajax/dropdownitems.php", $p);
                             echo "<span id='results_{$mynamei}{$rand}'>\n";
                             echo "</span>\n";
                             //}
                             echo "</td>";
                         }
                         echo self::showItem($hardware[$i]["mac"], "", "", "", true, "", $i);
                         echo "<tbody style=\"display:none\">";
                         echo "<tr><td><input type=\"hidden\" name='itemsip[" . $i . "]' value=\"{$ip}\" >\n                           <input type=\"hidden\" name='subnet' value=\"{$ipAdress}\" ></td></tr>";
                         echo "</tbody>";
                     }
                 }
                 echo "</table>\n";
                 echo "<div class='center' style=\"width=100%\">";
                 if ($action == "import") {
                     echo "<input type='submit' class='submit' name='IdentifyAndImport'  value=\"" . _sx('button', 'Import') . "\">";
                     echo "&nbsp;";
                 } else {
                     echo "<input type='submit' class='submit' name='IdentifyAndLink'  value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">";
                     echo "&nbsp;";
                 }
                 echo "<input type='submit' class='submit' name='delete'  value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>";
                 Html::closeForm();
                 self::checkBox($target);
                 break;
             default:
                 $link = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.php";
                 $target = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php" . $backValues;
                 $macConstructor = "";
                 self::checkBox($target);
                 echo "<form method='post' id='ipdiscover_form' name='ipdiscover_form' action='{$target}'>";
                 echo "<div class='center' style=\"width=100%\">";
                 if ($action == "import") {
                     echo "<input type='submit' class='submit' name='Import'  value=\"" . _sx('button', 'Import') . "\">";
                     echo "&nbsp;";
                 } else {
                     echo "<input type='submit' class='submit' name='Link'  value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">";
                     echo "&nbsp;";
                 }
                 echo "<input type='submit' class='submit' name='delete'  value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>";
                 echo "<table width='100%'class='tab_cadrehov'>";
                 echo Search::showHeaderItem($output_type, __('Date'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Description'), $header_num);
                 echo Search::showHeaderItem($output_type, __('OCS Type', 'ocsinventoryng'), $header_num);
                 echo Search::showHeaderItem($output_type, __('IP address'), $header_num);
                 echo Search::showHeaderItem($output_type, __('MAC address'), $header_num);
                 if ($action == "import") {
                     if (Session::isMultiEntitiesMode()) {
                         echo Search::showHeaderItem($output_type, __('Entity'), $header_num);
                     }
                     echo Search::showHeaderItem($output_type, __('Name'), $header_num);
                     echo Search::showHeaderItem($output_type, __('GLPI Type', 'ocsinventoryng') . "<span class='red'>*</span>", $header_num);
                 } else {
                     echo Search::showHeaderItem($output_type, __('Item to link', 'ocsinventoryng'), $header_num, "", 0, "", 'width=15%');
                 }
                 echo Search::showHeaderItem($output_type, __('&nbsp;'), $header_num);
                 echo Search::showEndLine($output_type);
                 $row_num = 1;
                 $itemstypes = array(Dropdown::EMPTY_VALUE);
                 foreach (self::$hardwareItemTypes as $items) {
                     $class = getItemForItemtype($items);
                     $itemstypes[$items] = $class->getTypeName();
                 }
                 for ($i = $start; $i < $lim + $start; $i++) {
                     if (isset($hardware[$i])) {
                         $row_num++;
                         echo Search::showNewLine($output_type, $row_num % 2);
                         echo self::showItem(Html::convDateTime($hardware[$i]["date"]));
                         echo self::showItem($description = $hardware[$i]["description"]);
                         echo self::showItem($hardware[$i]["type"]);
                         echo self::showItem($ip = $hardware[$i]["ip"]);
                         if (isset($_SESSION["OCS"]["IpdiscoverMacConstructors"])) {
                             $macs = unserialize($_SESSION["OCS"]["IpdiscoverMacConstructors"]);
                             if (isset($macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))])) {
                                 $macConstructor = $macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))];
                             } else {
                                 $macConstructor = __("unknow");
                             }
                         }
                         $mac = $hardware[$i]["mac"] . "<small> ( " . $macConstructor . " )</small>";
                         echo self::showItem($mac);
                         if ($action == "import") {
                             if (Session::isMultiEntitiesMode()) {
                                 echo "<td>";
                                 Entity::dropdown(array('name' => "entities[{$i}]", 'entity' => $_SESSION["glpiactiveentities"]));
                                 echo "</td>";
                             }
                             echo "<td><input type=\"text\" name='itemsname[" . $i . "]' value=\"\"></td>";
                             echo "<td>";
                             Dropdown::showFromArray("glpiitemstype[{$i}]", $itemstypes);
                             echo "</td>";
                         } else {
                             echo "<td width='10'>";
                             $mtrand = mt_rand();
                             $mynamei = "itemtype";
                             $myname = "tolink_items[" . $i . "]";
                             $rand = Dropdown::showItemTypes($mynamei, self::$hardwareItemTypes, array('rand' => $mtrand));
                             $p = array('itemtype' => '__VALUE__', 'entity_restrict' => $_SESSION["glpiactiveentities"], 'id' => $i, 'rand' => $rand, 'myname' => $myname);
                             Ajax::updateItemOnSelectEvent("dropdown_{$mynamei}{$rand}", "results_{$mynamei}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/ajax/dropdownitems.php", $p);
                             echo "<span id='results_{$mynamei}{$rand}'>\n";
                             echo "</span>\n";
                             echo "</td>";
                         }
                         echo self::showItem($hardware[$i]["mac"], "", "", "", true, "", $i);
                         echo "<tbody style=\"display:none\">";
                         echo "<tr><td><input type=\"hidden\" name='itemsip[" . $i . "]' value=\"{$ip}\" >";
                         echo "<input type=\"hidden\" name='itemsdescription[" . $i . "]' value=\"{$description}\" >\n                             <input type=\"hidden\" name='subnet' value=\"{$ipAdress}\" ></tr>";
                         echo "</td></tr></tbody>";
                     }
                 }
                 echo "</table>";
                 echo "<div class='center' style=\"width=100%\">";
                 if ($action == "import") {
                     echo "<input type='submit' class='submit' name='Import'  value=\"" . _sx('button', 'Import') . "\">";
                     echo "&nbsp;";
                 } else {
                     echo "<input type='submit' class='submit' name='Link'  value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">";
                     echo "&nbsp;";
                 }
                 echo "<input type='submit' class='submit' name='delete'  value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>";
                 Html::closeForm();
                 self::checkBox($target);
                 break;
         }
     }
     if ($subnet >= 0) {
         $back = __('Back');
         echo "<div class='center'><a href='{$return}?{$returnargs}'>{$back}</div>";
     }
 }
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::showMassiveActionsSubForm()
  **/
 static function showMassiveActionsSubForm(MassiveAction $ma)
 {
     global $CFG_GLPI;
     switch ($ma->getAction()) {
         case 'transform_to':
             Dropdown::showItemTypes('transform_to', NetworkPort::getNetworkPortInstantiations(), array('value' => 'NetworkPortEthernet'));
             echo "<br><br>";
             echo Html::submit(_x('button', 'Post'), array('name' => 'massiveaction')) . "</span>";
             return true;
     }
     return parent::showMassiveActionsSubForm($ma);
 }
コード例 #7
0
ファイル: reminder.class.php プロジェクト: gaforeror/glpi
 /**
  * Show visibility config for a reminder
  **/
 function showVisibility()
 {
     global $DB, $CFG_GLPI;
     $ID = $this->fields['id'];
     $canedit = Session::haveRight('reminder_public', 'w');
     echo "<div class='center'>";
     $rand = mt_rand();
     $nb = count($this->users) + count($this->groups) + count($this->profiles) + count($this->entities);
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='remindervisibility_form{$rand}' id='remindervisibility_form{$rand}' ";
         echo " method='post' action='" . Toolbox::getItemTypeFormURL('Reminder') . "'>";
         echo "<input type='hidden' name='reminders_id' value='{$ID}'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Add a target') . "</tr>";
         echo "<tr class='tab_bg_2'><td width='100px'>";
         $types = array('Entity', 'Group', 'Profile', 'User');
         $addrand = Dropdown::showItemTypes('_type', $types);
         $params = array('type' => '__VALUE__', 'right' => 'reminder_public');
         Ajax::updateItemOnSelectEvent("dropdown__type" . $addrand, "visibility{$rand}", $CFG_GLPI["root_doc"] . "/ajax/visibility.php", $params);
         echo "</td>";
         echo "<td><span id='visibility{$rand}'></span>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $nb) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $paramsma = array('num_displayed' => $nb, 'specific_actions' => array('deletevisibility' => _x('button', 'Delete permanently')));
         if ($this->fields['users_id'] != Session::getLoginUserID()) {
             $paramsma['confirm'] = __('Caution! You are not the author of this element. Delete targets can result in loss of access to that element.');
         }
         Html::showMassiveActions(__CLASS__, $paramsma);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr>";
     if ($canedit && $nb) {
         echo "<th width='10'>";
         echo Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
         echo "</th>";
     }
     echo "<th>" . __('Type') . "</th>";
     echo "<th>" . _n('Recipient', 'Recipients', 2) . "</th>";
     echo "</tr>";
     // Users
     if (count($this->users)) {
         foreach ($this->users as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>";
                     echo "<input type='checkbox' name='item[Reminder_User][" . $data["id"] . "]'\n                          value='1' >";
                     echo "</td>";
                 }
                 echo "<td>" . __('User') . "</td>";
                 echo "<td>" . getUserName($data['users_id']) . "</td>";
                 echo "</tr>";
             }
         }
     }
     // Groups
     if (count($this->groups)) {
         foreach ($this->groups as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>";
                     echo "<input type='checkbox' name='item[Group_Reminder][" . $data["id"] . "]'\n                         value='1'>";
                     echo "</td>";
                 }
                 echo "<td>" . __('Group') . "</td>";
                 $names = Dropdown::getDropdownName('glpi_groups', $data['groups_id'], 1);
                 $entname = sprintf(__('%1$s %2$s'), $names["name"], Html::showToolTip($names["comment"], array('display' => false)));
                 if ($data['entities_id'] >= 0) {
                     $entname = sprintf(__('%1$s / %2$s'), $entname, Dropdown::getDropdownName('glpi_entities', $data['entities_id']));
                     if ($data['is_recursive']) {
                         //TRANS: R for Recursive
                         sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>");
                     }
                 }
                 echo "<td>" . $entname . "</td>";
                 echo "</tr>";
             }
         }
     }
     // Entity
     if (count($this->entities)) {
         foreach ($this->entities as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>";
                     echo "<input type='checkbox' name='item[Entity_Reminder][" . $data["id"] . "]'\n                          value='1'>";
                     echo "</td>";
                 }
                 echo "<td>" . __('Entity') . "</td>";
                 $names = Dropdown::getDropdownName('glpi_entities', $data['entities_id'], 1);
                 $tooltip = Html::showToolTip($names["comment"], array('display' => false));
                 $entname = sprintf(__('%1$s %2$s'), $names["name"], $tooltip);
                 if ($data['is_recursive']) {
                     $entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>");
                 }
                 echo "<td>" . $entname . "</td>";
                 echo "</tr>";
             }
         }
     }
     // Profiles
     if (count($this->profiles)) {
         foreach ($this->profiles as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>";
                     echo "<input type='checkbox' name='item[Profile_Reminder][" . $data["id"] . "]'\n                         value='1'>";
                     echo "</td>";
                 }
                 echo "<td>" . _n('Profile', 'Profiles', 1) . "</td>";
                 $names = Dropdown::getDropdownName('glpi_profiles', $data['profiles_id'], 1);
                 $tooltip = Html::showToolTip($names["comment"], array('display' => false));
                 $entname = sprintf(__('%1$s %2$s'), $names["name"], $entname);
                 if ($data['entities_id'] >= 0) {
                     $entname = sprintf(__('%1$s / %2$s'), $entname, Dropdown::getDropdownName('glpi_entities', $data['entities_id']));
                     if ($data['is_recursive']) {
                         $entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>");
                     }
                 }
                 echo "<td>" . $entname . "</td>";
                 echo "</tr>";
             }
         }
     }
     echo "</table>";
     if ($canedit && $nb) {
         $paramsma['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $paramsma);
         Html::closeForm();
     }
     echo "</div>";
     // Add items
     return true;
 }
コード例 #8
0
 function displayCriteriaSelectPattern($name, $ID, $condition, $value = "", $test = FALSE)
 {
     $crit = $this->getCriteria($ID);
     $display = FALSE;
     $tested = FALSE;
     foreach ($this->criterias as $criteria) {
         if ($criteria->fields['criteria'] == $name) {
             if ($criteria->fields['condition'] == Rule::PATTERN_CONTAIN || $criteria->fields['condition'] == Rule::PATTERN_NOT_CONTAIN || $criteria->fields['condition'] == Rule::PATTERN_BEGIN || $criteria->fields['condition'] == Rule::PATTERN_END || $criteria->fields['condition'] == Rule::REGEX_MATCH || $criteria->fields['condition'] == Rule::REGEX_NOT_MATCH) {
                 $rc = new $this->rulecriteriaclass();
                 Html::autocompletionTextField($rc, "pattern", array('name' => $name, 'value' => $value, 'size' => 70));
                 return;
             }
             if ($criteria->fields['condition'] == Rule::PATTERN_IS || $criteria->fields['condition'] == Rule::PATTERN_IS_NOT and ($name != "itemtype" and $name != 'states_id')) {
                 $rc = new $this->rulecriteriaclass();
                 Html::autocompletionTextField($rc, "pattern", array('name' => $name, 'value' => $value, 'size' => 70));
                 return;
             }
         }
     }
     if (isset($crit['type']) && ($test || $condition == Rule::PATTERN_IS || $condition == Rule::PATTERN_IS_NOT)) {
         switch ($crit['type']) {
             case "yesonly":
                 Dropdown::showYesNo($name, $value, 0);
                 $display = TRUE;
                 break;
             case "yesno":
                 Dropdown::showYesNo($name, $value);
                 $display = TRUE;
                 break;
             case "dropdown":
                 Dropdown::show(getItemTypeForTable($crit['table']), array('name' => $name, 'value' => $value));
                 $display = TRUE;
                 break;
             case "dropdown_users":
                 User::dropdown(array('value' => $value, 'name' => $name, 'right' => 'all'));
                 $display = TRUE;
                 break;
             case "dropdown_itemtype":
                 $types = $this->getTypes();
                 ksort($types);
                 Dropdown::showItemTypes($name, array_keys($types), array('value' => $value));
                 $display = TRUE;
                 break;
         }
         $tested = TRUE;
     }
     //Not a standard condition
     if (!$tested) {
         $display = $this->displayAdditionalRuleCondition($condition, $crit, $name, $value);
     }
     if (!$display) {
         $rc = new $this->rulecriteriaclass();
         Html::autocompletionTextField($rc, "pattern", array('name' => $name, 'value' => $value, 'size' => 70));
     }
 }
コード例 #9
0
 /**
  * Display form for unmanaged device
  *
  * @param $id integer id of the unmanaged device
  * @param $options array
  *
  * @return bool TRUE if form is ok
  *
  **/
 function showForm($id, $options = array())
 {
     $this->initForm($id, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . __('Name') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Html::autocompletionTextField($this, 'name', array('size' => 35));
     echo "</td>";
     if (Session::isMultiEntitiesMode()) {
         echo "<td align='center'>" . __('Entity') . "&nbsp;:</td>";
         echo "</td>";
         echo "<td align='center'>";
         Dropdown::show("Entity", array('name' => 'entities_id', 'value' => $this->fields["entities_id"]));
         echo "</td>";
         echo "</tr>";
         echo "</tr>";
     } else {
         echo "<td align='center'></td>";
         echo "</td>";
         echo "<td align='center'></td>";
         echo "</tr>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . __('Type') . "&nbsp;:</td>";
     echo "<td align='center'>";
     $type_list = array();
     $type_list[] = 'Computer';
     $type_list[] = 'NetworkEquipment';
     $type_list[] = 'Printer';
     $type_list[] = 'Peripheral';
     $type_list[] = 'Phone';
     Dropdown::showItemTypes('item_type', $type_list, array('value' => $this->fields["item_type"]));
     echo "</td>";
     echo "<td align='center'>" . __('Alternate username') . "&nbsp;:</td>";
     echo "</td>";
     echo "<td align='center'>";
     Html::autocompletionTextField($this, 'contact', array('size' => 35));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . __('Location') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::show("Location", array('name' => "locations_id", 'value' => $this->fields["locations_id"]));
     echo "</td>";
     echo "<td align='center'>" . __('Domain') . "&nbsp;:</td>";
     echo "</td>";
     echo "<td align='center'>";
     Dropdown::show("Domain", array('name' => "domain", 'value' => $this->fields["domain"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . __('Approved devices', 'fusioninventory') . " :</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("accepted", $this->fields["accepted"]);
     echo "</td>";
     echo "<td align='center'>" . __('Serial Number') . "&nbsp;:</td>";
     echo "</td>";
     echo "<td align='center'>";
     Html::autocompletionTextField($this, 'serial', array('size' => 35));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . __('Network hub', 'fusioninventory') . " :</td>";
     echo "<td align='center'>";
     echo Dropdown::getYesNo($this->fields["hub"]);
     echo "</td>";
     echo "<td align='center'>" . __('Inventory number') . "&nbsp;:</td>";
     echo "</td>";
     echo "<td align='center'>";
     Html::autocompletionTextField($this, 'otherserial', array('size' => 35));
     echo "</td>";
     echo "</tr>";
     if (!empty($this->fields["ip"]) or !empty($this->fields["mac"])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td align='center'>" . __('IP') . " :</td>";
         echo "<td align='center'>";
         Html::autocompletionTextField($this, 'ip', array('size' => 35));
         echo "</td>";
         echo "<td colspan='2'></td>";
         echo "</tr>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center' rowspan='2'>";
     echo __('Sysdescr', 'fusioninventory') . "&nbsp;:";
     echo "</td>";
     echo "<td rowspan='2'>";
     echo "<textarea name='sysdescr'  cols='45' rows='5'>" . $this->fields["sysdescr"] . "</textarea>";
     echo "<td align='center'></td>";
     echo "<td align='center'>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . __('SNMP authentication', 'fusioninventory') . "&nbsp;:</td>";
     echo "<td align='center'>";
     PluginFusioninventoryConfigSecurity::auth_dropdown($this->fields['plugin_fusioninventory_configsecurities_id']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td align='center'>" . __('Comments') . " : </td>";
     echo "</td>";
     echo "<td align='middle' colspan='3'>";
     echo "<textarea  cols='80' rows='2' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return TRUE;
 }
コード例 #10
0
 /**
  * @param $params
  */
 static function showSnmpDeviceToAdd($params)
 {
     global $DB, $CFG_GLPI;
     // Default values of parameters
     $p['link'] = array();
     $p['field'] = array();
     $p['contains'] = array();
     $p['searchtype'] = array();
     $p['sort'] = '1';
     $p['order'] = 'ASC';
     $p['start'] = 0;
     $p['export_all'] = 0;
     $p['link2'] = '';
     $p['contains2'] = '';
     $p['field2'] = '';
     $p['itemtype2'] = '';
     $p['searchtype2'] = '';
     $p['itemtype'] = '';
     $p['ip'] = '';
     $p['tolinked'] = 0;
     $p['check'] = 'all';
     $p['plugin_ocsinventoryng_ocsservers_id'] = 0;
     foreach ($params as $key => $val) {
         $p[$key] = $val;
     }
     $tolinked = $p['tolinked'];
     $start = $p['start'];
     $plugin_ocsinventoryng_ocsservers_id = $p['plugin_ocsinventoryng_ocsservers_id'];
     $title = __('Import new SNMP devices', 'ocsinventoryng');
     if ($tolinked) {
         $title = __('Import new SNMP devices into glpi', 'ocsinventoryng');
     }
     $target = $CFG_GLPI['root_doc'] . '/plugins/ocsinventoryng/front/ocsngsnmp.import.php';
     if ($tolinked) {
         $target = $CFG_GLPI['root_doc'] . '/plugins/ocsinventoryng/front/ocsngsnmp.link.php';
     }
     if (!$start) {
         $start = 0;
     }
     // Get all links between glpi and OCS
     $query_glpi = "SELECT ocs_id\n                     FROM `glpi_plugin_ocsinventoryng_snmpocslinks`\n                     WHERE `plugin_ocsinventoryng_ocsservers_id` = '" . $plugin_ocsinventoryng_ocsservers_id . "'";
     $result_glpi = $DB->query($query_glpi);
     $already_linked = array();
     if ($DB->numrows($result_glpi) > 0) {
         while ($data = $DB->fetch_array($result_glpi)) {
             $already_linked[] = $data["ocs_id"];
         }
     }
     $snmpOptions = array('ORDER' => 'LASTDATE', 'FILTER' => array('EXCLUDE_IDS' => $already_linked), 'DISPLAY' => array('CHECKSUM' => PluginOcsinventoryngOcsClient::CHECKSUM_BIOS), 'ORDER' => 'NAME');
     //if ($cfg_ocs["tag_limit"] and $tag_limit = explode("$", trim($cfg_ocs["tag_limit"]))) {
     //   $snmpOptions['FILTER']['TAGS'] = $tag_limit;
     //}
     //if ($cfg_ocs["tag_exclude"] and $tag_exclude = explode("$", trim($cfg_ocs["tag_exclude"]))) {
     //   $snmpOptions['FILTER']['EXCLUDE_TAGS'] = $tag_exclude;
     //}
     $ocsClient = PluginOcsinventoryngOcsServer::getDBocs($plugin_ocsinventoryng_ocsservers_id);
     $ocsResult = $ocsClient->getSnmp($snmpOptions);
     if (isset($ocsResult['SNMP'])) {
         if (count($ocsResult['SNMP'])) {
             // Get all hardware from OCS DB
             $hardware = array();
             $snmp = array_slice($ocsResult['SNMP'], $start, $_SESSION['glpilist_limit']);
             foreach ($snmp as $data) {
                 $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data));
                 $id = $data['META']['ID'];
                 $hardware[$id]["id"] = $data['META']["ID"];
                 $hardware[$id]["date"] = $data['META']["LASTDATE"];
                 $hardware[$id]["name"] = $data['META']["NAME"];
                 $hardware[$id]["ipaddr"] = $data['META']["IPADDR"];
                 $hardware[$id]["snmpdeviceid"] = $data['META']["SNMPDEVICEID"];
                 $hardware[$id]["description"] = $data['META']["DESCRIPTION"];
                 $hardware[$id]["type"] = $data['META']["TYPE"];
                 $hardware[$id]["contact"] = $data['META']["CONTACT"];
                 $hardware[$id]["location"] = $data['META']["LOCATION"];
             }
             foreach ($hardware as $id => $field) {
                 if ($field["type"] == "Network") {
                     $field["type"] = "NetworkEquipment";
                 }
                 if (!empty($p['itemtype']) && $field['type'] != $p['itemtype']) {
                     unset($hardware[$id]);
                 }
                 if (!empty($p['ip']) && !preg_match("/" . $p['ip'] . "/", $field['ipaddr'])) {
                     unset($hardware[$id]);
                 }
             }
             $output_type = Search::HTML_OUTPUT;
             if (isset($_GET["display_type"])) {
                 $output_type = $_GET["display_type"];
             }
             $parameters = "itemtype=" . $p['itemtype'] . "&amp;ip=" . $p['ip'];
             // Define begin and end var for loop
             // Search case
             $begin_display = $start;
             $end_display = $start + $_SESSION["glpilist_limit"];
             $numrows = $ocsResult['TOTAL_COUNT'];
             // Export All case
             if (isset($_GET['export_all'])) {
                 $begin_display = 0;
                 $end_display = $numrows;
             }
             $nbcols = 10;
             if ($output_type == Search::HTML_OUTPUT && $tolinked && count($hardware)) {
                 echo "<div class='center b'>" . __('Caution! The imported data (see your configuration) will overwrite the existing one', 'ocsinventoryng') . "</div>";
             }
             if ($numrows) {
                 $parameters = "";
                 Html::printPager($start, $numrows, $target, $parameters);
                 //Show preview form only in import even in multi-entity mode because computer import
                 //can be refused by a rule
                 /*if (!$tolinked) {
                      echo "<div class='firstbloc'>";
                      echo "<form method='post' name='ocsng_import_mode' id='ocsng_import_mode'
                             action='$target'>\n";
                      echo "<table class='tab_cadre_fixe'>";
                      echo "<tr><th>" . __('Manual import mode', 'ocsinventoryng') . "</th></tr>\n";
                      echo "<tr class='tab_bg_1'><td class='center'>";
                      echo "</td></tr>";
                      echo "</table>";
                      Html::closeForm();
                      echo "</div>";
                   }*/
                 if ($output_type == Search::HTML_OUTPUT) {
                     echo "<form method='post' name='ocsng_form' id='ocsng_form' action='{$target}'>";
                 }
                 if ($output_type == Search::HTML_OUTPUT && !$tolinked) {
                     echo "<div class='center'>";
                     PluginOcsinventoryngOcsServer::checkBox($target);
                     echo "</div>";
                 }
                 if ($output_type == Search::HTML_OUTPUT) {
                     echo "<table class='tab_cadrehov'>";
                     echo "<tr class='tab_bg_1'><td colspan='10' class='center'>";
                     if (!$tolinked) {
                         echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Import', 'ocsinventoryng') . "\">";
                     } else {
                         echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">";
                     }
                     echo "</td></tr>\n";
                 }
                 echo Search::showHeader($output_type, $end_display - $begin_display + 1, $nbcols);
                 echo Search::showNewLine($output_type);
                 $header_num = 1;
                 echo Search::showHeaderItem($output_type, __('Name'), $header_num);
                 //, $linkto, $p['sort']==$val, $p['order']
                 echo Search::showHeaderItem($output_type, __('Description'), $header_num);
                 echo Search::showHeaderItem($output_type, __('IP address'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Date'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Contact SNMP', 'ocsinventoryng'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Location SNMP', 'ocsinventoryng'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Type SNMP', 'ocsinventoryng'), $header_num);
                 if (!$tolinked) {
                     echo Search::showHeaderItem($output_type, __('Item type to create', 'ocsinventoryng'), $header_num, "", 0, "", 'width=15%');
                     echo Search::showHeaderItem($output_type, "", $header_num);
                 } else {
                     echo Search::showHeaderItem($output_type, __('Item to link', 'ocsinventoryng'), $header_num, "", 0, "", 'width=15%');
                 }
                 // End Line for column headers
                 echo Search::showEndLine($output_type);
                 $row_num = 1;
                 foreach ($hardware as $ID => $tab) {
                     $row_num++;
                     $item_num = 1;
                     if ($tab["type"] == "Network") {
                         $tab["type"] = "NetworkEquipment";
                     }
                     echo Search::showNewLine($output_type, $row_num % 2);
                     echo Search::showItem($output_type, $tab["name"], $item_num, $row_num);
                     echo Search::showItem($output_type, $tab["description"], $item_num, $row_num, 'width=15%');
                     echo Search::showItem($output_type, $tab["ipaddr"], $item_num, $row_num, 'width=5%');
                     echo Search::showItem($output_type, Html::convDateTime($tab["date"]), $item_num, $row_num, 'width=15%');
                     echo Search::showItem($output_type, $tab["contact"], $item_num, $row_num, 'width=5%');
                     echo Search::showItem($output_type, $tab["location"], $item_num, $row_num, 'width=15%');
                     echo Search::showItem($output_type, $tab["type"], $item_num, $row_num);
                     if (!$tolinked) {
                         echo "<td width='15%'>";
                         $value = false;
                         if (getItemForItemtype($tab["type"])) {
                             $value = $tab["type"];
                         }
                         $type = "toimport_itemtype[" . $tab["id"] . "]";
                         Dropdown::showItemTypes($type, self::$snmptypes, array('value' => $value));
                         echo "</td>\n";
                     }
                     /* if ($p['change_import_mode'] && !$tolinked){
                        if (!isset ($data['entities_id']) || $data['entities_id'] == -1){
                        echo "<td class='center'><img src=\"".$CFG_GLPI['root_doc']. "/pics/redbutton.png\"></td>\n";
                        $data['entities_id'] = -1;
                        } else{
                        echo "<td class='center'>";
                        $tmprule = new RuleImportEntity();
                        if ($tmprule->can($data['_ruleid'],READ)){
                        echo "<a href='". $tmprule->getLinkURL()."'>".$tmprule->getName()."</a>";
                        }  else{
                        echo $tmprule->getName();
                        }
                        echo "</td>\n";
                        }
                        echo "<td width='30%'>";
                        $ent = "toimport_entities[".$tab["id"]."]";
                        Entity::dropdown(array('name'     => $ent,
                        'value'    => $data['entities_id'],
                        'comments' => 0));
                        echo "</td>\n";
                        } */
                     echo "<td width='10'>";
                     if (!$tolinked) {
                         echo "<input type='checkbox' name='toimport[" . $tab["id"] . "]' " . ($p['check'] == "all" ? "checked" : "") . ">";
                     } else {
                         /* $tab['entities_id'] = $p['glpiactiveentities'];
                                                $rulelink         = new RuleImportComputerCollection();
                                                $rulelink_results = array();
                                                $params           = array('entities_id' => $p['glpiactiveentities'],
                                                'plugin_ocsinventoryng_ocsservers_id'
                                                => $plugin_ocsinventoryng_ocsservers_id);
                                                $rulelink_results = $rulelink->processAllRules(Toolbox::stripslashes_deep($tab),
                                                array(), $params);
                         
                                                //Look for the computer using automatic link criterias as defined in OCSNG configuration
                                                $options       = array('name' => "tolink[".$tab["id"]."]");
                                                $show_dropdown = true;
                                                //If the computer is not explicitly refused by a rule
                                                if (!isset($rulelink_results['action'])
                                                || $rulelink_results['action'] != PluginOcsinventoryngOcsServer::LINK_RESULT_NO_IMPORT){
                         
                                                if (!empty($rulelink_results['found_computers'])){
                                                $options['value']  = $rulelink_results['found_computers'][0];
                                                $options['entity'] = $p['glpiactiveentities'];
                                                } */
                         /* } else{
                            echo "<img src='".$CFG_GLPI['root_doc']. "/pics/redbutton.png'>";
                            } */
                         $value = false;
                         if (getItemForItemtype($tab["type"])) {
                             $type = $tab["type"];
                             $options['name'] = "tolink_items[" . $tab["id"] . "]";
                             $self = new self();
                             if ($item = $self->getFromDBbyName($tab["type"], $tab["name"])) {
                                 $options['value'] = isset($item->fields['id']) ? $item->fields['id'] : false;
                             }
                             $type::dropdown($options);
                             echo "<input type='hidden' name='tolink_itemtype[" . $tab["id"] . "]' value='" . $tab["type"] . "'>";
                         } else {
                             $mtrand = mt_rand();
                             $mynamei = "itemtype";
                             $myname = "tolink_items[" . $tab["id"] . "]";
                             $rand = Dropdown::showItemTypes($mynamei, self::$snmptypes, array('rand' => $mtrand));
                             $p = array('itemtype' => '__VALUE__', 'id' => $tab["id"], 'rand' => $rand, 'myname' => $myname);
                             //print_r($p);
                             Ajax::updateItemOnSelectEvent("dropdown_{$mynamei}{$rand}", "results_{$mynamei}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/ajax/dropdownitems.php", $p);
                             echo "<span id='results_{$mynamei}{$rand}'>\n";
                             echo "</span>\n";
                         }
                     }
                     echo "</td></tr>\n";
                 }
                 echo "<tr class='tab_bg_1'><td colspan='10' class='center'>";
                 if (!$tolinked) {
                     echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Import', 'ocsinventoryng') . "\">";
                 } else {
                     echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">";
                 }
                 echo "<input type=hidden name='plugin_ocsinventoryng_ocsservers_id' " . "value='" . $plugin_ocsinventoryng_ocsservers_id . "'>";
                 echo "</td></tr>";
                 echo "</table>\n";
                 Html::closeForm();
                 if (!$tolinked) {
                     echo "<div class='center'>";
                     PluginOcsinventoryngOcsServer::checkBox($target);
                     echo "</div>";
                 }
                 Html::printPager($start, $numrows, $target, $parameters);
             } else {
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr><th>" . $title . "</th></tr>\n";
                 echo "<tr class='tab_bg_1'>";
                 echo "<td class='center b'>" . __('No new SNMP device to be imported', 'ocsinventoryng') . "</td></tr>\n";
                 echo "</table>";
             }
             echo "</div>";
         } else {
             echo "<div class='center'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr><th>" . $title . "</th></tr>\n";
             echo "<tr class='tab_bg_1'>";
             echo "<td class='center b'>" . __('No new SNMP device to be imported', 'ocsinventoryng') . "</td></tr>\n";
             echo "</table></div>";
         }
     } else {
         echo "<div class='center'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . $title . "</th></tr>\n";
         echo "<tr class='tab_bg_1'>";
         echo "<td class='center b'>" . __('No new SNMP device to be imported', 'ocsinventoryng') . "</td></tr>\n";
         echo "</table></div>";
     }
 }
コード例 #11
0
 /**
  * Select a field using standard system
  *
  * @since version 0.83
  *
  * @param $field_id_or_search_options  integer/string/array id of the search option field
  *                                                             or field name
  *                                                             or search option array
  * @param $name                        string               name of the select (if empty use linkfield)
  *                                                          (default '')
  * @param $values                                           mixed default value to display
  *                                                          (default '')
  * @param $options                     array                of possible options:
  * Parameters which could be used in options array :
  *    - comments : boolean / is the comments displayed near the value (default false)
  *    - any others options passed to specific display method
  *
  * @return return the string to display
  **/
 function getValueToSelect($field_id_or_search_options, $name = '', $values = '', $options = array())
 {
     global $CFG_GLPI;
     $param['comments'] = false;
     $param['html'] = false;
     foreach ($param as $key => $val) {
         if (!isset($options[$key])) {
             $options[$key] = $val;
         }
     }
     $searchoptions = array();
     if (is_array($field_id_or_search_options)) {
         $searchoptions = $field_id_or_search_options;
     } else {
         $searchopt = $this->getSearchOptions();
         // Get if id of search option is passed
         if (is_numeric($field_id_or_search_options)) {
             if (isset($searchopt[$field_id_or_search_options])) {
                 $searchoptions = $searchopt[$field_id_or_search_options];
             }
         } else {
             // Get if field name is passed
             $searchoptions = $this->getSearchOptionByField('field', $field_id_or_search_options, $this->getTable());
         }
     }
     if (count($searchoptions)) {
         $field = $searchoptions['field'];
         // Normalize option
         if (is_array($values)) {
             $value = $values[$field];
         } else {
             $value = $values;
             $values = array($field => $value);
         }
         if (empty($name)) {
             $name = $searchoptions['linkfield'];
         }
         // If not set : set to specific
         if (!isset($searchoptions['datatype'])) {
             $searchoptions['datatype'] = 'specific';
         }
         $options['display'] = false;
         $unit = '';
         if (isset($searchoptions['unit'])) {
             $unit = $searchoptions['unit'];
         }
         if (isset($options[$searchoptions['table'] . '.' . $searchoptions['field']])) {
             $options = array_merge($options, $options[$searchoptions['table'] . '.' . $searchoptions['field']]);
         }
         switch ($searchoptions['datatype']) {
             case "count":
             case "number":
             case "integer":
                 $copytooption = array('min', 'max', 'step', 'toadd', 'unit');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Dropdown::showNumber($name, $options);
             case "decimal":
             case "mac":
             case "ip":
             case "string":
             case "email":
             case "weblink":
                 $this->fields[$name] = $value;
                 return Html::autocompletionTextField($this, $name, $options);
             case "text":
                 $out = '';
                 if (isset($searchoptions['htmltext']) && $searchoptions['htmltext']) {
                     $out = Html::initEditorSystem($name, '', false);
                 }
                 return $out . "<textarea cols='45' rows='5' name='{$name}'>{$value}</textarea>";
             case "bool":
                 return Dropdown::showYesNo($name, $value, -1, $options);
             case "color":
                 return Html::showColorField($name, $options);
             case "date":
             case "date_delay":
                 if (isset($options['relative_dates']) && $options['relative_dates']) {
                     if (isset($searchoptions['maybefuture']) && $searchoptions['maybefuture']) {
                         $options['with_future'] = true;
                     }
                     return Html::showGenericDateTimeSearch($name, $value, $options);
                 }
                 $copytooption = array('min', 'max', 'maybeempty', 'showyear');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Html::showDateField($name, $options);
             case "datetime":
                 if (isset($options['relative_dates']) && $options['relative_dates']) {
                     if (isset($searchoptions['maybefuture']) && $searchoptions['maybefuture']) {
                         $options['with_future'] = true;
                     }
                     $options['with_time'] = true;
                     return Html::showGenericDateTimeSearch($name, $value, $options);
                 }
                 $copytooption = array('mindate', 'maxdate', 'mintime', 'maxtime', 'maybeempty', 'timestep');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Html::showDateTimeField($name, $options);
             case "timestamp":
                 $copytooption = array('addfirstminutes', 'emptylabel', 'inhours', 'max', 'min', 'step', 'toadd', 'display_emptychoice');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Dropdown::showTimeStamp($name, $options);
             case "itemlink":
                 // Do not use dropdown if wanted to select string value instead of ID
                 if (isset($options['itemlink_as_string']) && $options['itemlink_as_string']) {
                     break;
                 }
             case "dropdown":
                 $copytooption = array('condition', 'displaywith', 'emptylabel', 'right', 'toadd');
                 $options['name'] = $name;
                 $options['value'] = $value;
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 if (!isset($options['entity'])) {
                     $options['entity'] = $_SESSION['glpiactiveentities'];
                 }
                 $itemtype = getItemTypeForTable($searchoptions['table']);
                 return $itemtype::dropdown($options);
             case "right":
                 return Profile::dropdownRights(Profile::getRightsFor($searchoptions['rightclass']), $name, $value, array('multiple' => false, 'display' => false));
             case "itemtypename":
                 if (isset($searchoptions['itemtype_list'])) {
                     $options['types'] = $CFG_GLPI[$searchoptions['itemtype_list']];
                 }
                 $copytooption = array('types');
                 $options['value'] = $value;
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 if (isset($options['types'])) {
                     return Dropdown::showItemTypes($name, $options['types'], $options);
                 }
                 return false;
             case "language":
                 $copytooption = array('emptylabel', 'display_emptychoice');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Dropdown::showLanguages($name, $options);
         }
         // Get specific display if available
         $itemtype = getItemTypeForTable($searchoptions['table']);
         if ($item = getItemForItemtype($itemtype)) {
             $specific = $item->getSpecificValueToSelect($searchoptions['field'], $name, $values, $options);
             if (strlen($specific)) {
                 return $specific;
             }
         }
     }
     // default case field text
     $this->fields[$name] = $value;
     return Html::autocompletionTextField($this, $name, $options);
 }
コード例 #12
0
function plugin_fusioninventory_MassiveActionsFieldsDisplay($options = array())
{
    $table = $options['options']['table'];
    $field = $options['options']['field'];
    $linkfield = $options['options']['linkfield'];
    switch ($table . "." . $field) {
        case "glpi_plugin_fusioninventory_unmanageds.item_type":
            $type_list = array();
            $type_list[] = 'Computer';
            $type_list[] = 'NetworkEquipment';
            $type_list[] = 'Printer';
            $type_list[] = 'Peripheral';
            $type_list[] = 'Phone';
            Dropdown::showItemTypes($linkfield, $type_list, array('value' => 0));
            return TRUE;
            break;
        case 'glpi_plugin_fusioninventory_configsecurities.name':
            Dropdown::show("PluginFusioninventoryConfigSecurity", array('name' => $linkfield));
            return TRUE;
            break;
        case 'glpi_plugin_fusioninventory_agents.id':
            Dropdown::show("PluginFusinvsnmpAgent", array('name' => $linkfield, 'comment' => FALSE));
            return TRUE;
            break;
        case 'glpi_plugin_fusioninventory_agents.threads_networkdiscovery':
            Dropdown::showNumber("threads_networkdiscovery", array('value' => $linkfield, 'min' => 1, 'max' => 400));
            return TRUE;
            break;
        case 'glpi_plugin_fusioninventory_agents.threads_networkinventory':
            Dropdown::showNumber("threads_networkinventory", array('value' => $linkfield, 'min' => 1, 'max' => 400));
            return TRUE;
            break;
        case 'glpi_entities.name':
            if (Session::isMultiEntitiesMode()) {
                Dropdown::show("Entities", array('name' => "entities_id", 'value' => $_SESSION["glpiactive_entity"]));
            }
            return TRUE;
            break;
    }
    return FALSE;
}
コード例 #13
0
 /**
  * @see CommonDBTM::showSpecificMassiveActionsParameters()
  **/
 function showSpecificMassiveActionsParameters($input = array())
 {
     switch ($input['action']) {
         case "transform_to":
             Dropdown::showItemTypes('transform_to', NetworkPort::getNetworkPortInstantiations(), array('value' => 'NetworkPortEthernet'));
             echo "<br><br><input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Save') . "'>";
             return true;
         default:
             return parent::showSpecificMassiveActionsParameters($input);
     }
     return false;
 }
コード例 #14
0
 /**
  * Display specific options add action button for massive actions
  *
  * Parameters must not be : itemtype, action, is_deleted, check_itemtype or check_items_id
  * @param $input array of input datas
  * @since version 0.84
  * 
  * @return boolean if parameters displayed ?
  **/
 public function showSpecificMassiveActionsParameters($input = array())
 {
     switch ($input['action']) {
         case "InstallTEST":
             Dropdown::showItemTypes("item_item", self::getTypes(true));
             echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"" . __('Post') . "\" >";
             return true;
             break;
         case "Desinstall":
             Dropdown::showItemTypes("item_item", self::getTypes(true));
             echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"" . __('Post') . "\" >";
             return true;
             break;
         default:
             return parent::showSpecificMassiveActionsParameters($input);
             break;
     }
     return false;
 }
コード例 #15
0
 /**
  * Make a select box for  connected port
  *
  * @param $ID                 ID of the current port to connect
  * @param $options   array    of possible options:
  *    - name : string / name of the select (default is networkports_id)
  *    - comments : boolean / is the comments displayed near the dropdown (default true)
  *    - entity : integer or array / restrict to a defined entity or array of entities
  *                   (default -1 : no restriction)
  *    - entity_sons : boolean / if entity restrict specified auto select its sons
  *                   only available if entity is a single value not an array (default false)
  *
  * @return nothing (print out an HTML select box)
  **/
 static function dropdownConnect($ID, $options = array())
 {
     global $CFG_GLPI;
     $p['name'] = 'networkports_id';
     $p['comments'] = 1;
     $p['entity'] = -1;
     $p['entity_sons'] = false;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $p[$key] = $val;
         }
     }
     // Manage entity_sons
     if (!($p['entity'] < 0) && $p['entity_sons']) {
         if (is_array($p['entity'])) {
             echo "entity_sons options is not available with entity option as array";
         } else {
             $p['entity'] = getSonsOf('glpi_entities', $p['entity']);
         }
     }
     echo "<input type='hidden' name='NetworkPortConnect_networkports_id_1'value='{$ID}'>";
     $rand = Dropdown::showItemTypes('NetworkPortConnect_itemtype', $CFG_GLPI["networkport_types"]);
     $params = array('itemtype' => '__VALUE__', 'entity_restrict' => $p['entity'], 'networkports_id' => $ID, 'comments' => $p['comments'], 'myname' => $p['name'], 'instantiation_type' => get_called_class());
     Ajax::updateItemOnSelectEvent("dropdown_NetworkPortConnect_itemtype{$rand}", "show_" . $p['name'] . "{$rand}", $CFG_GLPI["root_doc"] . "/ajax/dropdownConnectNetworkPortDeviceType.php", $params);
     echo "<span id='show_" . $p['name'] . "{$rand}'>&nbsp;</span>\n";
     return $rand;
 }
コード例 #16
0
 /**
  * Make a select box for Tracking All Devices
  *
  * @param $myname             select name
  * @param $itemtype           preselected value.for item type
  * @param $items_id           preselected value for item ID (default 0)
  * @param $admin              is an admin access ? (default 0)
  * @param $users_id           user ID used to display my devices (default 0
  * @param $entity_restrict    Restrict to a defined entity (default -1)
  * @param $tickets_id         Id of the ticket
  *
  * @return nothing (print out an HTML select box)
  **/
 static function dropdownAllDevices($myname, $itemtype, $items_id = 0, $admin = 0, $users_id = 0, $entity_restrict = -1, $tickets_id = 0)
 {
     global $CFG_GLPI, $DB;
     $rand = mt_rand();
     if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] == 0) {
         echo "<input type='hidden' name='{$myname}' value=''>";
         echo "<input type='hidden' name='items_id' value='0'>";
     } else {
         $rand = mt_rand();
         echo "<span id='tracking_all_devices{$rand}'>";
         if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] & pow(2, Ticket::HELPDESK_ALL_HARDWARE)) {
             if ($users_id && $_SESSION["glpiactiveprofile"]["helpdesk_hardware"] & pow(2, Ticket::HELPDESK_MY_HARDWARE)) {
                 echo __('Or complete search') . "&nbsp;";
             }
             $types = Ticket::getAllTypesForHelpdesk();
             $emptylabel = Dropdown::EMPTY_VALUE;
             $rand = Dropdown::showItemTypes($myname, array_keys($types), array('emptylabel' => $emptylabel, 'value' => $itemtype, 'width' => 200));
             $found_type = isset($types[$itemtype]);
             $width = 250;
             $params = array('itemtype' => '__VALUE__', 'entity_restrict' => $entity_restrict, 'admin' => $admin, 'width' => $width, 'myname' => "items_id");
             Ajax::updateItemOnSelectEvent("dropdown_{$myname}{$rand}", "results_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/shellcommands/ajax/dropdownTrackingDeviceType.php", $params);
             echo "<span id='results_{$myname}{$rand}'>\n";
             // Display default value if itemtype is displayed
             if ($found_type && $itemtype) {
                 if (($item = getItemForItemtype($itemtype)) && $items_id) {
                     if ($item->getFromDB($items_id)) {
                         Dropdown::showFromArray('items_id', array($items_id => $item->getName()), array('value' => $items_id, 'width' => $width));
                     }
                 } else {
                     $params['itemtype'] = $itemtype;
                     echo "<script type='text/javascript' >\n";
                     Ajax::updateItemJsCode("results_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/shellcommands/ajax/dropdownTrackingDeviceType.php", $params);
                     echo '</script>';
                 }
             }
             echo "</span>\n";
         }
         echo "</span>";
     }
     return $rand;
 }
コード例 #17
0
 /**
  * Show visibility config for a knowbaseitem
  *
  * @since version 0.83
  **/
 function showVisibility()
 {
     global $DB, $CFG_GLPI;
     $ID = $this->fields['id'];
     $canedit = $this->can($ID, UPDATE);
     echo "<div class='center'>";
     $rand = mt_rand();
     $nb = count($this->users) + count($this->groups) + count($this->profiles) + count($this->entities);
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='knowbaseitemvisibility_form{$rand}' id='knowbaseitemvisibility_form{$rand}' ";
         echo " method='post' action='" . Toolbox::getItemTypeFormURL('KnowbaseItem') . "'>";
         echo "<input type='hidden' name='knowbaseitems_id' value='{$ID}'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Add a target') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td width='100px'>";
         $types = array('Entity', 'Group', 'Profile', 'User');
         $addrand = Dropdown::showItemTypes('_type', $types);
         $params = array('type' => '__VALUE__', 'right' => $this->getField('is_faq') ? 'faq' : 'knowbase');
         Ajax::updateItemOnSelectEvent("dropdown__type" . $addrand, "visibility{$rand}", $CFG_GLPI["root_doc"] . "/ajax/visibility.php", $params);
         echo "</td>";
         echo "<td><span id='visibility{$rand}'></span>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $nb) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('delete' => _x('button', 'Delete permanently')));
         if ($this->fields['users_id'] != Session::getLoginUserID()) {
             $massiveactionparams['confirm'] = __('Caution! You are not the author of this element. Delete targets can result in loss of access to that element.');
         }
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $nb) {
         $header_begin .= "<th width='10'>";
         $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_end .= "</th>";
     }
     $header_end .= "<th>" . __('Type') . "</th>";
     $header_end .= "<th>" . _n('Recipient', 'Recipients', Session::getPluralNumber()) . "</th>";
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     // Users
     if (count($this->users)) {
         foreach ($this->users as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td>";
                     Html::showMassiveActionCheckBox('KnowbaseItem_User', $data["id"]);
                     echo "</td>";
                 }
                 echo "<td>" . __('User') . "</td>";
                 echo "<td>" . getUserName($data['users_id']) . "</td>";
                 echo "</tr>";
             }
         }
     }
     // Groups
     if (count($this->groups)) {
         foreach ($this->groups as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td>";
                     Html::showMassiveActionCheckBox('Group_KnowbaseItem', $data["id"]);
                     echo "</td>";
                 }
                 echo "<td>" . __('Group') . "</td>";
                 echo "<td>";
                 $names = Dropdown::getDropdownName('glpi_groups', $data['groups_id'], 1);
                 $groupname = sprintf(__('%1$s %2$s'), $names["name"], Html::showToolTip($names["comment"], array('display' => false)));
                 if ($data['entities_id'] >= 0) {
                     $groupname = sprintf(__('%1$s / %2$s'), $groupname, Dropdown::getDropdownName('glpi_entities', $data['entities_id']));
                     if ($data['is_recursive']) {
                         $groupname = sprintf(__('%1$s %2$s'), $groupname, "<span class='b'>(" . __('R') . ")</span>");
                     }
                 }
                 echo $groupname;
                 echo "</td>";
                 echo "</tr>";
             }
         }
     }
     // Entity
     if (count($this->entities)) {
         foreach ($this->entities as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td>";
                     Html::showMassiveActionCheckBox('Entity_KnowbaseItem', $data["id"]);
                     echo "</td>";
                 }
                 echo "<td>" . __('Entity') . "</td>";
                 echo "<td>";
                 $names = Dropdown::getDropdownName('glpi_entities', $data['entities_id'], 1);
                 $entityname = sprintf(__('%1$s %2$s'), $names["name"], Html::showToolTip($names["comment"], array('display' => false)));
                 if ($data['is_recursive']) {
                     $entityname = sprintf(__('%1$s %2$s'), $entityname, "<span class='b'>(" . __('R') . ")</span>");
                 }
                 echo $entityname;
                 echo "</td>";
                 echo "</tr>";
             }
         }
     }
     // Profiles
     if (count($this->profiles)) {
         foreach ($this->profiles as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td>";
                     Html::showMassiveActionCheckBox('KnowbaseItem_Profile', $data["id"]);
                     echo "</td>";
                 }
                 echo "<td>" . _n('Profile', 'Profiles', 1) . "</td>";
                 echo "<td>";
                 $names = Dropdown::getDropdownName('glpi_profiles', $data['profiles_id'], 1);
                 $profilename = sprintf(__('%1$s %2$s'), $names["name"], Html::showToolTip($names["comment"], array('display' => false)));
                 if ($data['entities_id'] >= 0) {
                     $profilename = sprintf(__('%1$s / %2$s'), $profilename, Dropdown::getDropdownName('glpi_entities', $data['entities_id']));
                     if ($data['is_recursive']) {
                         $profilename = sprintf(__('%1$s %2$s'), $profilename, "<span class='b'>(" . __('R') . ")</span>");
                     }
                 }
                 echo $profilename;
                 echo "</td>";
                 echo "</tr>";
             }
         }
     }
     if ($nb) {
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $nb) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
     // Add items
     return true;
 }
コード例 #18
0
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td rowspan='6' class='middle right'>" . __('Comments') . "</td>";
     echo "<td class='center middle' rowspan='6'><textarea cols='45' rows='9' class='form-control' name='comment' >" . $this->fields["comment"] . "</textarea></td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Active') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('is_active', $this->fields['is_active']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Type') . "</td>";
     echo "<td>";
     if (!Session::haveRight(static::$rightname, UPDATE)) {
         $itemtype = $this->fields['itemtype'];
         echo $itemtype::getTypeName(1);
         $rand = '';
     } else {
         if (Config::canUpdate() && $this->getEntityID() == 0) {
             $rand = Dropdown::showItemTypes('itemtype', $CFG_GLPI["notificationtemplates_types"], array('value' => $this->fields['itemtype']));
         } else {
             $rand = Dropdown::showItemTypes('itemtype', array_diff($CFG_GLPI["notificationtemplates_types"], array('Crontask', 'DBConnection', 'User')), array('value' => $this->fields['itemtype']));
         }
     }
     $params = array('itemtype' => '__VALUE__');
     Ajax::updateItemOnSelectEvent("dropdown_itemtype{$rand}", "show_events", $CFG_GLPI["root_doc"] . "/ajax/dropdownNotificationEvent.php", $params);
     Ajax::updateItemOnSelectEvent("dropdown_itemtype{$rand}", "show_templates", $CFG_GLPI["root_doc"] . "/ajax/dropdownNotificationTemplate.php", $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __('Notification method') . "</td>";
     echo "<td>";
     self::dropdownMode(array('value' => $this->fields['mode']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . NotificationEvent::getTypeName(1) . "</td>";
     echo "<td><span id='show_events'>";
     NotificationEvent::dropdownEvents($this->fields['itemtype'], array('value' => $this->fields['event']));
     echo "</span></td></tr>";
     echo "<tr class='tab_bg_1'><td>" . NotificationTemplate::getTypeName(1) . "</td>";
     echo "<td><span id='show_templates'>";
     NotificationTemplate::dropdownTemplates('notificationtemplates_id', $this->fields['itemtype'], $this->fields['notificationtemplates_id']);
     echo "</span></td></tr>";
     $this->showFormButtons($options);
     return true;
 }
コード例 #19
0
ファイル: planning.class.php プロジェクト: geldarr/hack-space
 /**
  * Show the planning selection form
  *
  * @param $type            planning type : can be day, week, month
  * @param $date            working date
  * @param $usertype        type of planning to view : can be user or group
  * @param $value           ID of the item
  * @param $limititemtype   itemtype only display this itemtype (default '')
  *
  * @return Display form
  **/
 static function showSelectionForm($type, $date, $usertype, $value, $limititemtype = '')
 {
     global $CFG_GLPI;
     switch ($type) {
         case "month":
             $split = explode("-", $date);
             $year_next = $split[0];
             $month_next = $split[1] + 1;
             if ($month_next > 12) {
                 $year_next++;
                 $month_next -= 12;
             }
             $year_prev = $split[0];
             $month_prev = $split[1] - 1;
             if ($month_prev == 0) {
                 $year_prev--;
                 $month_prev += 12;
             }
             $next = $year_next . "-" . sprintf("%02u", $month_next) . "-" . $split[2];
             $prev = $year_prev . "-" . sprintf("%02u", $month_prev) . "-" . $split[2];
             break;
         default:
             $time = strtotime($date);
             $step = 0;
             switch ($type) {
                 case "week":
                     $step = WEEK_TIMESTAMP;
                     break;
                 case "day":
                     $step = DAY_TIMESTAMP;
                     break;
             }
             $next = $time + $step + 10;
             $prev = $time - $step;
             $next = strftime("%Y-%m-%d", $next);
             $prev = strftime("%Y-%m-%d", $prev);
             break;
     }
     $uID = 0;
     $gID = 0;
     switch ($usertype) {
         case 'my':
             $uID = $_SESSION['glpiID'];
             break;
         case 'mygroups':
             if (!Session::haveRight("show_group_planning", "1")) {
                 exit;
             }
             $gID = 'mine';
             break;
         case 'users':
             if (!Session::haveRight("show_all_planning", "1")) {
                 exit;
             }
             $uID = $value;
             break;
         case 'groups':
             if (!Session::haveRight("show_all_planning", "1")) {
                 exit;
             }
             $gID = $value;
             break;
     }
     echo "<div class='center'><form method='get' name='form' action='planning.php'>\n";
     echo "<table class='tab_cadre_fixe'><tr class='tab_bg_1'>";
     echo "<td>";
     echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/planning.php?type=" . $type . "&amp;uID=" . $uID . "&amp;date={$prev}&amp;usertype={$usertype}&amp;gID={$gID}&amp;limititemtype={$limititemtype}\">";
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/left.png' alt=\"" . __s('Previous') . "\"\n             title=\"" . __s('Previous') . "\"></a>";
     echo "</td>";
     switch ($usertype) {
         case 'users':
             echo "<td>";
             $rand_user = User::dropdown(array('name' => 'uID', 'value' => $value, 'right' => 'interface', 'all' => 1, 'entity' => $_SESSION["glpiactive_entity"]));
             echo "</td>";
             break;
         case 'groups':
             echo "<td>";
             $rand_group = Group::dropdown(array('value' => $value, 'name' => 'gID', 'entity' => $_SESSION["glpiactive_entity"], 'condition' => '`is_usergroup`'));
             echo "</td>";
             break;
     }
     echo "</td>";
     echo "<td>";
     Dropdown::showItemTypes('limititemtype', $CFG_GLPI['planning_types'], array('value' => $limititemtype));
     echo "</td>";
     echo "<td>";
     Html::showDateFormItem("date", $date, false);
     echo '</td><td>';
     echo "<select name='type'>";
     echo "<option value='day' " . ($type == "day" ? " selected " : "") . ">" . __('Day') . "</option>";
     echo "<option value='week' " . ($type == "week" ? " selected " : "") . ">" . __('Week') . "</option>";
     echo "<option value='month' " . ($type == "month" ? " selected " : "") . ">" . __('Month') . "</option>";
     echo "</select></td>\n";
     echo "<td rowspan='2' class='center'>";
     echo "<input type='submit' class='submit' name='submit' value=\"" . _sx('button', 'Show') . "\">";
     echo "</td>\n";
     if ($uID || $gID) {
         echo "<td>";
         echo "<a target='_blank'\n                href=\"" . $CFG_GLPI["root_doc"] . "/front/planning.php?genical=1&amp;uID=" . $uID . "&amp;gID=" . $gID . "&amp;usertype=" . $usertype . "&amp;limititemtype={$limititemtype}" . "&amp;entities_id=" . $_SESSION["glpiactive_entity"] . "&amp;is_recursive=" . $_SESSION["glpiactive_entity_recursive"] . "&amp;token=" . User::getPersonalToken(Session::getLoginUserID(true)) . "\"\n                 title=\"" . __s('Download the planning in Ical format') . "\">" . "<span style='font-size:10px'>" . __('Ical') . "</span></a>";
         echo "<br>";
         $url = parse_url($CFG_GLPI["url_base"]);
         $port = 80;
         if (isset($url['port'])) {
             $port = $url['port'];
         } else {
             if (isset($url['scheme']) && $url["scheme"] == 'https') {
                 $port = 443;
             }
         }
         echo "<a target='_blank' href=\"webcal://" . $url['host'] . ':' . $port . (isset($url['path']) ? $url['path'] : '') . "/front/planning.php?genical=1&amp;uID=" . $uID . "&amp;gID=" . $gID . "&amp;usertype=" . $usertype . "&amp;limititemtype={$limititemtype}" . "&amp;entities_id=" . $_SESSION["glpiactive_entity"] . "&amp;is_recursive=" . $_SESSION["glpiactive_entity_recursive"] . "&amp;token=" . User::getPersonalToken(Session::getLoginUserID(true)) . "\" title=\"" . __s('webcal:// synchronization') . "\">";
         echo "<span style='font-size:10px'>" . __('Webcal') . "</span></a>";
         echo "</td>\n";
     }
     echo "<td>";
     echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/planning.php?type=" . $type . "&amp;uID=" . $uID . "&amp;date={$next}&amp;usertype={$usertype}&amp;gID={$gID}&amp;limititemtype={$limititemtype}\">";
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/right.png' alt=\"" . __s('Next') . "\"\n             title=\"" . __s('Next') . "\"></a>";
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>\n";
 }
コード例 #20
0
ファイル: item_ticket.class.php プロジェクト: korial29/glpi
 /**
  * Make a select box for Tracking All Devices
  *
  * @param $myname             select name
  * @param $itemtype           preselected value.for item type
  * @param $items_id           preselected value for item ID (default 0)
  * @param $admin              is an admin access ? (default 0)
  * @param $users_id           user ID used to display my devices (default 0
  * @param $entity_restrict    Restrict to a defined entity (default -1)
  * @param $options   array of possible options:
  *    - tickets_id : ID of the ticket
  *    - used       : ID of the requester user
  *    - multiple   : allow multiple choice
  *    - rand       : random number
  *
  * @return nothing (print out an HTML select box)
  **/
 static function dropdownAllDevices($myname, $itemtype, $items_id = 0, $admin = 0, $users_id = 0, $entity_restrict = -1, $options = array())
 {
     global $CFG_GLPI, $DB;
     $params = array('tickets_id' => 0, 'used' => array(), 'multiple' => 0, 'rand' => mt_rand());
     foreach ($options as $key => $val) {
         $params[$key] = $val;
     }
     $rand = $params['rand'];
     if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] == 0) {
         echo "<input type='hidden' name='{$myname}' value=''>";
         echo "<input type='hidden' name='items_id' value='0'>";
     } else {
         echo "<div id='tracking_all_devices{$rand}'>";
         if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] & pow(2, Ticket::HELPDESK_ALL_HARDWARE)) {
             // Display a message if view my hardware
             if ($users_id && $_SESSION["glpiactiveprofile"]["helpdesk_hardware"] & pow(2, Ticket::HELPDESK_MY_HARDWARE)) {
                 echo __('Or complete search') . "&nbsp;";
             }
             $types = Ticket::getAllTypesForHelpdesk();
             $emptylabel = __('General');
             if ($params['tickets_id'] > 0) {
                 $emptylabel = Dropdown::EMPTY_VALUE;
             }
             Dropdown::showItemTypes($myname, array_keys($types), array('emptylabel' => $emptylabel, 'value' => $itemtype, 'rand' => $rand, 'display_emptychoice' => true));
             $found_type = isset($types[$itemtype]);
             $p = array('itemtype' => '__VALUE__', 'entity_restrict' => $entity_restrict, 'admin' => $admin, 'used' => $params['used'], 'multiple' => $params['multiple'], 'rand' => $rand, 'myname' => "add_items_id");
             Ajax::updateItemOnSelectEvent("dropdown_{$myname}{$rand}", "results_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/dropdownTrackingDeviceType.php", $p);
             echo "<span id='results_{$myname}{$rand}'>\n";
             // Display default value if itemtype is displayed
             if ($found_type && $itemtype) {
                 if (($item = getItemForItemtype($itemtype)) && $items_id) {
                     if ($item->getFromDB($items_id)) {
                         Dropdown::showFromArray('items_id', array($items_id => $item->getName()), array('value' => $items_id));
                     }
                 } else {
                     $p['itemtype'] = $itemtype;
                     echo "<script type='text/javascript' >\n";
                     Ajax::updateItemJsCode("results_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/ajax/dropdownTrackingDeviceType.php", $p);
                     echo '</script>';
                 }
             }
             echo "</span>\n";
         }
         echo "</div>";
     }
     return $rand;
 }
コード例 #21
0
 /**
  * Print the HTML array for device on link
  *
  * @param $link : Link
  *
  * @return Nothing (display)
  **/
 static function showForLink($link)
 {
     global $DB, $CFG_GLPI;
     $links_id = $link->getField('id');
     $canedit = $link->can($links_id, 'w');
     $rand = mt_rand();
     if (!Session::haveRight("link", "r") || !$link->can($links_id, 'r')) {
         return false;
     }
     $query = "SELECT *\n                FROM `glpi_links_itemtypes`\n                WHERE `links_id` = '{$links_id}'\n                ORDER BY `itemtype`";
     $result = $DB->query($query);
     $types = array();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $types[$data['id']] = $data;
             $used[$data['itemtype']] = $data['itemtype'];
         }
     }
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='changeticket_form{$rand}' id='changeticket_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item type') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td class='right'>";
         echo "<input type='hidden' name='links_id' value='{$links_id}'>";
         Dropdown::showItemTypes('itemtype', $CFG_GLPI["link_types"], array('used' => $used));
         echo "</td><td class='center'>";
         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 && $numrows) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $numrows);
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     if ($canedit && $numrows) {
         echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
     }
     echo "<th>" . __('Type') . "</th>";
     echo "</tr>";
     foreach ($types as $data) {
         $typename = NOT_AVAILABLE;
         if ($item = getItemForItemtype($data['itemtype'])) {
             $typename = $item->getTypeName(1);
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
                 echo "</td>";
             }
             echo "<td class='center'>{$typename}</td>";
             echo "</tr>";
         }
     }
     echo "</table>";
     if ($canedit && $numrows) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
コード例 #22
0
 static function showMassiveActionsSubForm(MassiveAction $ma)
 {
     switch ($ma->getAction()) {
         case "install":
             Dropdown::showItemTypes("item_item", self::getTypes(true));
             echo Html::submit(_x('button', 'Post'), array('name' => 'massiveaction'));
             return true;
             break;
         case "uninstall":
             Dropdown::showItemTypes("item_item", self::getTypes(true));
             echo Html::submit(_x('button', 'Post'), array('name' => 'massiveaction'));
             return true;
             break;
         case 'generate':
             $PluginShellcommandsShellcommand = new PluginShellcommandsShellcommand();
             $itemtype = $ma->getItemtype(false);
             if (in_array($itemtype, PluginShellcommandsShellcommand::getTypes(true))) {
                 $PluginShellcommandsShellcommand->dropdownCommands($itemtype);
                 echo "<br><br>";
             }
             break;
     }
     return parent::showMassiveActionsSubForm($ma);
 }