Esempio n. 1
0
function plugin_uninstall_uninstall()
{
    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::uninstall();
    PluginUninstallModel::uninstall();
    PluginUninstallPreference::uninstall();
    return true;
}
Esempio n. 2
0
 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();
 }
Esempio n. 3
0
 /**
  * @param $name
  * @param $user
  * @param $entity
  **/
 static function dropdownUninstallModels($name, $user, $entity)
 {
     global $DB;
     $used = array();
     if (!PluginUninstallModel::canReplace()) {
         foreach ($DB->request('glpi_plugin_uninstall_models', "`types_id` = '2'") as $data) {
             $used[] = $data['id'];
         }
     }
     return PluginUninstallModel::dropdown(array('name' => $name, 'value' => 0, 'entity' => $entity, 'used' => $used));
 }
Esempio n. 4
0
 static function showForm($type, $model_id, $tab_ids, $location)
 {
     global $DB, $CFG_GLPI;
     // Retrieve model informations and show details
     // It's just for helping user!
     $model = new PluginUninstallModel();
     $model->getConfig($model_id);
     echo "<div class='first_bloc'>";
     echo "<table class='tab_cadre_fixe' cellpadding='5'>";
     echo "<tr class='tab_bg_1 center'>" . "<th colspan='6'>" . sprintf(__('%1$s - %2$s'), __('Reminder of the replacement model', 'uninstall'), __('General informations', 'uninstall')) . "</th></tr>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<td>" . sprintf(__('%1$s %2$s'), __('Copy'), __('Name')) . "</td>";
     echo "<td>" . self::coloredYN($model->fields["replace_name"]) . "</td>";
     echo "<td>" . sprintf(__('%1$s %2$s'), __('Copy'), __('Serial number')) . "</td>";
     echo "<td>" . self::coloredYN($model->fields["replace_serial"]) . "</td>";
     echo "<td>" . sprintf(__('%1$s %2$s'), __('Copy'), __('Inventory number')) . "</td>";
     echo "<td>" . self::coloredYN($model->fields["replace_otherserial"]) . "</td>";
     echo "</tr>";
     echo "<tr><td colspan='6'></td></tr>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<td colspan='2'>" . __('Overwrite informations (from old item to the new)', 'uninstall') . "</td>";
     echo "<td>" . self::coloredYN($model->fields["overwrite"]) . "</td>";
     echo "<td colspan='2'>" . __('Archiving method of the old material', 'uninstall') . "</td>";
     echo "<td>";
     $methods = PluginUninstallModel::getReplacementMethods();
     switch ($model->fields["replace_method"]) {
         case self::METHOD_PURGE:
             echo "<span class='red b'>" . $methods[self::METHOD_PURGE] . "</span>";
             break;
         case self::METHOD_DELETE_AND_COMMENT:
             echo "<span class='green b'>" . $methods[self::METHOD_DELETE_AND_COMMENT] . "</span>";
             break;
     }
     echo "</td></tr>";
     echo "<tr><td colspan='6'></td></tr>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<td></td><td>" . __('New location of item', 'uninstall') . "</td>";
     switch ($location) {
         case -1:
             echo "<td><span class='red b'>" . __('Keep previous location', 'uninstall') . "</span></td>";
             break;
         case 0:
             echo "<td><span class='red b'>" . __('Empty location', 'uninstall') . "</span></td>";
             break;
         default:
             echo "<td><span class='green b'>";
             echo Dropdown::getDropdownName('glpi_locations', $location);
             echo "</span></td>";
             break;
     }
     echo "<td>" . __('New status of the computer', 'uninstall') . "</td>";
     echo "<td>";
     if ($model->fields['states_id'] == 0) {
         echo "<span class='red b'>" . __('Status') . "</span>";
     } else {
         echo "<span class='green b'>";
         echo Dropdown::getDropdownName('glpi_states', $model->fields['states_id']);
         echo "</span>";
     }
     echo "</td>";
     echo "<td></td></tr>";
     echo "</table>";
     echo "</div>";
     // CONNEXIONS with other items
     echo "<div class='firstbloc'>";
     echo "<table class='tab_cadre_fixe' cellpadding='5'>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<th colspan='4'>" . sprintf(__('%1$s - %2$s'), __('Reminder of the replacement model', 'uninstall'), __('Connections with other materials', 'uninstall')) . "</th></tr>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<td>" . sprintf(__('%1$s %2$s'), __('Copy'), _n('Document', 'Documents', 2)) . "</td>";
     echo "<td>" . self::coloredYN($model->fields["replace_documents"]) . "</td>";
     echo "<td>" . sprintf(__('%1$s %2$s'), __('Copy'), _n('Contract', 'Contracts', 2)) . "</td>";
     echo "<td>" . self::coloredYN($model->fields["replace_contracts"]) . "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<td>" . sprintf(__('%1$s %2$s'), __('Copy'), __('Financial and administratives information')) . "</td>";
     echo "<td>" . self::coloredYN($model->fields["replace_infocoms"]) . "</td>";
     echo "<td>" . sprintf(__('%1$s %2$s'), __('Copy'), _n('Reservation', 'Reservations', 2)) . "</td>";
     echo "<td>" . self::coloredYN($model->fields["replace_reservations"]) . "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<td>" . sprintf(__('%1$s %2$s'), __('Copy'), __('User')) . "</td>";
     echo "<td>" . self::coloredYN($model->fields["replace_users"]) . "</td>";
     echo "<td>" . sprintf(__('%1$s %2$s'), __('Copy'), __('Group')) . "</td>";
     echo "<td>" . self::coloredYN($model->fields["replace_groups"]) . "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<td>" . sprintf(__('%1$s %2$s'), __('Copy'), _n('Ticket', 'Tickets', 2)) . "</td>";
     echo "<td>" . self::coloredYN($model->fields["replace_tickets"]) . "</td>";
     echo "<td>" . sprintf(__('%1$s %2$s'), __('Copy'), sprintf(__('%1$s %2$s'), _n('Connection', 'Connections', 2), _n('Network', 'Networks', 2))) . "</td>";
     echo "<td>" . self::coloredYN($model->fields["replace_netports"]) . "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<td>" . sprintf(__('%1$s %2$s'), __('Copy'), __('Direct connections', 'uninstall')) . "</td>";
     echo "<td>" . self::coloredYN($model->fields["replace_direct_connections"]) . "</td>";
     echo "<td colspan='2'></td>";
     echo "</tr></table></div>";
     // Show form for selecting new items
     echo "<form action='../front/action.php' method='post'>";
     echo "<table class='tab_cadre_fixe' cellpadding='5'>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<th colspan='4'>" . __('Choices for item to replace', 'uninstall') . "</th></tr>";
     echo "<tr class='tab_bg_1 center'>";
     echo "<th>" . __('Old item', 'uninstall') . "</th>";
     if (self::searchFieldInSearchOptions($type, 'otherserial')) {
         echo "<th>" . __('Inventory number') . "</th>";
     }
     if (self::searchFieldInSearchOptions($type, 'serial')) {
         echo "<th>" . __('Serial number') . "</th>";
     }
     echo "<th>" . __('New item', 'uninstall') . "</th>";
     echo "</tr>";
     $commonitem = new $type();
     foreach ($tab_ids[$type] as $id => $value) {
         $commonitem->getFromDB($id);
         echo "<tr class='tab_bg_1 center'>";
         echo "<td>" . $commonitem->getName() . "</td>";
         if (self::searchFieldInSearchOptions($type, 'otherserial')) {
             echo "<td>" . $commonitem->fields['otherserial'] . "</td>";
         }
         if (self::searchFieldInSearchOptions($type, 'serial')) {
             echo "<td>" . $commonitem->fields['serial'] . "</td>";
         }
         echo "<td>";
         $type::dropdown(array('name' => "newItems[{$id}]", 'displaywith' => array('serial', 'otherserial'), 'url' => $CFG_GLPI['root_doc'] . "/plugins/uninstall/ajax/dropdownReplaceFindDevice.php"));
         echo "</td></tr>";
     }
     echo "<tr class='tab_bg_1 center'>";
     echo "<td colspan='4' class='center'>";
     echo "<input type='hidden' name='device_type' value='" . $type . "' />";
     echo "<input type='hidden' name='model_id' value='" . $model_id . "' />";
     echo "<input type='hidden' name='locations_id' value='" . $location . "' />";
     echo "<input type='submit' name='replace' value=\"" . __('Replace', 'uninstall') . "\"\n             class='submit'>";
     echo "</td></tr>";
     echo "</table>";
     Html::closeForm();
 }
