Exemple #1
0
function plugin_uninstall_install()
{
    $plugin_infos = plugin_version_uninstall();
    $migration = new Migration($plugin_infos['version']);
    //Plugin classes are not loaded when plugin is not activated : force class loading
    require_once GLPI_ROOT . "/plugins/uninstall/inc/uninstall.class.php";
    require_once GLPI_ROOT . "/plugins/uninstall/inc/profile.class.php";
    require_once GLPI_ROOT . "/plugins/uninstall/inc/preference.class.php";
    require_once GLPI_ROOT . "/plugins/uninstall/inc/model.class.php";
    require_once GLPI_ROOT . "/plugins/uninstall/inc/replace.class.php";
    PluginUninstallProfile::install($migration);
    PluginUninstallModel::install($migration);
    PluginUninstallPreference::install($migration);
    return true;
}
 static function getMenuContent()
 {
     global $CFG_GLPI;
     $menu = array();
     // get Menu name :
     $tab = plugin_version_uninstall();
     $menu['title'] = $tab["name"];
     $menu['page'] = '/plugins/uninstall/front/model.php';
     if (Session::haveRight(PluginUninstallProfile::$rightname, READ)) {
         $menu['options']['model']['title'] = self::getTypeName(1);
         $menu['options']['model']['page'] = Toolbox::getItemTypeSearchUrl('PluginUninstallModel', false);
         $menu['options']['model']['links']['search'] = Toolbox::getItemTypeSearchUrl('PluginUninstallModel', false);
         if (Session::haveRight(PluginUninstallProfile::$rightname, UPDATE)) {
             $menu['options']['model']['links']['add'] = Toolbox::getItemTypeFormUrl('PluginUninstallModel', false);
         }
     }
     return $menu;
 }
 function showFormUserPreferences()
 {
     global $DB;
     $entity = $_SESSION['glpiactive_entity'];
     $userID = Session::getLoginUserID();
     $templates = PluginUninstallUninstall::getAllTemplatesByEntity($_SESSION["glpiactive_entity"], true);
     $data = plugin_version_uninstall();
     echo "<form action='" . $this->getFormURL() . "' method='post'>";
     echo "<div class='center'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>" . $data['name'] . "</th></tr>";
     if (!empty($templates)) {
         echo "<tr class='tab_bg_1 center'>";
         echo "<th>" . PluginUninstallModel::getTypeName() . "</th>";
         echo "<th>" . __("Item's location after uninstall", "uninstall") . "</th>";
         echo "</tr>";
         foreach ($templates as $ID => $name) {
             $pref_ID = self::checkIfPreferenceExistsByEntity($userID, $ID, $entity);
             if (!$pref_ID) {
                 $pref_ID = self::addDefaultPreference($userID, $ID, $entity);
             }
             $this->getFromDB($pref_ID);
             echo "<tr class='tab_bg_1'><td>" . $name . "</td>";
             echo "<td>";
             $value = isset($this->fields["locations_id"]) ? $this->fields["locations_id"] : 0;
             Location::dropdown(array('name' => "id[{$pref_ID}][locations_id]", 'value' => $value == '' ? 0 : $value, 'comments' => 1, 'entity' => $entity, 'toadd' => array(-1 => __('Keep previous location', 'uninstall'), 0 => __('Empty location', 'uninstall'))));
             echo "<input type='hidden' name='id[" . $pref_ID . "][id]' value='" . $pref_ID . "'>";
             echo "</td></tr>";
         }
         echo "<tr class='tab_bg_1'><td colspan='2' class='center'>";
         echo "<input type='submit' name='update_user_preferences_uninstall' value='" . _sx('button', 'Post') . "' class='submit'>";
         echo "</td></tr>";
     }
     echo "</table>";
     echo "</div>";
     Html::closeForm();
 }