Ejemplo n.º 1
0
 function is_active($oUser)
 {
     if (!Permission::userIsSystemAdministrator()) {
         return false;
     }
     $indexerDiagnosis = KTUtil::getSystemSetting('indexerDiagnostics');
     $extractorDiagnosis = KTUtil::getSystemSetting('extractorDiagnostics');
     if (!empty($indexerDiagnosis)) {
         $indexerDiagnosis = unserialize($indexerDiagnosis);
     }
     if (!empty($extractorDiagnosis)) {
         $extractorDiagnosis = unserialize($extractorDiagnosis);
     }
     if (empty($indexerDiagnosis) && empty($extractorDiagnosis)) {
         return false;
     }
     $this->indexerDiagnosis = $indexerDiagnosis;
     $this->extractorDiagnosis = array();
     $result = array();
     foreach ($extractorDiagnosis as $class => $diagnosis) {
         $name = $diagnosis['name'];
         $diag = $diagnosis['diagnosis'];
         $result[$diag][] = $name;
     }
     foreach ($result as $problem => $indexers) {
         if (empty($problem)) {
             continue;
         }
         $this->extractorDiagnosis[] = array('problem' => $problem, 'indexers' => $indexers);
     }
     $this->indexerDiagnosis = str_replace(array("\n", 'Administrator Guide'), array('<br>', sprintf("<a target='_blank' href=\"http://www.knowledgetree.com/go/ktAdminManual\">%s</a>", _kt('Administrator Guide'))), $this->indexerDiagnosis);
     return true;
 }
Ejemplo n.º 2
0
 function check()
 {
     $oConfig =& KTConfig::getSingleton();
     if ($this->oUser->getId() == -2 || $oConfig->get('user_prefs/restrictPreferences', false) && !Permission::userIsSystemAdministrator($this->oUser->getId())) {
         return false;
     }
     $this->aBreadcrumbs = array(array('action' => 'preferences', 'name' => _kt('Preferences')));
     return parent::check();
 }
 function is_active($oUser)
 {
     $usage = KTUtil::getSystemSetting('KTUsage');
     if (empty($usage)) {
         return false;
     }
     $this->usage = unserialize($usage);
     return Permission::userIsSystemAdministrator();
 }
 function is_active($oUser)
 {
     $stats = KTUtil::getSystemSetting('indexerStats');
     if (empty($stats)) {
         return false;
     }
     $this->stats = unserialize($stats);
     return Permission::userIsSystemAdministrator();
 }
Ejemplo n.º 5
0
 function is_active($oUser)
 {
     // Check if the user has admin rights
     if (Permission::userIsSystemAdministrator($_SESSION['userID'])) {
         // Check if the scheduler is overdue
         return schedulerDashlet::checkOverDue();
     }
     return false;
 }
Ejemplo n.º 6
0
 function getInfo()
 {
     global $default;
     if ($default->disableBulkImport) {
         return null;
     }
     if (!Permission::userIsSystemAdministrator($this->oUser->getId())) {
         return null;
     }
     return parent::getInfo();
 }
Ejemplo n.º 7
0
 function is_active($oUser)
 {
     if (!Permission::userIsSystemAdministrator()) {
         return false;
     }
     $this->resources = KTUtil::getSystemSetting('externalResourceIssues');
     if (empty($this->resources)) {
         return false;
     }
     $this->resources = unserialize($this->resources);
     return count($this->resources) > 0;
 }
Ejemplo n.º 8
0
 function is_active($oUser)
 {
     if (!Permission::userIsSystemAdministrator($oUser)) {
         return false;
     }
     $sql = "select count(*) as no from document_text";
     $no = DBUtil::getOneResultKey($sql, 'no');
     if ($no == 0) {
         return false;
     }
     $this->migratingDocuments = $no;
     return true;
 }
Ejemplo n.º 9
0
 function is_active($oUser)
 {
     if (OS_WINDOWS && (double) php_uname('r') >= 6) {
         return false;
     }
     $usage = KTUtil::getSystemSetting('DiskUsage');
     if (empty($usage)) {
         return false;
     }
     $usage = unserialize($usage);
     $this->usage = $usage;
     return Permission::userIsSystemAdministrator();
 }
