Horde_Kolab_Server currently has no caching so we mainly cache some core user information in the Kolab session handler as reading this data is expensive and it is sufficient to read it once per session. The users account id needs to be provided from the outside. Any additional Kolab user data relevant for the user session should be accessed via the Horde_Kolab_Session class. Copyright 2008-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Author: Gunnar Wrobel (wrobel@pardus.de)
Exemple #1
0
 protected function _initializeApplication()
 {
     global $registry;
     try {
         $registry->pushApp('koward', empty($this->auth_handler) || $this->auth_handler != $this->params[':action']);
     } catch (Horde_Exception $e) {
         if ($e->getCode() == 'permission_denied') {
             $this->urlFor(array('controller' => 'index', 'action' => 'login'))->redirect();
         }
     }
     $this->koward = Koward::singleton();
     if ($this->koward->objects instanceof PEAR_Error) {
         return;
     }
     if (!empty($this->koward->objects)) {
         $this->types = array_keys($this->koward->objects);
     } else {
         throw new Koward_Exception('No object types have been configured!');
     }
     $this->checkAccess();
     $this->menu = $this->getMenu();
     $this->theme = isset($this->koward->conf['koward']['theme']) ? $this->koward->conf['koward']['theme'] : 'koward';
     $this->welcome = isset($this->koward->conf['koward']['greeting']) ? $this->koward->conf['koward']['greeting'] : _("Welcome.");
     $this->current_user = $GLOBALS['registry']->getAuth();
     $session = Horde_Kolab_Session::singleton();
     if (!empty($session->user_uid)) {
         $user = $this->koward->getObject($session->user_uid);
         $type = $this->koward->getType($user);
         $this->role = $this->koward->objects[$type]['label'];
     }
 }
Exemple #2
0
 /**
  * Reset the current session information in case it does not match the
  * authentication information anymore.
  *
  * @param string $user The user the session information is being requested
  *                     for. This is usually empty, indicating the current
  *                     user.
  *
  * @return boolean True if the session is still valid.
  */
 public function validate($user = null)
 {
     $mail = $this->_session->getMail();
     if ($this->_auth != $mail) {
         $this->_session->purge();
         return false;
     }
     if (empty($user)) {
         return true;
     }
     if ($user != $mail && $user != $this->_session->getUid()) {
         $this->_session->purge();
         return false;
     }
     return true;
 }
Exemple #3
0
 /**
  * In the long run we might wish to use the Horde permission system
  * here. But for the first draft this would be too much as the permission
  * system would also require integration with the group system etc.
  */
 public function hasPermission($id, $user = null, $perm = null)
 {
     $global = $this->_hasPermission($this->perms, $id, $perm);
     if ($user === null) {
         try {
             $session = Horde_Kolab_Session::singleton();
             if (!empty($session->user_uid)) {
                 $user = $this->getObject($session->user_uid);
                 if (get_class($user) == $this->conf['koward']['cli_admin'] && Horde_Cli::runningFromCLI()) {
                     return true;
                 }
                 $type = $this->getType($user);
                 if (isset($this->objects[$type]['permission'])) {
                     return $this->_hasPermission($this->objects[$type]['permission'], $id, $perm);
                 }
             }
         } catch (Exception $e) {
             Horde::log($e, 'DEBUG');
         }
     }
     return $global;
 }
Exemple #4
0
 /**
  * Test class construction with missing configuration data.
  */
 public function testGetImapFailNoServer()
 {
     $this->markTestIncomplete('Currently broken');
     $session = Horde_Kolab_Session::singleton('anonymous', null, true);
     $imap = $session->getImapParams();
     $this->assertEquals('localhost', $imap['hostspec']);
 }
Exemple #5
0
 /**
  * Clear the session data.
  *
  * @return NULL
  */
 public function purge()
 {
     $this->_session->purge();
 }