本文整理汇总了PHP中KTUtil::getSystemSetting方法的典型用法代码示例。如果您正苦于以下问题:PHP KTUtil::getSystemSetting方法的具体用法?PHP KTUtil::getSystemSetting怎么用?PHP KTUtil::getSystemSetting使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KTUtil
的用法示例。
在下文中一共展示了KTUtil::getSystemSetting方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_active
function is_active($oUser)
{
if (!Permission::userIsSystemAdministrator()) {
return false;
}
$indexerDiagnosis = KTUtil::getSystemSetting('indexerDiagnostics');
$extractorDiagnosis = KTUtil::getSystemSetting('extractorDiagnostics');
if (!empty($indexerDiagnosis)) {
$indexerDiagnosis = unserialize($indexerDiagnosis);
}
if (!empty($extractorDiagnosis)) {
$extractorDiagnosis = unserialize($extractorDiagnosis);
}
if (empty($indexerDiagnosis) && empty($extractorDiagnosis)) {
return false;
}
$this->indexerDiagnosis = $indexerDiagnosis;
$this->extractorDiagnosis = array();
$result = array();
foreach ($extractorDiagnosis as $class => $diagnosis) {
$name = $diagnosis['name'];
$diag = $diagnosis['diagnosis'];
$result[$diag][] = $name;
}
foreach ($result as $problem => $indexers) {
if (empty($problem)) {
continue;
}
$this->extractorDiagnosis[] = array('problem' => $problem, 'indexers' => $indexers);
}
$this->indexerDiagnosis = str_replace(array("\n", 'Administrator Guide'), array('<br>', sprintf("<a target='_blank' href=\"http://www.knowledgetree.com/go/ktAdminManual\">%s</a>", _kt('Administrator Guide'))), $this->indexerDiagnosis);
return true;
}
示例2: render
function render()
{
$oTemplating =& KTTemplating::getSingleton();
$oTemplate = $oTemplating->loadTemplate('ktcore/search2/lucene_migration');
$config = KTConfig::getSingleton();
$batchDocuments = $config->get('indexer/batchMigrateDocuments');
$migratedDocuments = KTUtil::getSystemSetting('migratedDocuments', 0);
$migratingDocuments = $this->migratingDocuments;
$migrationStart = KTUtil::getSystemSetting('migrationStarted');
if (is_null($migrationStart)) {
$migrationStartString = _kt('Not started');
$migrationPeriod = _kt('N/A');
$estimatedTime = _kt('Unknown');
$estimatedPeriod = $estimatedTime;
} else {
$migrationStartString = date('Y-m-d H:i:s', $migrationStart);
$migrationTime = KTUtil::getSystemSetting('migrationTime', 0);
$migrationPeriod = KTUtil::computePeriod($migrationTime, '');
// Cannot divide by zero so make it 1
$divMigratedDocuments = $migratedDocuments > 0 ? $migratedDocuments : 1;
$timePerDocument = $migrationTime / $divMigratedDocuments;
$estimatedPeriod = $timePerDocument * $migratingDocuments;
$estimatedTime = date('Y-m-d H:i:s', $migrationStart + $estimatedPeriod);
$estimatedPeriod = KTUtil::computePeriod($estimatedPeriod, '');
}
$aTemplateData = array('context' => $this, 'batchDocuments' => $batchDocuments, 'batchPeriod' => 'Periodically', 'migrationStart' => $migrationStartString, 'migrationPeriod' => $migrationPeriod, 'migratedDocuments' => $migratedDocuments, 'migratingDocuments' => $migratingDocuments, 'estimatedTime' => $estimatedTime, 'estimatedPeriod' => $estimatedPeriod);
return $oTemplate->render($aTemplateData);
}
示例3: is_active
function is_active($oUser)
{
$usage = KTUtil::getSystemSetting('KTUsage');
if (empty($usage)) {
return false;
}
$this->usage = unserialize($usage);
return Permission::userIsSystemAdministrator();
}
示例4: is_active
function is_active($oUser)
{
$stats = KTUtil::getSystemSetting('indexerStats');
if (empty($stats)) {
return false;
}
$this->stats = unserialize($stats);
return Permission::userIsSystemAdministrator();
}
示例5: do_main
/**
* Dispatch function
*/
function do_main()
{
$this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Document Indexer Statistics'));
$stats = KTUtil::getSystemSetting('indexerStats');
$this->stats = unserialize($stats);
$oTemplating =& KTTemplating::getSingleton();
$oTemplate = $oTemplating->loadTemplate('ktcore/search2/lucene_statistics');
$aTemplateData = array('context' => $this, 'stats' => $this->stats);
return $oTemplate->render($aTemplateData);
}
示例6: is_active
function is_active($oUser)
{
if (!Permission::userIsSystemAdministrator()) {
return false;
}
$this->resources = KTUtil::getSystemSetting('externalResourceIssues');
if (empty($this->resources)) {
return false;
}
$this->resources = unserialize($this->resources);
return count($this->resources) > 0;
}
示例7: do_main
/**
* Dispatch function
*/
function do_main()
{
// Load Templating Engine
$oTemplating =& KTTemplating::getSingleton();
// Set Template to use
$oTemplate = $oTemplating->loadTemplate('ktcore/search2/indexing_status');
// Do a runtime Service Resource Check
$checker = new ResourceChecker();
$checker->check();
// Get Results
$serviceErrors = KTUtil::getSystemSetting('externalResourceIssues');
$serviceErrors = unserialize($serviceErrors);
// Array to Hold Items not working
$this->serviceErrors = array();
// A reference array to use with extractors that depend on the service
$errorReference = array();
if (count($serviceErrors) > 0) {
// Add Service Errors
foreach ($serviceErrors as $error) {
$this->serviceErrors[$error['name']] = array('name' => $error['name'], 'status' => $error['status'], 'help' => IndexingHelp::getHelp($error['name']));
// Create Reference to the array
$errorReference[$error['status']] =& $this->serviceErrors[$error['name']];
}
}
// ---------------------------
// Do a run time check for extractors not working
Indexer::updateIndexStats();
// Get Results
$extractorDiagnosis = KTUtil::getSystemSetting('extractorDiagnostics');
if (!empty($extractorDiagnosis)) {
$extractorDiagnosis = unserialize($extractorDiagnosis);
}
// Create an Array to store errors
$this->extractorErrors = array();
if (count($extractorDiagnosis > 0)) {
foreach ($extractorDiagnosis as $extractor => $props) {
// Check if Extractor fault is due to a service not running
if (array_key_exists($props['diagnosis'], $errorReference)) {
// One service may affect multiple extractors
$errorReference[$props['diagnosis']]['alsoaffects'] = array(array('extractor' => $props['name'], 'affectedtypes' => IndexingHelp::affectedTypes($extractor)));
} else {
// Else list as normal extractor error
$this->extractorErrors[$extractor] = array('name' => $props['name'], 'status' => $props['diagnosis'], 'help' => IndexingHelp::getHelp($extractor), 'affectedtypes' => IndexingHelp::affectedTypes($extractor));
}
}
}
// Create URL to Send to Template
$url = KTUtil::kt_url();
// Prepare Template Data
$aTemplateData = array('context' => $this, 'serviceErrors' => $this->serviceErrors, 'extractorErrors' => $this->extractorErrors, 'url' => $url);
// Send to template and render
return $oTemplate->render($aTemplateData);
}
示例8: is_active
function is_active($oUser)
{
if (OS_WINDOWS && (double) php_uname('r') >= 6) {
return false;
}
$usage = KTUtil::getSystemSetting('DiskUsage');
if (empty($usage)) {
return false;
}
$usage = unserialize($usage);
$this->usage = $usage;
return Permission::userIsSystemAdministrator();
}
示例9: migrateDocuments
public function migrateDocuments($max = null)
{
global $default;
$default->log->info(_kt('migrateDocuments: starting'));
if (!$this->doesDiagnosticsPass(true)) {
$default->log->info(_kt('migrateDocuments: stopping - diagnostics problem. The dashboard will provide more information.'));
return;
}
if (KTUtil::getSystemSetting('migrationComplete') == 'true') {
$default->log->info(_kt('migrateDocuments: stopping - migration is complete.'));
return;
}
$config =& KTConfig::getSingleton();
if (is_null($max)) {
$max = $config->get('indexer/batchMigrateDocument', 500);
}
$lockFile = $config->get('cache/cacheDirectory') . '/migration.lock';
if (is_file($lockFile)) {
$default->log->info(_kt('migrateDocuments: stopping - migration lockfile detected.'));
return;
}
touch($lockFile);
$startTime = KTUtil::getSystemSetting('migrationStarted');
if (is_null($startTime)) {
KTUtil::setSystemSetting('migrationStarted', time());
}
$maxLoops = 5;
$max = ceil($max / $maxLoops);
$start = KTUtil::getBenchmarkTime();
$noDocs = false;
$numDocs = 0;
for ($loop = 0; $loop < $maxLoops; $loop++) {
$sql = "SELECT\n \t\t\tdocument_id, document_text\n\t\t\t\tFROM\n\t\t\t\t\tdocument_text\n\t\t\t\tORDER BY document_id\n \t\t\t\t\tLIMIT {$max}";
$result = DBUtil::getResultArray($sql);
if (PEAR::isError($result)) {
$default->log->info(_kt('migrateDocuments: db error'));
break;
}
$docs = count($result);
if ($docs == 0) {
$noDocs = true;
break;
}
$numDocs += $docs;
foreach ($result as $docinfo) {
$docId = $docinfo['document_id'];
$document = Document::get($docId);
if (PEAR::isError($document) || is_null($document)) {
$sql = "DELETE FROM document_text WHERE document_id={$docId}";
DBUtil::runQuery($sql);
$default->log->error(sprintf(_kt('migrateDocuments: Could not get document %d\'s document! Removing content!'), $docId));
continue;
}
$version = $document->getMajorVersionNumber() . '.' . $document->getMinorVersionNumber();
$targetFile = tempnam($tempPath, 'ktindexer');
if (file_put_contents($targetFile, $docinfo['document_text']) === false) {
$default->log->error(sprintf(_kt('migrateDocuments: Cannot write to \'%s\' for document id %d'), $targetFile, $docId));
continue;
}
// free memory asap ;)
unset($docinfo['document_text']);
$title = $document->getName();
$indexStatus = $this->indexDocumentAndDiscussion($docId, $targetFile, $title, $version);
if ($indexStatus) {
$sql = "DELETE FROM document_text WHERE document_id={$docId}";
DBUtil::runQuery($sql);
} else {
$default->log->error(sprintf(_kt("migrateDocuments: Problem indexing document %d"), $docId));
}
@unlink($targetFile);
}
}
@unlink($lockFile);
$time = KTUtil::getBenchmarkTime() - $start;
KTUtil::setSystemSetting('migrationTime', KTUtil::getSystemSetting('migrationTime', 0) + $time);
KTUtil::setSystemSetting('migratedDocuments', KTUtil::getSystemSetting('migratedDocuments', 0) + $numDocs);
$default->log->info(sprintf(_kt('migrateDocuments: stopping - done in %d seconds!'), $time));
if ($noDocs) {
$default->log->info(_kt('migrateDocuments: Completed!'));
KTUtil::setSystemSetting('migrationComplete', 'true');
schedulerUtil::deleteByName('Index Migration');
$default->log->debug(_kt('migrateDocuments: Disabling \'Index Migration\' task by removing scheduler entry.'));
}
}
示例10: do_resetPassword
function do_resetPassword()
{
$email = $_REQUEST['email'];
$user = $_REQUEST['username'];
$password = $_REQUEST['password'];
$confirm = $_REQUEST['confirm'];
if (!($password == $confirm)) {
return _kt('The passwords do not match, please re-enter them.');
}
$password = md5($password);
// Get user from db
$sQuery = 'SELECT id FROM users WHERE username = ? AND email = ?';
$aParams = array($user, $email);
$id = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id');
if (!is_numeric($id) || $id < 1) {
//PEAR::isError($res) || is_null($res)){
return _kt('Please check that you have entered a valid username and email address.');
}
// Check expiry
$expiry = KTUtil::getSystemSetting('password_reset_expire-' . $id);
if ($expiry < time()) {
return _kt('The password reset key has expired, please send a new request.');
}
// Update password
$res = DBUtil::autoUpdate('users', array('password' => $password), $id);
if (PEAR::isError($res) || is_null($res)) {
return _kt('Your password could not be reset, please try again.');
}
// Unset expiry date and key
KTUtil::setSystemSetting('password_reset_expire-' . $id, '');
KTUtil::setSystemSetting('password_reset_key-' . $id, '');
// Email confirmation
$url = KTUtil::addQueryStringSelf('');
$subject = APP_NAME . ': ' . _kt('password successfully reset');
$body = '<dd><p>';
$body .= _kt('Your password has been successfully reset, click the link below to login.');
$body .= "</p><p><a href = '{$url}'>" . _kt('Login') . '</a></p></dd>';
$oEmail = new Email();
$res = $oEmail->send($email, $subject, $body);
if ($res === true) {
return _kt('Your password has been successfully reset.');
}
return _kt('An error occurred while sending the email, please try again or contact the System Administrator.');
}
示例11: getKTVersion
function getKTVersion()
{
$version = KTUtil::getSystemSetting('knowledgeTreeVersion');
if (empty($version) || PEAR::isError($version)) {
$version = file_get_contents(KT_DIR . 'docs/VERSION.txt');
}
// remove newline that is in the version file
$version = str_replace("\n", '', $version);
return $version;
}