Пример #1
0
 /**
  * Display Sample
  *
  * @param $model     PluginDatainjectionModel object
  **/
 function showSample(PluginDatainjectionModel $model)
 {
     $headers = PluginDatainjectionMapping::getMappingsSortedByRank($model->fields['id']);
     $sample = '"' . implode('"' . $this->getDelimiter() . '"', $headers) . "\"\n";
     header('Content-disposition: attachment; filename="' . str_replace(' ', '_', $model->getName()) . '.csv"');
     header('Content-Type: text/comma-separated-values');
     header('Content-Transfer-Encoding: UTF-8');
     header('Content-Length: ' . mb_strlen($sample, 'UTF-8'));
     header('Pragma: no-cache');
     header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
     header('Expires: 0');
     echo $sample;
 }
Пример #2
0
 /**
  * @param $model  PluginDatainjectionModel object
  **/
 static function showFormMappings(PluginDatainjectionModel $model)
 {
     global $CFG_GLPI;
     $canedit = $model->can($model->fields['id'], UPDATE);
     if (isset($_SESSION['datainjection']['lines'])) {
         $lines = unserialize($_SESSION['datainjection']['lines']);
     } else {
         $lines = array();
     }
     echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     //Display link to the preview popup
     if (isset($_SESSION['datainjection']['lines']) && !empty($lines)) {
         $nblines = $_SESSION['datainjection']['nblines'];
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><td class='center'>";
         $url = $CFG_GLPI["root_doc"] . "/plugins/datainjection/front/popup.php?popup=preview&amp;models_id=" . $model->getID();
         echo "<a href=#  onClick=\"var w = window.open('{$url}' , 'glpipopup', " . "'height=400, width=600, top=100, left=100, scrollbars=yes' );w.focus();\"/>";
         echo __('See the file', 'datainjection') . "</a>";
         echo "</td></tr>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th>" . __('Header of the file', 'datainjection') . "</th>";
     echo "<th>" . __('Tables', 'datainjection') . "</th>";
     echo "<th>" . _n('Field', 'Fields', 2) . "</th>";
     echo "<th>" . __('Link field', 'datainjection') . "</th>";
     echo "</tr>";
     $model->loadMappings();
     foreach ($model->getMappings() as $mapping) {
         $mapping->fields = Toolbox::stripslashes_deep($mapping->fields);
         $mappings_id = $mapping->getID();
         echo "<tr class='tab_bg_1'>";
         echo "<td class='center'>" . $mapping->fields['name'] . "</td>";
         echo "<td class='center'>";
         $options = array('primary_type' => $model->fields['itemtype']);
         PluginDatainjectionInjectionType::dropdownLinkedTypes($mapping, $options);
         echo "</td>";
         echo "<td class='center'><span id='span_field_{$mappings_id}'>";
         echo "</span></td>";
         echo "<td class='center'><span id='span_mandatory_{$mappings_id}'></span></td>";
     }
     if ($canedit) {
         echo "<tr> <td class='tab_bg_2 center' colspan='4'>";
         echo "<input type='hidden' name='models_id' value='" . $model->fields['id'] . "'>";
         echo "<input type='submit' name='update' value='" . _sx('button', 'Save') . "' class='submit'>";
         echo "</td></tr>";
     }
     echo "</table>";
     Html::closeForm();
 }
Пример #3
0
 static function getMenuContent()
 {
     global $CFG_GLPI;
     $menu = array();
     $menu['title'] = self::getMenuName();
     $menu['page'] = '/plugins/datainjection/front/clientinjection.form.php';
     if (Session::haveRight(static::$rightname, READ)) {
         $image_model = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/rdv.png' title='";
         $image_model .= PluginDatainjectionModel::getTypeName();
         $image_model .= "' alt='" . PluginDatainjectionModel::getTypeName() . "'>";
         $image_import = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/actualiser.png' title='";
         $image_import .= __s('Injection of the file', 'datainjection');
         $image_import .= "' alt='" . __s('Injection of the file', 'datainjection') . "'>";
         $menu['options']['client']['title'] = self::getMenuName();
         $menu['options']['client']['page'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
         $menu['options']['client']['links']['search'] = '/plugins/datainjection/front/clientinjection.form.php';
         if (Session::haveRight('plugin_datainjection_model', READ)) {
             $menu['options']['model']['title'] = PluginDatainjectionModel::getTypeName();
             $menu['options']['model']['page'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
             $menu['options']['model']['links']['search'] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
             $menu['options']['client']['links'][$image_model] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
         }
         //$menu['options']['client']['links'][$image_model]  = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
         $menu['options']['model']['links'][$image_import] = '/plugins/datainjection/front/clientinjection.form.php';
         if (Session::haveRight('plugin_datainjection_model', UPDATE) || Session::haveRight('plugin_datainjection_model', CREATE)) {
             $menu['options']['model']['links']['add'] = Toolbox::getItemTypeFormUrl('PluginDatainjectionModel', false);
             $menu['options']['client']['links'][$image_model] = Toolbox::getItemTypeSearchUrl('PluginDatainjectionModel', false);
         }
     }
     return $menu;
 }
Пример #4
0
/*
 LICENSE

 This file is part of the datainjection plugin.

 Datainjection 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.

 Datainjection 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 datainjection. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
 @package   datainjection
 @author    the datainjection plugin team
 @copyright Copyright (c) 2010-2013 Datainjection plugin team
 @license   GPLv2+
            http://www.gnu.org/licenses/gpl.txt
 @link      https://forge.indepnet.net/projects/datainjection
 @link      http://www.glpi-project.org/
 @since     2009
 ---------------------------------------------------------------------- */
include '../../../inc/includes.php';
include "../../../lib/ezpdf/class.ezpdf.php";
PluginDatainjectionModel::exportAsPDF($_GET['models_id']);
Пример #5
0
function plugin_badges_uninstall()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/badges/inc/profile.class.php";
    include_once GLPI_ROOT . "/plugins/badges/inc/menu.class.php";
    $tables = array("glpi_plugin_badges_badges", "glpi_plugin_badges_badgetypes", "glpi_plugin_badges_configs", "glpi_plugin_badges_notificationstates", "glpi_plugin_badges_requests");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    //old versions
    $tables = array("glpi_plugin_badges", "glpi_dropdown_plugin_badges_type", "glpi_plugin_badges_users", "glpi_plugin_badges_profiles", "glpi_plugin_badges_config", "glpi_plugin_badges_mailing", "glpi_plugin_badges_default");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $notif = new Notification();
    $options = array('itemtype' => 'PluginBadgesBadge', 'event' => 'ExpiredBadges', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginBadgesBadge', 'event' => 'BadgesWhichExpire', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginBadgesBadge', 'event' => 'BadgesReturn', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginBadgesBadge', 'event' => 'AccessBadgeRequest', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    //templates
    $template = new NotificationTemplate();
    $translation = new NotificationTemplateTranslation();
    $options = array('itemtype' => 'PluginBadgesBadge', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notificationtemplates', $options) as $data) {
        $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id');
        foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) {
            $translation->delete($data_template);
        }
        $template->delete($data);
    }
    $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_items_tickets", "glpi_notepads", "glpi_dropdowntranslations");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` LIKE 'PluginBadges%';");
    }
    if (class_exists('PluginDatainjectionModel')) {
        PluginDatainjectionModel::clean(array('itemtype' => 'PluginBadgesBadge'));
    }
    CronTask::Unregister('PluginBadgesReturn');
    //Delete rights associated with the plugin
    $profileRight = new ProfileRight();
    foreach (PluginBadgesProfile::getAllRights() as $right) {
        $profileRight->deleteByCriteria(array('name' => $right['field']));
    }
    PluginBadgesMenu::removeRightsFromSession();
    PluginBadgesProfile::removeRightsFromSession();
    return true;
}
Пример #6
0
function plugin_domains_uninstall()
{
    global $DB;
    $tables = array("glpi_plugin_domains_domains", "glpi_plugin_domains_domains_items", "glpi_plugin_domains_domaintypes", "glpi_plugin_domains_profiles", "glpi_plugin_domains_configs", "glpi_plugin_domains_notificationstates");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    //old versions
    $tables = array("glpi_plugin_domain", "glpi_plugin_domain_device", "glpi_dropdown_plugin_domain_type", "glpi_plugin_domain_profiles", "glpi_plugin_domain_mailing");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $notif = new Notification();
    $options = array('itemtype' => 'PluginDomainsDomain', 'event' => 'ExpiredDomains', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginDomainsDomain', 'event' => 'DomainsWhichExpire', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    //templates
    $template = new NotificationTemplate();
    $translation = new NotificationTemplateTranslation();
    $options = array('itemtype' => 'PluginDomainsDomain', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notificationtemplates', $options) as $data) {
        $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id');
        foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) {
            $translation->delete($data_template);
        }
        $template->delete($data);
    }
    $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets", "glpi_contracts_items");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` = 'PluginDomainsDomain';");
    }
    if (class_exists('PluginDatainjectionModel')) {
        PluginDatainjectionModel::clean(array('itemtype' => 'PluginDomainsDomain'));
    }
    return true;
}
Пример #7
0
function plugin_accounts_uninstall()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/accounts/inc/profile.class.php";
    include_once GLPI_ROOT . "/plugins/accounts/inc/menu.class.php";
    $tables = array("glpi_plugin_accounts_accounts", "glpi_plugin_accounts_accounts_items", "glpi_plugin_accounts_accounttypes", "glpi_plugin_accounts_accountstates", "glpi_plugin_accounts_configs", "glpi_plugin_accounts_hashs", "glpi_plugin_accounts_hashes", "glpi_plugin_accounts_aeskeys", "glpi_plugin_accounts_notificationstates");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    //old versions
    $tables = array("glpi_plugin_comptes", "glpi_plugin_compte_device", "glpi_dropdown_plugin_compte_type", "glpi_dropdown_plugin_compte_status", "glpi_plugin_compte_profiles", "glpi_plugin_compte_config", "glpi_plugin_compte_default", "glpi_plugin_compte_mailing", "glpi_plugin_compte", "glpi_plugin_compte_hash", "glpi_plugin_compte_aeskey", "glpi_plugin_accounts_profiles");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $notif = new Notification();
    $options = array('itemtype' => 'PluginAccountsAccount', 'event' => 'new', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginAccountsAccount', 'event' => 'ExpiredAccounts', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginAccountsAccount', 'event' => 'AccountsWhichExpire', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    //templates
    $template = new NotificationTemplate();
    $translation = new NotificationTemplateTranslation();
    $options = array('itemtype' => 'PluginAccountsAccount', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notificationtemplates', $options) as $data) {
        $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id');
        foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) {
            $translation->delete($data_template);
        }
        $template->delete($data);
    }
    $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_items_tickets", "glpi_dropdowntranslations");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE FROM `{$table_glpi}`\n               WHERE `itemtype` = 'PluginAccountsAccount'\n               OR `itemtype` = 'PluginAccountsHelpdesk'\n               OR `itemtype` = 'PluginAccountsGroup'\n               OR `itemtype` = 'PluginAccountsAccountState'\n               OR `itemtype` = 'PluginAccountsAccountType' ;");
    }
    if (class_exists('PluginDatainjectionModel')) {
        PluginDatainjectionModel::clean(array('itemtype' => 'PluginAccountsAccount'));
    }
    //Delete rights associated with the plugin
    $profileRight = new ProfileRight();
    foreach (PluginAccountsProfile::getAllRights() as $right) {
        $profileRight->deleteByCriteria(array('name' => $right['field']));
    }
    PluginAccountsProfile::removeRightsFromSession();
    PluginAccountsMenu::removeRightsFromSession();
    return true;
}
Пример #8
0
function plugin_webapplications_uninstall()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/webapplications/inc/profile.class.php";
    include_once GLPI_ROOT . "/plugins/webapplications/inc/menu.class.php";
    $tables = array("glpi_plugin_webapplications_webapplications", "glpi_plugin_webapplications_webapplicationtypes", "glpi_plugin_webapplications_webapplicationservertypes", "glpi_plugin_webapplications_webapplicationtechnics", "glpi_plugin_webapplications_webapplications_items");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    //old versions
    $tables = array("glpi_plugin_appweb", "glpi_dropdown_plugin_appweb_type", "glpi_dropdown_plugin_appweb_server_type", "glpi_dropdown_plugin_appweb_technic", "glpi_plugin_appweb_device", "glpi_plugin_appweb_profiles", "glpi_plugin_webapplications_profiles");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_notepads");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE\n                  FROM `{$table_glpi}`\n                  WHERE `itemtype` = 'PluginWebapplicationsWebapplication'");
    }
    if (class_exists('PluginDatainjectionModel')) {
        PluginDatainjectionModel::clean(array('itemtype' => 'PluginWebapplicationsWebapplication'));
    }
    //Delete rights associated with the plugin
    $profileRight = new ProfileRight();
    foreach (PluginWebapplicationsProfile::getAllRights() as $right) {
        $profileRight->deleteByCriteria(array('name' => $right['field']));
    }
    PluginWebapplicationsMenu::removeRightsFromSession();
    PluginWebapplicationsProfile::removeRightsFromSession();
    return true;
}
Пример #9
0
 static function methodInject($params, $protocol)
 {
     if (isset($params['help'])) {
         return array('uri' => 'string,mandatory', 'base64' => 'string,optional', 'additional' => 'array,optional', 'models_id' => 'integer, mandatory', 'entities_id' => 'integer,mandatory', 'mandatory' => 'array,optional', 'uri' => 'uri,mandatory', 'help' => 'bool,optional');
     }
     $model = new PluginDatainjectionModel();
     //-----------------------------------------------------------------
     //-------------------------- Check parameters ---------------------
     //-----------------------------------------------------------------
     if (!isset($_SESSION['glpiID'])) {
         return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED);
     }
     if (!isset($params['uri']) && !isset($params['base64'])) {
         return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'uri or base64');
     }
     if (!isset($params['models_id'])) {
         return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, 'models_id');
     }
     if (!$model->getFromDB($params['models_id'])) {
         return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_NOTFOUND, __('Model unknown', 'datainjection'));
     }
     if (!$model->can($params['models_id'], 'r')) {
         return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED, __('You cannot access this model', 'datainjection'));
     }
     if ($model->fields['step'] < PluginDatainjectionModel::READY_TO_USE_STEP) {
         return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED, __('You cannot access this model', 'datainjection'));
     }
     //Check entity
     if (!isset($params['entities_id'])) {
         return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, 'entities_id');
     }
     $entities_id = $params['entities_id'];
     if ($entities_id > 0) {
         $entity = new Entity();
         if (!$entity->getFromDB($entities_id)) {
             return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_NOTFOUND, __('Entity unknown', 'datainjection'));
         }
         if (!Session::haveAccessToEntity($entities_id)) {
             return PluginWebservicesMethodCommon::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED, __('You cannot access this entity', 'datainjection'));
         }
     }
     //Mandatory fields
     $additional_infos = array();
     if (isset($params['additional']) && is_array($params['additional'])) {
         $additional_infos = $params['additional'];
     }
     //Upload CSV file
     $document_name = basename($params['uri']);
     $filename = tempnam(PLUGIN_DATAINJECTION_UPLOAD_DIR, 'PWS');
     $response = PluginWebservicesMethodCommon::uploadDocument($params, $protocol, $filename, $document_name);
     if (PluginWebservicesMethodCommon::isError($protocol, $response)) {
         return $response;
     }
     //Uploade successful : now perform import !
     $options = array('file_encoding' => PluginDatainjectionBackend::ENCODING_AUTO, 'webservice' => true, 'original_filename' => $params['uri'], 'unique_filename' => $filename, 'mode' => PluginDatainjectionModel::PROCESS, 'delete_file' => false, 'protocol' => $protocol);
     //The Webservice protocol used
     $results = array();
     $response = $model->processUploadedFile($options);
     if (!PluginWebservicesMethodCommon::isError($protocol, $response)) {
         $engine = new PluginDatainjectionEngine($model, $additional_infos, $params['entities_id']);
         //Remove first line if header is present
         $first = true;
         foreach ($model->injectionData->getDatas() as $id => $data) {
             if ($first && $model->getSpecificModel()->isHeaderPresent()) {
                 $first = false;
             } else {
                 $results[] = $engine->injectLine($data[0], $id);
             }
         }
         $model->cleanData();
         return $results;
     }
     return $response;
 }
