Esempio n. 1
0
 function render()
 {
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate("ktcore/search2/search_portlet");
     $iFolderId = KTUtil::arrayGet($_REQUEST, 'fFolderId', 1);
     $iDocumentId = KTUtil::arrayGet($_REQUEST, 'fDocumentId');
     if (!$iFolderId && !$iDocumentId) {
         return null;
     }
     $savedSearches = SearchHelper::getSavedSearches($_SESSION['userID']);
     $aTemplateData = array('context' => $this, 'folder_id' => $iFolderId, 'document_id' => $iDocumentId, 'savedSearches' => $savedSearches);
     return $oTemplate->render($aTemplateData);
 }
Esempio n. 2
0
 function render()
 {
     global $default;
     $oConfig = KTConfig::getSingleton();
     if (empty($this->contents)) {
         $this->contents = "";
     }
     if (is_string($this->contents) && trim($this->contents) === "") {
         $this->addError(_kt("This page did not produce any content"));
         $this->contents = "";
     }
     if (!is_string($this->contents)) {
         $this->contents = $this->contents->render();
     }
     // if we have no portlets, make the ui a tad nicer.
     if (empty($this->portlets)) {
         $this->show_portlets = false;
     }
     if (empty($this->title)) {
         if (!empty($this->breadcrumbDetails)) {
             $this->title = $this->breadcrumbDetails;
         } else {
             if (!empty($this->breadcrumbs)) {
                 $this->title = array_slice($this->breadcrumbs, -1);
                 $this->title = $this->title[0]['label'];
             } else {
                 if (!empty($this->breadcrumbSection)) {
                     $this->title = $this->breadcrumbSection['label'];
                 } else {
                     $this->title = $this->componentLabel;
                 }
             }
         }
     }
     $this->userMenu = array();
     $sBaseUrl = KTUtil::kt_url();
     if (!(PEAR::isError($this->user) || is_null($this->user) || $this->user->isAnonymous())) {
         if ($oConfig->get("user_prefs/restrictPreferences", false) && !Permission::userIsSystemAdministrator($this->user->getId())) {
             $this->userMenu['logout'] = array('label' => _kt('Logout'), 'url' => $sBaseUrl . '/presentation/logout.php');
         } else {
             if ($default->enableESignatures) {
                 $sUrl = KTPluginUtil::getPluginPath('electronic.signatures.plugin', true);
                 $heading = _kt('You are attempting to modify Preferences');
                 $this->userMenu['preferences']['url'] = '#';
                 $this->userMenu['preferences']['onclick'] = "javascript: showSignatureForm('{$sUrl}', '{$heading}', 'dms.administration.accessing_preferences', 'system', '{$sBaseUrl}/preferences.php', 'redirect');";
             } else {
                 $this->userMenu['preferences']['url'] = $sBaseUrl . '/preferences.php';
             }
             //	        $this->userMenu['preferences'] = array('label' => _kt('Preferences'), 'url' => $sBaseUrl.'/preferences.php');
             $this->userMenu['preferences']['label'] = _kt('Preferences');
             $this->userMenu['aboutkt'] = array('label' => _kt('About'), 'url' => $sBaseUrl . '/about.php');
             $this->userMenu['logout'] = array('label' => _kt('Logout'), 'url' => $sBaseUrl . '/presentation/logout.php');
         }
     } else {
         $this->userMenu['login'] = array('label' => _kt('Login'), 'url' => $sBaseUrl . '/login.php');
     }
     // FIXME we need a more complete solution to navigation restriction
     if (!is_null($this->menu['administration']) && !is_null($this->user)) {
         if (!Permission::userIsSystemAdministrator($this->user->getId())) {
             unset($this->menu['administration']);
         }
     }
     $sContentType = 'Content-type: ' . $this->contentType;
     if (!empty($this->charset)) {
         $sContentType .= '; charset=' . $this->charset;
     }
     header($sContentType);
     $savedSearches = SearchHelper::getSavedSearches($_SESSION['userID']);
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate($this->template);
     $aTemplateData = array("page" => $this, "systemversion" => $default->systemVersion, "versionname" => $default->versionName, 'smallVersion' => substr($default->versionName, -17), 'savedSearches' => $savedSearches);
     if ($oConfig->get("ui/automaticRefresh", false)) {
         $aTemplateData['refreshTimeout'] = (int) $oConfig->get("session/sessionTimeout") + 3;
     }
     // unlike the rest of KT, we use echo here.
     echo $oTemplate->render($aTemplateData);
 }
Esempio n. 3
0
 public static function getSavedSearches($userID)
 {
     $rs = SearchHelper::getSavedSearches($userID);
     if (PEAR::isError($rs)) {
         AjaxSearchHelper::createResponse(AjaxSearchHelper::STATUS_INTERNAL);
     }
     AjaxSearchHelper::createResponse(AjaxSearchHelper::STATUS_SUCCESS, null, 'searches', $rs);
 }
Esempio n. 4
0
 /**
  * This method gets a list of saved searches
  *
  * @author KnowledgeTree Tean
  * @access public
  * @return array|object $list SUCESS - The list of saved searches | FAILURE - an error object
  */
 public function get_list()
 {
     $user = $this->ktapi->get_user();
     if (is_null($user) || PEAR::isError($user)) {
         $list = new PEAR_Error(KTAPI_ERROR_USER_INVALID);
         return $list;
     }
     $userID = $user->getId();
     $list = SearchHelper::getSavedSearches($userID);
     if (PEAR::isError($list)) {
         $list = new PEAR_Error('Invalid saved search result');
         return $list;
     }
     return $list;
 }