示例#1
0
function plugin_timelineticket_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/timelineticket/inc/profile.class.php";
    include_once GLPI_ROOT . "/plugins/timelineticket/inc/config.class.php";
    $migration = new Migration(160);
    // installation
    if (!TableExists("glpi_plugin_timelineticket_states")) {
        $query = "CREATE TABLE `glpi_plugin_timelineticket_states` (\n                  `id` int(11) NOT NULL AUTO_INCREMENT,\n                  `tickets_id` int(11) NOT NULL DEFAULT '0',\n                  `date` datetime DEFAULT NULL,\n                  `old_status` varchar(255) DEFAULT NULL,\n                  `new_status` varchar(255) DEFAULT NULL,\n                  `delay` INT( 11 ) NULL,\n                  PRIMARY KEY (`id`),\n                  KEY `tickets_id` (`tickets_id`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die($DB->error());
    }
    if (!TableExists("glpi_plugin_timelineticket_assigngroups")) {
        $query = "CREATE TABLE `glpi_plugin_timelineticket_assigngroups` (\n                  `id` int(11) NOT NULL AUTO_INCREMENT,\n                  `tickets_id` int(11) NOT NULL DEFAULT '0',\n                  `date` datetime DEFAULT NULL,\n                  `groups_id` varchar(255) DEFAULT NULL,\n                  `begin` INT( 11 ) NULL,\n                  `delay` INT( 11 ) NULL,\n                  PRIMARY KEY (`id`),\n                  KEY `tickets_id` (`tickets_id`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die($DB->error());
    }
    if (!TableExists("glpi_plugin_timelineticket_assignusers")) {
        $query = "CREATE TABLE `glpi_plugin_timelineticket_assignusers` (\n                  `id` int(11) NOT NULL AUTO_INCREMENT,\n                  `tickets_id` int(11) NOT NULL DEFAULT '0',\n                  `date` datetime DEFAULT NULL,\n                  `users_id` varchar(255) DEFAULT NULL,\n                  `begin` INT(11) NULL,\n                  `delay` INT(11) NULL,\n                  PRIMARY KEY (`id`),\n                  KEY `tickets_id` (`tickets_id`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die($DB->error());
    }
    if (!TableExists("glpi_plugin_timelineticket_grouplevels")) {
        $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_timelineticket_grouplevels` (\n               `id` int(11) NOT NULL AUTO_INCREMENT,\n               `entities_id` int(11) NOT NULL DEFAULT '0',\n               `is_recursive` tinyint(1) NOT NULL default '0',\n               `name` varchar(255) collate utf8_unicode_ci default NULL,\n               `groups` longtext collate utf8_unicode_ci,\n               `rank` smallint(6) NOT NULL default '0',\n               `comment` text collate utf8_unicode_ci,\n               PRIMARY KEY (`id`)\n             ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
        $DB->query($query) or die($DB->error());
    }
    if (!TableExists("glpi_plugin_timelineticket_configs")) {
        $query = "CREATE TABLE IF NOT EXISTS `glpi_plugin_timelineticket_configs` (\n              `id` int(11) NOT NULL AUTO_INCREMENT,\n              `add_waiting` int(11) NOT NULL DEFAULT '1',\n              PRIMARY KEY  (`id`)\n            ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
        $DB->query($query) or die($DB->error());
    }
    $status = array('new' => Ticket::INCOMING, 'assign' => Ticket::ASSIGNED, 'plan' => Ticket::PLANNED, 'waiting' => Ticket::WAITING, 'solved' => Ticket::SOLVED, 'closed' => Ticket::CLOSED);
    // Update field in tables
    foreach (array('glpi_plugin_timelineticket_states') as $table) {
        // Migrate datas
        foreach ($status as $old => $new) {
            $query = "UPDATE `{$table}`\n                   SET `old_status` = '{$new}'\n                   WHERE `old_status` = '{$old}'";
            $DB->queryOrDie($query, "0.84 status in {$table} {$old} to {$new}");
            $query = "UPDATE `{$table}`\n                   SET `new_status` = '{$new}'\n                   WHERE `new_status` = '{$old}'";
            $DB->queryOrDie($query, "0.84 status in {$table} {$old} to {$new}");
        }
    }
    PluginTimelineticketConfig::createFirstConfig();
    if (isset($_SESSION['glpiactiveprofile']) && isset($_SESSION['glpiactiveprofile']['id'])) {
        PluginTimelineticketProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    }
    $migration = new Migration("0.90+1.0");
    $migration->dropTable('glpi_plugin_timelineticket_profiles');
    return true;
}
  it under the terms of the GNU Affero General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  TimelineTicket 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 Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with TimelineTicket plugin. If not, see <http://www.gnu.org/licenses/>.

  ------------------------------------------------------------------------

  @package   TimelineTicket plugin
  @copyright Copyright (c) 2013-2013 TimelineTicket team
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://forge.indepnet.net/projects/timelineticket
  @since     2013

  ------------------------------------------------------------------------
*/
include '../../../inc/includes.php';
Session::checkRight("profile", "w");
$prof = new PluginTimelineticketProfile();
//Save profile
if (isset($_POST['update'])) {
    $prof->update($_POST);
    Html::back();
}