Пример #10
0
function plugin_databases_uninstall()
{
    global $DB;
    $tables = array("glpi_plugin_databases_databases", "glpi_plugin_databases_databasetypes", "glpi_plugin_databases_databasecategories", "glpi_plugin_databases_servertypes", "glpi_plugin_databases_scripttypes", "glpi_plugin_databases_instances", "glpi_plugin_databases_scripts", "glpi_plugin_databases_databases_items", "glpi_plugin_databases_profiles");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    //old versions
    $tables = array("glpi_plugin_sgbd", "glpi_dropdown_plugin_sgbd_type", "glpi_dropdown_plugin_sgbd_server_type", "glpi_plugin_sgbd_device", "glpi_plugin_sgbd_profiles", "glpi_dropdown_plugin_sgbd_script_type", "glpi_plugin_sgbd_instances", "glpi_plugin_sgbd_scripts", "glpi_dropdown_plugin_sgbd_category");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` = 'PluginDatabasesDatabase' ;");
    }
    if (class_exists('PluginDatainjectionModel')) {
        PluginDatainjectionModel::clean(array('itemtype' => 'PluginDatabasesDatabase'));
    }
    return true;
}
Пример #11
0
/**
 * Used for filter list of models
 *
 * @param $itemtype
**/
function plugin_datainjection_addDefaultWhere($itemtype)
{
    switch ($itemtype) {
        case 'PluginDatainjectionModel':
            $models = PluginDatainjectionModel::getModels(Session::getLoginUserID(), 'name', $_SESSION['glpiactive_entity'], true);
            if (count($models) > 0) {
                $tab = array();
                foreach ($models as $model) {
                    $tab[] = $model['id'];
                }
                if (count($tab) > 0) {
                    $where = "`glpi_plugin_datainjection_models`.`id` IN ('" . implode("','", $tab) . "')";
                }
                return $where;
            }
            return false;
    }
}
Пример #12
0
function plugin_resources_uninstall()
{
    global $DB;
    $tables = array("glpi_plugin_resources_resources", "glpi_plugin_resources_resources_items", "glpi_plugin_resources_employees", "glpi_plugin_resources_employers", "glpi_plugin_resources_clients", "glpi_plugin_resources_choices", "glpi_plugin_resources_choiceitems", "glpi_plugin_resources_departments", "glpi_plugin_resources_contracttypes", "glpi_plugin_resources_resourcestates", "glpi_plugin_resources_tasktypes", "glpi_plugin_resources_profiles", "glpi_plugin_resources_tasks", "glpi_plugin_resources_taskplannings", "glpi_plugin_resources_tasks_items", "glpi_plugin_resources_checklists", "glpi_plugin_resources_checklistconfigs", "glpi_plugin_resources_reportconfigs", "glpi_plugin_resources_resourcerestings", "glpi_plugin_resources_resourceholidays", "glpi_plugin_resources_ticketcategories", "glpi_plugin_resources_resourcesituations", "glpi_plugin_resources_contractnatures", "glpi_plugin_resources_ranks", "glpi_plugin_resources_resourcespecialities", "glpi_plugin_resources_leavingreasons", "glpi_plugin_resources_professions", "glpi_plugin_resources_professionlines", "glpi_plugin_resources_professioncategories", "glpi_plugin_resources_employments", "glpi_plugin_resources_employmentstates", "glpi_plugin_resources_budgets", "glpi_plugin_resources_costs", "glpi_plugin_resources_budgettypes", "glpi_plugin_resources_budgetvolumes");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    //old versions
    $tables = array("glpi_plugin_resources", "glpi_plugin_resources_device", "glpi_plugin_resources_needs", "glpi_plugin_resources_employee", "glpi_dropdown_plugin_resources_employer", "glpi_dropdown_plugin_resources_client", "glpi_dropdown_plugin_resources_type", "glpi_dropdown_plugin_resources_department", "glpi_dropdown_plugin_resources_tasks_type", "glpi_plugin_resources_mailingsettings", "glpi_plugin_resources_mailing");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $in = "IN (" . implode(',', array("'PluginResourcesResource'", "'PluginResourcesTask'", "'PluginResourcesHelpdesk'", "'PluginResourcesDirectory'", "'PluginResourcesChecklistconfig'", "'PluginResourcesResourceResting'", "'PluginResourcesResourceHoliday'", "'PluginResourcesBudget'", "'PluginResourcesEmployment'", "'PluginResourcesRecap'")) . ")";
    $tables = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets");
    foreach ($tables as $table) {
        $query = "DELETE FROM `{$table}` WHERE (`itemtype` " . $in . " ) ";
        $DB->query($query);
    }
    //drop rules
    $Rule = new Rule();
    $a_rules = $Rule->find("`sub_type`='PluginResourcesRuleChecklist'\n                              OR `sub_type`='PluginResourcesRuleContracttype'");
    foreach ($a_rules as $data) {
        $Rule->delete($data);
    }
    $notif = new Notification();
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'new', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'update', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'delete', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'newtask', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'updatetask', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'deletetask', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'AlertExpiredTasks', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'AlertLeavingResources', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'AlertArrivalChecklists', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'AlertLeavingChecklists', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'LeavingResource', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'report', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'newresting', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'updateresting', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'deleteresting', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'newholiday', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'updateholiday', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginResourcesResource', 'event' => 'deleteholiday', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    //templates
    $template = new NotificationTemplate();
    $translation = new NotificationTemplateTranslation();
    $options = array('itemtype' => 'PluginResourcesResource', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notificationtemplates', $options) as $data) {
        $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id');
        foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) {
            $translation->delete($data_template);
        }
        $template->delete($data);
    }
    if (class_exists('PluginDatainjectionModel')) {
        PluginDatainjectionModel::clean(array('itemtype' => 'PluginResourcesResource'));
        PluginDatainjectionModel::clean(array('itemtype' => 'PluginResourcesClient'));
    }
    $rep_files_resources = GLPI_PLUGIN_DOC_DIR . "/resources";
    Toolbox::deleteDir($rep_files_resources);
    return true;
}
Пример #13
0
 This file is part of the datainjection plugin.

 Datainjection 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.

 Datainjection 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 datainjection. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
 @package   datainjection
 @author    the datainjection plugin team
 @copyright Copyright (c) 2010-2013 Datainjection plugin team
 @license   GPLv2+
            http://www.gnu.org/licenses/gpl.txt
 @link      https://forge.indepnet.net/projects/datainjection
 @link      http://www.glpi-project.org/
 @since     2009
 ---------------------------------------------------------------------- */
include '../../../inc/includes.php';
Html::header(PluginDatainjectionModel::getTypeName(), '', "tools", "plugindatainjectionmenu", "model");
$model = new PluginDatainjectionModel();
$model->checkGlobal(READ);
Search::show('PluginDatainjectionModel');
Html::footer();
Пример #14
0
if (isset($_POST["update"])) {
    $at_least_one_mandatory = false;
    $mapping = new PluginDatainjectionMapping();
    foreach ($_POST['data'] as $id => $mapping_infos) {
        $mapping_infos['id'] = $id;
        //If no field selected, reset other values
        if ($mapping_infos['value'] == PluginDatainjectionInjectionType::NO_VALUE) {
            $mapping_infos['itemtype'] = PluginDatainjectionInjectionType::NO_VALUE;
            $mapping_infos['is_mandatory'] = 0;
        } else {
            $mapping_infos['is_mandatory'] = isset($mapping_infos['is_mandatory']) ? 1 : 0;
        }
        if ($mapping_infos['is_mandatory']) {
            $at_least_one_mandatory = true;
        }
        $mapping->update($mapping_infos);
    }
    if (!$at_least_one_mandatory) {
        Session::addMessageAfterRedirect(__('One link field must be selected: it will be used to check if data already exists', 'datainjection'), true, ERROR, true);
    } else {
        $model = new PluginDatainjectionModel();
        $model->getFromDB($_POST['models_id']);
        if ($model->fields['step'] != PluginDatainjectionModel::READY_TO_USE_STEP) {
            PluginDatainjectionModel::changeStep($_POST['models_id'], PluginDatainjectionModel::OTHERS_STEP);
            Session::setActiveTab('PluginDatainjectionModel', 'PluginDatainjectionModel$5');
            Session::addMessageAfterRedirect(__("This step allows you to add informations not present in the file. You'll be asked for theses informations while using the model.", 'datainjection'));
        }
        unset($_SESSION['datainjection']['lines']);
    }
}
Html::back();
Пример #15
0
function plugin_accounts_uninstall()
{
    global $DB;
    $tables = array("glpi_plugin_accounts_accounts", "glpi_plugin_accounts_accounts_items", "glpi_plugin_accounts_accounttypes", "glpi_plugin_accounts_accountstates", "glpi_plugin_accounts_profiles", "glpi_plugin_accounts_configs", "glpi_plugin_accounts_hashs", "glpi_plugin_accounts_hashes", "glpi_plugin_accounts_aeskeys", "glpi_plugin_accounts_notificationstates");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    //old versions
    $tables = array("glpi_plugin_comptes", "glpi_plugin_compte_device", "glpi_dropdown_plugin_compte_type", "glpi_dropdown_plugin_compte_status", "glpi_plugin_compte_profiles", "glpi_plugin_compte_config", "glpi_plugin_compte_default", "glpi_plugin_compte_mailing", "glpi_plugin_compte", "glpi_plugin_compte_hash", "glpi_plugin_compte_aeskey");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $notif = new Notification();
    $options = array('itemtype' => 'PluginAccountsAccount', 'event' => 'new', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginAccountsAccount', 'event' => 'ExpiredAccounts', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginAccountsAccount', 'event' => 'AccountsWhichExpire', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    //templates
    $template = new NotificationTemplate();
    $translation = new NotificationTemplateTranslation();
    $options = array('itemtype' => 'PluginAccountsAccount', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notificationtemplates', $options) as $data) {
        $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id');
        foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) {
            $translation->delete($data_template);
        }
        $template->delete($data);
    }
    $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE FROM `{$table_glpi}`\n               WHERE `itemtype` = 'PluginAccountsAccount'\n               OR `itemtype` = 'PluginAccountsHelpdesk'\n               OR `itemtype` = 'PluginAccountsGroup' ;");
    }
    if (class_exists('PluginDatainjectionModel')) {
        PluginDatainjectionModel::clean(array('itemtype' => 'PluginAccountsAccount'));
    }
    return true;
}
Пример #16
0
 Datainjection 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 datainjection. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
 @package   datainjection
 @author    the datainjection plugin team
 @copyright Copyright (c) 2010-2013 Datainjection plugin team
 @license   GPLv2+
            http://www.gnu.org/licenses/gpl.txt
 @link      https://forge.indepnet.net/projects/datainjection
 @link      http://www.glpi-project.org/
 @since     2009
 ---------------------------------------------------------------------- */
include '../../../inc/includes.php';
Session::checkLoginUser();
switch ($_GET["popup"]) {
    case "preview":
        Html::popHeader(__('See the file', 'datainjection'), $_SERVER['PHP_SELF']);
        PluginDatainjectionModel::showPreviewMappings($_GET['models_id']);
        Html::popFooter();
        break;
    case "log":
        Html::popHeader(__('File injection report', 'datainjection'), $_SERVER['PHP_SELF']);
        PluginDatainjectionModel::showLogResults($_GET['models_id']);
        Html::popFooter();
        break;
}
Пример #17
0
function plugin_routetables_uninstall()
{
    global $DB;
    $tables = array("glpi_plugin_routetables_routetables", "glpi_plugin_routetables_routetables_items", "glpi_plugin_routetables_profiles");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    //old versions
    $tables = array("glpi_plugin_routetable", "glpi_plugin_routetable_device", "glpi_plugin_routetable_profiles");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` = 'PluginRoutetablesRoutetable' ;");
    }
    if (class_exists('PluginDatainjectionModel')) {
        PluginDatainjectionModel::clean(array('itemtype' => 'PluginRoutetablesRoutetable'));
    }
    return true;
}
Пример #18
0
 static function uninstall()
 {
     global $DB;
     // Remove unicity constraints on simcards
     FieldUnicity::deleteForItemtype("SimcardSimcard");
     foreach (array('Notepad', 'DisplayPreference', 'Contract_Item', 'Infocom', 'Fieldblacklist', 'Document_Item', 'Bookmark', 'Log') as $itemtype) {
         $item = new $itemtype();
         $item->deleteByCriteria(array('itemtype' => __CLASS__));
     }
     $plugin = new Plugin();
     if ($plugin->isActivated('datainjection') && class_exists('PluginDatainjectionModel')) {
         PluginDatainjectionModel::clean(array('itemtype' => __CLASS__));
     }
     if ($plugin->isInstalled('customfields') && $plugin->isActivated('customfields')) {
         PluginCustomfieldsItemtype::unregisterItemtype('PluginSimcardSimcard');
     }
     $table = getTableForItemType(__CLASS__);
     $DB->query("DROP TABLE IF EXISTS `{$table}`");
 }
