Пример #1
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;
}
Пример #2
0
Copyright (C) 2003-2011 by the badges Development Team.

https://forge.indepnet.net/projects/badges
-------------------------------------------------------------------------

LICENSE
		
This file is part of badges.

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

Badges 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 Badges. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
Session::checkRight("profile", "r");
$prof = new PluginBadgesProfile();
//Save profile
if (isset($_POST['update'])) {
    $prof->update($_POST);
    Html::back();
}
Пример #3
0
function plugin_badges_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/badges/inc/profile.class.php";
    $install = false;
    $update78 = false;
    $update80 = false;
    if (!TableExists("glpi_plugin_badges") && !TableExists("glpi_plugin_badges_badgetypes")) {
        $install = true;
        $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/empty-1.7.0.sql");
    } else {
        if (TableExists("glpi_plugin_badges_users") && !TableExists("glpi_plugin_badges_default")) {
            $update78 = true;
            $update80 = true;
            $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.4.sql");
            $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.0.sql");
            plugin_badges_configure15();
            $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.1.sql");
            $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql");
        } else {
            if (TableExists("glpi_plugin_badges_profiles") && FieldExists("glpi_plugin_badges_profiles", "interface")) {
                $update78 = true;
                $update80 = true;
                $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.0.sql");
                plugin_badges_configure15();
                $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.1.sql");
                $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql");
            } else {
                if (TableExists("glpi_plugin_badges") && !FieldExists("glpi_plugin_badges", "date_mod")) {
                    $update78 = true;
                    $update80 = true;
                    $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.5.1.sql");
                    $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql");
                } else {
                    if (!TableExists("glpi_plugin_badges_badgetypes")) {
                        $update78 = true;
                        $update80 = true;
                        $DB->runFile(GLPI_ROOT . "/plugins/badges/sql/update-1.6.0.sql");
                    }
                }
            }
        }
    }
    if ($install || $update78) {
        //Do One time on 0.78
        $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginBadgesBadge' AND `name` = 'Alert Badges'";
        $result = $DB->query($query_id) or die($DB->error());
        $itemtype = $DB->result($result, 0, 'id');
        $query = "INSERT INTO `glpi_notificationtemplatetranslations`\n                                 VALUES(NULL, " . $itemtype . ", '','##badge.action## : ##badge.entity##',\n                        '##lang.badge.entity## :##badge.entity##\n   ##FOREACHbadges##\n   ##lang.badge.name## : ##badge.name## - ##lang.badge.dateexpiration## : ##badge.dateexpiration####IFbadge.serial## - ##lang.badge.serial## : ##badge.serial####ENDIFbadge.serial####IFbadge.users## - ##lang.badge.users## : ##badge.users####ENDIFbadge.users##\n   ##ENDFOREACHbadges##',\n                        '&lt;p&gt;##lang.badge.entity## :##badge.entity##&lt;br /&gt; &lt;br /&gt;\n                        ##FOREACHbadges##&lt;br /&gt;\n                        ##lang.badge.name##  : ##badge.name## - ##lang.badge.dateexpiration## :  ##badge.dateexpiration####IFbadge.serial## - ##lang.badge.serial## :  ##badge.serial####ENDIFbadge.serial####IFbadge.users## - ##lang.badge.users## :  ##badge.users####ENDIFbadge.users##&lt;br /&gt; \n                        ##ENDFOREACHbadges##&lt;/p&gt;');";
        $result = $DB->query($query);
        $query = "INSERT INTO `glpi_notifications`\n                                   VALUES (NULL, 'Alert Expired Badges', 0, 'PluginBadgesBadge', 'ExpiredBadges',\n                                          'mail'," . $itemtype . ",\n                                          '', 1, 1, '2010-02-17 22:36:46');";
        $result = $DB->query($query);
        $query = "INSERT INTO `glpi_notifications`\n                                   VALUES (NULL, 'Alert Badges Which Expire', 0, 'PluginBadgesBadge', 'BadgesWhichExpire',\n                                          'mail'," . $itemtype . ",\n                                          '', 1, 1, '2010-02-17 22:36:46');";
        $result = $DB->query($query);
    }
    if ($update78) {
        $query_ = "SELECT *\n            FROM `glpi_plugin_badges_profiles` ";
        $result_ = $DB->query($query_);
        if ($DB->numrows($result_) > 0) {
            while ($data = $DB->fetch_array($result_)) {
                $query = "UPDATE `glpi_plugin_badges_profiles`\n                  SET `profiles_id` = '" . $data["id"] . "'\n                  WHERE `id` = '" . $data["id"] . "';";
                $result = $DB->query($query);
            }
        }
        $query = "ALTER TABLE `glpi_plugin_badges_profiles`\n               DROP `name` ;";
        $result = $DB->query($query);
        Plugin::migrateItemType(array(1600 => 'PluginBadgesBadge'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"));
    }
    CronTask::Register('PluginBadgesBadge', 'BadgesAlert', DAY_TIMESTAMP);
    PluginBadgesProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    return true;
}