function &getByNamespace($sNamespace) { return KTEntityUtil::getBy('KTDocumentTransactionType', 'namespace', $sNamespace); }
function &getByLookup($oLookup) { $aOptions = array('multi' => true); $iLookupId = KTUtil::getId($oLookup); return KTEntityUtil::getBy('KTValueInstance', 'field_value_id', $iLookupId, $aOptions); }
function &getList($sWhereClause = null) { global $default; return KTEntityUtil::getList($default->permission_objects_table, 'KTPermissionObject', $sWhereClause); }
function &getByField($oField) { $iFieldId = KTUtil::getId($oField); $aOptions = array('multi' => true); return KTEntityUtil::getBy('KTFieldBehaviour', 'field_id', $iFieldId, $aOptions); }
function clearAllCaches() { return KTEntityUtil::clearAllCaches('KTPluginEntity'); }
function clearAllCaches() { return KTEntityUtil::clearAllCaches('schedulerEntity'); }
function checkFile($path, $first = true) { $oDocument = KTEntityUtil::getByDict('KTDocumentContentVersion', array('storage_path' => $path)); if (is_a($oDocument, 'ktentitynoobjects')) { $this->aFilesToRemove[] = $path; return; } }
/** * Reads the plugin cache file. This must still be unserialised. * @deprecated * @return mixed Returns false on failure, or the serialised cache. */ static function readPluginCache() { $config = KTConfig::getSingleton(); $cachePlugins = $config->get('cache/cachePlugins', false); if (!$cachePlugins) { return false; } $cacheDir = $config->get('cache/cacheDirectory'); $cacheFile = $cacheDir . '/' . KTPluginUtil::CACHE_FILENAME; if (!is_file($cacheFile)) { return false; } $cache = file_get_contents($cacheFile); // we check for an empty cache in case there was a problem. We rather try and reload everything otherwise. if (strlen($cache) == 0) { return false; } if (!class_exists('KTPluginEntityProxy')) { KTEntityUtil::_proxyCreate('KTPluginEntity', 'KTPluginEntityProxy'); } return unserialize($cache); }
function &getByDescriptor($sDescriptor) { return KTEntityUtil::getBy('KTPermissionDescriptor', 'descriptor', $sDescriptor); }
function getLastLogins($aOptions = null) { $oUser = KTUtil::arrayGet($aOptions, 'user'); if ($oUser) { $iUserId = KTUtil::getId($oUser); } else { $iUserId = null; } $aOptions = KTUtil::meldOptions(array('limit' => 5, 'orderby' => 'datetime DESC'), $aOptions); $sTable = KTUserHistory::_table(); if ($iUserId) { return KTEntityUtil::getByDict($sTable, array('user_id' => $iUserId), $aOptions); } else { return KTEntityUtil::getList2('KTUserHistory', null, $aOptions); } }
function &getByObjectMulti($oObject) { return KTEntityUtil::getByDict('KTPermissionAssignment', array('permission_object_id' => $oObject->getId()), array('multi' => true)); }
function &getByDocument($oDocument) { $iDocumentId = KTUtil::getId($oDocument); return KTEntityUtil::getByDict('KTDocumentMetadataVersion', array('document_id' => $iDocumentId), array('multi' => true, 'orderby' => 'version_created DESC')); }
function &createFromArray($aOptions) { return KTEntityUtil::createFromArray('KTNotification', $aOptions); }
function &getInterceptorInstances() { return KTEntityUtil::getList2('KTInterceptorInstance', $sWhereClause); }
function &getByName($sName) { return KTEntityUtil::getByDict('KTFieldset', array('name' => $sName, 'disabled' => false)); }
/** * Renders the search results. * * @return string */ function do_searchResults() { if (array_key_exists('format', $_GET)) { switch ($_GET['format']) { case 'searchengine': $_SESSION['search2resultFormat'] = 'searchengine'; break; case 'browseview': $_SESSION['search2resultFormat'] = 'browseview'; break; } } else { if (!array_key_exists('search2resultFormat', $_SESSION)) { global $default; $_SESSION['search2resultFormat'] = $default->resultsDisplayFormat; } } if ($_SESSION['search2resultFormat'] == 'browseview') { $this->redirectTo('oldSearchResults'); } $this->oPage->setBreadcrumbDetails(_kt("Search Results")); $this->oPage->title = _kt("Search Results"); $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate("ktcore/search2/search_results"); KTEntityUtil::_proxyCreate('KTDocumentContentVersion', 'KTDocumentContentVersionProxy'); KTEntityUtil::_proxyCreate('KTDocumentCore', 'KTDocumentCoreProxy'); KTEntityUtil::_proxyCreate('KTDocumentMetadataVersion', 'KTDocumentMetadataVersionProxy'); $results = unserialize($_SESSION['search2_results']); // NOTE: sorting results (when it is implemented) might have to be done per section, as it is done with the browse view // Get the order of display - folders first / documents first // Get the display order of the results - documents / folders first $_SESSION['display_order'] = isset($_POST['display_order']) ? $_POST['display_order'] : $_SESSION['display_order']; $display_order = $_SESSION['display_order']; $selected_order = array('f' => '', 'd' => '', 's' => ''); switch ($display_order) { case 's': $selected_order['s'] = 'selected'; $resultArray = $results['shortfolders']; foreach ($results['shortdocs'] as $f) { $resultArray[] = $f; } foreach ($results['folders'] as $d) { $resultArray[] = $d; } foreach ($results['docs'] as $f) { $resultArray[] = $f; } break; case 'd': $selected_order['d'] = 'selected'; $resultArray = $results['docs']; foreach ($results['folders'] as $f) { $resultArray[] = $f; } foreach ($results['shortdocs'] as $d) { $resultArray[] = $d; } foreach ($results['shortfolders'] as $f) { $resultArray[] = $f; } break; case 'f': default: $selected_order['f'] = 'selected'; $resultArray = $results['folders']; foreach ($results['docs'] as $f) { $resultArray[] = $f; } foreach ($results['shortfolders'] as $d) { $resultArray[] = $d; } foreach ($results['shortdocs'] as $f) { $resultArray[] = $f; } } $results = $resultArray; if (!is_array($results) || count($results) == 0) { $results = array(); } $numRecs = count($results); $showall = $_GET['showAll']; if (is_numeric($showall)) { $showall = $showall + 0 > 0; } else { $showall = $showall == 'true'; } $config = KTConfig::getSingleton(); $resultsPerPage = $showall ? $numRecs : $config->get('search/resultsPerPage', SearchDispatcher::RESULTS_PER_PAGE); $maxPageMove = SearchDispatcher::MAX_PAGE_MOVEMENT; $pageOffset = 1; if (isset($_GET['pageOffset'])) { $pageOffset = $_GET['pageOffset']; } $maxPages = ceil($numRecs / $resultsPerPage); if ($pageOffset <= 0 || $pageOffset > $maxPages) { $pageOffset = 1; } $firstRec = ($pageOffset - 1) * $resultsPerPage; $lastRec = $firstRec + $resultsPerPage; if ($lastRec > $numRecs) { $lastRec = $numRecs; } $display = array_slice($results, $firstRec, $resultsPerPage); $startOffset = $pageOffset - $maxPageMove; if ($startOffset < 1) { $startOffset = 1; } $endOffset = $pageOffset + $maxPageMove; if ($endOffset > $maxPages) { $endOffset = $maxPages; } $pageMovement = array(); for ($i = $startOffset; $i <= $endOffset; $i++) { $pageMovement[] = $i; } $aBulkActions = KTBulkActionUtil::getAllBulkActions(); $aTemplateData = array("context" => $this, 'selected_order' => $selected_order, 'bulkactions' => $aBulkActions, 'firstRec' => $firstRec, 'lastRec' => $lastRec, 'showAll' => $showall, 'numResults' => count($results), 'pageOffset' => $pageOffset, 'resultsPerPage' => $resultsPerPage, 'maxPages' => $maxPages, 'results' => $display, 'pageMovement' => $pageMovement, 'startMovement' => $startOffset, 'endMovement' => $endOffset, 'txtQuery' => $_SESSION['search2_query'], 'iSavedID' => $_SESSION['search2_savedid'], 'txtSavedName' => $_SESSION['search2_savedname']); return $oTemplate->render($aTemplateData); }
function delete($oStartFolder, $oUser, $sReason, $aOptions = null, $bulk_action = false) { require_once KT_LIB_DIR . '/unitmanagement/Unit.inc'; $oPerm = KTPermission::getByName('ktcore.permissions.delete'); $bIgnorePermissions = KTUtil::arrayGet($aOptions, 'ignore_permissions'); $aFolderIds = array(); // of oFolder $aDocuments = array(); // of oDocument $aFailedDocuments = array(); // of String $aFailedFolders = array(); // of String $aRemainingFolders = array($oStartFolder->getId()); DBUtil::startTransaction(); while (!empty($aRemainingFolders)) { $iFolderId = array_pop($aRemainingFolders); $oFolder = Folder::get($iFolderId); if (PEAR::isError($oFolder) || $oFolder == false) { DBUtil::rollback(); return PEAR::raiseError(sprintf(_kt('Failure resolving child folder with id = %d.'), $iFolderId)); } $oUnit = Unit::getByFolder($oFolder); if (!empty($oUnit)) { DBUtil::rollback(); return PEAR::raiseError(sprintf(_kt('Cannot remove unit folder: %s.'), $oFolder->getName())); } // don't just stop ... plough on. if (!$bIgnorePermissions && !KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oFolder)) { $aFailedFolders[] = $oFolder->getName(); } else { $aFolderIds[] = $iFolderId; } // child documents $aChildDocs = Document::getList(array('folder_id = ?', array($iFolderId))); foreach ($aChildDocs as $oDoc) { if (!$bIgnorePermissions && $oDoc->getImmutable()) { if (!KTBrowseUtil::inAdminMode($oUser, $oStartFolder)) { $aFailedDocuments[] = $oDoc->getName(); continue; } } if ($bIgnorePermissions || KTPermissionUtil::userHasPermissionOnItem($oUser, $oPerm, $oDoc) && $oDoc->getIsCheckedOut() == false) { $aDocuments[] = $oDoc; } else { $aFailedDocuments[] = $oDoc->getName(); } } // child folders. $aCFIds = Folder::getList(array('parent_id = ?', array($iFolderId)), array('ids' => true)); $aRemainingFolders = kt_array_merge($aRemainingFolders, $aCFIds); } // FIXME we could subdivide this to provide a per-item display (viz. bulk upload, etc.) if (!empty($aFailedDocuments) || !empty($aFailedFolders)) { $sFD = ''; $sFF = ''; if (!empty($aFailedDocuments)) { $sFD = _kt('Documents: ') . implode(', ', $aFailedDocuments) . '. '; } if (!empty($aFailedFolders)) { $sFF = _kt('Folders: ') . implode(', ', $aFailedFolders) . '.'; } return PEAR::raiseError(_kt('You do not have permission to delete these items. ') . $sFD . $sFF); } // now we can go ahead. foreach ($aDocuments as $oDocument) { $res = KTDocumentUtil::delete($oDocument, $sReason); if (PEAR::isError($res)) { DBUtil::rollback(); return PEAR::raiseError(_kt('Delete Aborted. Unexpected failure to delete document: ') . $oDocument->getName() . $res->getMessage()); } } $oStorage =& KTStorageManagerUtil::getSingleton(); $oStorage->removeFolderTree($oStartFolder); // Check for symbolic links to the folder and its sub folders $aSymlinks = array(); foreach ($aFolderIds as $iFolder) { $oFolder = Folder::get($iFolder); $aLinks = $oFolder->getSymbolicLinks(); $aSymlinks = array_merge($aSymlinks, $aLinks); } // documents all cleared. $sQuery = 'DELETE FROM ' . KTUtil::getTableName('folders') . ' WHERE id IN (' . DBUtil::paramArray($aFolderIds) . ')'; $aParams = $aFolderIds; $res = DBUtil::runQuery(array($sQuery, $aParams)); if (PEAR::isError($res)) { DBUtil::rollback(); return PEAR::raiseError(_kt('Failure deleting folders.')); } // now that the folder has been deleted we delete all the shortcuts if (!empty($aSymlinks)) { $links = array(); foreach ($aSymlinks as $link) { $links[] = $link['id']; } $linkIds = implode(',', $links); $query = "DELETE FROM folders WHERE id IN ({$linkIds})"; DBUtil::runQuery($query); } /* foreach($aSymlinks as $aSymlink){ KTFolderUtil::deleteSymbolicLink($aSymlink['id']); } */ // purge caches KTEntityUtil::clearAllCaches('Folder'); // and store DBUtil::commit(); return true; }
function &getSystemSearches($sWhereClause = null) { return KTEntityUtil::getByDict('KTSavedSearch', array('is_condition' => false, 'user_id' => null), array('multi' => true, 'noneok' => true)); }
function &createFromArray($aOptions) { return KTEntityUtil::createFromArray('RoleAllocation', $aOptions); }
function nameExists($sName, $oWorkflow) { $iWorkflowId = KTUtil::getId($oWorkflow); $res = KTEntityUtil::getByDict('KTWorkflowState', array('name' => $sName, 'workflow_id' => $iWorkflowId)); // expect KTEntityNoObjects if (PEAR::isError($res)) { return false; } return true; }
function &createFromArray($aOptions) { return KTEntityUtil::createFromArray('KTDashletDisable', $aOptions); }
function &getByFilename($sFilename) { return KTEntityUtil::getBy('KTHelpEntity', 'help_info', $sFilename); }
function &getByTransition($oTransition, $aOptions = null) { $iTransitionId = KTUtil::getId($oTransition); $aOptions = KTUtil::meldOptions($aOptions, array('multi' => true)); return KTEntityUtil::getByDict('KTWorkflowTriggerInstance', array('workflow_transition_id' => $iTransitionId), $aOptions); }
function &getSources() { return KTEntityUtil::getList2('KTAuthenticationSource'); }
function &createFromArray($aOptions) { return KTEntityUtil::createFromArray('KTDocumentCore', $aOptions); }
function &getByName($sName) { return KTEntityUtil::getBy('KTHelpReplacement', 'name', $sName); }
function &getByView($sViewNamespace, $aOptions = null) { if (is_null($aOptions)) { $aOptions = array(); } $aOptions['multi'] = true; $aOptions['orderby'] = 'position'; $aSelect = array('view_namespace' => $sViewNamespace); return KTEntityUtil::getByDict('KTColumnEntry', $aSelect, $aOptions); }
function &_getLookupIDsByPermissionIDAndDescriptorID($iPermissionID, $iDescriptorID) { return KTEntityUtil::getByDict('KTPermissionLookupAssignment', array('permission_id' => $iPermissionID, 'permission_descriptor_id' => $iDescriptorID), array('multi' => true, 'ids' => true, 'idfield' => 'permission_lookup_id')); }
function &getList($sWhereClause = null) { global $default; return KTEntityUtil::getList($default->permission_lookups_table, 'KTPermissionLookup', $sWhereClause); }
function &getByState($oState) { $iStateId = KTUtil::getId($oState); return KTEntityUtil::GetList2('KTWorkflowStatePermissionAssignment', 'workflow_state_id = ' . $iStateId); }