Пример #19
0
 function uninstall()
 {
     global $DB;
     foreach (array('DisplayPreference', 'Document_Item', 'Bookmark', 'Log') as $itemtype) {
         $item = new $itemtype();
         $item->deleteByCriteria(array('itemtype' => __CLASS__));
     }
     $plugin = new Plugin();
     if ($plugin->isActivated('datainjection') && class_exists('PluginDatainjectionModel')) {
         PluginDatainjectionModel::clean(array('itemtype' => __CLASS__));
     }
     if ($plugin->isInstalled('customfields') && $plugin->isActivated('customfields')) {
         PluginCustomfieldsItemtype::unregisterItemtype('PluginSimcardSimcard');
     }
     $table = getTableForItemType(__CLASS__);
     $DB->query("DROP TABLE IF EXISTS `{$table}`");
 }
Пример #20
0
function plugin_connections_uninstall()
{
    global $DB;
    $tables = array('glpi_plugin_connections_configs', "glpi_plugin_connections_connections", "glpi_plugin_connections_connections_items", "glpi_plugin_connections_connectiontypes", "glpi_plugin_connections_connectionrates", "glpi_plugin_connections_guaranteedconnectionrates", "glpi_plugin_connections_profiles", "glpi_plugin_connections_notificationstates");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    //old versions
    $tables = array("glpi_plugin_connection", "glpi_plugin_connection_device", 'glpi_plugin_connections_connectionratesguaranteed', "glpi_dropdown_plugin_connections_type", "glpi_plugin_connection_profiles", "glpi_plugin_connection_mailing");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` = 'PluginConnectionsConnection';");
    }
    if (class_exists('PluginDatainjectionModel')) {
        PluginDatainjectionModel::clean(array('itemtype' => 'PluginConnectionsConnection'));
    }
    return true;
}
Пример #21
0
            $model->update($_POST);
            $specific_model = PluginDatainjectionModel::getInstance('csv');
            $specific_model->saveFields($_POST);
            Html::back();
            /* update order */
        } elseif (isset($_POST["validate"])) {
            $model->check($_POST['id'], UPDATE);
            $model->switchReadyToUse();
            Html::back();
        } elseif (isset($_POST['upload'])) {
            if (!empty($_FILES)) {
                $model->check($_POST['id'], UPDATE);
                if ($model->processUploadedFile(array('file_encoding' => 'csv', 'mode' => PluginDatainjectionModel::CREATION))) {
                    Session::setActiveTab('PluginDatainjectionModel', 'PluginDatainjectionModel$4');
                } else {
                    Session::addMessageAfterRedirect(__('The file could not be found', 'datainjection'), true, ERROR, true);
                }
            }
            Html::back();
        } elseif (isset($_GET['sample'])) {
            $model->check($_GET['sample'], READ);
            $modeltype = PluginDatainjectionModel::getInstance($model->getField('filetype'));
            $modeltype->getFromDBByModelID($model->getField('id'));
            $modeltype->showSample($model);
            exit(0);
        }
    }
}
Html::header(PluginDatainjectionModel::getTypeName(), '', "tools", "plugindatainjectionmenu", "model");
$model->display(array('id' => $_GET["id"]));
Html::footer();
Пример #22
0
function plugin_ideabox_uninstall()
{
    global $DB;
    $tables = array("glpi_plugin_ideabox_ideaboxs", "glpi_plugin_ideabox_ideaboxes", "glpi_plugin_ideabox_comments", "glpi_plugin_ideabox_profiles");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    //old tables
    $tables = array("glpi_plugin_ideabox", "glpi_plugin_ideabox_mailing");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $notif = new Notification();
    $options = array('itemtype' => 'PluginIdeaboxIdeabox', 'event' => 'new', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginIdeaboxIdeabox', 'event' => 'update', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginIdeaboxIdeabox', 'event' => 'delete', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginIdeaboxIdeabox', 'event' => 'newcomment', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginIdeaboxIdeabox', 'event' => 'updatecomment', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    $options = array('itemtype' => 'PluginIdeaboxIdeabox', 'event' => 'deletecomment', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notifications', $options) as $data) {
        $notif->delete($data);
    }
    //templates
    $template = new NotificationTemplate();
    $translation = new NotificationTemplateTranslation();
    $options = array('itemtype' => 'PluginIdeaboxIdeabox', 'FIELDS' => 'id');
    foreach ($DB->request('glpi_notificationtemplates', $options) as $data) {
        $options_template = array('notificationtemplates_id' => $data['id'], 'FIELDS' => 'id');
        foreach ($DB->request('glpi_notificationtemplatetranslations', $options_template) as $data_template) {
            $translation->delete($data_template);
        }
        $template->delete($data);
    }
    $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_tickets");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` = 'PluginIdeaboxIdeabox' OR `itemtype` = 'PluginIdeaboxComment';");
    }
    if (class_exists('PluginDatainjectionModel')) {
        PluginDatainjectionModel::clean(array('itemtype' => 'PluginIdeaboxIdeabox'));
    }
    return true;
}
Пример #23
0
function plugin_webapplications_uninstall()
{
    global $DB;
    $tables = array("glpi_plugin_webapplications_webapplications", "glpi_plugin_webapplications_webapplicationtypes", "glpi_plugin_webapplications_webapplicationservertypes", "glpi_plugin_webapplications_webapplicationtechnics", "glpi_plugin_webapplications_webapplications_items", "glpi_plugin_webapplications_profiles");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    //old versions
    $tables = array("glpi_plugin_appweb", "glpi_dropdown_plugin_appweb_type", "glpi_dropdown_plugin_appweb_server_type", "glpi_dropdown_plugin_appweb_technic", "glpi_plugin_appweb_device", "glpi_plugin_appweb_profiles");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE\n                  FROM `{$table_glpi}`\n                  WHERE `itemtype` = 'PluginWebapplicationsWebapplication'");
    }
    if (class_exists('PluginDatainjectionModel')) {
        PluginDatainjectionModel::clean(array('itemtype' => 'PluginWebapplicationsWebapplication'));
    }
    return true;
}
Пример #24
0
 /**
  * @param $model     PluginDatainjectionModel object
  **/
 static function showAdditionalInformationsForm(PluginDatainjectionModel $model)
 {
     $infos = getAllDatasFromTable('glpi_plugin_datainjection_infos', "`models_id` = '" . $model->getField('id') . "'");
     $table = false;
     $modeltype = PluginDatainjectionModel::getInstance($model->getField('filetype'));
     $modeltype->getFromDBByModelID($model->getField('id'));
     if (count($infos) || $modeltype->haveSample() || $model->fields['comment']) {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='2'>" . sprintf(__('%1$s (%2$s)'), __('Complementary information', 'datainjection'), __('Choose a file', 'datainjection'));
         echo "</th></tr>\n";
         $table = true;
     }
     if ($modeltype->haveSample()) {
         echo "<tr class='tab_bg_1'>";
         echo "<td colspan='2' class='center'>";
         echo "<a href='" . $model->getFormURL() . "?sample=";
         echo $model->getField('id') . "' class='vsubmit'>" . __('Download file sample', 'datainjection');
         echo "</a></td></tr>\n";
     }
     if ($model->fields['comment']) {
         echo "<tr class='tab_bg_2'>";
         echo "<td colspan='2' class='center'>" . nl2br($model->fields['comment']) . "</td></tr>\n";
     }
     if (count($infos)) {
         $info = new PluginDatainjectionInfo();
         foreach ($infos as $tmp) {
             $info->fields = $tmp;
             echo "<tr class='tab_bg_1'>";
             self::displayAdditionalInformation($info, isset($_SESSION['datainjection']['infos']) ? $_SESSION['datainjection']['infos'] : array());
             echo "</tr>";
         }
     }
     if ($table) {
         echo "</table><br>";
     }
     $options['models_id'] = $model->getField('id');
     $options['confirm'] = 'process';
     PluginDatainjectionClientInjection::showUploadFileForm($options);
     //Store models_id in session for future usage
     $_SESSION['datainjection']['models_id'] = $model->getField('id');
 }
 /**
  * @param $model        PluginDatainjectionModel object
  * @param $entities_id
  **/
 static function processInjection(PluginDatainjectionModel $model, $entities_id)
 {
     global $CFG_GLPI;
     // To prevent problem of execution time during injection
     ini_set("max_execution_time", "0");
     // Disable recording each SQL request in $_SESSION
     $CFG_GLPI["debug_sql"] = 0;
     $nblines = PluginDatainjectionSession::getParam('nblines');
     $clientinjection = new PluginDatainjectionClientInjection();
     //New injection engine
     $engine = new PluginDatainjectionEngine($model, PluginDatainjectionSession::getParam('infos'), $entities_id);
     $backend = $model->getBackend();
     $model->loadSpecificModel();
     //Open CSV file
     $backend->openFile();
     $index = 0;
     //Read CSV file
     $line = $backend->getNextLine();
     //If header is present, then get the second line
     if ($model->getSpecificModel()->isHeaderPresent()) {
         $line = $backend->getNextLine();
     }
     //While CSV file is not EOF
     $prev = '';
     $deb = time();
     while ($line != null) {
         //Inject line
         $injectionline = $index + ($model->getSpecificModel()->isHeaderPresent() ? 2 : 1);
         $clientinjection->results[] = $engine->injectLine($line[0], $injectionline);
         $pos = number_format($index * 100 / $nblines, 1);
         if ($pos != $prev) {
             $prev = $pos;
             $fin = time() - $deb;
             //TODO yllen
             Html::changeProgressBarPosition($index, $nblines, sprintf(__('%1$s (%2$s)'), sprintf(__('Injection of the file... %d%%', 'datainjection'), $pos), Html::timestampToString(time() - $deb, true)));
         }
         $line = $backend->getNextLine();
         $index++;
     }
     //EOF : change progressbar to 100% !
     Html::changeProgressBarPosition(100, 100, sprintf(__('%1$s (%2$s)'), __('Injection finished', 'datainjection'), Html::timestampToString(time() - $deb, true)));
     // Restore
     $CFG_GLPI["debug_sql"] = 1;
     //Close CSV file
     $backend->closeFile();
     //Delete CSV file
     $backend->deleteFile();
     //Change step
     $_SESSION['datainjection']['step'] = self::STEP_RESULT;
     //Display results form
     PluginDatainjectionSession::setParam('results', json_encode($clientinjection->results));
     PluginDatainjectionSession::setParam('error_lines', json_encode($engine->getLinesInError()));
     $p['models_id'] = $model->fields['id'];
     $p['nblines'] = $nblines;
     unset($_SESSION['datainjection']['go']);
     $_SESSION["MESSAGE_AFTER_REDIRECT"] = "";
     $url = $CFG_GLPI["root_doc"] . "/plugins/datainjection/ajax/results.php";
     Ajax::updateItem("span_injection", $url, $p);
 }
