当前位置: 首页>>代码示例>>PHP>>正文


PHP FieldExists函数代码示例

本文整理汇总了PHP中FieldExists函数的典型用法代码示例。如果您正苦于以下问题:PHP FieldExists函数的具体用法?PHP FieldExists怎么用?PHP FieldExists使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了FieldExists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: plugin_manufacturersimports_install

function plugin_manufacturersimports_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/manufacturersimports/inc/profile.class.php";
    include_once GLPI_ROOT . "/plugins/manufacturersimports/inc/config.class.php";
    $migration = new Migration("1.7.0");
    $update = false;
    //Root of SQL files for DB installation or upgrade
    $sql_root = GLPI_ROOT . "/plugins/manufacturersimports/sql/";
    if (!TableExists("glpi_plugin_manufacturersimports_configs")) {
        $DB->runFile($sql_root . "/empty-1.7.0.sql");
    } else {
        if (TableExists("glpi_plugin_suppliertag_config") && !FieldExists("glpi_plugin_suppliertag_config", "FK_entities")) {
            $update = true;
            $DB->runFile($sql_root . "/update-1.1.sql");
            $DB->runFile($sql_root . "/update-1.2.0.sql");
            $DB->runFile($sql_root . "/update-1.3.0.sql");
            $DB->runFile($sql_root . "/update-1.4.1.sql");
            $DB->runFile($sql_root . "/update-1.5.0.sql");
            $DB->runFile($sql_root . "/update-1.7.0.sql");
        } else {
            if (TableExists("glpi_plugin_suppliertag_profiles") && FieldExists("glpi_plugin_suppliertag_profiles", "interface")) {
                $update = true;
                $DB->runFile($sql_root . "/update-1.2.0.sql");
                $DB->runFile($sql_root . "/update-1.3.0.sql");
                $DB->runFile($sql_root . "/update-1.4.1.sql");
                $DB->runFile($sql_root . "/update-1.5.0.sql");
                $DB->runFile($sql_root . "/update-1.7.0.sql");
            } else {
                if (!TableExists("glpi_plugin_manufacturersimports_profiles") && !FieldExists("glpi_plugin_manufacturersimports_configs", "supplier_key")) {
                    $update = true;
                    $DB->runFile($sql_root . "/update-1.3.0.sql");
                    $DB->runFile($sql_root . "/update-1.4.1.sql");
                    $DB->runFile($sql_root . "/update-1.5.0.sql");
                    $DB->runFile($sql_root . "/update-1.7.0.sql");
                } else {
                    if (!FieldExists("glpi_plugin_manufacturersimports_configs", "supplier_key")) {
                        $DB->runFile($sql_root . "/update-1.7.0.sql");
                    }
                }
            }
        }
    }
    $query = "UPDATE `glpi_plugin_manufacturersimports_configs` \n             SET `Supplier_url` = 'http://www.dell.com/support/troubleshooting/us/en/04/Index?c=us&l=en&s=bsd&cs=04&t=system&ServiceTag=' \n             WHERE `name` ='" . PluginManufacturersimportsConfig::DELL . "'";
    $DB->query($query);
    if ($update) {
        foreach ($DB->request('glpi_plugin_manufacturersimports_profiles') as $data) {
            $query = "UPDATE `glpi_plugin_manufacturersimports_profiles`\n                   SET `profiles_id` = '" . $data["id"] . "'\n                   WHERE `id` = '" . $data["id"] . "';";
            $DB->query($query);
        }
        $migration->dropField('glpi_plugin_manufacturersimports_profiles', 'name');
        Plugin::migrateItemType(array(2150 => 'PluginManufacturersimportsModel', 2151 => 'PluginManufacturersimportsConfig'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_manufacturersimports_models", "glpi_plugin_manufacturersimports_logs"));
    }
    //Migrate profiles to the system introduced in 0.85
    PluginManufacturersimportsProfile::initProfile();
    PluginManufacturersimportsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    //Drop old profile table : not used anymore
    $migration->dropTable('glpi_plugin_manufacturersimports_profiles');
    return true;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:60,代码来源:hook.php

示例2: install

 public static function install(Migration $migration)
 {
     global $DB;
     $table = getTableForItemType(__CLASS__);
     if (!TableExists($table)) {
         $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\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 '1',\n                     `name` varchar(255) NOT NULL DEFAULT '',\n                     `comment` text collate utf8_unicode_ci,\n                     `color` varchar(50) NOT NULL DEFAULT '' COLLATE 'utf8_unicode_ci',\n                     PRIMARY KEY (`id`),\n                     KEY `name` (`name`)\n                     ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
         $GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error());
     }
     if (!FieldExists($table, 'type_menu')) {
         $migration->addField($table, 'type_menu', "varchar(50) NOT NULL DEFAULT ''");
         $migration->addKey($table, 'type_menu');
         $migration->migrationOneTable($table);
     }
     // Version 0.90-1.1
     $result = $DB->query("SHOW FIELDS FROM `{$table}` where Field ='type_menu'");
     if ($result && $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             if (stristr($data["Type"], 'varchar') !== FALSE) {
                 $DB->query("ALTER TABLE `{$table}` DROP INDEX `type_menu`;");
                 $DB->query("ALTER TABLE `{$table}` MODIFY `type_menu` text COLLATE utf8_unicode_ci;");
                 $datas = getAllDatasFromTable($table, "`type_menu` IS NOT NULL");
                 if (!empty($datas)) {
                     foreach ($datas as $data) {
                         $itemtypes = PluginTagTagItem::getItemtypes($data['type_menu']);
                         $DB->query("UPDATE `{$table}` SET `type_menu` = '" . json_encode($itemtypes) . "' WHERE `id` = '" . $data['id'] . "'");
                     }
                 }
                 break;
             }
         }
     }
     return true;
 }
