Пример #1
0
https://forge.indepnet.net/projects/pdf
-------------------------------------------------------------------------

LICENSE

This file is part of pdf.

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

pdf 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 pdf. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
include_once "../../../inc/includes.php";
Session::checkRight("profile", "r");
// Mainly usefull if not actived
Plugin::load('pdf', true);
$prof = new PluginPdfProfile();
if (isset($_POST["update_user_profile"])) {
    Session::checkRight("profile", "w");
    $prof->update($_POST);
    Html::back();
}
Пример #2
0
function plugin_pdf_install()
{
    global $DB;
    $migration = new Migration('0.84');
    if (!TableExists('glpi_plugin_pdf_profiles')) {
        $query = "CREATE TABLE IF NOT EXISTS\n               `glpi_plugin_pdf_profiles` (\n                  `id` int(11) NOT NULL,\n                  `profile` varchar(255) default NULL,\n                  `use` tinyint(1) default 0,\n                  PRIMARY KEY (`id`)\n               ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->queryOrDir($query, $DB->error());
    } else {
        if (FieldExists('glpi_plugin_pdf_profiles', 'ID')) {
            //< 0.7.0
            $migration->changeField('glpi_plugin_pdf_profiles', 'ID', 'id', 'autoincrement');
        }
    }
    if (!TableExists('glpi_plugin_pdf_preference')) {
        $query = "CREATE TABLE IF NOT EXISTS\n               `glpi_plugin_pdf_preferences` (\n                  `id` int(11) NOT NULL AUTO_INCREMENT,\n                  `users_id` int(11) NOT NULL COMMENT 'RELATION to glpi_users (id)',\n                  `itemtype` VARCHAR(100) NOT NULL COMMENT 'see define.php *_TYPE constant',\n                  `tabref` varchar(255) NOT NULL COMMENT 'ref of tab to display, or plugname_#, or option name',\n                  PRIMARY KEY (`id`)\n               ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die($DB->error());
    } else {
        $migration->renameTable('glpi_plugin_pdf_preference', 'glpi_plugin_pdf_preferences');
        // 0.6.0
        if (FieldExists('glpi_plugin_pdf_preferences', 'user_id')) {
            $migration->changeField('glpi_plugin_pdf_preferences', 'user_id', 'users_id', 'integer', array('comment' => 'RELATION to glpi_users (id)'));
        }
        // 0.6.1
        if (FieldExists('glpi_plugin_pdf_preferences', 'FK_users')) {
            $migration->changeField('glpi_plugin_pdf_preferences', 'FK_users', 'users_id', 'integer', array('comment' => 'RELATION to glpi_users (id)'));
        }
        // 0.6.0
        if (FieldExists('glpi_plugin_pdf_preferences', 'cat')) {
            $migration->changeField('glpi_plugin_pdf_preferences', 'cat', 'itemtype', 'VARCHAR(100) NOT NULL', array('comment' => 'see define.php *_TYPE constant'));
        }
        // 0.6.1
        if (FieldExists('glpi_plugin_pdf_preferences', 'device_type')) {
            $migration->changeField('glpi_plugin_pdf_preferences', 'device_type', 'itemtype', 'VARCHAR(100) NOT NULL', array('comment' => 'see define.php *_TYPE constant'));
        }
        // 0.6.0
        if (FieldExists('glpi_plugin_pdf_preferences', 'table_num')) {
            $migration->changeField('glpi_plugin_pdf_preferences', 'table_num', 'tabref', 'string', array('comment' => 'ref of tab to display, or plugname_#, or option name'));
        }
        $migration->executeMigration();
    }
    // Give right to current Profile
    include_once GLPI_ROOT . '/plugins/pdf/inc/profile.class.php';
    $prof = new PluginPdfProfile();
    if (!$prof->getFromDB($_SESSION['glpiactiveprofile']['id'])) {
        $prof->add(array('id' => $_SESSION['glpiactiveprofile']['id'], 'profile' => $_SESSION['glpiactiveprofile']['name'], 'use' => 1));
    }
    return true;
}