function renderHeader() { // short-circuit if (empty($this->label)) { return ''; } // for safety $label = htmlentities($this->label, ENT_NOQUOTES, 'UTF-8'); // without sorthing to sort on, don't bother. if (empty($this->namespace)) { $this->sortable = false; // if we haven't set which column we're sorted by, do nothing. } // no sorting, no link if (!$this->sortable) { return $label; } // merge the sorting options into the header. $sort_order = $this->sort_direction == 'asc' ? 'desc' : 'asc'; $qs = sprintf('sort_on=%s&sort_order=%s', $this->namespace, $sort_order); if (is_null($this->return_url)) { $url = KTUtil::addQueryStringSelf($qs); } else { $url = KTUtil::addQueryString($this->return_url, $qs); } return sprintf('<a href="%s">%s</a>', $url, $label); }
function setupServerVariables() { $oKTConfig =& KTConfig::getSingleton(); $bPathInfoSupport = $oKTConfig->get('KnowledgeTree/pathInfoSupport'); if ($bPathInfoSupport) { // KTS-21: Some environments (FastCGI only?) don't set PATH_INFO // correctly, but do set ORIG_PATH_INFO. $path_info = KTUtil::arrayGet($_SERVER, 'PATH_INFO'); $orig_path_info = KTUtil::arrayGet($_SERVER, 'ORIG_PATH_INFO'); if (empty($path_info) && !empty($orig_path_info)) { $_SERVER['PATH_INFO'] = strip_tags($_SERVER['ORIG_PATH_INFO']); $_SERVER['PHP_SELF'] .= $_SERVER['PATH_INFO']; } $env_path_info = KTUtil::arrayGet($_SERVER, 'REDIRECT_kt_path_info'); if (empty($path_info) && !empty($env_path_info)) { $_SERVER['PATH_INFO'] = strip_tags($env_path_info); $_SERVER['PHP_SELF'] .= $_SERVER['PATH_INFO']; } // KTS-50: IIS (and probably most non-Apache web servers) don't // set REQUEST_URI. Fake it. $request_uri = KTUtil::arrayGet($_SERVER, 'REQUEST_URI'); if (empty($request_uri)) { $_SERVER['REQUEST_URI'] = strip_tags(KTUtil::addQueryString($_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING'])); } } else { unset($_SERVER['PATH_INFO']); } $script_name = strip_tags(KTUtil::arrayGet($_SERVER, 'SCRIPT_NAME')); $php_self = strip_tags(KTUtil::arrayGet($_SERVER, 'PHP_SELF')); $_SERVER['SCRIPT_NAME'] = $script_name; $_SERVER['PHP_SELF'] = $php_self; $kt_path_info = strip_tags(KTUtil::arrayGet($_REQUEST, 'kt_path_info')); if (!empty($kt_path_info)) { $_SERVER['PHP_SELF'] .= '?kt_path_info=' . $kt_path_info; $_SERVER['PATH_INFO'] = $kt_path_info; } $sServerName = $oKTConfig->get('KnowledgeTree/serverName'); $_SERVER['HTTP_HOST'] = $sServerName; }
function buildFolderLink($aDataRow) { return KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('action=addUnit2&unit_name=%s&fFolderId=%d', $this->sName, $aDataRow['folder']->getId())); }
function do_main() { $sCode = KTUtil::arrayGet($_REQUEST, 'code'); $sName = KTUtil::arrayGet($_REQUEST, 'varname', 'fFolderId'); $oWidget = unserialize($_SESSION['collection_widgets'][$sCode]); $oCollection = $oWidget->getCollection(); $oFolder = Folder::get(KTUtil::arrayGet($_REQUEST, 'fFolderId', 1)); if (PEAR::isError($oFolder)) { $this->errorRedirectToMain(_kt('Invalid folder selected.')); exit(0); } $aOptions = array('ignorepermissions' => KTBrowseUtil::inAdminMode($this->oUser, $oFolder)); $oCollection->_queryObj->folder_id = $oFolder->getId(); $aOptions = $oCollection->getEnvironOptions(); $aOptions['return_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], array('code' => $sCode, 'varname' => $sName, 'fFolderId' => $oFolder->getId())); $oCollection->setOptions($aOptions); // add the collection code to the title column QS params foreach ($oWidget->aCols as $ns) { $aColOpts = $oCollection->getColumnOptions($ns); $aColOpts['qs_params'] = kt_array_merge(KTUtil::arrayGet($aColOpts, 'qs_params', array()), array('code' => $sCode, 'varname' => $sName)); $oCollection->setColumnOptions($ns, $aColOpts); } // make the breadcrumbs $aBreadcrumbs = $this->_generate_breadcrumbs($oFolder, $sCode, $oWidget->aBCUrlParams, $sName); print KTTemplating::renderTemplate('ktcore/forms/widgets/collection', array('collection' => $oCollection, 'folder' => $oFolder, 'breadcrumbs' => $aBreadcrumbs, 'targetname' => $sName)); exit(0); }
function errorRedirectToBrowse($sErrorMessage, $sQuery = "", $event = 'main') { if ($this->bTransactionStarted) { $this->rollbackTransaction(); } $_SESSION['KTErrorMessage'][] = $sErrorMessage; // meld persistant options $sQuery = $this->meldPersistQuery($sQuery, $event); $server = str_replace('action.php', 'browse.php', $_SERVER['PHP_SELF']); $sRedirect = KTUtil::addQueryString($server, $sQuery); $this->oRedirector->redirect($sRedirect); exit(0); }
function getBulkReturnUrl() { $sReturnAction = $_REQUEST['fReturnAction']; $sReturnData = $_REQUEST['fReturnData']; $sAction = 'main'; $qs = ''; switch ($sReturnAction) { case 'browse': $sReturnData = empty($sReturnData) ? $_REQUEST['fFolderId'] : $sReturnData; $sTargetUrl = KTBrowseUtil::getUrlForFolder(Folder::get($sReturnData)); break; case 'simpleSearch': $sTargetUrl = KTBrowseUtil::getSimpleSearchBaseUrl(); $extra = 'fSearchableText=' . $sReturnData; break; case 'booleanSearch': $sTargetUrl = KTBrowseUtil::getBooleanSearchBaseUrl(); $sAction = 'performSearch'; $extra = 'boolean_search_id=' . $sReturnData; break; case 'search2': $sTargetUrl = KTBrowseUtil::getSearchResultURL(); $sAction = 'searchResults'; break; default: $sTargetUrl = $sReturnAction; $sAction = ''; } $qs = !empty($sAction) ? 'action=' . $sAction : ''; $qs .= !empty($extra) ? '&' . $extra : ''; $sTargetUrl = KTUtil::addQueryString($sTargetUrl, $qs); return $sTargetUrl; }
function check() { $this->browse_mode = KTUtil::arrayGet($_REQUEST, 'fBrowseMode', 'folder'); $action = KTUtil::arrayGet($_REQUEST, $this->event_var, 'main'); $this->editable = false; // catch the alternative actions. if ($action != 'main') { return true; } // if we're going to main ... // folder browse mode if ($this->browse_mode == 'folder') { $in_folder_id = KTUtil::arrayGet($_REQUEST, 'fFolderId'); if (empty($in_folder_id)) { $oConfig = KTConfig::getSingleton(); if ($oConfig->get('tweaks/browseToUnitFolder')) { $iHomeFolderId = $this->oUser->getHomeFolderId(); if ($iHomeFolderId) { $in_folder_id = $iHomeFolderId; } } } $folder_id = (int) $in_folder_id; // conveniently, will be 0 if not possible. if ($folder_id == 0) { $folder_id = 1; } $_REQUEST['fBrowseMode'] = 'folder'; // here we need the folder object to do the breadcrumbs. $oFolder =& Folder::get($folder_id); if (PEAR::isError($oFolder)) { return false; // just fail. } // check whether the user can edit this folder $oPerm = KTPermission::getByName('ktcore.permissions.write'); if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPerm, $oFolder)) { $this->editable = true; } else { $this->editable = false; } // set the title and breadcrumbs... $this->oPage->setTitle(_kt('Browse')); if (KTPermissionUtil::userHasPermissionOnItem($this->oUser, 'ktcore.permissions.folder_details', $oFolder)) { $this->oPage->setSecondaryTitle($oFolder->getName()); } else { if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) { $this->oPage->setSecondaryTitle(sprintf('(%s)', $oFolder->getName())); } else { $this->oPage->setSecondaryTitle('...'); } } //Figure out if we came here by navigating trough a shortcut. //If we came here from a shortcut, the breadcrumbspath should be relative //to the shortcut folder. $iSymLinkFolderId = KTUtil::arrayGet($_REQUEST, 'fShortcutFolder', null); if (is_numeric($iSymLinkFolderId)) { $oBreadcrumbsFolder = Folder::get($iSymLinkFolderId); $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForFolder($oBreadcrumbsFolder, array('final' => false))); $this->aBreadcrumbs[] = array('name' => $oFolder->getName()); } else { $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForFolder($oFolder)); } $this->oFolder =& $oFolder; // we now have a folder, and need to create the query. $aOptions = array('ignorepermissions' => KTBrowseUtil::inAdminMode($this->oUser, $oFolder)); $this->oQuery = new BrowseQuery($oFolder->getId(), $this->oUser, $aOptions); $this->resultURL = KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fFolderId=%d', $oFolder->getId())); // and the portlets $portlet = new KTActionPortlet(sprintf(_kt('About this folder'))); $aActions = KTFolderActionUtil::getFolderInfoActionsForFolder($this->oFolder, $this->oUser); $portlet->setActions($aActions, $this->sName); $this->oPage->addPortlet($portlet); $portlet = new KTActionPortlet(sprintf(_kt('Actions on this folder'))); $aActions = KTFolderActionUtil::getFolderActionsForFolder($oFolder, $this->oUser); $portlet->setActions($aActions, null); $this->oPage->addPortlet($portlet); } else { if ($this->browse_mode == 'lookup_value') { // browsing by a lookup value $this->editable = false; // check the inputs $field = KTUtil::arrayGet($_REQUEST, 'fField', null); $oField = DocumentField::get($field); if (PEAR::isError($oField) || $oField == false) { $this->errorRedirectToMain('No Field selected.'); exit(0); } $value = KTUtil::arrayGet($_REQUEST, 'fValue', null); $oValue = MetaData::get($value); if (PEAR::isError($oValue) || $oValue == false) { $this->errorRedirectToMain('No Value selected.'); exit(0); } $this->oQuery = new ValueBrowseQuery($oField, $oValue); $this->resultURL = KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fBrowseMode=lookup_value&fField=%d&fValue=%d', $field, $value)); // setup breadcrumbs $this->aBreadcrumbs = array(array('name' => _kt('Lookup Values'), 'url' => KTUtil::addQueryString($_SERVER['PHP_SELF'], 'action=selectField')), array('name' => $oField->getName(), 'url' => KTUtil::addQueryString($_SERVER['PHP_SELF'], 'action=selectLookup&fField=' . $oField->getId())), array('name' => $oValue->getName(), 'url' => KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fBrowseMode=lookup_value&fField=%d&fValue=%d', $field, $value)))); } else { if ($this->browse_mode == 'document_type') { // browsing by document type $this->editable = false; $doctype = KTUtil::arrayGet($_REQUEST, 'fType', null); $oDocType = DocumentType::get($doctype); if (PEAR::isError($oDocType) || $oDocType == false) { $this->errorRedirectToMain('No Document Type selected.'); exit(0); } $this->oQuery = new TypeBrowseQuery($oDocType); // FIXME probably want to redirect to self + action=selectType $this->aBreadcrumbs[] = array('name' => _kt('Document Types'), 'url' => KTUtil::addQueryString($_SERVER['PHP_SELF'], 'action=selectType')); $this->aBreadcrumbs[] = array('name' => $oDocType->getName(), 'url' => KTUtil::addQueryString($_SERVER['PHP_SELF'], 'fBrowseMode=document_type&fType=' . $oDocType->getId())); $this->resultURL = KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fType=%s&fBrowseMode=document_type', $doctype)); } else { // FIXME what should we do if we can't initiate the browse? we "pretend" to have no perms. return false; } } } return true; }
function do_new() { $this->oPage->setBreadcrumbDetails(_kt("New Link")); $this->oPage->setTitle(_kt("New Link")); $oPermission =& KTPermission::getByName('ktcore.permissions.write'); if (PEAR::isError($oPermission) || !KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oDocument)) { $this->errorRedirectToMain(_kt('You do not have sufficient permissions to add a document link'), sprintf("fDocumentId=%d", $this->oDocument->getId())); exit(0); } $oParentDocument =& $this->oDocument; if (PEAR::isError($oParentDocument)) { $this->errorRedirectToMain(_kt('Invalid parent document selected.')); exit(0); } $oFolder = Folder::get(KTUtil::arrayGet($_REQUEST, 'fFolderId', $oParentDocument->getFolderID())); if (PEAR::isError($oFolder) || $oFolder == false) { $this->errorRedirectToMain(_kt('Invalid folder selected.')); exit(0); } $iFolderId = $oFolder->getId(); // Setup the collection for move display. $collection = new AdvancedCollection(); $aBaseParams = array('fDocumentId' => $oParentDocument->getId()); $oCR =& KTColumnRegistry::getSingleton(); $col = $oCR->getColumn('ktcore.columns.selection'); $aColOptions = array(); $aColOptions['qs_params'] = kt_array_merge($aBaseParams, array('fFolderId' => $oFolder->getId())); $aColOptions['show_folders'] = false; $aColOptions['show_documents'] = true; $aColOptions['rangename'] = 'linkselection[]'; $col->setOptions($aColOptions); $collection->addColumn($col); $col = $oCR->getColumn('ktdocumentlinks.columns.title'); $col->setOptions(array('qs_params' => kt_array_merge($aBaseParams, array('action' => 'new', 'fFolderId' => $oFolder->getId())))); $collection->addColumn($col); $qObj = new BrowseQuery($iFolderId); $collection->setQueryObject($qObj); $aOptions = $collection->getEnvironOptions(); //$aOptions['is_browse'] = true; $aResultUrl = $aBaseParams; $aResultUrl['fFolderId'] = $oFolder->getId(); $aResultUrl['action'] = 'new'; $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], $aResultUrl); $collection->setOptions($aOptions); $aURLParams = $aBaseParams; $aURLParams['action'] = 'new'; $aBreadcrumbs = KTUtil::generate_breadcrumbs($oFolder, $iFolderId, $aURLParams); // Add an electronic signature global $default; if ($default->enableESignatures) { $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true); $heading = _kt('You are attempting to add a document link'); $submit['type'] = 'button'; $submit['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.add_link', 'document', 'document_add_link_form', 'submit', {$oParentDocument->iId});"; } else { $submit['type'] = 'submit'; $submit['onclick'] = ''; } $aTemplateData = array('context' => $this, 'folder' => $oFolder, 'parent' => $oParentDocument, 'breadcrumbs' => $aBreadcrumbs, 'collection' => $collection, 'link_types' => LinkType::getList("id > 0"), 'submit' => $submit); $oTemplate =& $this->oValidator->validateTemplate('ktstandard/action/link'); return $oTemplate->render($aTemplateData); }
function do_update() { $aOptions = array('redirect_to' => array('main', 'fFolderId=' . $this->oFolder->getId())); if (!KTBrowseUtil::inAdminMode($this->oUser, $this->oFolder)) { $this->oValidator->userHasPermissionOnItem($this->oUser, $this->_sEditShowPermission, $this->oFolder, $aOptions); } $aFoo = $_REQUEST['foo']; $aPermissions = KTPermission::getList(); /* --- This section has been commented out to remove these checks when permissions --- are updated. --------------------------------------------------------------------------------- //------------------- //This section is used to make sure that a user doesn't disable the admin groups //Manage security permission or the Manage Security permission of a group they //are currently a member of. // Check which groups have permission to manage security $aNewGroups = (isset($aFoo[4]['group']) ? $aFoo[4]['group'] : array()); $aNewRoles = (isset($aFoo[4]['role']) ? $aFoo[4]['role'] : array()); $iUserId = $this->oUser->getId(); //Check that they aren't removing the sys admin Manage Security permission //1 in this case is the admin group. if(!in_array('1', $aNewGroups)) { $this->addErrorMessage(_kt('You cannot remove the Manage Security permission from the System Administrators Group')); $this->redirectTo('edit', 'fFolderId=' . $this->oFolder->getId()); exit(0); } //Check that they aren't removing the Manage Security permission from a group //They are a member of. if(!GroupUtil::checkUserInGroups($iUserId, array(1))) { //Ensure the user is not removing his/her own permission to update the folder permissions (manage security) if(!in_array(-3, $aNewRoles)) { if(!GroupUtil::checkUserInGroups($iUserId, $aNewGroups)) { // If user no longer has permission, return an error. $this->addErrorMessage(_kt('You cannot remove the Manage Security permission from a group you belong to.')); $this->redirectTo('edit', 'fFolderId=' . $this->oFolder->getId()); exit(0); } } } //----------------- */ require_once KT_LIB_DIR . '/documentmanagement/observers.inc.php'; $oPO = KTPermissionObject::get($this->oFolder->getPermissionObjectId()); foreach ($aPermissions as $oPermission) { $iPermId = $oPermission->getId(); $aAllowed = KTUtil::arrayGet($aFoo, $iPermId, array()); KTPermissionUtil::setPermissionForId($oPermission, $oPO, $aAllowed); } $oTransaction = KTFolderTransaction::createFromArray(array('folderid' => $this->oFolder->getId(), 'comment' => _kt('Updated permissions'), 'transactionNS' => 'ktcore.transactions.permissions_change', 'userid' => $_SESSION['userID'], 'ip' => Session::getClientIP())); $aOptions = array('defaultmessage' => _kt('Error updating permissions'), 'redirect_to' => array('edit', sprintf('fFolderId=%d', $this->oFolder->getId()))); $this->oValidator->notErrorFalse($oTransaction, $aOptions); $po =& new JavascriptObserver($this); $po->start(); $oChannel =& KTPermissionChannel::getSingleton(); $oChannel->addObserver($po); KTPermissionUtil::updatePermissionLookupForPO($oPO); $this->commitTransaction(); $this->addInfoMessage(_kt('Permissions on folder updated')); $po->redirect(KTUtil::addQueryString($_SERVER['PHP_SELF'], 'action=edit&fFolderId=' . $this->oFolder->getId())); exit(0); }
function handleError($sGlobalError = null, $aSimplerErrors = null) { if (!is_null($sGlobalError)) { $this->_errors['_kt_global'][] = $sGlobalError; } if (!is_null($aSimplerErrors)) { foreach ($aSimplerErrors as $k => $v) { $this->_errors[$k] = kt_array_merge($this->_errors[$k], $v); } // since we've changed them, update the stored version $_SESSION['_kt_old_data'][$this->_kt_form_name]['errors'] = serialize($this->_errors); } if (is_array($this->_errors)) { $global_errors = KTUtil::arrayGet($this->_errors, '_kt_global', array()); $_SESSION['KTErrorMessage'] = kt_array_merge($_SESSION['KTErrorMessage'], $global_errors); } if (!empty($this->_failaction) && !is_null($this->_context)) { $this->_context->errorRedirectTo($this->_failaction, _kt("Please correct the errors indicated."), sprintf("_kt_form_name=%s", $this->_kt_form_name)); exit(0); } else { if ($this->_failurl) { redirect(KTUtil::addQueryString($this->_failurl, sprintf("_kt_form_name=%s", $this->_kt_form_name))); exit(0); } else { return '<div class="ktError"><p>' . _kt("An error occured, and no error handlers were configured.") . '</p></div>'; exit(0); } } }
function do_search() { // Get the tag to search for and create search query $tag = isset($_REQUEST['tag']) ? $_REQUEST['tag'] : ''; $decode = isset($_REQUEST['decode']) ? $_REQUEST['decode'] : ''; if ($decode == 'true') { $tag = urldecode($tag); } $iUserId = $_SESSION['userID']; $oUser = User::get($iUserId); // set breadcrumbs $this->aBreadcrumbs[] = array('url' => 'dashboard.php', 'name' => _kt('Dashboard')); $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Tag Cloud Search')); $tagList = $_SESSION['tagList']; if (!empty($tagList)) { $aPrevTag = end($tagList); $aTagTree = $aPrevTag['tagTree']; $base = KTUtil::addQueryString('TagCloudRedirection&action=recall', null); foreach ($aTagTree as $key => $item) { if ($tag == $item) { continue; } $url = $base . '&tag=' . urlencode($item) . '&pos=' . $key; $this->aBreadcrumbs[] = array('url' => $url, 'name' => $item); } } if (!empty($tag)) { $this->aBreadcrumbs[] = array('url' => '', 'name' => $tag); } // set page title $sTitle = _kt('Search Results'); $this->oPage->setBreadcrumbDetails($sTitle); // Set tag cloud portlet $portlet = new TagCloudPortlet($oUser, $tag); $this->oPage->addPortlet($portlet); $collection = new AdvancedCollection(); $oColumnRegistry = KTColumnRegistry::getSingleton(); $aColumns = $oColumnRegistry->getColumnsForView('ktcore.views.search'); $collection->addColumns($aColumns); // set a view option $aTitleOptions = array('documenturl' => $GLOBALS['KTRootUrl'] . '/view.php'); $collection->setColumnOptions('ktcore.columns.title', $aTitleOptions); $collection->setColumnOptions('ktcore.columns.selection', array('rangename' => 'selection', 'show_folders' => true, 'show_documents' => true)); $aOptions = $collection->getEnvironOptions(); // extract data from the environment $returnUrl = KTUtil::addQueryString('TagCloudRedirection&action=search&tag=' . urlencode($tag), false); $aOptions['return_url'] = $returnUrl; $aOptions['empty_message'] = _kt('No documents or folders match this query.'); $aOptions['is_browse'] = true; $collection->setOptions($aOptions); $collection->setQueryObject(new TagQuery($oUser, $tag)); $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('kt3/browse'); $aTemplateData = array('context' => $this, 'collection' => $collection, 'custom_title' => $sTitle, 'isEditable' => true, 'boolean_search' => $sSearch, 'bulkactions' => KTBulkActionUtil::getAllBulkActions(), 'browseutil' => new KTBrowseUtil(), 'returnaction' => $returnUrl); return $oTemplate->render($aTemplateData); }
function addQueryString($url, $qs) { return KTUtil::addQueryString($url, $qs); }
function render() { $iFolderId = KTUtil::arrayGet($_REQUEST, 'fFolderId', 1); $iDocumentId = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); if (!$iFolderId && !$iDocumentId) { return null; } if ($iDocumentId) { $oDocument = Document::get($iDocumentId); if (PEAR::isError($oDocument) || $oDocument === false) { return null; } $iFolderId = $oDocument->getFolderId(); } require_once KT_LIB_DIR . '/security/Permission.inc'; $oUser =& User::get($_SESSION['userID']); if (!Permission::userIsSystemAdministrator($oUser) && !Permission::isUnitAdministratorForFolder($oUser, $iFolderId)) { return null; } require_once KT_LIB_DIR . '/browse/browseutil.inc.php'; $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate("kt3/portlets/admin_mode_portlet"); $toggleMode = 'action=disableAdminMode'; if (KTUtil::arrayGet($_SESSION, 'adminmode', false) == false) { $toggleMode = 'action=enableAdminMode'; } $QS = sprintf('fDocumentId=%s&fFolderId=%s&%s', $iDocumentId, $iFolderId, $toggleMode); $toggleUrl = KTUtil::addQueryString(KTBrowseUtil::getBrowseBaseUrl(), $QS); $aTemplateData = array("context" => $this, 'toggleurl' => $toggleUrl, 'enabled' => KTUtil::arrayGet($_SESSION, 'adminmode', false)); return $oTemplate->render($aTemplateData); }
function buildFolderLink($aDataRow) { if (is_null(KTUtil::arrayGet($this->aOptions, 'direct_folder'))) { $dest = KTUtil::arrayGet($this->aOptions, 'folder_link'); if ($aDataRow['folder']->isSymbolicLink()) { $params = array('fFolderId' => $aDataRow['folder']->getLinkedFolderId(), 'fShortcutFolder' => $aDataRow['folder']->getParentID()); } else { $params = array('fFolderId' => $aDataRow['folder']->getId()); } $params = kt_array_merge(KTUtil::arrayGet($this->aOptions, 'qs_params', array()), $params); if (empty($dest)) { return KTUtil::addQueryStringSelf($params); } else { return KTUtil::addQueryString($dest, $params); } } else { if ($aDataRow['folder']->isSymbolicLink()) { return KTBrowseUtil::getUrlForFolder($aDataRow['folder']->getLinkedFolder()) . "&fShortcutFolder=" . $aDataRow['folder']->getParentID(); } else { return KTBrowseUtil::getUrlForFolder($aDataRow['folder']); } } }
function pageLink($iPageNumber) { $qs = sprintf('page=%s&sort_on=%s&sort_order=%s', $iPageNumber, $this->sort_column, $this->sort_order); return KTUtil::addQueryString($this->returnURL, $qs); }
function _actionhelper($aActionTuple) { $aTuple = array("label" => $aActionTuple["name"]); if ($aActionTuple["action"]) { $aTuple["url"] = generateControllerLink($aActionTuple["action"], $aActionTuple["query"]); } else { if ($aActionTuple["url"]) { $sUrl = $aActionTuple["url"]; $sQuery = KTUtil::arrayGet($aActionTuple, 'query'); if ($sQuery) { $sUrl = KTUtil::addQueryString($sUrl, $sQuery); } $aTuple["url"] = $sUrl; } else { if ($aActionTuple["query"]) { $aTuple['url'] = KTUtil::addQueryStringSelf($aActionTuple["query"]); } else { $aTuple["url"] = false; } } } return $aTuple; }
function form_collectinfo() { $cancelUrl = $this->getReturnUrl(); $oForm = new KTForm(); $oForm->setOptions(array('identifier' => 'ktcore.actions.bulk.copy.form', 'label' => _kt('Copy Items'), 'submit_label' => _kt('Copy'), 'action' => 'performaction', 'fail_action' => 'collectinfo', 'cancel_url' => $cancelUrl, 'context' => $this)); // Setup the collection for move display. require_once KT_LIB_DIR . '/browse/DocumentCollection.inc.php'; $collection = new AdvancedCollection(); $oCR =& KTColumnRegistry::getSingleton(); $col = $oCR->getColumn('ktcore.columns.title'); //$col->setOptions(array('qs_params'=>array('fMoveCode'=>$sMoveCode, // 'fFolderId'=>$oFolder->getId(), // 'action'=>'startMove'))); $collection->addColumn($col); $qObj = new FolderBrowseQuery($this->oFolder->iId); $exclude = array(); foreach ($this->oEntityList->aFolderIds as $folderid) { $exclude[] = $folderid + 0; } $qObj->exclude_folders = $exclude; $collection->setQueryObject($qObj); $aOptions = $collection->getEnvironOptions(); $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], array('fFolderId' => $this->oFolder->iId, 'action' => 'collectinfo')); $collection->setOptions($aOptions); $oWF =& KTWidgetFactory::getSingleton(); $oWidget = $oWF->get('ktcore.widgets.collection', array('label' => _kt('Target Folder'), 'description' => _kt('Use the folder collection and path below to browse to the folder you wish to copy the documents into.'), 'required' => true, 'name' => 'fFolderId', 'broken_name' => true, 'folder_id' => $this->oFolder->iId, 'collection' => $collection)); $oForm->addInitializedWidget($oWidget); // Electronic Signature if enabled global $default; if ($default->enableESignatures) { $oForm->addWidget(array('ktcore.widgets.info', array('label' => _kt('This action requires authentication'), 'description' => _kt('Please provide your user credentials as confirmation of this action.'), 'name' => 'info'))); $oForm->addWidget(array('ktcore.widgets.string', array('label' => _kt('Username'), 'name' => 'sign_username', 'required' => true))); $oForm->addWidget(array('ktcore.widgets.password', array('label' => _kt('Password'), 'name' => 'sign_password', 'required' => true))); } $oForm->addWidget(array('ktcore.widgets.reason', array('name' => 'reason', 'label' => _kt('Reason'), 'description' => _kt('The reason for copying these documents and folders, for historical purposes.'), 'value' => null, 'required' => true))); $oForm->setValidators(array(array('ktcore.validators.string', array('test' => 'reason', 'output' => 'reason')))); if ($default->enableESignatures) { $oForm->addValidator(array('electonic.signatures.validators.authenticate', array('object_id' => $this->oFolder->getID(), 'type' => 'bulk', 'action' => 'ktcore.transactions.bulk_copy', 'test' => 'info', 'output' => 'info'))); } return $oForm; }
function finalise() { $fWizardKey = KTUtil::arrayGet($_REQUEST, 'fWizardKey'); if (!empty($fWizardKey)) { $this->errorRedirectToMain(_kt("Could not create workflow.")); exit; } $wiz_data = $_SESSION['_wiz_data'][$fWizardKey]; // gather all our data. we're sure this is all good and healthy. $states = $wiz_data['states']; $transitions = $wiz_data['transitions']; $from = $wiz_data['from']; $to = $wiz_data['to']; $initial_state = $wiz_data['initial_state']; $workflow_name = $wiz_data['workflow_name']; $this->startTransaction(); // create the initial workflow $oWorkflow = KTWorkflow::createFromArray(array('name' => $workflow_name, 'humanname' => $workflow_name, 'enabled' => true)); if (PEAR::isError($oWorkflow)) { $this->errorRedirectToMain(sprintf(_kt("Failed to create workflow: %s"), $oWorkflow->getMessage())); } $iWorkflowId = $oWorkflow->getId(); // create the states. $aStates = array(); foreach ($states as $state_name) { $oState = KTWorkflowState::createFromArray(array('workflowid' => $iWorkflowId, 'name' => $state_name, 'humanname' => $state_name)); if (PEAR::isError($oState)) { $this->errorRedirectToMain(sprintf(_kt("Failed to create state: %s"), $oState->getMessage())); } $aStates[$state_name] = $oState; } // update the initial state on workflow $oInitialState = $aStates[$initial_state]; $oWorkflow->setStartStateId($oInitialState->getId()); $res = $oWorkflow->update(); if (PEAR::isError($res)) { $this->errorRedirectToMain(sprintf(_kt("Failed to update workflow: %s"), $res->getMessage())); } // next, we create and hook up the transitions. $aTransitions = array(); foreach ($transitions as $transition) { $dest_name = $to[$transition]; $oDestState = $aStates[$dest_name]; $oTransition = KTWorkflowTransition::createFromArray(array("WorkflowId" => $iWorkflowId, "Name" => $transition, "HumanName" => $transition, "TargetStateId" => $oDestState->getId(), "GuardPermissionId" => null, "GuardGroupId" => null, "GuardRoleId" => null, "GuardConditionId" => null)); if (PEAR::isError($oTransition)) { $this->errorRedirectToMain(sprintf(_kt("Failed to create transition: %s"), $oTransition->getMessage())); } // hook up source states. $state_ids = array(); $sources = (array) $from[$transition]; foreach ($sources as $state_name) { // must exist. $oState = $aStates[$state_name]; $state_ids[] = $oState->getId(); } $res = KTWorkflowAdminUtil::saveTransitionSources($oTransition, $state_ids); if (PEAR::isError($res)) { $this->errorRedirectToMain(sprintf(_kt("Failed to set transition origins: %s"), $res->getMessage())); } } $this->commitTransaction(); // finally, we want to redirect the user to the parent dispatcher somehow. // FIXME nbm: how do you recommend we do this? $base = $_SERVER['PHP_SELF']; $qs = sprintf("action=view&fWorkflowId=%d", $oWorkflow->getId()); $url = KTUtil::addQueryString($base, $qs); $this->addInfoMessage(_kt("Your new workflow has been created. You may want to configure security and notifications from the menu on the left.")); redirect($url); }
function do_main() { $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Archived Documents')); $this->oPage->setBreadcrumbDetails(_kt('browse')); $oFolder = Folder::get(KTUtil::arrayGet($_REQUEST, 'fFolderId', 1)); if (PEAR::isError($oFolder)) { $this->errorRedirectToMain(_kt('Invalid folder selected.')); exit(0); } // Setup the collection for restore display. $aBaseParams = array(); $collection = new AdvancedCollection(); $oCR =& KTColumnRegistry::getSingleton(); $col = $oCR->getColumn('ktcore.columns.selection'); $aColOptions = array(); //$aColOptions['qs_params'] = kt_array_merge($aBaseParams, array('fFolderId'=>$oFolder->getId())); $aColOptions['show_folders'] = false; $aColOptions['show_documents'] = true; $aColOptions['rangename'] = '_d[]'; $col->setOptions($aColOptions); $collection->addColumn($col); $col = $oCR->getColumn('ktcore.columns.title'); //$col->setOptions(array('qs_params'=>kt_array_merge($aBaseParams, array('action' => 'new', 'fFolderId'=>$oFolder->getId())))); $col->setOptions(array('link_documents' => false)); $collection->addColumn($col); //$qObj = new BrowseQuery($iFolderId); $qObj = new ArchivedBrowseQuery($oFolder->getId()); $collection->setQueryObject($qObj); $aOptions = $collection->getEnvironOptions(); $aOptions['result_url'] = KTUtil::addQueryString($_SERVER['PHP_SELF'], array(kt_array_merge($aBaseParams, array('fFolderId' => $oFolder->getId())))); $collection->setOptions($aOptions); $aURLParams = $aBaseParams; $aURLParams['action'] = 'restore'; $aBreadcrumbs = KTUtil::generate_breadcrumbs($oFolder, $iFolderId, $aURLParams); $aTemplateData = array('context' => $this, 'folder' => $oFolder, 'breadcrumbs' => $aBreadcrumbs, 'collection' => $collection); $oTemplate =& $this->oValidator->validateTemplate('ktcore/document/admin/archivebrowse'); return $oTemplate->render($aTemplateData); }
function buildFolderLink($aDataRow) { return KTUtil::addQueryString($_SERVER['PHP_SELF'], sprintf('fDocumentId=%d&fFolderId=%d', $this->oDocument->getId(), $aDataRow['folder']->getId())); }
function showUserSource($oUser, $oSource) { $sQuery = sprintf('action=editUserSource&user_id=%d', $oUser->getId()); $sUrl = KTUtil::addQueryString($_SERVER['PHP_SELF'], $sQuery); return '<p class="descriptiveText"><a href="' . $sUrl . '">' . sprintf(_kt('Change %s\'s password'), $oUser->getName()) . '</a></p>'; }