开发者ID:korial29,项目名称:tag,代码行数:33,代码来源:tag.class.php

示例3: plugin_moreticket_install

function plugin_moreticket_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/moreticket/inc/profile.class.php";
    if (!TableExists("glpi_plugin_moreticket_configs")) {
        // table sql creation
        $DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/empty-1.2.0.sql");
    }
    PluginMoreticketProfile::initProfile();
    PluginMoreticketProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    $migration = new Migration("1.1.0");
    $migration->dropTable('glpi_plugin_moreticket_profiles');
    if (!FieldExists("glpi_plugin_moreticket_configs", "solution_status")) {
        $DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.1.1.sql");
    }
    if (FieldExists("glpi_plugin_moreticket_waitingtypes", "is_helpdeskvisible")) {
        $DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.1.2.sql");
    }
    if (!FieldExists("glpi_plugin_moreticket_closetickets", "documents_id")) {
        $DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.1.3.sql");
    }
    if (!FieldExists("glpi_plugin_moreticket_configs", "date_report_mandatory")) {
        $DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.2.0.sql");
    }
    return true;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:26,代码来源:hook.php

示例4: plugin_immobilizationsheets_install

function plugin_immobilizationsheets_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/immobilizationsheets/inc/profile.class.php";
    $update = false;
    if (!TableExists("glpi_plugin_immo_profiles") && !TableExists("glpi_plugin_immobilizationsheets_profiles")) {
        $DB->runFile(GLPI_ROOT . "/plugins/immobilizationsheets/sql/empty-1.3.0.sql");
    } else {
        if (TableExists("glpi_plugin_immo_profiles") && FieldExists("glpi_plugin_immo_profiles", "interface")) {
            $update = true;
            $DB->runFile(GLPI_ROOT . "/plugins/immobilizationsheets/sql/update-1.2.0.sql");
            $DB->runFile(GLPI_ROOT . "/plugins/immobilizationsheets/sql/update-1.3.0.sql");
        } else {
            if (!TableExists("glpi_plugin_immobilizationsheets_profiles")) {
                $update = true;
                $DB->runFile(GLPI_ROOT . "/plugins/immobilizationsheets/sql/update-1.3.0.sql");
            }
        }
    }
    if ($update) {
        //Do One time on 0.78
        $query_ = "SELECT *\n            FROM `glpi_plugin_immobilizationsheets_profiles` ";
        $result_ = $DB->query($query_);
        if ($DB->numrows($result_) > 0) {
            while ($data = $DB->fetch_array($result_)) {
                $query = "UPDATE `glpi_plugin_immobilizationsheets_profiles`\n                  SET `profiles_id` = '" . $data["id"] . "'\n                  WHERE `id` = '" . $data["id"] . "';";
                $result = $DB->query($query);
            }
        }
        $query = "ALTER TABLE `glpi_plugin_immobilizationsheets_profiles`\n               DROP `name` ;";
        $result = $DB->query($query);
    }
    PluginImmobilizationsheetsProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    return true;
}
开发者ID:geldarr,项目名称:hack-space,代码行数:35,代码来源:hook.php

示例5: plugin_racks_install

