コード例 #1
0
 /**
  * Show shellcommands associated to an item
  *
  * @since version 0.84
  *
  * @param $item            CommonDBTM object for which associated shellcommands must be displayed
  * @param $withtemplate    (default '')
  * */
 static function showForItem(CommonDBTM $item, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $ID = $item->getField('id');
     if ($item->isNewID($ID)) {
         return false;
     }
     if (!self::canView()) {
         return false;
     }
     if (!$item->can($item->fields['id'], READ)) {
         return false;
     }
     if (empty($withtemplate)) {
         $withtemplate = 0;
     }
     $width = 200;
     $command_group = new PluginShellcommandsCommandGroup();
     $restrict = getEntitiesRestrictRequest(" AND", "glpi_plugin_shellcommands_commandgroups", '', '', true);
     $data = $command_group->find("1" . $restrict);
     $shells = array(0 => Dropdown::EMPTY_VALUE);
     if (!empty($data)) {
         foreach ($data as $val) {
             $shells['[IP]-' . $val['id'] . '-0'] = $val['name'];
         }
     }
     echo "<div class='spaced'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th>" . PluginShellcommandsCommandGroup::getTypeName(1) . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>\n            <td class='center'>" . PluginShellcommandsCommandGroup::getTypeName(1) . " ";
     $randSelect = Dropdown::showFromArray("name", $shells, array('width' => $width));
     echo "<span id='command_name{$randSelect}'></span></td>";
     echo "</tr>";
     Ajax::updateItemOnSelectEvent("dropdown_name{$randSelect}", "command_name{$randSelect}", $CFG_GLPI["root_doc"] . "/plugins/shellcommands/ajax/dropdownCommandValue.php", array('idtable' => $item->getType(), 'value' => '__VALUE__', 'itemID' => $ID, 'countItem' => 1, 'width' => $width, 'command_type' => 'PluginShellcommandsCommandGroup', 'toupdate' => 'command_group_result', 'itemtype' => $item->getType(), 'myname' => "command_ip"));
     echo "</table>";
     echo "</div>";
     echo "<div class='spaced' id='command_group_result'></div>";
 }