📄 upgradefunctions.inc.php
字号:
if (PEAR::isError($res)) {
return $res;
} else {
$bad_group_links = kt_array_merge($bad_group_links, $res);
}
foreach ($bad_group_links as $link_id) {
$res = DBUtil::runQuery(array("DELETE FROM groups_groups_link WHERE id = ?", $link_id));
if (PEAR::isError($res)) {
return $res;
}
}
$res = DBUtil::getResultArrayKey(array($group_query, null), 'link_id');
if (PEAR::isError($res)) {
return $res;
} else {
$bad_user_links = $res;
}
$res = DBUtil::getResultArrayKey(array($user_query, null), 'link_id');
if (PEAR::isError($res)) {
return $res;
} else {
$bad_user_links = kt_array_merge($bad_user_links, $res);
}
foreach ($bad_user_links as $link_id) {
$res = DBUtil::runQuery(array("DELETE FROM users_groups_link WHERE id = ?", $link_id));
if (PEAR::isError($res)) {
return $res;
}
}
return true;
}
// }}}
// {{{ cleanupOldKTAdminVersionNotifier
function cleanupOldKTAdminVersionNotifier() {
global $default;
$oldFile = KT_DIR . "/plugins/ktstandard/KTAdminVersionPlugin.php";
if(file_exists($oldFile)) return unlink($oldFile);
return true;
}
// }}}
// {{{ updateConfigFile35
function updateConfigFile35()
{
// The following is no longer needed due to defaults now being in place.
// It also was corrupting the file "sometimes".
// We leave the function in but do nothing so we don't mess with the upgrades table.
return;
/* $config = KTConfig::getSingleton();
$configPath = KTConfig::getConfigFilename();
$configPath = str_replace(array("\n","\r"), array('',''), $configPath);
if(file_exists($configPath)) {
$ini = new Ini($configPath);
// Webservices Section
$ini->addItem('webservice', 'uploadDirectory', '${varDirectory}/uploads');
$ini->addItem('webservice', 'downloadUrl', '${rootUrl}/ktwebservice/download.php');
$ini->addItem('webservice', 'uploadExpiry', '30');
$ini->addItem('webservice', 'downloadExpiry', '30');
$ini->addItem('webservice', 'randomKeyText', 'bkdfjhg23yskjdhf2iu');
$ini->addItem('webservice', 'validateSessionCount', 'false');
// externalBinary Section
$ini->delSection('externalBinary');
if(OS_WINDOWS){
$ini->addItem('externalBinary', 'xls2csv', KT_STACK_DIR . '/bin/catdoc/xls2csv.exe', '', 'The following are external binaries that may be used by various parts of knowledgeTree.');
$ini->addItem('externalBinary', 'pdftotext', KT_STACK_DIR . '/bin/xpdf/pdftotext.exe');
$ini->addItem('externalBinary', 'catppt', KT_STACK_DIR . '/bin/catdoc/catppt.exe');
$ini->addItem('externalBinary', 'pstotext', KT_STACK_DIR . '/bin/pstotext/pstotext.exe');
$ini->addItem('externalBinary', 'catdoc', KT_STACK_DIR . '/bin/catdoc/catdoc.exe');
$ini->addItem('externalBinary', 'antiword', KT_STACK_DIR . '/bin/antiword/antiword.exe');
$ini->addItem('externalBinary', 'python', KT_STACK_DIR . '/openoffice/program/python.bat');
$ini->addItem('externalBinary', 'java', KT_STACK_DIR . '/java/jre/bin/java.exe');
$ini->addItem('externalBinary', 'php', KT_STACK_DIR . '/php/php.exe');
$ini->addItem('externalBinary', 'df', KT_STACK_DIR . '/bin/gnuwin32/df.exe');
} else {
$ini->addItem('externalBinary', 'xls2csv', KT_STACK_DIR . '/common/bin/xls2csv', '', 'The following are external binaries that may be used by various parts of knowledgeTree.');
$ini->addItem('externalBinary', 'pdftotext', KT_STACK_DIR . '/common/bin/pdftotext');
$ini->addItem('externalBinary', 'catppt', KT_STACK_DIR . '/common/bin/catppt');
$ini->addItem('externalBinary', 'pstotext', KT_STACK_DIR . '/common/bin/pstotext');
$ini->addItem('externalBinary', 'catdoc', KT_STACK_DIR . '/common/bin/catdoc');
$ini->addItem('externalBinary', 'antiword', KT_STACK_DIR . '/common/bin/antiword');
$ini->addItem('externalBinary', 'python', KT_STACK_DIR . '/openoffice/program/python');
$ini->addItem('externalBinary', 'java', KT_STACK_DIR . '/java/jre/bin/java');
$ini->addItem('externalBinary', 'php', KT_STACK_DIR . '/php/bin/php');
$ini->addItem('externalBinary', 'df', ';'. KT_STACK_DIR . '/common/bin/df');
}
// search Section
$ini->addItem('search', 'resultsPerPage', 'default', "The number of results per page\r\n; defaults to 25");
$ini->addItem('search', 'dateFormat', 'default', "The date format used when making queries using widgets\r\n; defaults to Y-m-d");
// indexer Section
$ini->addItem('indexer', 'coreClass', 'JavaXMLRPCLuceneIndexer', "The core indexing class\r\n;coreClass=PHPLuceneIndexer");
$ini->addItem('indexer', 'batchDocuments', 'default', "The number of documents to be indexed in a cron session\r\n; defaults to 20");
$ini->addItem('indexer', 'batchMigrateDocuments', 'default', "The number of documents to be migrated in a cron session\r\n; defaults to 500");
$ini->addItem('indexer', 'luceneDirectory', '${varDirectory}/indexes', "The location of the lucene indexes");
$ini->addItem('indexer', 'javaLuceneURL', 'default', "The url for the Java Lucene Server. This should match up with the Lucene Server configuration.\r\n; defaults to http://127.0.0.1:8875");
// openoffice Section
$ini->addItem('openoffice', 'host', 'default', "The host on which open office is installed\r\n; defaults to 127.0.0.1");
$ini->addItem('openoffice', 'port', 'default', "The port on which open office is listening\r\n; defaults to 8100");
// user_prefs Section
$ini->addItem('user_prefs', 'passwordLength', '6', "The minimum password length on password-setting\r\n; could be moved into DB-auth-config");
$ini->addItem('user_prefs', 'restrictAdminPasswords', 'default', "Apply the minimum password length to admin while creating / editing accounts?\r\n; default is set to \"false\" meaning that admins can create users with shorter passwords.");
$ini->addItem('user_prefs', 'restrictPreferences', 'false', "Restrict users from accessing their preferences menus?");
// builtinauth Section
$ini->addItem('builtinauth', 'password_change_interval', '30', "This would force users that use the built-in authentication provider\r\n; to have to change their passwords every 30 days." ,"This is configuration for the built-in authentication provider");
// cache Section
if(OS_WINDOWS){
$ini->addItem('cache', 'cacheEnabled', 'false', '', "Enable/disable the cache and set the cache location");
} else {
$ini->addItem('cache', 'cacheEnabled', 'true', '', "Enable/disable the cache and set the cache location");
}
$ini->addItem('cache', 'cacheDirectory', '${varDirectory}/cache');
$ini->addItem('cache', 'cachePlugins', 'true');
// KTWebDAVSettings Section
$ini->addItem('KTWebDAVSettings', 'debug', 'off', '_LOTS_ of debug info will be logged if the following is "on"', 'This section is for KTWebDAV only');
$ini->addItem('KTWebDAVSettings', 'safemode', 'on', 'To allow write access to WebDAV clients set safe mode to "off" below');
// BaobabSettings Section
$ini->addItem('BaobabSettings', 'debug', 'off', '_LOTS_ of debug info will be logged if the following is "on"', 'This section is for Boabab only');
$ini->addItem('BaobabSettings', 'safemode', 'on', 'To allow write access to WebDAV clients set safe mode to "off" below');
// backup Section
$ini->addItem('backup', 'backupDirectory', 'default', "Identify location of kt-backup for database backups\r\n;backupDirectory = c:/kt-backups\r\n;backupDirectory = /tmp/kt-backups");
$ini->addItem('backup', 'mysqlDirectory', 'default', "Identify the location of the mysql.exe and mysqldump.exe\r\n;mysqlDirectory = c:/program files/ktdms/mysql/bin");
// clientToolPolicies Section
$ini->addItem('clientToolPolicies', 'explorerMetadataCapture', 'true', "These two settings control whether or not the client is prompted for metadata when a\r\n;document is added to knowledgetree via KTtools. They default to true.");
$ini->addItem('clientToolPolicies', 'officeMetadataCapture', 'true');
$ini->addItem('clientToolPolicies', 'captureReasonsDelete', 'true', "These settings govern whether reasons are asked for in KTtools.");
$ini->addItem('clientToolPolicies', 'captureReasonsCheckin', 'true');
$ini->addItem('clientToolPolicies', 'captureReasonsCheckout', 'true');
$ini->addItem('clientToolPolicies', 'captureReasonsCancelCheckout', 'true');
$ini->addItem('clientToolPolicies', 'captureReasonsCopyInKT', 'true');
$ini->addItem('clientToolPolicies', 'captureReasonsMoveInKT', 'true');
$ini->addItem('clientToolPolicies', 'allowRememberPassword', 'true');
// DiskUsage Section
$ini->addItem('DiskUsage', 'warningThreshold', '10', "When free space in a mount point is less than this percentage,\r\n; the disk usage dashlet will highlight the mount in ORANGE", "settings for the Disk Usage dashlet");
$ini->addItem('DiskUsage', 'urgentThreshold', '5', "When free space in a mount point is less than this percentage,\r\n; the disk usage dashlet will highlight the mount in RED");
// CustomErrorMessages Section
$ini->addItem('CustomErrorMessages', 'customerrormessages', 'on', 'Turn custom error messages on or off here (account wide)');
$ini->addItem('CustomErrorMessages', 'customerrorpagepath', 'customerrorpage.php', 'Name or url of custom error page');
$ini->addItem('CustomErrorMessages', 'customerrorhandler', 'on', 'Turn custom error handler on or off');
// URLS Section
$ini->delSection('urls');
$ini->addItem('urls', 'varDirectory', '"'.str_replace('\\', '/', $config->get("urls/varDirectory")).'"', 'directories');
$ini->addItem('urls', 'logDirectory', '${varDirectory}/log');
$ini->addItem('urls', 'documentRoot', '"'.str_replace('\\', '/', $config->get("urls/documentRoot")).'"');
$ini->addItem('urls', 'uiDirectory', '${fileSystemRoot}/presentation/lookAndFeel/knowledgeTree');
$ini->addItem('urls', 'tmpDirectory', '${varDirectory}/tmp');
$ini->addItem('urls', 'graphicsUrl', '${rootUrl}/graphics', 'urls');
$ini->addItem('urls', 'uiUrl', '${rootUrl}/presentation/lookAndFeel/knowledgeTree');
$ini->addItem('urls', ';dedicatedrsstitle', 'RSS Feed Title', 'RSS dedicated feed url');
$ini->addItem('urls', ';dedicatedrssurl', '');
$ini->addItem('urls', 'stopwordsFile', '${fileSystemRoot}/config/stopwords.txt', 'files');
$ini->write();
}
*/
}
// }}}
// {{{ registerIndexingTasks
/**
* Registers the functions that are required by the indexing sub-system.
*
*/
function registerIndexingTasks()
{
$ext = OS_WINDOWS?'bat':'sh';
$year = date('Y');
$mon = date('m');
$day = date('d');
$hour = date('H');
$min = date('i');
$min = floor( $min / 5) * 5;
$oScheduler = new Scheduler('Indexing');
$oScheduler->setScriptPath(KT_DIR . '/bin/indexingTask.' . $ext);
$oScheduler->setFrequency('1min');
$oScheduler->setFirstRunTime(date('Y-m-d H:i',mktime($hour, $min, 0, $mon, $day, $year)));
$oScheduler->registerTask();
$oScheduler = new Scheduler('Index Migration');
$oScheduler->setScriptPath(KT_DIR . '/bin/indexMigrationTask.' . $ext);
$oScheduler->setFrequency('5mins');
$oScheduler->setFirstRunTime(date('Y-m-d H:i',mktime($hour, $min, 0, $mon, $day, $year)));
$oScheduler->registerTask();
$oScheduler = new Scheduler('Index Optimisation');
$oScheduler->setScriptPath(KT_DIR . '/bin/optimizeIndexes.' . $ext);
$oScheduler->setFrequency('weekly');
$oScheduler->setFirstRunTime(date('Y-m-d 00:00'));
$oScheduler->registerTask();
}
// }}}
// {{{ removeAdminVersionNotifier
function removeAdminVersionNotifier() {
global $default;
$oldPath = KT_DIR . "/plugins/ktstandard/AdminVersionPlugin";
if(file_exists($oldPath)) return rmdir($oldPath);
}
// }}}
// {{{ removeOldSearchPlugins
function removeOldSearchPlugins() {
global $default;
$oldFile = KT_DIR . "/plugins/ktstandard/SearchDashletPlugin.php";
if(file_exists($oldFile)) unlink($oldFile);
$oldFile = KT_DIR . "/plugins/ktstandard/SearchDashlet.php";
if(file_exists($oldFile)) unlink($oldFile);
// Files MUST be removed before folders and folders MUST be empty
$oldPath1 = KT_DIR . "/templates/ktstandard/searchdashlet/";
UpgradeFunctions::rm_recursive($oldPath1);
$oldPath2 = KT_DIR . "/plugins/generalmetadata/";
UpgradeFunctions::rm_recursive($oldPath2);
// FIXME: We should check that they all worked
return true;
}
function rm_recursive($filepath)
{
if (is_dir($filepath) && !is_link($filepath))
{
if ($dh = opendir($filepath))
{
while (($sf = readdir($dh)) !== false)
{
if ($sf == '.' || $sf == '..')
{
continue;
}
if (!UpgradeFunctions::rm_recursive($filepath.'/'.$sf))
{
//throw new Exception( $filepath.'/'.$sf.' could not be deleted.');
return false;
}
}
closedir($dh);
}
return rmdir($filepath);
}
return unlink($filepath);
}
// }}}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -