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 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 &form_step1() { $oForm = new KTForm(); $oForm->setOptions(array('action' => 'process_step1', 'cancel_url' => KTUtil::addQueryStringSelf(''), 'fail_action' => 'main', 'label' => _kt('Workflow Details'), 'submit_label' => _kt('Next'), 'description' => _kt('This first step requires that you provide basic details about the workflow: its name, etc.'), 'context' => $this)); $oForm->setWidgets(array(array('ktcore.widgets.string', array('label' => _kt('Workflow Name'), 'description' => _kt('Each workflow must have a unique name.'), 'required' => true, 'name' => 'workflow_name')), array('ktcore.widgets.text', array('label' => _kt('States'), 'description' => _kt('As documents progress through their lifecycle, they pass through a number of <strong>states</strong>. These states describe a step in the process the document must follow. Examples of states include "reviewed","submitted" or "pending". Please enter a list of states, one per line. State names must be unique.'), 'important_description' => _kt('Note that the first state you list is the one in which documents will start the workflow - this can be changed later on. '), 'required' => true, 'name' => 'states', 'rows' => 15)), array('ktcore.widgets.text', array('label' => _kt('Transitions'), 'description' => _kt('In order to move between states, users will cause "transitions" to occur. These transitions represent processes followed, e.g. "review document", "distribute invoice" or "publish". Please enter a list of transitions, one per line. Transition names must be unique. You\'ll assign transitions to states in the next step.'), 'required' => false, 'name' => 'transitions')), array('ktcore.widgets.hidden', array('required' => false, 'name' => 'fWizardKey', 'value' => KTUtil::randomString())))); $oForm->setValidators(array(array('ktcore.validators.string', array('test' => 'workflow_name', 'output' => 'workflow_name')), array('ktcore.validators.string', array('test' => 'fWizardKey', 'output' => 'fWizardKey')), array('ktcore.validators.string', array('test' => 'states', 'output' => 'states', 'max_length' => 9999)), array('ktcore.validators.string', array('test' => 'transitions', 'output' => 'transitions', 'max_length' => 9999)))); return $oForm; }
function breadcrumbsForDocument($oDocument, $aOptions = null, $iFolderId = null) { $bFinal = KTUtil::arrayGet($aOptions, 'final', true, false); $aOptions = KTUtil::meldOptions($aOptions, array('final' => false)); if ($iFolderId == null) { $iFolderId = $oDocument->getFolderId(); } $aBreadcrumbs = KTBrowseUtil::breadcrumbsForFolder($iFolderId, $aOptions); $sAction = KTUtil::arrayGet($aOptions, 'documentaction'); $url = KTUtil::addQueryStringSelf('fDocumentId=' . $oDocument->getId()); if (!empty($sAction)) { $url = generateControllerUrl($sAction, 'fDocumentId=' . $oDocument->getId()); } if ($bFinal) { $aBreadcrumbs[] = array('name' => $oDocument->getName()); } else { $aBreadcrumbs[] = array('url' => $url, 'name' => $oDocument->getName()); } return $aBreadcrumbs; }
function showUserSource($oUser, $oSource) { return '<a href="' . KTUtil::addQueryStringSelf('action=editUserSource&user_id=' . $oUser->getId()) . '">' . _kt('Edit LDAP info') . '</a>'; }
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 loginRequired() { $oKTConfig =& KTConfig::getSingleton(); if ($oKTConfig->get('allowAnonymousLogin', false)) { // anonymous logins are now allowed. // the anonymous user is -1. // // we short-circuit the login mechanisms, setup the session, and go. $oUser =& User::get(-2); if (PEAR::isError($oUser) || $oUser->getName() != 'Anonymous') { // do nothing - the database integrity would break if we log the user in now. } else { $session = new Session(); $sessionID = $session->create($oUser); $this->sessionStatus = $this->session->verify(); if ($this->sessionStatus === true) { return; } } } $sErrorMessage = ""; if (PEAR::isError($this->sessionStatus)) { $sErrorMessage = $this->sessionStatus->getMessage(); } // check if we're in JSON mode - in which case, throw error // but JSON mode only gets set later, so gonna have to check action if (KTUtil::arrayGet($_REQUEST, 'action', '') == 'json') { //$this->bJSONMode) { $this->handleOutputJSON(array('error' => true, 'type' => 'kt.not_logged_in', 'alert' => true, 'message' => _kt('Your session has expired, please log in again.'))); exit(0); } // redirect to login with error message if ($sErrorMessage) { // session timed out $url = generateControllerUrl("login", "errorMessage=" . urlencode($sErrorMessage)); } else { $url = generateControllerUrl("login"); } $redirect = urlencode(KTUtil::addQueryStringSelf($_SERVER["QUERY_STRING"])); if (strlen($redirect) > 1) { global $default; $default->log->debug("checkSession:: redirect url={$redirect}"); // this session verification failure represents either the first visit to // the site OR a session timeout etc. (in which case we still want to bounce // the user to the login page, and then back to whatever page they're on now) $url = $url . urlencode("&redirect=" . urlencode($redirect)); } $default->log->debug("checkSession:: about to redirect to {$url}"); redirect($url); exit(0); }
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.'); }
function do_performEditSourceProvider() { $oSource =& KTAuthenticationSource::get($_REQUEST['source_id']); $sProvider = $oSource->getAuthenticationProvider(); $oRegistry =& KTAuthenticationProviderRegistry::getSingleton(); $oProvider =& $oRegistry->getAuthenticationProvider($sProvider); $this->aBreadcrumbs[] = array('name' => $oSource->getName(), 'url' => KTUtil::addQueryStringSelf("source_id=" . $oSource->getId())); $oProvider->subDispatch($this); exit(0); }
function do_oldSearchResults() { // call the results sorting function in case of sort options selected search2QuerySort(stripslashes($_GET['sort_on']), stripslashes($_GET['sort_order'])); $this->oPage->setBreadcrumbDetails(_kt("Search Results")); $this->oPage->title = _kt("Search Results"); $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', 'direct_folder' => true); $collection->setColumnOptions('ktcore.columns.title', $aTitleOptions); // set the selection options $collection->setColumnOptions('ktcore.columns.selection', array('rangename' => 'selection', 'show_folders' => true, 'show_documents' => true)); $aOptions = $collection->getEnvironOptions(); // extract data from the environment $aOptions['empty_message'] = _kt("No documents or folders match this query."); $aOptions['is_browse'] = true; $aOptions['return_url'] = KTUtil::addQueryStringSelf("action=oldSearchResults"); $collection->setOptions($aOptions); $collection->setQueryObject(new Search2Query()); $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate("kt3/browse"); $aTemplateData = array("context" => $this, "collection" => $collection, 'isEditable' => true, 'bulkactions' => KTBulkActionUtil::getAllBulkActions(), 'browseutil' => new KTBrowseUtil(), 'returnaction' => 'search2'); return $oTemplate->render($aTemplateData); }
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 do_performaction() { // Get reason for checkout & check if docs must be downloaded $this->store_lists(); $this->get_lists(); $oForm = $this->form_collectinfo(); $res = $oForm->validate(); if (!empty($res['errors'])) { $oForm->handleError(); } $this->sReason = $_REQUEST['data']['reason']; $this->bDownload = $_REQUEST['data']['download_file']; $oKTConfig =& KTConfig::getSingleton(); $this->bNoisy = $oKTConfig->get("tweaks/noisyBulkOperations"); $folderurl = KTBrowseUtil::getUrlForFolder($this->oFolder); $sReturn = sprintf('<p>' . _kt('Return to the original <a href="%s">folder</a>') . "</p>\n", $folderurl); $this->startTransaction(); // if files are to be downloaded - create the temp directory for the bulk export if ($this->bDownload) { $folderName = $this->oFolder->getName(); $this->oZip = new ZipFolder($folderName); $res = $this->oZip->checkConvertEncoding(); if (PEAR::isError($res)) { $this->addErrorMessage($res->getMessage()); return $sReturn; } } $result = parent::do_performaction(); if (PEAR::isError($result)) { $this->addErrorMessage($result->getMessage()); return $sReturn; } if ($this->bDownload) { $sExportCode = $this->oZip->createZipFile(); if (PEAR::isError($sExportCode)) { $this->addErrorMessage($sExportCode->getMessage()); return $sReturn; } } $this->commitTransaction(); if ($this->bDownload) { $url = KTUtil::addQueryStringSelf(sprintf('action=downloadZipFile&fFolderId=%d&exportcode=%s', $this->oFolder->getId(), $sExportCode)); $str = sprintf('<p>' . _kt('Go <a href="%s">here</a> to download the zip file if you are not automatically redirected there') . "</p>\n", $url); $folderurl = KTBrowseUtil::getUrlForFolder($this->oFolder); $str .= sprintf('<p>' . _kt('Once downloaded, return to the original <a href="%s">folder</a>') . "</p>\n", $folderurl); $str .= sprintf("</div></div></body></html>\n"); $str .= sprintf('<script language="JavaScript"> function kt_bulkexport_redirect() { document.location.href = "%s"; } callLater(1, kt_bulkexport_redirect); </script>', $url); return $str; } return $result; }
function do_main() { $aErrorOptions = array("message" => _kt("Please provide a search term")); $searchable_text = sanitizeForSQL(KTUtil::arrayGet($_REQUEST, "fSearchableText")); $this->oValidator->notEmpty($searchable_text, $aErrorOptions); $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', 'direct_folder' => true); $collection->setColumnOptions('ktcore.columns.title', $aTitleOptions); // set the selection options $collection->setColumnOptions('ktcore.columns.selection', array('rangename' => 'selection', 'show_folders' => true, 'show_documents' => true)); $aOptions = $collection->getEnvironOptions(); // extract data from the environment $aOptions['return_url'] = KTUtil::addQueryStringSelf("fSearchableText=" . urlencode($searchable_text)); $aOptions['empty_message'] = _kt("No documents or folders match this query."); $aOptions['is_browse'] = true; $collection->setOptions($aOptions); $collection->setQueryObject(new SimpleSearchQuery($searchable_text)); $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate("kt3/browse"); $aTemplateData = array("context" => $this, "collection" => $collection, 'isEditable' => true, 'bulkactions' => KTBulkActionUtil::getAllBulkActions(), 'browseutil' => new KTBrowseUtil(), 'returnaction' => 'simpleSearch', 'returndata' => $searchable_text); return $oTemplate->render($aTemplateData); }
function do_graphrepresentation() { $oTemplate = $this->oValidator->validateTemplate('ktcore/workflow/admin/graphrep'); // this is not ideal // is there no way to get graphviz to give us this more "usefully" $graph = $this->get_graph($this->oWorkflow); $rdata = $graph['graph']->fetch("imap"); // we can skip some of this. $data = explode("\n", $rdata); $data = array_slice($data, 1, -1); if (false) { print '<pre>'; print print_r($data, true); exit(0); } $pat = '|^([\\w]+). # rect, circle, etc. ([^ ]+). # href ([\\d]+), # x0 ([\\d]+). # x1 ([\\d]+), # y0 ([\\d]+) # y1 |x'; $coords = array(); foreach ($data as $row) { $matches = array(); if (preg_match($pat, $row, $matches)) { $rowdata = array_slice($matches, 1); list($shape, $href, $x0, $y0, $x1, $y1) = $rowdata; // FIXME sanity check, we only handle "rect" $real_href = null; $m = array(); $alt = null; if (preg_match('|^(\\w)([\\d]+)$|', $href, $m)) { if ($m[1] == 's') { $real_href = KTUtil::addQueryStringSelf($this->meldPersistQuery(array('fStateId' => $m[2]), "editstate")); $alt = sprintf('Edit State "%s"', $this->state_names[$m[2]]); } else { $real_href = KTUtil::addQueryStringSelf($this->meldPersistQuery(array('fTransitionId' => $m[2]), "edittransition")); $alt = sprintf('Edit Transition "%s"', $this->transition_names[$m[2]]); } } $coords[] = array('shape' => $shape, 'href' => $real_href, 'coords' => sprintf("%d,%d,%d,%d", $x0, $y0, $x1, $y1), 'alt' => $alt); } } if (false) { print '<pre>'; var_dump($coords); exit(0); } $oTemplate->setData(array('context' => $this, 'coords' => $coords)); print $oTemplate->render(); exit(0); }
function do_main() { $config = KTConfig::getSingleton(); $useQueue = $config->get('export/useDownloadQueue', true); // Create the export code $exportCode = KTUtil::randomString(); $this->oZip = new ZipFolder('', $exportCode); if (!$this->oZip->checkConvertEncoding()) { redirect(KTBrowseUtil::getUrlForFolder($this->oFolder)); exit(0); } $bNoisy = $config->get("tweaks/noisyBulkOperations"); $bNotifications = $config->get('export/enablenotifications', 'on') == 'on' ? true : false; $sCurrentFolderId = $this->oFolder->getId(); $url = KTUtil::addQueryStringSelf(sprintf('action=downloadZipFile&fFolderId=%d&exportcode=%s', $sCurrentFolderId, $exportCode)); $folderurl = KTBrowseUtil::getUrlForFolder($this->oFolder); if ($useQueue) { DownloadQueue::addItem($exportCode, $sCurrentFolderId, $sCurrentFolderId, 'folder'); $task_url = KTUtil::kt_url() . '/bin/ajaxtasks/downloadTask.php'; $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/action/bulk_download'); $aParams = array('folder_url' => $folderurl, 'url' => $task_url, 'code' => $exportCode, 'download_url' => $url); return $oTemplate->render($aParams); } // Get all folders and sub-folders $sWhereClause = "parent_folder_ids = '{$sCurrentFolderId}' OR\n parent_folder_ids LIKE '{$sCurrentFolderId},%' OR\n parent_folder_ids LIKE '%,{$sCurrentFolderId},%' OR\n parent_folder_ids LIKE '%,{$sCurrentFolderId}'"; $aFolderList = $this->oFolder->getList($sWhereClause); // Get any folder shortcuts within the folders $aLinkedFolders = KTBulkAction::getLinkingEntities($aFolderList); $aFolderList = array_merge($aFolderList, $aLinkedFolders); // Add the folders to the zip file $aFolderObjects = array($sCurrentFolderId => $this->oFolder); if (!empty($aFolderList)) { foreach ($aFolderList as $oFolderItem) { $itemId = $oFolderItem->getId(); $linkedFolder = $oFolderItem->getLinkedFolderId(); // If the folder has been added or is a shortcut then skip // The shortcut folders don't need to be added as their targets will be added. if (array_key_exists($itemId, $aFolderObjects) || !empty($linkedFolder)) { continue; } $this->oZip->addFolderToZip($oFolderItem); $aFolderObjects[$oFolderItem->getId()] = $oFolderItem; } } // Get the list of folder ids $aFolderIds = array_keys($aFolderObjects); // Get all documents in the folder list $aQuery = $this->buildQuery($aFolderIds); $aDocumentIds = DBUtil::getResultArrayKey($aQuery, 'id'); if (PEAR::isError($aDocumentIds)) { $this->addErrorMessage(_kt('There was a problem exporting the documents: ') . $aDocumentIds->getMessage()); redirect(KTBrowseUtil::getUrlForFolder($this->oFolder)); exit(0); } // Redirect if there are no documents and no folders to export if (empty($aDocumentIds) && empty($aFolderList)) { $this->addErrorMessage(_kt("No documents found to export")); redirect(KTBrowseUtil::getUrlForFolder($this->oFolder)); exit(0); } $this->oPage->template = "kt3/minimal_page"; $this->handleOutput(""); // Add the documents to the zip file if (!empty($aDocumentIds)) { foreach ($aDocumentIds as $iId) { $oDocument = Document::get($iId); $sFolderId = $oDocument->getFolderID(); if (!KTWorkflowUtil::actionEnabledForDocument($oDocument, 'ktcore.actions.document.view')) { $this->addErrorMessage($oDocument->getName() . ': ' . _kt('Document cannot be exported as it is restricted by the workflow.')); continue; } $oFolder = isset($aFolderObjects[$sFolderId]) ? $aFolderObjects[$sFolderId] : Folder::get($sFolderId); if ($bNoisy) { $oDocumentTransaction =& new DocumentTransaction($oDocument, "Document part of bulk export", 'ktstandard.transactions.bulk_export', array()); $oDocumentTransaction->create(); } // fire subscription alerts for the downloaded document if ($bNotifications) { //$oSubscriptionEvent = new SubscriptionEvent(); //$oSubscriptionEvent->DownloadDocument($oDocument, $oFolder); } $this->oZip->addDocumentToZip($oDocument, $oFolder); } } $sExportCode = $this->oZip->createZipFile(TRUE); $oTransaction = KTFolderTransaction::createFromArray(array('folderid' => $this->oFolder->getId(), 'comment' => "Bulk export", 'transactionNS' => 'ktstandard.transactions.bulk_export', 'userid' => $_SESSION['userID'], 'ip' => Session::getClientIP())); $sReturn = '<p>' . _kt('Creating zip file. Compressing and archiving in progress ...') . '</p>'; $sReturn .= "<p style='margin-bottom: 10px;'><br /><b>" . _kt('Warning! Please wait for archiving to complete before closing the page.') . '</b><br />' . _kt('Note: Closing the page before the download link displays will cancel your Bulk Download.') . '</p>'; $sReturn .= '<p>' . _kt('Once your download is complete, click <a href="' . $folderurl . '">here</a> to return to the original folder') . "</p>\n"; print $sReturn; printf("</div></div></body></html>\n"); printf('<script language="JavaScript"> function kt_bulkexport_redirect() { document.location.href = "%s"; } callLater(2, kt_bulkexport_redirect); </script>', $url); exit(0); }
function setOptions($aOptions) { // we grab the "context" dispatcher(ish) object here $context =& KTUtil::arrayGet($aOptions, 'context'); $this->_context =& $context; // form identifier (namespace) $this->sIdentifier = KTUtil::arrayGet($aOptions, 'identifier', 'kt.default'); // form name $this->_kt_form_name = KTUtil::arrayGet($aOptions, '_kt_form_name', $this->generateFormName($this->sIdentifier), false); // form labelling $this->sLabel = KTUtil::arrayGet($aOptions, 'label'); $this->sDescription = KTUtil::arrayGet($aOptions, 'description'); // actions $this->_action = KTUtil::arrayGet($aOptions, 'action'); $qs = KTUtil::arrayGet($aOptions, 'actionparams', ''); $this->_enctype = KTUtil::arrayGet($aOptions, 'encoding'); if (empty($this->_enctype)) { if (KTUtil::arrayGet($aOptions, 'file_upload', false)) { $this->_enctype = "multipart/form-data"; } } $targeturl = KTUtil::arrayGet($aOptions, 'targeturl', false); if ($targeturl === false) { $this->_actionurl = KTUtil::addQueryStringSelf($qs); } else { $this->_actionurl = KTUtil::addQueryString($targeturl, $qs); } $this->_failaction = KTUtil::arrayGet($aOptions, 'fail_action'); $this->_failurl = KTUtil::arrayGet($aOptions, 'fail_url'); $this->_submitlabel = KTUtil::arrayGet($aOptions, 'submit_label', _kt('Submit')); $this->_event = KTUtil::arrayGet($aOptions, 'event'); if (empty($this->_event)) { if (!is_null($context)) { $this->_event = $context->event_var; } else { $this->_event = "action"; } } $this->_noframe = KTUtil::arrayGet($aOptions, 'noframe', false); // cancel // there are a few options here: // 1. cancel_action // 2. cancel_url $cancel_action = KTUtil::arrayGet($aOptions, 'cancel_action'); $cancel_url = KTUtil::arrayGet($aOptions, 'cancel_url'); if (!empty($cancel_action)) { $this->bCancel = true; // there are two cases here - if we have a context, we can // use the meldPersistQuery to create the url. if (!is_null($context)) { $sQuery = $context->meldPersistQuery("", $cancel_action); $this->_cancelurl = KTUtil::addQueryString($_SERVER['PHP_SELF'], $sQuery); } else { // give it a try using addQSSelf $this->_cancelurl = KTUtil::addQueryStringSelf(sprintf('%s=%s', $this->_event, $cancel_action)); } } else { if (!empty($cancel_url)) { $this->bCancel = true; $this->_cancelurl = $cancel_url; } else { $this->bCancel = false; } } // FIXME process extra arguments more intelligently $default_args = array(); if (!is_null($this->_context)) { $default_args = $this->_context->meldPersistQuery("", "", true); } $this->_extraargs = KTUtil::arrayGet($aOptions, 'extraargs', $default_args); // method $this->_method = KTUtil::arrayGet($aOptions, 'method', 'post'); $this->_extraargs['postReceived'] = 1; }
function displayConfiguration($args) { $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate('ktcore/workflowtriggers/moveaction'); require_once KT_LIB_DIR . '/browse/DocumentCollection.inc.php'; require_once KT_LIB_DIR . '/browse/columnregistry.inc.php'; $collection = new AdvancedCollection(); $oColumnRegistry = KTColumnRegistry::getSingleton(); $aColumns = array(); $aColumns[] = $oColumnRegistry->getColumn('ktcore.columns.singleselection'); $aColumns[] = $oColumnRegistry->getColumn('ktcore.columns.title'); $collection->addColumns($aColumns); $aOptions = $collection->getEnvironOptions(); // extract data from the environment $qsFrag = array(); foreach ($args as $k => $v) { if ($k == 'action') { $v = 'editactiontrigger'; } // horrible hack - we really need iframe embedding. $qsFrag[] = sprintf('%s=%s', urlencode($k), urlencode($v)); } $qs = implode('&', $qsFrag); $aOptions['result_url'] = KTUtil::addQueryStringSelf($qs); $aOptions['show_documents'] = false; $fFolderId = KTUtil::arrayGet($_REQUEST, 'fFolderId', KTUtil::arrayGet($this->aConfig, 'folder_id', 1)); $oFolder = Folder::get($fFolderId); if (PEAR::isError($oFolder)) { $iRoot = 1; $oFolder = Folder::get($iRoot); $fFolderId = 1; } $collection->setOptions($aOptions); $collection->setQueryObject(new BrowseQuery($fFolderId, $this->oUser)); $collection->setColumnOptions('ktcore.columns.singleselection', array('rangename' => 'folder_id', 'show_folders' => true, 'show_documents' => false)); $collection->setColumnOptions('ktcore.columns.title', array('direct_folder' => false, 'folder_link' => $aOptions['result_url'])); $aBreadcrumbs = array(); $folder_path_names = $oFolder->getPathArray(); $folder_path_ids = explode(',', $oFolder->getParentFolderIds()); $folder_path_ids[] = $oFolder->getId(); if ($folder_path_ids[0] == 0) { array_shift($folder_path_ids); array_shift($folder_path_names); } foreach (range(0, count($folder_path_ids) - 1) as $index) { $id = $folder_path_ids[$index]; $qsFrag2 = $qsFrag; $qsFrag2[] = sprintf('fFolderId=%d', $id); $qs2 = implode('&', $qsFrag2); $url = KTUtil::addQueryStringSelf($qs2); $aBreadcrumbs[] = sprintf('<a href="%s">%s</a>', $url, htmlentities($folder_path_names[$index], ENT_NOQUOTES, 'UTF-8')); } $sBreadcrumbs = implode(' » ', $aBreadcrumbs); $aTemplateData = array('context' => $this, 'breadcrumbs' => $sBreadcrumbs, 'collection' => $collection, 'args' => $args); return $oTemplate->render($aTemplateData); }
function buildFolderLink($aDataRow) { if (is_null(KTUtil::arrayGet($this->aOptions, 'direct_folder'))) { return KTUtil::addQueryStringSelf('fFolderId=' . $aDataRow['folder']->getId()); } else { return KTBrowseUtil::getUrlForFolder($aDataRow['folder']); } }
function do_viewComparison() { $document_data = array(); $document_id = KTUtil::arrayGet($_REQUEST, 'fDocumentId'); if ($document_id === null) { $this->oPage->addError(sprintf(_kt("No document was requested. Please <a href=\"%s\">browse</a> for one."), KTBrowseUtil::getBrowseBaseUrl())); return $this->do_error(); } $document_data['document_id'] = $document_id; $base_version = KTUtil::arrayGet($_REQUEST, 'fBaseVersion'); // try get the document. $oDocument =& Document::get($document_id, $base_version); if (PEAR::isError($oDocument)) { $this->oPage->addError(sprintf(_kt("The base document you attempted to retrieve is invalid. Please <a href=\"%s\">browse</a> for one."), KTBrowseUtil::getBrowseBaseUrl())); return $this->do_error(); } if (!Permission::userHasDocumentReadPermission($oDocument)) { // FIXME inconsistent. $this->oPage->addError(_kt('You are not allowed to view this document')); return $this->permissionDenied(); } $this->oDocument =& $oDocument; $this->oPage->setSecondaryTitle($oDocument->getName()); $aOptions = array('documentaction' => 'viewDocument', 'folderaction' => 'browse'); $this->aBreadcrumbs = kt_array_merge($this->aBreadcrumbs, KTBrowseUtil::breadcrumbsForDocument($oDocument, $aOptions)); $this->oPage->setBreadcrumbDetails(_kt('compare versions')); $comparison_version = KTUtil::arrayGet($_REQUEST, 'fComparisonVersion'); if ($comparison_version === null) { $this->oPage->addError(sprintf(_kt("No comparison version was requested. Please <a href=\"%s\">select a version</a>."), KTUtil::addQueryStringSelf('action=history&fDocumentId=' . $document_id))); return $this->do_error(); } $oComparison =& Document::get($oDocument->getId(), $comparison_version); if (PEAR::isError($oComparison)) { $this->errorRedirectToMain(_kt('Invalid document to compare against.')); } $comparison_data = array(); $comparison_data['document_id'] = $oComparison->getId(); $document_data['document'] = $oDocument; $comparison_data['document'] = $oComparison; $document_data['document_type'] =& DocumentType::get($oDocument->getDocumentTypeID()); $comparison_data['document_type'] =& DocumentType::get($oComparison->getDocumentTypeID()); // follow twice: once for normal, once for comparison. $is_valid_doctype = true; if (PEAR::isError($document_data['document_type'])) { $this->oPage->addError(_kt('The document you requested has an invalid <strong>document type</strong>. Unfortunately, this means that we cannot effectively display it.')); $is_valid_doctype = false; } // we want to grab all the md for this doc, since its faster that way. $mdlist =& DocumentFieldLink::getList(array('metadata_version_id = ?', array($base_version))); $field_values = array(); foreach ($mdlist as $oFieldLink) { $field_values[$oFieldLink->getDocumentFieldID()] = $oFieldLink->getValue(); } $document_data['field_values'] = $field_values; $mdlist =& DocumentFieldLink::getList(array('metadata_version_id = ?', array($comparison_version))); $field_values = array(); foreach ($mdlist as $oFieldLink) { $field_values[$oFieldLink->getDocumentFieldID()] = $oFieldLink->getValue(); } $comparison_data['field_values'] = $field_values; // Fieldset generation. // // we need to create a set of FieldsetDisplay objects // that adapt the Fieldsets associated with this lot // to the view (i.e. ZX3). Unfortunately, we don't have // any of the plumbing to do it, so we handle this here. $fieldsets = array(); // we always have a generic. array_push($fieldsets, new GenericFieldsetDisplay()); // FIXME can we key this on fieldset namespace? or can we have duplicates? // now we get the other fieldsets, IF there is a valid doctype. if ($is_valid_doctype) { // these are the _actual_ fieldsets. $fieldsetDisplayReg =& KTFieldsetDisplayRegistry::getSingleton(); // and the generics $activesets = KTFieldset::getGenericFieldsets(); foreach ($activesets as $oFieldset) { $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace()); array_push($fieldsets, new $displayClass($oFieldset)); } $activesets = KTFieldset::getForDocumentType($oDocument->getDocumentTypeID()); foreach ($activesets as $oFieldset) { $displayClass = $fieldsetDisplayReg->getHandler($oFieldset->getNamespace()); array_push($fieldsets, new $displayClass($oFieldset)); } } // FIXME handle ad-hoc fieldsets. $this->addPortlets(); $oTemplate = $this->oValidator->validateTemplate('ktcore/document/compare'); $aTemplateData = array('context' => $this, 'document_id' => $document_id, 'document' => $oDocument, 'document_data' => $document_data, 'comparison_data' => $comparison_data, 'comparison_document' => $oComparison, 'fieldsets' => $fieldsets); //var_dump($aTemplateData['comparison_data']); return $oTemplate->render($aTemplateData); }
function handleCriteriaSet($aCriteriaSet, $iStartIndex, $sTitle = null, $bIsCondition = false) { if ($sTitle == null) { $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Advanced Search')); $sTitle = _kt('Search Results'); } else { if ($bIsCondition) { $this->aBreadcrumbs[] = array('name' => _kt('Test Condition')); $this->oPage->setTitle(sprintf(_kt('Test Condition: %s'), $sTitle)); } else { $this->aBreadcrumbs[] = array('name' => _kt('Saved Search')); $this->oPage->setTitle(sprintf(_kt('Saved Search: %s'), $sTitle)); } $this->oPage->setBreadcrumbDetails($sTitle); } $this->browseType = "Folder"; $searchable_text = KTUtil::arrayGet($_REQUEST, "fSearchableText"); $sSearch = md5(serialize($aCriteriaSet)); $_SESSION['boolean_search'][$sSearch] = $aCriteriaSet; $collection = new AdvancedCollection(); $oColumnRegistry = KTColumnRegistry::getSingleton(); $aColumns = $oColumnRegistry->getColumnsForView('ktcore.views.search'); $collection->addColumns($aColumns); // get search parameters $oCriteriaRegistry =& KTCriteriaRegistry::getSingleton(); $aParams = array(); $aJoins = array(); $aJoins['main'] = $aCriteriaSet['join'] == 'AND' ? _kt('all') : _kt('any'); foreach ($aCriteriaSet['subgroup'] as $k => $subgroup) { $aGroup = array(); $aJoins[$k] = $subgroup['join'] == 'AND' ? _kt('all') : _kt('any'); if (!empty($subgroup['values'])) { foreach ($subgroup['values'] as $value) { $oCriterion =& $oCriteriaRegistry->getCriterion($value['type']); if ($oCriterion == null || $oCriterion == "" || PEAR::isError($oCriterion)) { $this->errorRedirectToMain('Criterion error'); } $aGroup[] = $oCriterion->parameterDisplay($value['data']); } } $aParams[] = $aGroup; } // 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 $aOptions['return_url'] = KTUtil::addQueryStringSelf("action=performSearch&boolean_search_id=" . urlencode($sSearch)); $aOptions['empty_message'] = _kt("No documents or folders match this query."); $aOptions['is_browse'] = true; $collection->setOptions($aOptions); $collection->setQueryObject(new BooleanSearchQuery($aCriteriaSet)); //$a = new BooleanSearchQuery($aCriteriaSet); //var_dump($a->getDocumentCount()); exit(0); // form fields for saving the search $save_fields = array(); $save_fields[] = new KTStringWidget(_kt('New search'), _kt('The name to save this search as'), 'name', null, $this->oPage, true); $aUserSearches = KTSavedSearch::getUserSearches($this->oUser->getId(), true); if (count($aUserSearches)) { $aVocab = array('' => ' ---- '); foreach ($aUserSearches as $oSearch) { $aVocab[$oSearch->getId()] = $oSearch->getName(); } $aSelectOptions = array('vocab' => $aVocab); $save_fields[] = new KTLookupWidget(_kt('Existing search'), _kt('To save over one of your existing searches, select it here.'), 'fSearchId', null, $this->oPage, true, null, null, $aSelectOptions); } $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate("kt3/browse"); $aTemplateData = array("context" => $this, "collection" => $collection, "custom_title" => $sTitle, "save_fields" => $save_fields, "params" => $aParams, "joins" => $aJoins, 'isEditable' => true, "boolean_search" => $sSearch, 'bulkactions' => KTBulkActionUtil::getAllBulkActions(), 'browseutil' => new KTBrowseUtil(), 'returnaction' => 'booleanSearch', 'returndata' => $sSearch); return $oTemplate->render($aTemplateData); }
function do_addUserFromSource() { $oSource =& KTAuthenticationSource::get($_REQUEST['source_id']); $sProvider = $oSource->getAuthenticationProvider(); $oRegistry =& KTAuthenticationProviderRegistry::getSingleton(); $oProvider =& $oRegistry->getAuthenticationProvider($sProvider); $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('User Management')); $this->aBreadcrumbs[] = array('url' => KTUtil::addQueryStringSelf('action=addUser'), 'name' => _kt('add a new user')); $oProvider->aBreadcrumbs = $this->aBreadcrumbs; $oProvider->oPage->setBreadcrumbDetails($oSource->getName()); $oProvider->oPage->setTitle(_kt("Add New User")); $oProvider->dispatch(); exit(0); }
function do_main() { $folderName = $this->oFolder->getName(); $this->oZip = new ZipFolder($folderName); if (!$this->oZip->checkConvertEncoding()) { redirect(KTBrowseUtil::getUrlForFolder($this->oFolder)); exit(0); } $oKTConfig =& KTConfig::getSingleton(); $bNoisy = $oKTConfig->get("tweaks/noisyBulkOperations"); $bNotifications = $oKTConfig->get('export/enablenotifications', 'on') == 'on' ? true : false; // Get all folders and sub-folders $sCurrentFolderId = $this->oFolder->getId(); $sWhereClause = "parent_folder_ids = '{$sCurrentFolderId}' OR\n parent_folder_ids LIKE '{$sCurrentFolderId},%' OR\n parent_folder_ids LIKE '%,{$sCurrentFolderId},%' OR\n parent_folder_ids LIKE '%,{$sCurrentFolderId}'"; $aFolderList = $this->oFolder->getList($sWhereClause); // Get any folder shortcuts within the folders $aLinkedFolders = KTBulkAction::getLinkingEntities($aFolderList); $aFolderList = array_merge($aFolderList, $aLinkedFolders); // Add the folders to the zip file $aFolderObjects = array($sCurrentFolderId => $this->oFolder); if (!empty($aFolderList)) { foreach ($aFolderList as $oFolderItem) { $itemId = $oFolderItem->getId(); $linkedFolder = $oFolderItem->getLinkedFolderId(); // If the folder has been added or is a shortcut then skip // The shortcut folders don't need to be added as their targets will be added. if (array_key_exists($itemId, $aFolderObjects) || !empty($linkedFolder)) { continue; } $this->oZip->addFolderToZip($oFolderItem); $aFolderObjects[$oFolderItem->getId()] = $oFolderItem; } } // Get the list of folder ids $aFolderIds = array_keys($aFolderObjects); // Get all documents in the folder list $aQuery = $this->buildQuery($aFolderIds); $aDocumentIds = DBUtil::getResultArrayKey($aQuery, 'id'); if (PEAR::isError($aDocumentIds)) { $this->addErrorMessage(_kt('There was a problem exporting the documents: ') . $aDocumentIds->getMessage()); redirect(KTBrowseUtil::getUrlForFolder($this->oFolder)); exit(0); } // Redirect if there are no documents and no folders to export if (empty($aDocumentIds) && empty($aFolderList)) { $this->addErrorMessage(_kt("No documents found to export")); redirect(KTBrowseUtil::getUrlForFolder($this->oFolder)); exit(0); } $this->oPage->template = "kt3/minimal_page"; $this->handleOutput(""); // Add the documents to the zip file if (!empty($aDocumentIds)) { foreach ($aDocumentIds as $iId) { $oDocument = Document::get($iId); $sFolderId = $oDocument->getFolderID(); if (!KTWorkflowUtil::actionEnabledForDocument($oDocument, 'ktcore.actions.document.view')) { $this->addErrorMessage($oDocument->getName() . ': ' . _kt('Document cannot be exported as it is restricted by the workflow.')); continue; } $oFolder = isset($aFolderObjects[$sFolderId]) ? $aFolderObjects[$sFolderId] : Folder::get($sFolderId); if ($bNoisy) { $oDocumentTransaction =& new DocumentTransaction($oDocument, "Document part of bulk export", 'ktstandard.transactions.bulk_export', array()); $oDocumentTransaction->create(); } // fire subscription alerts for the downloaded document if ($bNotifications) { $oSubscriptionEvent = new SubscriptionEvent(); $oSubscriptionEvent->DownloadDocument($oDocument, $oFolder); } $this->oZip->addDocumentToZip($oDocument, $oFolder); } } $sExportCode = $this->oZip->createZipFile(TRUE); $oTransaction = KTFolderTransaction::createFromArray(array('folderid' => $this->oFolder->getId(), 'comment' => "Bulk export", 'transactionNS' => 'ktstandard.transactions.bulk_export', 'userid' => $_SESSION['userID'], 'ip' => Session::getClientIP())); $url = KTUtil::addQueryStringSelf(sprintf('action=downloadZipFile&fFolderId=%d&exportcode=%s', $this->oFolder->getId(), $sExportCode)); printf('<p>' . _kt('Your download will begin shortly. If you are not automatically redirected to your download, please click <a href="%s">here</a> ') . "</p>\n", $url); $folderurl = KTBrowseUtil::getUrlForFolder($this->oFolder); printf('<p>' . _kt('Once your download is complete, click <a href="%s">here</a> to return to the original folder') . "</p>\n", $folderurl); printf("</div></div></body></html>\n"); printf('<script language="JavaScript"> function kt_bulkexport_redirect() { document.location.href = "%s"; } callLater(1, kt_bulkexport_redirect); </script>', $url); exit(0); }
function _evilActionHelper($iFieldsetId, $iFieldId, $bIsKeyword, $current_node) { $actionStr = " ("; if ($bIsKeyword === true) { $actionStr .= '<a href="' . KTUtil::addQueryStringSelf(KTUtil::addQueryStringSelf($this->meldPersistQuery('keyword_id=' . $current_node . '&subaction=unlinkKeyword', 'managetree'))) . '">' . _kt('unlink') . '</a>'; } else { $actionStr .= '<a href="' . KTUtil::addQueryStringSelf($this->meldPersistQuery('current_node=' . $current_node, 'managetree')) . '">' . _kt('attach keywords') . '</a> '; $actionStr .= '| <a href="' . KTUtil::addQueryStringSelf($this->meldPersistQuery('current_node=' . $current_node . '&subaction=deleteCategory', 'managetree')) . '">' . _kt('delete') . '</a>'; } $actionStr .= ")"; return $actionStr; }
function addQueryStringSelf($qs) { return KTUtil::addQueryStringSelf($qs); }
function do_edit() { // here we engage in some major evil. // we check for the subevent var // and subdispatch if appropriate. // // saves a little code-duplication (actually, a lot of code-duplication) // FIXME this is essentially a stub for the fieldset-delegation code. if ($this->oFieldset->getIsConditional()) { require_once 'fieldsets/conditional.inc.php'; $oSubDispatcher = new ConditionalFieldsetManagementDispatcher(); } else { require_once 'fieldsets/basic.inc.php'; $oSubDispatcher = new BasicFieldsetManagementDispatcher(); } $subevent_var = 'fieldset_action'; $subevent = KTUtil::arrayGet($_REQUEST, $subevent_var); if (!empty($subevent)) { // do nothing, since this will handle everything $this_url = KTUtil::addQueryStringSelf($this->meldPersistQuery("", "edit")); $oSubDispatcher->redispatch($subevent_var, null, $this, $this_url); exit(0); } else { // what we want is the "additional info" section $additional = $oSubDispatcher->describe_fieldset($this->oFieldset); } $oTemplate =& $this->oValidator->validateTemplate('ktcore/metadata/admin/edit'); $oTemplate->setData(array('context' => $this, 'fieldset_name' => $this->oFieldset->getName(), 'additional' => $additional)); return $oTemplate->render(); }
function do_main() { $this->oPage->setTitle(_kt("Allocate Roles")); $this->oPage->setBreadcrumbDetails(_kt("Allocate Roles")); $oTemplating =& KTTemplating::getSingleton(); $oTemplate = $oTemplating->loadTemplate("ktcore/folder/roles"); // we need to have: // - a list of roles // - with their users / groups // - and that allocation id $aRoles = array(); // stores data for display. $aRoleList = Role::getList('id > 0'); foreach ($aRoleList as $oRole) { $iRoleId = $oRole->getId(); $aRoles[$iRoleId] = array("name" => $oRole->getName()); $oRoleAllocation = RoleAllocation::getAllocationsForFolderAndRole($this->oFolder->getId(), $iRoleId); $u = array(); $g = array(); $aid = null; $raid = null; if ($oRoleAllocation == null) { // nothing. } else { $raid = $oRoleAllocation->getId(); // real_alloc_id if ($oRoleAllocation->getFolderId() == $this->oFolder->getId()) { $aid = $oRoleAllocation->getid(); // alloc_id } $oPermDesc = KTPermissionDescriptor::get($oRoleAllocation->getPermissionDescriptorId()); if (!PEAR::isError($oPermDesc)) { $aAllowed = $oPermDesc->getAllowed(); if (!empty($aAllowed['user'])) { $u = $aAllowed['user']; } if (!empty($aAllowed['group'])) { $g = $aAllowed['group']; } } } $aRoles[$iRoleId]['users'] = $u; $aRoles[$iRoleId]['groups'] = $g; $aRoles[$iRoleId]['allocation_id'] = $aid; $aRoles[$iRoleId]['real_allocation_id'] = $raid; } /* print '<pre>'; var_dump($aRoles); print '</pre>'; */ // FIXME this is test data. /* $aRoles = array( 1 => array('name' => 'Manager', 'users' => array(1), 'groups' => array(1), 'allocation_id' => 1), 2 => array('name' => 'Peasant', 'users' => array(1), 'groups' => array(), 'allocation_id' => 2), 3 => array('name' => 'Inherited', 'users' => array(), 'groups' => array(1), 'allocation_id' => null), ); */ // final step. // Include the electronic signature global $default; $iFolderId = $this->oFolder->getId(); if ($default->enableESignatures) { $sign = true; $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true); $heading = _kt('You are attempting to modify roles'); $input_href = '#'; } else { $sign = false; $input_onclick = ''; } // map to users, groups. foreach ($aRoles as $key => $role) { $_users = array(); foreach ($aRoles[$key]['users'] as $iUserId) { $oUser = User::get($iUserId); if (!(PEAR::isError($oUser) || $oUser == false)) { $_users[] = $oUser->getName(); } } if (empty($_users)) { $aRoles[$key]['users'] = '<span class="descriptiveText"> ' . _kt('no users') . '</span>'; } else { $aRoles[$key]['users'] = join(', ', $_users); } $_groups = array(); foreach ($aRoles[$key]['groups'] as $iGroupId) { $oGroup = Group::get($iGroupId); if (!(PEAR::isError($oGroup) || $oGroup == false)) { $_groups[] = $oGroup->getName(); } } if (empty($_groups)) { $aRoles[$key]['groups'] = '<span class="descriptiveText"> ' . _kt('no groups') . '</span>'; } else { $aRoles[$key]['groups'] = join(', ', $_groups); } if ($sign) { $redirect_url = KTUtil::addQueryStringSelf("action=useParent&role_id={$key}&fFolderId={$iFolderId}"); $input_onclick = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'ktcore.transactions.role_allocations_change', 'folder', '{$redirect_url}', 'redirect', {$iFolderId});"; } else { $input_href = KTUtil::addQueryStringSelf("action=useParent&role_id={$key}&fFolderId={$iFolderId}"); } $aRoles[$key]['onclick'] = $input_onclick; $aRoles[$key]['href'] = $input_href; } $aTemplateData = array('context' => &$this, 'roles' => $aRoles, 'folderName' => $this->oFolder->getName(), 'is_root' => $this->oFolder->getId() == 1); return $oTemplate->render($aTemplateData); }