singleton() public static méthode

public static singleton ( )
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
 public function __construct(&$vars, &$object, $params = array())
 {
     $this->koward =& Koward::singleton();
     $this->object =& $object;
     parent::__construct($vars);
     $type = false;
     $this->setButtons(_("Search"));
     $this->_addFields($this->koward->search);
 }
Exemple #3
0
 public function __construct(&$object, $buttons)
 {
     $this->koward =& Koward::singleton();
     parent::__construct(Horde_Variables::getDefaultVariables());
     $this->setTitle(_("Object actions"));
     $this->object = $object;
     if (!empty($buttons)) {
         $this->setButtons($buttons);
     }
 }
Exemple #4
0
 public function __construct(&$vars, &$object, $params = array())
 {
     $this->koward =& Koward::singleton();
     $this->object =& $object;
     parent::__construct($vars);
     $type = false;
     if (empty($this->object)) {
         $title = _("Add Object");
         $this->setButtons(_("Add"));
         foreach ($this->koward->objects as $key => $config) {
             if (!$this->koward->hasAccess('object/add/' . $key, Koward::PERM_EDIT)) {
                 continue;
             }
             $options[$key] = $config['label'];
         }
         $v = $this->addVariable(_("Choose an object type"), 'type', 'enum', true, false, null, array($options, true));
         $action = Horde_Form_Action::factory('submit');
         $v->setAction($action);
         $v->setOption('trackchange', true);
         if (is_null($vars->get('formname')) && $vars->get($v->getVarName()) != $vars->get('__old_' . $v->getVarName())) {
             $this->koward->notification->push(sprintf(_("Selected object type \"%s\"."), $object_conf[$vars->get('type')]['label']), 'horde.message');
         }
         $type = $vars->get('type');
     } else {
         $title = _("Edit Object");
         $type = $this->koward->getType($this->object);
         if (empty($type)) {
             throw new Koward_Exception('Undefined object class!');
         }
         if (!$this->isSubmitted()) {
             $vars->set('type', $type);
             $keys = array_keys($this->_getFields($this->koward->objects[$type]));
             $vars->set('object', $this->object->toHash($keys));
             $this->setButtons(true);
         }
     }
     if (isset($params['title'])) {
         $title = $params['title'];
     }
     $this->setTitle($title);
     if (!empty($type)) {
         $this->_addFields($this->koward->objects[$type]);
     }
 }