Ejemplo n.º 10
0
 function do_main()
 {
     $folder = $this->oFolder;
     $folderid = $folder->getId();
     if (Permission::userIsSystemAdministrator()) {
         if ($folderid == 1) {
             Indexer::indexAll();
         } else {
             Indexer::indexFolder($folder);
         }
     }
     $full_path = $folder->getFullPath();
     $this->addInfoMessage(sprintf(_kt("All documents under the folder '%s' have been scheduled for indexing."), $full_path));
     redirect("browse.php?fFolderId={$folderid}");
     exit;
 }
Ejemplo n.º 11
0
 function do_main()
 {
     $doc = $this->oDocument;
     $docid = $doc->getId();
     if (Permission::userIsSystemAdministrator()) {
         $full_path = $doc->getFullPath();
         if (Indexer::isDocumentScheduled($docid)) {
             Indexer::unqueueDocument($docid);
             $this->addInfoMessage(sprintf(_kt("Document '%s' has been removed from the indexing queue."), $full_path));
         } else {
             Indexer::index($doc, 'A');
             $this->addInfoMessage(sprintf(_kt("Document '%s' has been added to the indexing queue."), $full_path));
         }
     }
     redirect("view.php?fDocumentId={$docid}");
     exit;
 }
Ejemplo n.º 12
0
 function do_deleteGroup()
 {
     $old_search = KTUtil::arrayGet($_REQUEST, 'old_search');
     $aErrorOptions = array('redirect_to' => array('main', sprintf("old_search=%s&do_search=1", $old_search)));
     $oGroup = $this->oValidator->validateGroup($_REQUEST['group_id'], $aErrorOptions);
     $sGroupName = $oGroup->getName();
     $this->startTransaction();
     foreach ($oGroup->getParentGroups() as $oParentGroup) {
         $res = $oParentGroup->removeMemberGroup($oGroup);
     }
     $res = $oGroup->delete();
     $this->oValidator->notError($res, $aErrorOptions);
     if (!Permission::userIsSystemAdministrator($_SESSION['userID'])) {
         $this->rollbackTransaction();
         $this->errorRedirectTo('main', _kt('For security purposes, you cannot remove your own administration priviledges.'), sprintf("old_search=%s&do_search=1", $old_search));
         exit(0);
     }
     $this->commitTransaction();
     $this->successRedirectToMain(sprintf(_kt('Group "%s" deleted.'), $sGroupName), sprintf("old_search=%s&do_search=1", $old_search));
 }
Ejemplo n.º 13
0
 function _show()
 {
     if (is_null($this->_sShowPermission)) {
         return true;
     }
     $oFolder = Folder::get($this->oDocument->getFolderId());
     if ($this->_bMutator && $this->oDocument->getImmutable()) {
         if ($this->_bMutationAllowedByAdmin === true) {
             if (!KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) {
                 return false;
             }
         } else {
             return false;
         }
     }
     if ($this->_bAdminAlwaysAvailable) {
         if (Permission::userIsSystemAdministrator($this->oUser->getId())) {
             return true;
         }
         if (Permission::isUnitAdministratorForFolder($this->oUser, $this->oDocument->getFolderId())) {
             return true;
         }
     }
     $oPermission =& KTPermission::getByName($this->_sShowPermission);
     if (PEAR::isError($oPermission)) {
         return true;
     }
     if (!KTWorkflowUtil::actionEnabledForDocument($this->oDocument, $this->sName)) {
         return false;
     }
     // be nasty in archive/delete status.
     $status = $this->oDocument->getStatusID();
     if ($status == DELETED || $status == ARCHIVED) {
         return false;
     }
     if ($this->bAllowInAdminMode) {
         // check if this user is in admin mode
         if (KTBrowseUtil::inAdminMode($this->oUser, $oFolder)) {
             return true;
         }
     }
     return KTPermissionUtil::userHasPermissionOnItem($this->oUser, $oPermission, $this->oDocument);
 }
Ejemplo n.º 14
0
 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);
 }
Ejemplo n.º 15
0
 function do_main()
 {
     // store referer
     $sBackKey = KTUtil::arrayGet($_REQUEST, 'back_key', false);
     $sSubPath = KTUtil::arrayGet($_SERVER, 'PATH_INFO');
     // we want to be able to say "i left the system at point x.  go back there"
     if (!$sBackKey) {
         $sReferer = KTUtil::arrayGet($_SERVER, 'HTTP_REFERER');
         $sBackKey = KTUtil::randomString();
         $_SESSION[$sBackKey] = $sReferer;
     }
     // no path specified
     if (empty($sSubPath)) {
         $this->oPage->setTitle(_kt('No help page specified.'));
         $this->oPage->addError(_kt('No help page specified.'));
         return '&nbsp;';
     }
     // simple test to see if this user is active.
     $bCanEdit = Permission::userIsSystemAdministrator($_SESSION['userID']);
     global $default;
     $sLangCode = $default->defaultLanguage;
     /* 
       now we need to know a few things.  
          1. can we find this help file?
          2. if we can, display it
             2.1 images directly
             2.2 html wrapped.
          3. if now, fail out.
          
       this is essentially handled by asking help.inc.php for the 
       subpath we've been given, PLUS THE LANGUAGE, and checking for 
       a PEAR::raiseError.
       
       The "Correct" response we care about is a dictionary:
       
          {
              'is_image': string
              'title': string
              'body': string
          }
     */
     $aHelpData = KTHelp::getHelpInfo($sSubPath);
     if (PEAR::isError($aHelpData)) {
         $this->oPage->setTitle($aHelpData->getMessage());
         $this->oPage->addError($aHelpData->getMessage());
         return '&nbsp';
     }
     $aLocInfo = KTHelp::_getLocationInfo($sSubPath);
     if ($aHelpData['is_image']) {
         KTHelp::outputHelpImage($sSubPath);
         exit(0);
         // done.
     } else {
         $this->oPage->setTitle($aHelpData['title']);
         $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => $aHelpData['title']);
         $oTemplating =& KTTemplating::getSingleton();
         $oTemplate = $oTemplating->loadTemplate('ktcore/help_with_edit');
         $aTemplateData = array('context' => $this, 'help_body' => $aHelpData['body'], 'help_title' => $aHelpData['title'], 'target_name' => KTUtil::arrayGet($aLocInfo, 'subpath'), 'back_key' => $sBackKey, 'can_edit' => $bCanEdit);
         return $oTemplate->render($aTemplateData);
     }
     /*
             $help_path = KTHelp::getHelpSubPath($pathinfo);
     
             if ($help_path == false) {
                 $this->oPage->setTitle(_kt('Invalid help location specified.'));
                 $this->oPage->addError(_kt('Invalid help location specified.'));
                 return '&nbsp';
             }
     // We now check for substitute help files.  try to generate an error.
             $oReplacementHelp = KTHelpReplacement::getByName($help_path);
     
             if (KTHelp::isImageFile($help_path)) {
                 KTHelp::outputHelpImage($help_path);
             } else {
                 // not an image, so:
                 $aHelpInfo = KTHelp::getHelpFromFile($pathinfo)
             }
     
             // NORMAL users never see edit-option.
             if (!$can_edit) {
                 if (!PEAR::isError($oReplacementHelp)) {
                     $this->oPage->setTitle($oReplacementHelp->getTitle());
                     //return $oReplacementHelp->getDescription();
                 } elseif ($aHelpInfo != false) {
                     $this->oPage->setTitle($aHelpInfo['title']);
                     //return $aHelpInfo['body'];
                 } else {
                     $this->oPage->setTitle(_kt('Invalid help location specified.'));
                     $this->oPage->addError(_kt('Invalid help location specified.'));
                     return '&nbsp';
                 }
             } 
     if (!PEAR::isError($oReplacementHelp)) {
                 $aHelpInfo['title'] = $oReplacementHelp->getTitle();
                 $aHelpInfo['body'] = $oReplacementHelp->getDescription();
             }
             // we now _can_ edit.
     
     $this->oPage->setTitle($aHelpInfo['title']);
             $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => $aHelpInfo['title']);
     */
 }
Ejemplo n.º 16
0
 /**
  * Determines whether the user is in administrator mode, including
  * whether the user is in the unit for which it is unit
  * administrator.
  */
 function inAdminMode($oUser, $oFolder)
 {
     if (KTUtil::arrayGet($_SESSION, 'adminmode', false) !== true) {
         return false;
     }
     if (Permission::userIsSystemAdministrator($oUser)) {
         return true;
     }
     return Permission::isUnitAdministratorForFolder($oUser, $oFolder);
 }
Ejemplo n.º 17
0
 function dispatch()
 {
     if (empty($this->session)) {
         $this->session = new Session();
         $this->sessionStatus = $this->session->verify();
         if ($this->sessionStatus !== true) {
             $this->loginRequired();
         }
         //var_dump($this->sessionStatus);
         $this->oUser =& User::get($_SESSION['userID']);
         $oProvider =& KTAuthenticationUtil::getAuthenticationProviderForUser($this->oUser);
         $oProvider->verify($this->oUser);
     }
     if ($this->bAdminRequired !== false) {
         if (!Permission::userIsSystemAdministrator($_SESSION['userID'])) {
             $this->permissionDenied();
             exit(0);
         }
     }
     if ($this->check() !== true) {
         $this->permissionDenied();
         exit(0);
     }
     return parent::dispatch();
 }
Ejemplo n.º 18
0
 function render()
 {
     $oTemplating =& KTTemplating::getSingleton();
     $oTemplate = $oTemplating->loadTemplate('ktcore/dashlets/mailserver');
     $admin = Permission::userIsSystemAdministrator($_SESSION['userID']);
     $aTemplateData = array('context' => $this, 'admin' => $admin);
     return $oTemplate->render($aTemplateData);
 }
Ejemplo n.º 19
0
 function do_disableAdminMode()
 {
     $iDocumentId = KTUtil::arrayGet($_REQUEST, 'fDocumentId');
     $iFolderId = KTUtil::arrayGet($_REQUEST, 'fFolderId');
     if ($iDocumentId) {
         $oDocument = Document::get($iDocumentId);
         if (PEAR::isError($oDocument) || $oDocument === false) {
             return null;
         }
         $iFolderId = $oDocument->getFolderId();
     }
     if (!Permission::userIsSystemAdministrator() && !Permission::isUnitAdministratorForFolder($this->oUser, $iFolderId)) {
         $this->errorRedirectToMain(_kt('You are not an administrator'));
     }
     // log this entry
     $oLogEntry =& KTUserHistory::createFromArray(array('userid' => $this->oUser->getId(), 'datetime' => date('Y-m-d H:i:s', time()), 'actionnamespace' => 'ktcore.user_history.disable_admin_mode', 'comments' => 'Admin Mode disabled', 'sessionid' => $_SESSION['sessionID']));
     $aOpts = array('redirect_to' => 'main', 'message' => _kt('Unable to log admin mode exit.  Not de-activating admin mode.'));
     $this->oValidator->notError($oLogEntry, $aOpts);
     $_SESSION['adminmode'] = false;
     if ($_REQUEST['fDocumentId']) {
         $_SESSION['KTInfoMessage'][] = _kt('Administrator mode disabled');
         redirect(KTBrowseUtil::getUrlForDocument($iDocumentId));
         exit(0);
     }
     if ($_REQUEST['fFolderId']) {
         $this->successRedirectToMain(_kt('Administrator mode disabled'), sprintf('fFolderId=%d', $_REQUEST['fFolderId']));
     }
     $this->successRedirectToMain(_kt('Administrator mode disabled'));
 }
Ejemplo n.º 20
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);
 }
Ejemplo n.º 21
0
 public static function getSavedSearches($userID)
 {
     // need to test for broken db configuration so that the queries dont fail
     // and so that we can be redirected to the db error page
     // TODO: maybe best to have a special db error page rather than the default template when logged in
     global $default;
     if (is_null($default->_db) || PEAR::isError($default->_db)) {
         return array();
     }
     $sql = "SELECT id, name FROM search_saved WHERE type='S'";
     // if we are not the system admin, then we get only ours or shared searches
     if (!Permission::userIsSystemAdministrator($userID)) {
         $sql .= "  and ( user_id={$userID} OR shared=1 ) ";
     }
     $rs = DBUtil::getResultArray($sql);
     return $rs;
 }