Esempio n. 5
0
    Html::back();
}
if (isset($_REQUEST["locations_id"])) {
    $location = $_REQUEST["locations_id"];
} else {
    $location = PluginUninstallPreference::getLocationByUserByEntity($_SESSION["glpiID"], $_REQUEST["model_id"], $_SESSION["glpiactive_entity"]);
}
if (isset($_REQUEST["replace"])) {
    PluginUninstallReplace::replace($_REQUEST["device_type"], $_REQUEST["model_id"], $_REQUEST['newItems'], $location);
    unset($_SESSION['glpi_uninstalllist']);
    Session::addMessageAfterRedirect(__('Replacement successful', 'uninstall'));
    Html::footer();
    $device_type = $_REQUEST["device_type"];
    Html::redirect($device_type::getSearchURL());
}
$model = new PluginUninstallModel();
$model->getConfig($_REQUEST["model_id"]);
//Case of a uninstallation initiated from the object form
if (isset($_REQUEST["uninstall"])) {
    //Uninstall only if a model is selected
    if ($model->fields['types_id'] == PluginUninstallModel::TYPE_MODEL_UNINSTALL) {
        //Massive uninstallation
        PluginUninstallUninstall::uninstall($_REQUEST["device_type"], $_REQUEST["model_id"], array($_REQUEST["device_type"] => array($_REQUEST["id"] => $_REQUEST["id"])), $location);
        Html::back();
    } else {
        PluginUninstallReplace::showForm($_REQUEST["device_type"], $_REQUEST["model_id"], array($_REQUEST["device_type"] => array($_REQUEST["id"] => $_REQUEST["id"])), $location);
        Html::footer();
    }
} else {
    if ($model->fields['types_id'] == PluginUninstallModel::TYPE_MODEL_UNINSTALL) {
        //Massive uninstallation
Esempio n. 6
0
 Uninstall plugin is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 Uninstall plugin is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with uninstall. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
 @package   uninstall
 @author    the uninstall plugin team
 @copyright Copyright (c) 2010-2013 Uninstall plugin team
 @license   GPLv2+
            http://www.gnu.org/licenses/gpl.txt
 @link      https://forge.indepnet.net/projects/uninstall
 @link      http://www.glpi-project.org/
 @since     2009
 ---------------------------------------------------------------------- */
include '../../../inc/includes.php';
Html::header(PluginUninstallModel::getTypeName(Session::getPluralNumber()), '', "admin", "PluginUninstallModel", "model");
if (Session::haveRight(PluginUninstallProfile::$rightname, READ)) {
    Search::show("PluginUninstallModel");
} else {
    Html::displayRightError();
}
Html::footer();
Esempio n. 7
0
 @link      http://www.glpi-project.org/
 @since     2009
 ---------------------------------------------------------------------- */
include '../../../inc/includes.php';
Session::checkRight(PluginUninstallProfile::$rightname, READ);
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
if (isset($_GET["id"])) {
    $id = $_GET["id"];
} elseif (isset($_POST["id"])) {
    $id = $_POST["id"];
} else {
    $id = -1;
}
$model = new PluginUninstallModel();
if (isset($_POST["add"])) {
    $model->check(-1, UPDATE, $_POST);
    $model->add($_POST);
    Html::back();
} else {
    if (isset($_POST["update"])) {
        $model->check($_POST['id'], UPDATE);
        $model->update($_POST);
        Html::back();
    } else {
        if (isset($_POST["delete"])) {
            $model->check($_POST['id'], DELETE);
            $model->delete($_POST);
            $model->redirectToList();
        } else {