Пример #26
0
 /**
  * Remove datainjection models for an itemtype
  * @param the itemtype
  * @return nothing
  */
 public static function removeDataInjectionModels($itemtype)
 {
     $plugin = new Plugin();
     //Delete if exists datainjection models
     if ($plugin->isInstalled("datainjection")) {
         $model = new PluginDatainjectionModel();
         foreach ($model->find("`itemtype`='{$itemtype}'") as $data) {
             $model->delete($data);
         }
     }
 }
Пример #27
0
 @author    the datainjection plugin team
 @copyright Copyright (c) 2010-2013 Datainjection plugin team
 @license   GPLv2+
            http://www.gnu.org/licenses/gpl.txt
 @link      https://forge.indepnet.net/projects/datainjection
 @link      http://www.glpi-project.org/
 @since     2009
 ---------------------------------------------------------------------- */
include '../../../inc/includes.php';
Html::header(__('File injection', 'datainjection'), $_SERVER["PHP_SELF"], "tools", "plugindatainjectionmenu", "client");
if (isset($_SESSION['datainjection']['go'])) {
    $model = unserialize($_SESSION['datainjection']['currentmodel']);
    PluginDatainjectionClientInjection::showInjectionForm($model, $_SESSION['glpiactive_entity']);
} else {
    if (isset($_POST['upload'])) {
        $model = new PluginDatainjectionModel();
        $model->can($_POST['id'], READ);
        $_SESSION['datainjection']['infos'] = isset($_POST['info']) ? $_POST['info'] : array();
        //If additional informations provided : check if mandatory infos are present
        if (!$model->checkMandatoryFields($_SESSION['datainjection']['infos'])) {
            Session::addMessageAfterRedirect(__('One mandatory field is not filled', 'datainjection'), true, ERROR, true);
        } else {
            if (isset($_FILES['filename']['name']) && $_FILES['filename']['name'] && $_FILES['filename']['tmp_name'] && !$_FILES['filename']['error'] && $_FILES['filename']['size']) {
                //Read file using automatic encoding detection, and do not delete file once readed
                $options = array('file_encoding' => $_POST['file_encoding'], 'mode' => PluginDatainjectionModel::PROCESS, 'delete_file' => false);
                $response = $model->processUploadedFile($options);
                $model->cleanData();
                if ($response) {
                    //File uploaded successfully and matches the given model : switch to the import tab
                    $_SESSION['datainjection']['file_name'] = $_FILES['filename']['name'];
                    $_SESSION['datainjection']['step'] = PluginDatainjectionClientInjection::STEP_PROCESS;
Пример #28
0
function plugin_databases_uninstall()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/databases/inc/profile.class.php";
    include_once GLPI_ROOT . "/plugins/databases/inc/menu.class.php";
    $tables = array("glpi_plugin_databases_databases", "glpi_plugin_databases_databasetypes", "glpi_plugin_databases_databasecategories", "glpi_plugin_databases_servertypes", "glpi_plugin_databases_scripttypes", "glpi_plugin_databases_instances", "glpi_plugin_databases_scripts", "glpi_plugin_databases_databases_items");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    //old versions
    $tables = array("glpi_plugin_sgbd", "glpi_dropdown_plugin_sgbd_type", "glpi_dropdown_plugin_sgbd_server_type", "glpi_plugin_sgbd_device", "glpi_plugin_sgbd_profiles", "glpi_dropdown_plugin_sgbd_script_type", "glpi_plugin_sgbd_instances", "glpi_plugin_sgbd_scripts", "glpi_dropdown_plugin_sgbd_category", "glpi_plugin_databases_profiles");
    foreach ($tables as $table) {
        $DB->query("DROP TABLE IF EXISTS `{$table}`;");
    }
    $tables_glpi = array("glpi_displaypreferences", "glpi_documents_items", "glpi_bookmarks", "glpi_logs", "glpi_items_tickets", "glpi_notepads");
    foreach ($tables_glpi as $table_glpi) {
        $DB->query("DELETE FROM `{$table_glpi}` WHERE `itemtype` = 'PluginDatabasesDatabase' ;");
    }
    if (class_exists('PluginDatainjectionModel')) {
        PluginDatainjectionModel::clean(array('itemtype' => 'PluginDatabasesDatabase'));
    }
    //Delete rights associated with the plugin
    $profileRight = new ProfileRight();
    foreach (PluginDatabasesProfile::getAllRights() as $right) {
        $profileRight->deleteByCriteria(array('name' => $right['field']));
    }
    PluginDatabasesMenu::removeRightsFromSession();
    PluginDatabasesProfile::removeRightsFromSession();
    return true;
}
Пример #29
0
 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 datainjection. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
 @package   datainjection
 @author    the datainjection plugin team
 @copyright Copyright (c) 2010-2013 Datainjection plugin team
 @license   GPLv2+
            http://www.gnu.org/licenses/gpl.txt
 @link      https://forge.indepnet.net/projects/datainjection
 @link      http://www.glpi-project.org/
 @since     2009
 ---------------------------------------------------------------------- */
// Direct access to file
if (strpos($_SERVER['PHP_SELF'], "dropdownSelectModel.php")) {
    include '../../../inc/includes.php';
    header("Content-Type: text/html; charset=UTF-8");
    Html::header_nocache();
}
Session::checkCentralAccess();
if (isset($_SESSION['datainjection']['models_id']) && $_SESSION['datainjection']['models_id'] != $_POST['models_id']) {
    PluginDatainjectionModel::cleanSessionVariables();
}
$_SESSION['datainjection']['step'] = PluginDatainjectionClientInjection::STEP_UPLOAD;
$model = new PluginDatainjectionModel();
if ($_POST['models_id'] > 0 && $model->can($_POST['models_id'], READ)) {
    PluginDatainjectionInfo::showAdditionalInformationsForm($model);
}