Ejemplo n.º 22
0
 function do_updateGroups()
 {
     $old_search = KTUtil::arrayGet($_REQUEST, 'old_search');
     $user_id = KTUtil::arrayGet($_REQUEST, 'user_id');
     $oUser = User::get($user_id);
     if (PEAR::isError($oUser) || $oUser === false) {
         $this->errorRedirectToMain(_kt('Please select a user first.'), sprintf("old_search=%s&do_search=1", $old_search));
     }
     $groupAdded = KTUtil::arrayGet($_REQUEST, 'groups_items_added', '');
     $groupRemoved = KTUtil::arrayGet($_REQUEST, 'groups_items_removed', '');
     $aGroupToAddIDs = explode(",", $groupAdded);
     $aGroupToRemoveIDs = explode(",", $groupRemoved);
     // FIXME we need to ensure that only groups which are allocatable by the admin are added here.
     // FIXME what groups are _allocatable_?
     $this->startTransaction();
     $groupsAdded = array();
     $groupsRemoved = array();
     $addWarnings = array();
     $removeWarnings = array();
     foreach ($aGroupToAddIDs as $iGroupID) {
         if ($iGroupID > 0) {
             $oGroup = Group::get($iGroupID);
             $memberReason = GroupUtil::getMembershipReason($oUser, $oGroup);
             //var_dump($memberReason);
             if (!(PEAR::isError($memberReason) || is_null($memberReason))) {
                 $addWarnings[] = $memberReason;
             }
             $res = $oGroup->addMember($oUser);
             if (PEAR::isError($res) || $res == false) {
                 $this->errorRedirectToMain(sprintf(_kt('Unable to add user to group "%s"'), $oGroup->getName()), sprintf("old_search=%s&do_search=1", $old_search));
             } else {
                 $groupsAdded[] = $oGroup->getName();
             }
         }
     }
     // Remove groups
     foreach ($aGroupToRemoveIDs as $iGroupID) {
         if ($iGroupID > 0) {
             $oGroup = Group::get($iGroupID);
             $res = $oGroup->removeMember($oUser);
             if (PEAR::isError($res) || $res == false) {
                 $this->errorRedirectToMain(sprintf(_kt('Unable to remove user from group "%s"'), $oGroup->getName()), sprintf("old_search=%s&do_search=1", $old_search));
             } else {
                 $groupsRemoved[] = $oGroup->getName();
                 $memberReason = GroupUtil::getMembershipReason($oUser, $oGroup);
                 //var_dump($memberReason);
                 if (!(PEAR::isError($memberReason) || is_null($memberReason))) {
                     $removeWarnings[] = $memberReason;
                 }
             }
         }
     }
     if (!empty($addWarnings)) {
         $sWarnStr = _kt('Warning:  the user was already a member of some subgroups') . ' &mdash; ';
         $sWarnStr .= implode(', ', $addWarnings);
         $_SESSION['KTInfoMessage'][] = $sWarnStr;
     }
     if (!empty($removeWarnings)) {
         $sWarnStr = _kt('Warning:  the user is still a member of some subgroups') . ' &mdash; ';
         $sWarnStr .= implode(', ', $removeWarnings);
         $_SESSION['KTInfoMessage'][] = $sWarnStr;
     }
     $msg = '';
     if (!empty($groupsAdded)) {
         $msg .= ' ' . _kt('Added to groups') . ': ' . implode(', ', $groupsAdded) . '.';
     }
     if (!empty($groupsRemoved)) {
         $msg .= ' ' . _kt('Removed from groups') . ': ' . implode(', ', $groupsRemoved) . '.';
     }
     if (!Permission::userIsSystemAdministrator($_SESSION['userID'])) {
         $this->rollbackTransaction();
         $this->errorRedirectTo('editgroups', _kt('For security purposes, you cannot remove your own administration priviledges.'), sprintf('user_id=%d&do_search=1&old_search=%s', $oUser->getId(), $old_search));
         exit(0);
     }
     $this->commitTransaction();
     $this->successRedirectToMain($msg, sprintf("old_search=%s&do_search=1", $old_search));
 }
