Пример #1
0
function plugin_shellcommands_MassiveActions($type)
{
    if (in_array($type, PluginShellcommandsShellcommand::getTypes(true))) {
        return array('PluginShellcommandsShellcommand' . MassiveAction::CLASS_ACTION_SEPARATOR . "generate" => __('Command launch', 'shellcommands'), 'PluginShellcommandsCommandGroup' . MassiveAction::CLASS_ACTION_SEPARATOR . "generate" => __('Command group launch', 'shellcommands'));
    }
    return array();
}
 /**
  * Show items links to a shellcommands
  *
  * @since version 0.84
  *
  * @param $shellcommand PluginShellcommandsShellcommand object
  *
  * @return nothing (HTML display)
  * */
 public static function showForShellcommands(PluginShellcommandsShellcommand $shellcommand)
 {
     global $DB, $CFG_GLPI;
     $shell_id = $shellcommand->getField('id');
     $canedit = $shellcommand->can($shell_id, UPDATE);
     $rand = mt_rand();
     if (!Session::haveRight("link", READ) || !$shellcommand->can($shell_id, READ)) {
         return false;
     }
     $query = "SELECT *\n                FROM `glpi_plugin_shellcommands_shellcommands_items`\n                WHERE `plugin_shellcommands_shellcommands_id` = '{$shell_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('PluginShellcommandsShellcommand') . "'>";
         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='plugin_shellcommands_shellcommands_id' value='{$shell_id}'>";
         Dropdown::showItemTypes('itemtype', PluginShellcommandsShellcommand::getTypes(true));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='additem' 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('item' => __CLASS__, 'container' => 'mass' . __CLASS__ . $rand, 'num_displayed' => $numrows);
         Html::showMassiveActions($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($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
Пример #3
0
function plugin_shellcommands_MassiveActionsDisplay($options = array())
{
    $PluginShellcommandsShellcommand = new PluginShellcommandsShellcommand();
    if (in_array($options['itemtype'], PluginShellcommandsShellcommand::getTypes(true))) {
        $PluginShellcommandsShellcommand->dropdownCommands($options['itemtype']);
        echo "&nbsp;<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"" . _sx('button', 'Post') . "\" >";
    }
    return "";
}
 /**
  * Main entry of the modal window for massive actions
  *
  * @return nothing: display
  **/
 static function showMassiveActionsSubForm(MassiveAction $ma)
 {
     $PluginShellcommandsShellcommand = new PluginShellcommandsShellcommand();
     switch ($ma->getAction()) {
         case 'generate':
             $itemtype = $ma->getItemtype(false);
             if (in_array($itemtype, PluginShellcommandsShellcommand::getTypes(true))) {
                 echo PluginShellcommandsCommandGroup::getTypeName(1) . " ";
                 Dropdown::show('PluginShellcommandsCommandGroup', array('name' => 'commandgroup', 'entity' => $_SESSION['glpiactive_entity'], 'comments' => false));
                 echo "<br><br>";
             }
             break;
     }
     return false;
 }
 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);
 }