Esempio n. 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'];
     }
 }
Esempio n. 2
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;
 }
Esempio n. 3
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']);
 }