Ejemplo n.º 23
0
 public function __construct()
 {
     parent::KTStandardDispatcher();
     $this->curUserId = $_SESSION['userID'];
     $this->sysAdmin = Permission::userIsSystemAdministrator();
     if (array_key_exists('fSavedSearchId', $_GET)) {
         $this->savedSearchId = sanitizeForSQL($_GET['fSavedSearchId']);
     }
 }
Ejemplo n.º 24
0
 /**
  * Display a list of versions for comparing
  *
  * @return unknown
  */
 function do_main()
 {
     $show_version = KTUtil::arrayGet($_REQUEST, 'show');
     $showall = isset($show_version) && $show_version == 'all' ? true : false;
     $this->oPage->setSecondaryTitle($this->oDocument->getName());
     $this->oPage->setBreadcrumbDetails(_kt('Version History'));
     $aMetadataVersions = KTDocumentMetadataVersion::getByDocument($this->oDocument);
     $aVersions = array();
     foreach ($aMetadataVersions as $oVersion) {
         $version = Document::get($this->oDocument->getId(), $oVersion->getId());
         if ($showall) {
             $aVersions[] = $version;
         } else {
             if ($version->getMetadataStatusID() != VERSION_DELETED) {
                 $aVersions[] = $version;
             }
         }
     }
     // render pass.
     $this->oPage->title = _kt('Document History');
     $oTemplate = $this->oValidator->validateTemplate('ktcore/document/metadata_history');
     $aActions = KTDocumentActionUtil::getDocumentActionsByNames(array('ktcore.actions.document.view'));
     $oAction = $aActions[0];
     $oAction->setDocument($this->oDocument);
     // create delete action if user is sys admin or folder admin
     $bShowDelete = false;
     require_once KT_LIB_DIR . '/security/Permission.inc';
     $oUser =& User::get($_SESSION['userID']);
     $iFolderId = $this->oDocument->getFolderId();
     if (Permission::userIsSystemAdministrator($oUser) || Permission::isUnitAdministratorForFolder($oUser, $iFolderId)) {
         // Check if admin mode is enabled
         $bShowDelete = KTUtil::arrayGet($_SESSION, 'adminmode', false);
     }
     // Check if the document comparison plugin is installed
     $isActive = KTPluginUtil::pluginIsActive('document.comparison.plugin');
     $bShowCompare = false;
     $bShowVersionCompare = false;
     $sUrl = false;
     if ($isActive) {
         $oRegistry =& KTPluginRegistry::getSingleton();
         $oPlugin =& $oRegistry->getPlugin('document.comparison.plugin');
         if ($oPlugin->loadHelpers()) {
             $sUrl = $oPlugin->getPagePath('DocumentComparison');
             $file = $oPlugin->_aPages['document.comparison.plugin/DocumentComparison'][2];
             include_once $file;
             // Check mime type of document for content comparison
             list($bShowCompare, $bShowVersionCompare) = DocumentComparison::checkMimeType($this->oDocument);
         }
     }
     $aTemplateData = array('context' => $this, 'document_id' => $this->oDocument->getId(), 'document' => $this->oDocument, 'versions' => $aVersions, 'downloadaction' => $oAction, 'showdelete' => $bShowDelete, 'showall' => $showall, 'bShowCompare' => $bShowCompare, 'bShowVersionCompare' => $bShowVersionCompare, 'sUrl' => $sUrl);
     return $oTemplate->render($aTemplateData);
 }
Ejemplo n.º 25
0
 public static function updateQuery($iSavedId, $txtQuery, $userID)
 {
     $txtQuery = sanitizeForSQL($txtQuery);
     $iSavedId = sanitizeForSQL($iSavedId);
     $sql = "UPDATE search_saved SET expression='{$txtQuery}' WHERE id={$iSavedId}";
     if (!Permission::userIsSystemAdministrator($userID)) {
         $sql .= " AND user_id = {$userID}";
     }
     $result = DBUtil::runQuery($sql);
     if (PEAR::isError($result)) {
         AjaxSearchHelper::createResponse(AjaxSearchHelper::STATUS_INTERNAL);
     }
     AjaxSearchHelper::createResponse(AjaxSearchHelper::STATUS_SUCCESS);
 }