function renderData($aDataRow) { // only _ever_ show this for documents. if ($aDataRow["type"] === "folder") { return ' '; } $sUrl = KTUtil::kt_url() . '/' . $this->sPluginPath . '/documentPreview.php'; $sDir = KT_DIR; $iDelay = 1000; // milliseconds $iDocumentId = $aDataRow['document']->getId(); $sTitle = _kt('Property Preview'); $sLoading = _kt('Loading...'); $width = 500; // Check for existence of thumbnail plugin if (KTPluginUtil::pluginIsActive('thumbnails.generator.processor.plugin')) { // hook into thumbnail plugin to get display for thumbnail include_once KT_DIR . '/plugins/thumbnails/thumbnails.php'; $thumbnailer = new ThumbnailViewlet(); $thumbnailwidth = $thumbnailer->get_width($iDocumentId); $width += $thumbnailwidth + 30; } //$link = '<a name = "ktP'.$iDocumentId.'" href = "#ktP'.$iDocumentId.'" class="ktAction ktPreview" id = "box_'.$iDocumentId.'" '; $link = '<a href = "#browseForm" class="ktAction ktPreview" id = "box_' . $iDocumentId . '" '; if ($this->sActivation == 'mouse-over') { $sJs = "javascript: this.t = setTimeout('showInfo(\\'{$iDocumentId}\\', \\'{$sUrl}\\', \\'{$sDir}\\', \\'{$sLoading}\\', {$width})', {$iDelay});"; $link .= 'onmouseover = "' . $sJs . '" onmouseout = "clearTimeout(this.t);">'; } else { $sJs = "javascript: showInfo('{$iDocumentId}', '{$sUrl}', '{$sDir}', '{$sLoading}', {$width});"; $link .= 'onclick = "' . $sJs . '" title="' . $sTitle . '">'; } return $link . $sTitle . '</a>'; }
function synchroniseGroupToSource($oGroup) { $oGroup =& KTUtil::getObject('Group', $oGroup); $iSourceId = $oGroup->getAuthenticationSourceId(); $oAuthenticator = KTAuthenticationUtil::getAuthenticatorForSource($iSourceId); return $oAuthenticator->synchroniseGroup($oGroup); }
function isRegistered($sName) { if (KTUtil::arrayGet($this->aResources, $sName)) { return true; } return false; }
function &getSingleton() { if (!KTUtil::arrayGet($GLOBALS, 'oKTFieldsetDisplayRegistry')) { $GLOBALS['oKTFieldsetDisplayRegistry'] = new KTFieldsetDisplayRegistry(); } return $GLOBALS['oKTFieldsetDisplayRegistry']; }
function check() { $this->checkOpenOffice(); $this->checkLucene(); $this->checkDF(); KTUtil::setSystemSetting('externalResourceIssues', serialize($this->resources)); }
function do_checkin() { global $default; $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); if (empty($document_id)) { return $this->errorRedirectToMain(_kt('You must select a document to check in first.')); } $oDocument = Document::get($document_id); if (PEAR::isError($oDocument)) { return $this->errorRedirectToMain(_kt('The document you specified appears to be invalid.')); } $this->startTransaction(); // actually do the checkin. $oDocument->setIsCheckedOut(0); $oDocument->setCheckedOutUserID(-1); if (!$oDocument->update()) { $this->rollbackTransaction(); return $this->errorRedirectToMain(_kt("Failed to force the document's checkin.")); } // checkout cancelled transaction $oDocumentTransaction =& new DocumentTransaction($oDocument, _kt('Document checked out cancelled'), 'ktcore.transactions.force_checkin'); $res = $oDocumentTransaction->create(); if (PEAR::isError($res) || $res == false) { $this->rollbackTransaction(); return $this->errorRedirectToMain(_kt("Failed to force the document's checkin.")); } $this->commitTransaction(); // FIXME do we want to do this if we can't created the document-transaction? return $this->successRedirectToMain(sprintf(_kt('Successfully forced "%s" to be checked in.'), $oDocument->getName())); }
function KTCache() { require_once "Cache/Lite.php"; require_once KT_LIB_DIR . '/config/config.inc.php'; $aOptions = array(); $oKTConfig = KTConfig::getSingleton(); $this->bEnabled = $oKTConfig->get('cache/cacheEnabled', false); if (empty($this->bEnabled)) { return; } $aOptions['cacheDir'] = $oKTConfig->get('cache/cacheDirectory') . "/"; $user = KTUtil::running_user(); if ($user) { $aOptions['cacheDir'] .= $user . '/'; } if (!file_exists($aOptions['cacheDir'])) { mkdir($aOptions['cacheDir']); } // See thirdparty/pear/Cache/Lite.php to customize cache $aOptions['lifeTime'] = 60; $aOptions['memoryCaching'] = true; $aOptions['automaticSerialization'] = true; /* Patched line */ // Disable fileCaching (when cache > 5Mo) $aOptions['onlyMemoryCaching'] = true; $this->cacheDir = $aOptions['cacheDir']; $this->oLite = new Cache_Lite($aOptions); }
function &getSingleton() { if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTFieldsetRegistry')) { $GLOBALS['_KT_PLUGIN']['oKTFieldsetRegistry'] = new KTFieldsetRegistry(); } return $GLOBALS['_KT_PLUGIN']['oKTFieldsetRegistry']; }
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); }
function do_main() { $this->oPage->setBreadcrumbDetails(_kt("transactions")); $this->oPage->setTitle(_kt('Folder transactions')); $folder_data = array(); $folder_data["folder_id"] = $this->oFolder->getId(); $this->oPage->setSecondaryTitle($this->oFolder->getName()); $aTransactions = array(); // FIXME do we really need to use a raw db-access here? probably... $sQuery = "SELECT DTT.name AS transaction_name, FT.transaction_namespace, U.name AS user_name, FT.comment AS comment, FT.datetime AS datetime " . "FROM " . KTUtil::getTableName("folder_transactions") . " AS FT LEFT JOIN " . KTUtil::getTableName("users") . " AS U ON FT.user_id = U.id " . "LEFT JOIN " . KTUtil::getTableName("transaction_types") . " AS DTT ON DTT.namespace = FT.transaction_namespace " . "WHERE FT.folder_id = ? ORDER BY FT.datetime DESC"; $aParams = array($this->oFolder->getId()); $res = DBUtil::getResultArray(array($sQuery, $aParams)); if (PEAR::isError($res)) { var_dump($res); // FIXME be graceful on failure. exit(0); } // FIXME roll up view transactions $aTransactions = $res; // Set the namespaces where not in the transactions lookup foreach ($aTransactions as $key => $transaction) { if (empty($transaction['transaction_name'])) { $aTransactions[$key]['transaction_name'] = $this->_getActionNameForNamespace($transaction['transaction_namespace']); } } // render pass. $this->oPage->title = _kt("Folder History"); $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate("kt3/view_folder_history"); $aTemplateData = array("context" => $this, "folder_id" => $folder_id, "folder" => $this->oFolder, "transactions" => $aTransactions); return $oTemplate->render($aTemplateData); }
function do_rename() { $aErrorOptions = array('redirect_to' => array('', sprintf('fFolderId=%d', $this->oFolder->getId()))); $sFolderName = KTUtil::arrayGet($_REQUEST, 'foldername'); $aErrorOptions['defaultmessage'] = _kt("No folder name given"); $sFolderName = $this->oValidator->validateString($sFolderName, $aErrorOptions); $sFolderName = $this->oValidator->validateIllegalCharacters($sFolderName, $aErrorOptions); $sOldFolderName = $this->oFolder->getName(); if ($this->oFolder->getId() != 1) { $oParentFolder =& Folder::get($this->oFolder->getParentID()); if (PEAR::isError($oParentFolder)) { $this->errorRedirectToMain(_kt('Unable to retrieve parent folder.'), $aErrorOptions['redirect_to'][1]); exit(0); } if (KTFolderUtil::exists($oParentFolder, $sFolderName)) { $this->errorRedirectToMain(_kt('A folder with that name already exists.'), $aErrorOptions['redirect_to'][1]); exit(0); } } $res = KTFolderUtil::rename($this->oFolder, $sFolderName, $this->oUser); if (PEAR::isError($res)) { $_SESSION['KTErrorMessage'][] = $res->getMessage(); redirect(KTBrowseUtil::getUrlForFolder($this->oFolder)); exit(0); } else { $_SESSION['KTInfoMessage'][] = sprintf(_kt('Folder "%s" renamed to "%s".'), $sOldFolderName, $sFolderName); } $this->commitTransaction(); redirect(KTBrowseUtil::getUrlForFolder($this->oFolder)); exit(0); }
static function &getSingleton() { if (!KTUtil::arrayGet($GLOBALS['_KT_PLUGIN'], 'oKTNotificationRegistry')) { $GLOBALS['_KT_PLUGIN']['oKTNotificationRegistry'] = new KTNotificationRegistry(); } return $GLOBALS['_KT_PLUGIN']['oKTNotificationRegistry']; }
function do_main() { $notifications = (array) KTNotification::getList(array("user_id = ?", $this->oUser->getId())); $num_notifications = count($notifications); $PAGE_SIZE = 5; $page = (int) KTUtil::arrayGet($_REQUEST, 'page', 0); $page_count = ceil($num_notifications / $PAGE_SIZE); if ($page >= $page_count) { $page = $page_count - 1; } if ($page < 0) { $page = 0; } // slice the notification array. $notifications = array_slice($notifications, $page * $PAGE_SIZE, $PAGE_SIZE); // prepare the batch html. easier to do this here than in the template. $batch = array(); for ($i = 0; $i < $page_count; $i++) { if ($i == $page) { $batch[] = sprintf("<strong>%d</strong>", $i + 1); } else { $batch[] = sprintf('<a href="%s">%d</a>', KTUtil::addQueryStringSelf($this->meldPersistQuery(array("page" => $i), "main", true)), $i + 1); } } $batch_html = implode(' · ', $batch); $count_string = sprintf(_kt("Showing Notifications %d - %d of %d"), $page * $PAGE_SIZE + 1, min(($page + 1) * $PAGE_SIZE, $num_notifications), $num_notifications); $this->oPage->setTitle(_kt("Items that require your attention")); $oTemplate =& $this->oValidator->validateTemplate("ktcore/misc/notification_overflow"); $oTemplate->setData(array('count_string' => $count_string, 'batch_html' => $batch_html, 'notifications' => $notifications)); return $oTemplate->render(); }
function do_update() { $sTable = KTUtil::getTableName('plugins'); $aIds = (array) KTUtil::arrayGet($_REQUEST, 'pluginids'); // Update disabled plugins $sIds = implode(',', $aIds); $sQuery = "UPDATE {$sTable} SET disabled = 1 WHERE id NOT IN ({$sIds})"; DBUtil::runQuery(array($sQuery)); // Select disabled plugins that have been enabled $sQuery = "SELECT * FROM {$sTable} WHERE disabled = 1 AND id IN ({$sIds})"; $res = DBUtil::getResultArray($sQuery); if (!PEAR::isError($res)) { // Enable the disabled plugins $sQuery = "UPDATE {$sTable} SET disabled = 0 WHERE id IN ({$sIds})"; DBUtil::runQuery(array($sQuery)); // run setup for each plugin $aEnabled = array(); if (!empty($res)) { foreach ($res as $item) { $aEnabled[] = $item['id']; } $sEnabled = implode(',', $aEnabled); $sQuery = "SELECT h.classname, h.pathname FROM {$sTable} p\n INNER JOIN plugin_helper h ON (p.namespace = h.plugin)\n WHERE classtype = 'plugin' AND p.id IN ({$sEnabled})"; $res = DBUtil::getResultArray($sQuery); if (!PEAR::isError($res)) { foreach ($res as $item) { $classname = $item['classname']; $path = $item['pathname']; if (!empty($path)) { require_once $path; } $oPlugin = new $classname($path); $oPlugin->setup(); } } } } KTPluginEntity::clearAllCaches(); // FIXME!!! Plugin manager needs to be updated to deal with this situation. This code should be in the plugin. //enabling or disabling Tag fieldset depending on whether tag cloud plugin is enabled or disabled. //Get tag cloud object $oTagClouPlugin = KTPluginEntity::getByNamespace('ktcore.tagcloud.plugin'); if (!PEAR::isError($oTagClouPlugin) && !is_a($oTagClouPlugin, 'KTEntityNoObjects') && !is_null($oTagClouPlugin)) { if ($oTagClouPlugin->getDisabled() == '1') { //disable tag fieldset $aFV = array('disabled' => true); $aWFV = array('namespace' => 'tagcloud'); $res = DBUtil::whereUpdate('fieldsets', $aFV, $aWFV); } else { //enable tag fieldset $aFV = array('disabled' => false); $aWFV = array('namespace' => 'tagcloud'); $res = DBUtil::whereUpdate('fieldsets', $aFV, $aWFV); } } // we reregister the plugins to ensure they are in the correct order KTPluginUtil::registerPlugins(); $this->successRedirectToMain(_kt('Plugins updated')); }
public function __construct() { $config = KTConfig::getSingleton(); $this->unzip = KTUtil::findCommand("import/unzip", 'unzip'); $this->unzip = str_replace('\\', '/', $this->unzip); $this->unzip_params = $config->get('extractorParameters/unzip', '"{source}" "{part}" -d "{target_dir}"'); parent::__construct(); }
function render() { $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/search2/indexing_status'); $url = KTUtil::kt_url(); $aTemplateData = array('context' => $this, 'indexerName' => $this->indexerName, 'indexerDiagnosis' => $this->indexerDiagnosis, 'extractorDiagnosis' => $this->extractorDiagnosis, 'rootUrl' => $url); return $oTemplate->render($aTemplateData); }
function &retrieveList($sCode) { $sList = KTUtil::arrayGet($_SESSION['ktentitylists'], $sCode, False); if ($sList === False) { return PEAR::raiseError(_kt('No such KTEntityList')); } $oList = unserialize($sList); return $oList; }
function is_active($oUser) { $stats = KTUtil::getSystemSetting('indexerStats'); if (empty($stats)) { return false; } $this->stats = unserialize($stats); return Permission::userIsSystemAdministrator(); }
function is_active($oUser) { $usage = KTUtil::getSystemSetting('KTUsage'); if (empty($usage)) { return false; } $this->usage = unserialize($usage); return Permission::userIsSystemAdministrator(); }
function renderDocumentLink($aDataRow) { $aOptions = $this->getOptions(); $fParentDocId = KTUtil::arrayGet(KTUtil::arrayGet($aOptions, 'qs_params', array()), 'fDocumentId', False); if ((int) $aDataRow["document"]->getId() === (int) $fParentDocId) { return htmlentities($aDataRow["document"]->getName(), ENT_QUOTES, 'UTF-8') . ' <span class="descriptiveText">(' . _kt('you cannot link to the source document') . ')'; } else { return parent::renderDocumentLink($aDataRow); } }
/** * Constructor for the download manager. * * @param KTAPI_Session $session * @return KTDownloadManager */ function KTDownloadManager() { $config =& KTConfig::getSingleton(); $this->age = $config->get('webservice/downloadExpiry', 5); $protocol = $config->get('KnowledgeTree/sslEnabled') ? 'https' : 'http'; $server = KTUtil::getServerName(TRUE); $url = $config->get('webservice/downloadUrl'); $this->download_url = $protocol . '://' . $server . $url; $this->random = $config->get('webservice/randomKeyText', 'jhsdf8q1jkjpoiudfs7sd3ds1'); }
function findLocalCommand() { if (OS_WINDOWS) { $this->command = 'c:\\antiword\\antiword.exe'; $this->commandconfig = 'indexer/antiword'; $this->args = array(); } $sCommand = KTUtil::findCommand($this->commandconfig, $this->command); return $sCommand; }
/** * 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); }
function takeover() { $oRegistry =& KTPluginRegistry::getSingleton(); $oPlugin =& $oRegistry->getPlugin('password.reset.plugin'); $dispatcherURL = $oPlugin->getURLPath('loginResetDispatcher.php'); $redirect = KTUtil::arrayGet($_REQUEST, 'redirect'); $url = KTUtil::kt_url() . $dispatcherURL; $url .= !empty($redirect) ? '?redirect=' . $redirect : ''; redirect($url); exit(0); }
function &getValidatorByNamespace($sNamespace) { $aInfo = KTUtil::arrayGet($this->validators, $sNamespace); if (empty($aInfo)) { return PEAR::raiseError(sprintf(_kt('No such validator: %s'), $sNamespace)); } if (!empty($aInfo['file'])) { require_once $aInfo['file']; } return new $aInfo['class'](); }
function render() { $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/search2/external_resources'); $sUrl = KTUtil::kt_url(); foreach ($this->resources as $k => $v) { $this->resources[$k]['status'] = str_replace(array("\n", _kt('Administrator Guide')), array('<br>', sprintf("<a target='_blank' href=\"http://www.knowledgetree.com/go/ktAdminManual\">%s</a>", _kt('Administrator Guide'))), $v['status']); } $aTemplateData = array('context' => $this, 'resources' => $this->resources, 'url' => $sUrl); return $oTemplate->render($aTemplateData); }
function do_main() { $clear_all = KTUtil::arrayGet($_REQUEST, 'clearAll'); if ($clear_all) { return $this->clearAll(); } // get the notification-handler, instantiate it, call resolveNotification. $oHandler =& $this->notification->getHandler(); $oHandler->notification =& $this->notification; $oHandler->subDispatch($this); exit(0); }
function getPage($sPath) { $aInfo = KTUtil::arrayGet($this->aResources, $sPath); if (empty($aInfo)) { return null; } $sClassName = $aInfo[1]; $sFilename = $aInfo[2]; if ($sFilename) { require_once $sFilename; } return new $sClassName(); }
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(); }
function takeover() { $oRegistry =& KTPluginRegistry::getSingleton(); $oPlugin =& $oRegistry->getPlugin('password.reset.plugin'); $dispatcherURL = $oPlugin->getURLPath('loginResetDispatcher.php'); $queryString = $_SERVER['QUERY_STRING']; $redirect = KTUtil::arrayGet($_REQUEST, 'redirect'); $redirect = urlencode($redirect); $url = KTUtil::kt_url() . $dispatcherURL; $url .= !empty($queryString) ? '?' . $queryString : ''; redirect($url); exit(0); }