function plugin_racks_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/racks/inc/profile.class.php";
    $migration = new Migration("1.5.0");
    $update = false;
    if (!TableExists("glpi_plugin_rack_profiles") && !TableExists("glpi_plugin_racks_profiles")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/empty-1.4.2.sql");
    } elseif (TableExists("glpi_plugin_rack_content") && !FieldExists("glpi_plugin_rack_content", "first_powersupply")) {
        $update = true;
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.0.2.sql");
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.1.0.sql");
    } elseif (!TableExists("glpi_plugin_racks_profiles")) {
        $update = true;
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.1.0.sql");
    }
    //from 1.1 version
    if (TableExists("glpi_plugin_racks_racks") && !FieldExists("glpi_plugin_racks_racks", "otherserial")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.2.1.sql");
    }
    if (TableExists("glpi_plugin_racks_racks") && !FieldExists("glpi_plugin_racks_racks", "users_id_tech")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.3.0.sql");
    }
    if (!TableExists("glpi_plugin_racks_racktypes")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.3.2.sql");
    }
    if (TableExists("glpi_plugin_racks_racktypes") && !FieldExists("glpi_plugin_racks_racktypes", "is_recursive")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.4.1.sql");
    }
    if (TableExists("glpi_plugin_racks_profiles") && !FieldExists("glpi_plugin_racks_profiles", "open_ticket")) {
        $DB->runFile(GLPI_ROOT . "/plugins/racks/sql/update-1.4.2.sql");
    }
    if ($update) {
        foreach ($DB->request('glpi_plugin_racks_profiles') as $data) {
            $query = "UPDATE `glpi_plugin_racks_profiles`\n                    SET `profiles_id` = '" . $data["id"] . "'\n                    WHERE `id` = '" . $data["id"] . "';";
            $result = $DB->query($query);
        }
        $migration->dropField('glpi_plugin_racks_profiles', 'name');
        Plugin::migrateItemType(array(4450 => 'PluginRacksRack', 4451 => 'PluginRacksOther'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_tickets"), array("glpi_plugin_racks_racks_items", "glpi_plugin_racks_itemspecifications"));
    }
    $notepad_tables = array('glpi_plugin_racks_racks');
    foreach ($notepad_tables as $t) {
        // Migrate data
        if (FieldExists($t, 'notepad')) {
            $query = "SELECT id, notepad\n                      FROM `{$t}`\n                      WHERE notepad IS NOT NULL\n                            AND notepad <>'';";
            foreach ($DB->request($query) as $data) {
                $iq = "INSERT INTO `glpi_notepads`\n                             (`itemtype`, `items_id`, `content`, `date`, `date_mod`)\n                      VALUES ('" . getItemTypeForTable($t) . "', '" . $data['id'] . "',\n                              '" . addslashes($data['notepad']) . "', NOW(), NOW())";
                $DB->queryOrDie($iq, "0.85 migrate notepad data");
            }
            $query = "ALTER TABLE `glpi_plugin_racks_racks` DROP COLUMN `notepad`;";
            $DB->query($query);
        }
    }
    //Migrate profiles to the system introduced in 0.85
    PluginRacksProfile::initProfile();
    PluginRacksProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    //Drop old profile table : not used anymore
    $migration->dropTable('glpi_plugin_racks_profiles');
    return true;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:60,代码来源:hook.php

示例6: plugin_ticketmail_install

function plugin_ticketmail_install()
{
    global $DB;
    $migration = new Migration(100);
    //Fresh install
    if (!TableExists('glpi_plugin_ticketmail_profiles')) {
        $query = "CREATE TABLE `glpi_plugin_ticketmail_profiles` (\n\t\t\t\t\t`id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_profiles (id)',\n\t\t\t\t\t`show_ticketmail_onglet` char(1) collate utf8_unicode_ci default NULL,\n\t\t\t\t\tPRIMARY KEY  (`id`)\n\t\t\t\t  ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
        $DB->queryOrDie($query, $DB->error());
        $migration->executeMigration();
        include_once GLPI_ROOT . "/plugins/ticketmail/inc/profile.class.php";
        PluginTicketmailProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']);
    } else {
        // Since v0.84 remove "profiles_id" column and use "id"
        if (FieldExists('glpi_plugin_ticketmail_profiles', 'profiles_id')) {
            $drop_column_query = "ALTER TABLE glpi_plugin_ticketmail_profiles DROP COLUMN `id`;";
            $rename_column_query = "ALTER TABLE glpi_plugin_ticketmail_profiles\n\t\t\t\t\t\t\t\t\tCHANGE profiles_id id int(11) NOT NULL default '0'\n\t\t\t\t\t\t\t\t\tCOMMENT 'RELATION to glpi_profiles (id)';";
            $DB->queryOrDie($drop_column_query, $DB->error());
            $DB->queryOrDie($rename_column_query, $DB->error());
            $add_primarykey_query = "ALTER TABLE glpi_plugin_ticketmail_profiles\n\t\t\t\t\t\t\t\t\t ADD PRIMARY KEY (id);";
            $drop_old_index_query = "ALTER TABLE glpi_plugin_ticketmail_profiles\n\t\t\t\t\t\t\t\t\t DROP INDEX profiles_id;";
            $DB->queryOrDie($add_primarykey_query, $DB->error());
            $DB->queryOrDie($drop_old_index_query, $DB->error());
        }
    }
    return true;
}
开发者ID:geldarr,项目名称:hack-space,代码行数:26,代码来源:hook.php

示例7: update0712to0713

function update0712to0713()
{
    global $DB, $CFG_GLPI;
    if (!FieldExists("glpi_rule_cache_software", "ignore_ocs_import", false)) {
        $query = "ALTER TABLE `glpi_rule_cache_software`\n                ADD `ignore_ocs_import` VARCHAR( 255 ) NULL ";
        $DB->queryOrDie($query, "0.71.3 add ignore_ocs_import field in dictionnary cache");
    }
    // Update to longtext for fields which may be very long
    if (FieldExists("glpi_kbitems", "answer", false)) {
        if (isIndex("glpi_kbitems", "fulltext")) {
            // to avoid pb in altering column answer
            $query = "ALTER TABLE `glpi_kbitems`\n                   DROP INDEX `fulltext`";
            $DB->queryOrDie($query, "0.71.3 alter kbitem drop index Fulltext");
        }
        // field question : only to change latin1 to utf-8 if not done in update 0.68.3 to 0.71
        // before creating index fulltext based on 2 fields (perhaps both are not in same encoding)
        $query = "ALTER TABLE `glpi_kbitems`\n                CHANGE `question` `question` TEXT,\n                CHANGE `answer` `answer` LONGTEXT NULL DEFAULT NULL ";
        $DB->queryOrDie($query, "0.71.3 alter kbitem answer field to longtext");
        $query = "ALTER TABLE `glpi_kbitems`\n                ADD FULLTEXT `fulltext` (`question`,`answer`)";
        $DB->queryOrDie($query, "0.71.3 alter kbitem re-add index Fulltext");
    }
    if (FieldExists("glpi_tracking", "contents", false)) {
        $query = "ALTER TABLE `glpi_tracking`\n                CHANGE `contents` `contents` LONGTEXT NULL DEFAULT NULL ";
        $DB->queryOrDie($query, "0.71.3 alter tracking contents field to longtext");
    }
}
开发者ID:gaforeror,项目名称:glpi,代码行数:26,代码来源:update_0712_0713.php

示例8: plugin_environment_install

function plugin_environment_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/environment/inc/profile.class.php";
    $update = false;
    if (TableExists("glpi_plugin_environment_profiles") && FieldExists("glpi_plugin_environment_profiles", "interface")) {
        $update = true;
        $DB->runFile(GLPI_ROOT . "/plugins/environment/sql/update-1.3.0.sql");
        $DB->runFile(GLPI_ROOT . "/plugins/environment/sql/update-1.4.0.sql");
    } else {
        if (TableExists("glpi_plugin_environment_profiles") && FieldExists("glpi_plugin_environment_profiles", "connections")) {
            $update = true;
            $DB->runFile(GLPI_ROOT . "/plugins/environment/sql/update-1.4.0.sql");
        }
    }
    if ($update) {
        //Do One time on 0.78
        $query_ = "SELECT *\n            FROM `glpi_plugin_environment_profiles` ";
        $result_ = $DB->query($query_);
        if ($DB->numrows($result_) > 0) {
            while ($data = $DB->fetch_array($result_)) {
                $query = "UPDATE `glpi_plugin_environment_profiles`\n                  SET `profiles_id` = '" . $data["id"] . "'\n                  WHERE `id` = '" . $data["id"] . "';";
                $result = $DB->query($query);
            }
        }
        $query = "ALTER TABLE `glpi_plugin_environment_profiles`\n               DROP `name` ;";
        $result = $DB->query($query);
    }
    PluginEnvironmentProfile::initProfile();
    PluginEnvironmentProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    $migration = new Migration("1.8.0");
    $migration->dropTable('glpi_plugin_environment_profiles');
    $_SESSION["glpi_plugin_environment_installed"] = 1;
    return true;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:35,代码来源:hook.php

示例9: pluginMonitoringGetCurrentVersion

function pluginMonitoringGetCurrentVersion($version)
{
    global $DB;
    if (!TableExists("glpi_plugin_monitoring_configs")) {
        return '0';
    } else {
        if (!FieldExists("glpi_plugin_monitoring_configs", "timezones")) {
            // Version before 0.80+1.0 (test version)
            return "1.0.0";
        } else {
            if (!FieldExists("glpi_plugin_monitoring_configs", "version")) {
                return "0.80+1.0";
            } else {
                if (FieldExists("glpi_plugin_monitoring_configs", "version")) {
                    $query = "SELECT `version`\n          FROM `glpi_plugin_monitoring_configs`\n          WHERE `id` = '1'";
                    $result = $DB->query($query);
                    if ($DB->numrows($result) > 0) {
                        $data = $DB->fetch_assoc($result);
                        if ($data['version'] != $version) {
                            return $data['version'];
                        }
                    } else {
                        return "0.80+1.0";
                    }
                } else {
                    return $version;
                }
            }
        }
    }
    return $version;
}
开发者ID:RubichonL,项目名称:glpi_monitoring,代码行数:32,代码来源:update.php

示例10: install

 static function install(Migration $migration)
 {
     global $DB;
     $obj = new self();
     $table = $obj->getTable();
     if (!TableExists($table)) {
         $migration->displayMessage("Installing {$table}");
         $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n                  `id`                                INT(11)        NOT NULL auto_increment,\n                  `name`                              VARCHAR(255)   DEFAULT NULL,\n                  `label`                             VARCHAR(255)   DEFAULT NULL,\n                  `type`                              VARCHAR(25)    DEFAULT NULL,\n                  `plugin_fields_containers_id`       INT(11)        NOT NULL DEFAULT '0',\n                  `ranking`                           INT(11)        NOT NULL DEFAULT '0',\n                  `default_value`                     VARCHAR(255)   DEFAULT NULL,\n                  `is_active`                         TINYINT(1)     NOT NULL DEFAULT '1',\n                  `is_readonly`                       TINYINT(1)     NOT NULL DEFAULT '1',\n                  `mandatory`                         TINYINT(1)     NOT NULL DEFAULT '0',\n                  PRIMARY KEY                         (`id`),\n                  KEY `plugin_fields_containers_id`   (`plugin_fields_containers_id`),\n                  KEY `is_active`                     (`is_active`),\n                  KEY `is_readonly`                   (`is_readonly`)\n               ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
         $DB->query($query) or die($DB->error());
     }
     $migration->displayMessage("Updating {$table}");
     if (!FieldExists($table, 'is_active')) {
         $migration->addField($table, 'is_active', 'bool', array('value' => 1));
         $migration->addKey($table, 'is_active', 'is_active');
     }
     if (!FieldExists($table, 'is_readonly')) {
         $migration->addField($table, 'is_readonly', 'bool', array('default' => false));
         $migration->addKey($table, 'is_readonly', 'is_readonly');
     }
     if (!FieldExists($table, 'mandatory')) {
         $migration->addField($table, 'mandatory', 'bool', array('value' => 0));
     }
     $migration->executeMigration();
     return true;
 }
开发者ID:publik1974,项目名称:fields,代码行数:25,代码来源:field.class.php

示例11: initSession

 static function initSession()
 {
     global $DB;
     if (TableExists("glpi_plugin_fusioninventory_config")) {
         if (FieldExists("glpi_plugin_fusioninventory_config", "ID")) {
             $profile = new PluginFusioninventoryProfile();
             $query = "SELECT DISTINCT `glpi_profiles`.*\n                      FROM `glpi_users_profiles` INNER JOIN `glpi_profiles`\n                           ON (`glpi_users_profiles`.`FK_profiles` = `glpi_profiles`.`ID`)\n                      WHERE `glpi_users_profiles`.`FK_users`='" . $_SESSION["glpiID"] . "'";
             $result = $DB->query($query);
             $_SESSION['glpi_plugin_fusioninventory_profile'] = array();
             if ($DB->numrows($result)) {
                 while ($data = $DB->fetch_assoc($result)) {
                     $profile->fields = array();
                     if (isset($_SESSION["glpiactiveprofile"]["ID"])) {
                         $profile->getFromDB($_SESSION["glpiactiveprofile"]["ID"]);
                         $_SESSION['glpi_plugin_fusioninventory_profile'] = $profile->fields;
                     } else {
                         $profile->getFromDB($data['ID']);
                         $_SESSION['glpi_plugin_fusioninventory_profile'] = $profile->fields;
                     }
                     $_SESSION["glpi_plugin_fusioninventory_installed"] = 1;
                 }
             }
         }
     }
 }
开发者ID:Hawke,项目名称:fusioninventory-for-glpi,代码行数:25,代码来源:auth.class.php

示例12: plugin_timezones_install

/**
 * Summary of plugin_timezones_install
 * @return true or die!
 */
function plugin_timezones_install()
{
    global $DB;
    if (!TableExists("glpi_plugin_timezones_users")) {
        $query = "  CREATE TABLE `glpi_plugin_timezones_users` (\r\n\t                    `id` INT(11) NOT NULL AUTO_INCREMENT,\r\n\t                    `users_id` INT(11) NOT NULL,\r\n\t                    `timezone` VARCHAR(50) NOT NULL,\r\n\t                    PRIMARY KEY (`id`),\r\n\t                    UNIQUE INDEX `users_id` (`users_id`),\r\n\t                    INDEX `timezone` (`timezone`)\r\n                    )\r\n                    COLLATE='utf8_general_ci'\r\n                    ENGINE=InnoDB                    \r\n                    ;\r\n\t\t\t";
        $DB->query($query) or die("error creating glpi_plugin_timezones_users" . $DB->error());
    } else {
        if (!FieldExists("glpi_plugin_timezones_users", "users_id")) {
            $query = "  ALTER TABLE `glpi_plugin_timezones_users`\r\n\t                    ADD COLUMN `id` INT(11) NOT NULL AUTO_INCREMENT FIRST,\r\n\t                    CHANGE COLUMN `id` `users_id` INT(11) NOT NULL AFTER `id`,\r\n\t                    DROP PRIMARY KEY,\r\n\t                    ADD PRIMARY KEY (`id`),\r\n\t                    ADD UNIQUE INDEX `users_id` (`users_id`);\r\n                ";
            $DB->query($query) or die("error altering glpi_plugin_timezones_users" . $DB->error());
        }
    }
    if (!TableExists("glpi_plugin_timezones_dbbackups")) {
        $query = "  CREATE TABLE `glpi_plugin_timezones_dbbackups` (\r\n\t                `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\n\t                `table_name` VARCHAR(255) NULL ,\r\n\t                `alter_table` TEXT NULL\r\n                )\r\n                COLLATE='utf8_general_ci'\r\n                ENGINE=InnoDB;\r\n\t\t\t";
        $DB->query($query) or die("error creating glpi_plugin_timezones_dbbackups" . $DB->error());
    }
    if (!TableExists("glpi_plugin_timezones_tasks_localtimes")) {
        $query = " CREATE TABLE `glpi_plugin_timezones_tasks_localtimes` (\r\n\t                    `id` INT(11) NOT NULL AUTO_INCREMENT,\r\n\t                    `items_type` VARCHAR(50) NOT NULL,\r\n\t                    `items_id` INT(11) NOT NULL,\r\n\t                    `begin` VARCHAR(20) NULL DEFAULT NULL COMMENT 'In order to keep local time',\r\n\t                    `end` VARCHAR(20) NULL DEFAULT NULL COMMENT 'In order to keep local time',\r\n\t                    PRIMARY KEY (`id`),\r\n\t                    UNIQUE INDEX `items_type_items_id` (`items_type`, `items_id`)\r\n                    )\r\n                    COLLATE='utf8_general_ci'\r\n                    ENGINE=InnoDB\r\n                    ;\r\n\t\t\t";
        $DB->query($query) or die("error creating glpi_plugin_timezones_tasks_localtimes" . $DB->error());
    }
    // here we update the time_zones mySQL tables.
    // with data from PHP module: php_timezonedb. See: https://pecl.php.net/package/timezonedb
    //$query = "TRUNCATE `mysql`.`time_zone`;";
    //$DB->query( $query ) or die("error truncating mysql.time_zone" . $DB->error());
    //$query = "TRUNCATE `mysql`.`time_zone_name`;";
    //$DB->query( $query ) or die("error truncating mysql.time_zonetime_zone_name" . $DB->error());
    //$query = "TRUNCATE `mysql`.`time_zone_transition`;";
    //$DB->query( $query ) or die("error truncating mysql.time_zone_transition" . $DB->error());
    //$query = "TRUNCATE `mysql`.`time_zone_transition_type`;";
    //$DB->query( $query ) or die("error truncating mysql.time_zone_transition_type" . $DB->error());
    //$query = "TRUNCATE `mysql`.`time_zone_leap_second`;";
    //$DB->query( $query ) or die("error truncating mysql.time_zone_leap_second" . $DB->error());
    //    $timezones = DateTimeZone::listIdentifiers( ) ;
    //    foreach( $timezones as $key => $tz ){
    //        $key++ ;
    //        // time_zone
    //        $query = "INSERT INTO `mysql`.`time_zone` (`Time_zone_id`, `Use_leap_seconds`) VALUES ($key, 'N');";
    //        $DB->query( $query ) or die("error inserting data into mysql.time_zone" . $DB->error());
    //        $query = "INSERT INTO `mysql`.`time_zone_name` (`Name`, `Time_zone_id`) VALUES ('$tz', $key);";
    //        $DB->query( $query ) or die("error inserting data into mysql.time_zone_name" . $DB->error());
    //        $tz_trans = (new DateTimeZone( $tz ))->getTransitions() ;
    //        $trans_array = array( ) ;
    //        $trans_type_id=0;
    //        foreach($tz_trans as $key_trans => $trans) {
    //            $trans_key = $trans['offset'].", ".($trans['isdst']?1:0).", '".$trans['abbr']."'";
    //            if( !in_array( $trans_key, $trans_array ) ){
    //                $trans_array[$trans_type_id++] = $trans_key ;
    //            }
    //            $query = "REPLACE INTO `mysql`.`time_zone_transition` (`Time_zone_id`, `Transition_time`, `Transition_type_id`) VALUES ($key, ".$trans['ts'].", ".$trans_type_id.");" ;
    //            $DB->query( $query ) or die("error inserting data into mysql.time_zone_transition" . $DB->error());
    //        }
    //        foreach( $trans_array as $trans_type_id => $trans_key ){
    //            $trans_type_id++;
    //            $query = "INSERT INTO `mysql`.`time_zone_transition_type` (`Time_zone_id`, `Transition_type_id`, `Offset`, `Is_DST`, `Abbreviation`) VALUES ($key, $trans_type_id, $trans_key);";
    //            $DB->query( $query ) or die("error inserting data into mysql.time_zone_transition_type" . $DB->error());
    //        }
    //    }
    return true;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:63,代码来源:hook.php

示例13: setUp

   protected function setUp() {
      global $DB;
      
      $DB->connect();

      // Store Max(id) for each glpi tables
      $result = $DB->list_tables();
      while ($data=$DB->fetch_row($result)) {
         $query = "SELECT MAX(`id`) AS MAXID
                   FROM `".$data[0]."`";
         foreach ($DB->request($query) as $row) {
            $this->tables[$data[0]] = (empty($row['MAXID']) ? 0 : $row['MAXID']);
         }
      }
      $DB->free_result($result);

      $tab  = array();
      $auth = new Auth();
      // First session
      $auth->Login('glpi', 'glpi') ;

      // Create entity tree
      $entity = new Entity();
      $tab['entity'][0] = $entity->add(array('name' => 'PHP Unit root',
                                             'entities_id' => 0));

      if (!$tab['entity'][0]                                   // Crash detection
          || !FieldExists('glpi_profiles','notification')   // Schema detection
          || countElementsInTable('glpi_rules')!=6) {    // Old rules

         if (!$tab['entity'][0]) {
            echo "Couldn't run test (previous run not cleaned)\n";
         } else {
            echo "Schema need to be updated\n";
         }
         echo "Loading a fresh empty database:";
         $DB->runFile(GLPI_ROOT ."/install/mysql/glpi-0.84-empty.sql");
         die(" done\nTry again\n");
      }

      $tab['entity'][1] = $entity->add(array('name'        => 'PHP Unit Child 1',
                                             'entities_id' => $tab['entity'][0]));

      $tab['entity'][2] = $entity->add(array('name'        => 'PHP Unit Child 2',
                                             'entities_id' => $tab['entity'][0]));

      $tab['entity'][3] = $entity->add(array('name'        => 'PHP Unit Child 2.1',
                                             'entities_id' => $tab['entity'][2]));

      $tab['entity'][4] = $entity->add(array('name'        => 'PHP Unit Child 2.2',
                                             'entities_id' => $tab['entity'][2]));

      // New session with all the entities
      $auth->Login('glpi', 'glpi') or die("Login glpi/glpi invalid !\n");

      // Shared this with all tests
      $this->sharedFixture = $tab;
   }
开发者ID:KaneoGmbH,项目名称:glpi,代码行数:58,代码来源:AllTests.php

示例14: update078to0781

/**
 * Update from 0.78 to 0.78.1
 *
 * @return bool for success (will die for most error)
 */
function update078to0781()
{
    global $DB, $migration;
    $updateresult = true;
    $migration->displayTitle(sprintf(__('Update to %s'), '0.78.1'));
    $migration->setVersion('0.78.1');
    //TRANS: %s is 'Clean reservation entity link'
    $migration->displayMessage(sprintf(__('Data migration - %s'), 'Clean reservation entity link'));
    // Updating schema
    $entities = getAllDatasFromTable('glpi_entities');
    $entities[0] = "Root";
    $query = "SELECT DISTINCT `itemtype` FROM `glpi_reservationitems`";
    if ($result = $DB->query($query)) {
        if ($DB->numrows($result) > 0) {
            while ($data = $DB->fetch_assoc($result)) {
                $itemtable = getTableForItemType($data['itemtype']);
                // ajout d'un contrôle pour voir si la table existe ( cas migration plugin non fait)
                if (!TableExists($itemtable)) {
                    $migration->displayWarning("*** Skip : no table {$itemtable} ***", true);
                    continue;
                }
                $do_recursive = false;
                if (FieldExists($itemtable, 'is_recursive', false)) {
                    $do_recursive = true;
                }
                foreach ($entities as $entID => $val) {
                    if ($do_recursive) {
                        // Non recursive ones
                        $query3 = "UPDATE `glpi_reservationitems`\n                           SET `entities_id`={$entID}, `is_recursive`=0\n                           WHERE `itemtype`='" . $data['itemtype'] . "'\n                              AND `items_id` IN (SELECT `id` FROM `{$itemtable}`\n                              WHERE `entities_id`={$entID} AND `is_recursive`=0)";
                        $DB->queryOrDie($query3, "0.78.1 update entities_id and is_recursive=0 in glpi_reservationitems for " . $data['itemtype']);
                        // Recursive ones
                        $query3 = "UPDATE `glpi_reservationitems`\n                           SET `entities_id`={$entID}, `is_recursive`=1\n                           WHERE `itemtype`='" . $data['itemtype'] . "'\n                              AND `items_id` IN (SELECT `id` FROM `{$itemtable}`\n                              WHERE `entities_id`={$entID} AND `is_recursive`=1)";
                        $DB->queryOrDie($query3, "0.78.1 update entities_id and is_recursive=1 in glpi_reservationitems for " . $data['itemtype']);
                    } else {
                        $query3 = "UPDATE `glpi_reservationitems`\n                           SET `entities_id`={$entID}\n                           WHERE `itemtype`='" . $data['itemtype'] . "'\n                              AND `items_id` IN (SELECT `id` FROM `{$itemtable}`\n                              WHERE `entities_id`={$entID})";
                        $DB->queryOrDie($query3, "0.78.1 update entities_id in glpi_reservationitems for " . $data['itemtype']);
                    }
                }
            }
        }
    }
    $query = "ALTER TABLE `glpi_tickets`\n             CHANGE `global_validation` `global_validation` VARCHAR(255) DEFAULT 'none'";
    $DB->query($query) or die("0.78.1 change ticket global_validation default state");
    $query = "UPDATE `glpi_tickets`\n             SET `global_validation`='none'\n             WHERE `id` NOT IN (SELECT DISTINCT `tickets_id`\n                                FROM `glpi_ticketvalidations`)";
    $DB->query($query) or die("0.78.1 update ticket global_validation state");
    if (!FieldExists('glpi_knowbaseitemcategories', 'entities_id', false)) {
        $query = "ALTER TABLE `glpi_knowbaseitemcategories`\n                    ADD `entities_id` INT NOT NULL DEFAULT '0' AFTER `id`,\n                    ADD `is_recursive` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `entities_id`,\n                    ADD INDEX `entities_id` (`entities_id`),ADD INDEX `is_recursive` (`is_recursive`)";
        $DB->queryOrDie($query, "0.78.1 add entities_id,is_recursive in glpi_knowbaseitemcategories");
        // Set existing categories recursive global
        $query = "UPDATE `glpi_knowbaseitemcategories` SET `is_recursive` = '1'";
        $DB->queryOrDie($query, "0.78.1 set value of is_recursive in glpi_knowbaseitemcategories");
        $query = "ALTER TABLE `glpi_knowbaseitemcategories` DROP INDEX `unicity` ,\n               ADD UNIQUE `unicity` ( `entities_id`, `knowbaseitemcategories_id` , `name` ) ";
        $DB->queryOrDie($query, "0.78.1 update unicity index on glpi_knowbaseitemcategories");
    }
    // must always be at the end (only for end message)
    $migration->executeMigration();
    return $updateresult;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:63,代码来源:update_078_0781.php

示例15: plugin_addressing_install

function plugin_addressing_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/addressing/inc/profile.class.php";
    $update = false;
    if (!TableExists("glpi_plugin_addressing_display") && !TableExists("glpi_plugin_addressing") && !TableExists("glpi_plugin_addressing_configs")) {
        $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/empty-2.0.0.sql");
    } else {
        if (!TableExists("glpi_plugin_addressing_profiles") && TableExists("glpi_plugin_addressing_display") && !FieldExists("glpi_plugin_addressing_display", "ipconf1")) {
            //1.4
            $update = true;
            $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.4.sql");
        }
        if (!TableExists("glpi_plugin_addressing") && TableExists("glpi_plugin_addressing_display") && FieldExists("glpi_plugin_addressing_display", "ipconf1")) {
            $update = true;
            $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.5.sql");
        }
        if (TableExists("glpi_plugin_addressing_display") && !FieldExists("glpi_plugin_addressing", "ipdeb")) {
            $update = true;
            $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.6.sql");
        }
        if (TableExists("glpi_plugin_addressing_profiles") && FieldExists("glpi_plugin_addressing_profiles", "interface")) {
            $update = true;
            $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.7.0.sql");
        }
        if (!TableExists("glpi_plugin_addressing_configs")) {
            $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.8.0.sql");
            $update = true;
        }
        if (TableExists("glpi_plugin_addressing_profiles") && !FieldExists("glpi_plugin_addressing_profiles", "use_ping_in_equipment")) {
            $DB->runFile(GLPI_ROOT . "/plugins/addressing/sql/update-1.9.0.sql");
            $update = true;
        }
    }
    if ($update) {
        $query_ = "SELECT *\n                  FROM `glpi_plugin_addressing_profiles` ";
        $result_ = $DB->query($query_);
        if ($DB->numrows($result_) > 0) {
            while ($data = $DB->fetch_array($result_)) {
                $query = "UPDATE `glpi_plugin_addressing_profiles`\n                      SET `profiles_id` = '" . $data["id"] . "'\n                      WHERE `id` = '" . $data["id"] . "'";
                $result = $DB->query($query);
            }
        }
        if (FieldExists("glpi_plugin_addressing_profiles", "name")) {
            $query = "ALTER TABLE `glpi_plugin_addressing_profiles`\n                    DROP `name` ";
            $result = $DB->query($query);
        }
        Plugin::migrateItemType(array(5000 => 'PluginAddressingAddressing', 5001 => 'PluginAddressingReport'), array("glpi_bookmarks", "glpi_bookmarks_users", "glpi_displaypreferences", "glpi_documents_items", "glpi_infocoms", "glpi_logs", "glpi_items_tickets"));
    }
    //0.85 : new profile system
    PluginAddressingProfile::migrateProfiles();
    //Add all rights for current user profile
    PluginAddressingProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    //Drop old profile table : not used anymore
    $migration = new Migration("2.2.0");
    $migration->dropTable('glpi_plugin_addressing_profiles');
    return true;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:58,代码来源:hook.php


注:本文中的FieldExists函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。