Exemplo n.º 1
0
 public function welcomeNamedUser($node, $template, $named_welcome_str, $unamed_welcome_str = '')
 {
     if (!$template instanceof I2CE_Template && !$node instanceof DOMNode) {
         return;
     }
     $user = new I2CE_User();
     if ($named_welcome_str && $user->logged_in() && ($name = $user->displayName())) {
         $text = sprintf($named_welcome_str, $name);
     } else {
         $text = $unamed_welcome_str;
     }
     $t_node = $template->createTextNode($text);
     $node->appendChild($t_node);
 }
Exemplo n.º 2
0
 /**
  * Main display method for web interface
  * @param boolean $supress_output  defaults to false.  set to true to supress the output of a webpage
  */
 protected function displayWeb($supress_output = false)
 {
     $i2ce_config = I2CE::getConfig()->I2CE;
     if (!$this->initPage()) {
         $pages = $i2ce_config->page;
         if (isset($pages->login) && !$this->user->logged_in()) {
             $this->setRedirect('login');
             //defined in module Login
         } else {
             $this->setRedirect('noaccess');
             //defined in I2CE
         }
         $this->redirect($this->redirect);
         return;
     }
     $error = false;
     $permission = 'role(' . implode(",", $this->access) . ')';
     if (array_key_exists('tasks', $this->args) && is_array($this->args['tasks']) && count($this->args['tasks']) > 0) {
         $permission .= ' | task(' . implode(',', $this->args['tasks']) . ')';
     }
     if ($this->hasPermission($permission)) {
         I2CE_ModuleFactory::callHooks('pre_page_action', $this);
         if (!$supress_output) {
             I2CE_ModuleFactory::callHooks('pre_displayed_page_action', $this);
         }
         if ($this->loadHTMLTemplates() === false) {
             $error = true;
         } else {
             if ($this->setActiveMenu() === false) {
                 $error = true;
             } else {
                 if ($this->action() === false) {
                     $error = true;
                 } else {
                     I2CE_ModuleFactory::callHooks('post_page_action', $this);
                 }
             }
         }
     } else {
         if ($this->user->logged_in()) {
             $this->userMessage("You do not have access to the page `{$this->page}`", 'notice');
         }
         if ($this->redirect == "") {
             //if there is a login page available, use it.   Otherwise, go to the no access page.
             $pages = $i2ce_config->page;
             if (isset($pages->login) && !$this->user->logged_in()) {
                 $this->setRedirect('login');
                 //defined in module Login
             } else {
                 $this->setRedirect('noaccess');
                 //defined in I2CE
             }
         }
     }
     if ($this->redirect != "") {
         $this->redirect($this->redirect);
         return;
     }
     if ($error) {
         $this->userMessage("There was an unexpected error in processing the requested page", "notice", false);
         I2CE_ModuleFactory::callHooks('pre_page_display_error', $this);
     }
     $this->_display($supress_output);
 }