⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upgradefunctions.inc.php.tmp

📁 PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。
💻 TMP
📖 第 1 页 / 共 5 页
字号:
<?php/** * $Id$ * * KnowledgeTree Community Edition * Document Management Made Simple * Copyright (C) 2008 KnowledgeTree Inc. * Portions copyright The Jam Warehouse Software (Pty) Limited * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. * * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>. * * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, * California 94120-7775, or email info@knowledgetree.com. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices * must display the words "Powered by KnowledgeTree" and retain the original * copyright notice. * Contributor( s): ______________________________________ * *///debugger_start_debug();require_once(KT_LIB_DIR . '/upgrades/Ini.inc.php');require_once(KT_DIR . '/plugins/ktcore/scheduler/scheduler.php');require_once(KT_LIB_DIR . '/database/schema.inc.php');class UpgradeFunctions {    var $upgrades = array(            '2.0.0' => array('setPermissionFolder'),            '2.0.6' => array('addTemplateMimeTypes'),            '2.0.8' => array('setPermissionObject'),            '2.99.1' => array('createFieldSets'),            '2.99.7' => array('normaliseDocuments', 'applyDiscussionUpgrade'),            '2.99.8' => array('fixUnits'),            '2.99.9' => array('createLdapAuthenticationProvider', 'createSecurityDeletePermissions'),            '3.0.1.3' => array('addTransactionTypes3013'),            '3.0.1.4' => array('createWorkflowPermission'),            '3.0.2' => array('fixDocumentRoleAllocation'),            '3.0.3.2' => array('createFolderDetailsPermission'),            '3.0.3.3' => array('generateWorkflowTriggers'),            '3.0.3.7' => array('rebuildAllPermissions'),            '3.1.5' => array('upgradeSavedSearches'),            '3.1.6.3' => array('cleanupGroupMembership'),            '3.5.0' => array('cleanupOldKTAdminVersionNotifier', 'updateConfigFile35', 'registerIndexingTasks'),            '3.5.2' => array('setStorageEngine','dropForeignKeys','dropPrimaryKeys','dropIndexes','createPrimaryKeys','createForeignKeys','createIndexes', 'removeSlashesFromObjects'),            '3.5.3' => array('moveConfigSettingsToDB','removeAdminVersionNotifier','removeOldSearchPlugins','addAutoIncrementToTables', 'addAutoIncrementToTables2')            );    var $descriptions = array(            "rebuildSearchPermissions" => "Rebuild search permissions with updated algorithm",            "setPermissionFolder" => "Set permission folder for each folder for simplified permissions management",            "addTemplateMimeTypes" => "Add MIME types for Excel and Word templates",            "setPermissionObject" => "Set the permission object in charge of a document or folder",            "createFieldSets" => "Create a fieldset for each field without one",            "normaliseDocuments" => "Normalise the documents table",            "createLdapAuthenticationProvider" => "Create an LDAP authentication source based on your KT2 LDAP settings (must keep copy of config/environment.php to work)",            'createSecurityDeletePermissions' => 'Create the Core: Manage Security and Core: Delete permissions',            'addTransactionTypes3013' => 'Add new folder transaction types',            'createWorkflowPermission' => 'Create the Core: Manage Workflow',            'fixDocumentRoleAllocation' => 'Fix the document role allocation upgrade from 3.0.1',            'createFolderDetailsPermission' => 'Create the Core: Folder Details permission',            'generateWorkflowTriggers' => 'Migrate old in-transition guards to triggers',            'rebuildAllPermissions' => 'Rebuild all permissions to ensure correct functioning of permission-definitions.',            'upgradeSavedSearches' => 'Upgrade saved searches to use namespaces instead of integer ids',            'cleanupGroupMembership' => 'Cleanup any old references to missing groups, etc.',            'cleanupOldKTAdminVersionNotifier' => 'Cleanup any old files from the old KTAdminVersionNotifier',            'updateConfigFile35' => 'Update the config.ini file for 3.5',            'registerIndexingTasks'=>'Register the required indexing background tasks',            'setStorageEngine'=>'Recreate db integrity: Set storage engine to InnoDB for transaction safety',            'dropForeignKeys'=>'Recreate db integrity: Drop foreign keys on the database',            'dropPrimaryKeys'=>'Recreate db integrity:Drop primary keys on the database',            'dropIndexes'=>'Recreate db integrity:Drop indexes on the database',            'createPrimaryKeys'=>'Recreate db integrity:Create primary keys on the database',            'createForeignKeys'=>'Recreate db integrity:Create foreign keys on the database',            'createIndexes'=>'Recreate db integrity:Create indexes on the database',            'removeSlashesFromObjects'=>'Remove slashes from documents and folders',            'moveConfigSettingsToDB' => 'Move the configuration settings from the config.ini file into the new database table.',            'removeAdminVersionNotifier' => 'Remove the old Admin Version Notifier Plugin.',            'removeOldSearchPlugins' => 'Remove the old Search Plugins.',            'addAutoIncrementToTables' => 'Update all current db tables to use auto_increment.',            'addAutoIncrementToTables2' => 'Update all new db tables to use auto_increment.'            );    var $phases = array(            "setPermissionFolder" => 1,            "setPermissionObject" => 1,            "createFieldSets" => 1,            "normaliseDocuments" => 1,            "fixUnits" => 1,            'applyDiscussionUpgrade' => -1,            'fixDocumentRoleAllocation' => -1,            'setStorageEngine'=>1,            'dropForeignKeys'=>2,            'dropPrimaryKeys'=>3,            'dropIndexes'=>4,            'createPrimaryKeys'=>5,            'createForeignKeys'=>6,            'createIndexes'=>7            );    var $priority = array(            'addAutoIncrementToTables'=>1,            'addAutoIncrementToTables2'=>-1            );    function addAutoIncrementToTables2()    {        return self::addAutoIncrementToTables();    }    /**     * Set all tables in the DB to auto increment, thereby removing the use of the zseq tables     */    function addAutoIncrementToTables()    {        static $doneTables = array();        global $default;		DBUtil::setupAdminDatabase();		$db = $default->_admindb;        // Get all tables in the database        $query = "SHOW TABLES";        $tableList = DBUtil::getResultArray($query, $db);        // Loop through tables and add auto increment        foreach ($tableList as $tableArr){            $key = key($tableArr);            $tableName = $tableArr[$key];            if(in_array($tableName, $doneTables)){                // already been set - skip                continue;            }            $doneTables[] = $tableName;            if(strpos($tableName, 'zseq_', 0) !== false){                // ignore zseq tables                continue;            }            $query = "SELECT max(id) FROM {$tableName}";            $aId = DBUtil::getOneResult($query);            // If there's no result, then the table may be empty            if(!PEAR::isError($aId)){                $id = (int)$aId['max(id)'] + 1;                $query = "UPDATE {$tableName} SET id = {$id} WHERE id = 0";                $res = DBUtil::runQuery($query, $db);            }else{                $default->log->error('Add auto_increment, fail on get max id: '.$aId->getMessage());            }            // Update the table, set id to auto_increment            $query = "ALTER TABLE {$tableName} CHANGE `id` `id` int (11) NOT NULL AUTO_INCREMENT";            $res = DBUtil::runQuery($query, $db);            if(PEAR::isError($res)){                $default->log->error('Add auto_increment, fail on change id to auto_increment: '.$res->getMessage());                // try again with mediumint                $query = "ALTER TABLE {$tableName} CHANGE `id` `id` mediumint (9) NOT NULL AUTO_INCREMENT";                $res = DBUtil::runQuery($query, $db);            }        }    }    /**     * Copy the modified config values from the config.ini to the appropriate setting in the database     */    function moveConfigSettingsToDB()    {        require_once('Config.php');        // Get config settings from config.ini        $oKTConfig = KTConfig::getSingleton();        $configPath = $oKTConfig->getConfigFilename();		$c = new Config;        $root =& $c->parseConfig($configPath, "IniCommented");        if (PEAR::isError($root)) {            return $root;        }        $confRoot = $root->toArray();        $conf = $confRoot['root'];        // Get the default settings from the database        $query = "SELECT id, s.group_name, s.item, s.value, s.default_value            FROM config_settings s            ORDER BY group_name, item";		$settings = DBUtil::getResultArray($query);		if(PEAR::isError($settings)){		    return $settings;		}        // update the settings in the database if not set to default or equal to the default value        foreach ($settings as $item){            if(!isset($conf[$item['group_name']][$item['item']])){                continue; // Don't overwrite the default with a null value            }            $confValue = $conf[$item['group_name']][$item['item']];            if($confValue == 'default'){                continue; // skip over if its set to default            }            if($confValue == $item['value']){                continue; // skip over if it already has the same value            }            if($confValue == $item['default_value']){                if($item['value'] == 'default' || $item['value'] == $item['default_value']){                    continue; // skip over if it has the same value as the default value                }                // Set the value to default                $confValue = 'default';            }            // Update the setting            $res = DBUtil::autoUpdate('config_settings', array('value' => $confValue), $item['id']);            if(PEAR::isError($res)){                return $res;            }        }        return true;    }    function dropForeignKeys()    {		$schemautil = KTSchemaUtil::getSingleton();		$schemautil->dropForeignKeys();    }    function dropPrimaryKeys()    {		$schemautil = KTSchemaUtil::getSingleton();		$schemautil->dropPrimaryKeys();    }    function dropIndexes()    {		$schemautil = KTSchemaUtil::getSingleton();		$schemautil->dropIndexes();    }    function createPrimaryKeys()    {		$schemautil = KTSchemaUtil::getSingleton();		$schemautil->createPrimaryKeys();    }    function createForeignKeys()    {		$schemautil = KTSchemaUtil::getSingleton();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -