Example #1
0
 private function _defineTplInformation()
 {
     $tplFile = array();
     $tplVars = array();
     if (\Session::isLogged()) {
         $this->wallabag->action($this->action, $this->url, $this->id, FALSE, $this->autoclose);
         $tplFile = Tools::getTplFile($this->view);
         $tplVars = array_merge($this->vars, $this->wallabag->displayView($this->view, $this->id));
     } elseif (ALLOW_REGISTER && isset($_GET['registerform'])) {
         Tools::logm('register');
         $tplFile = Tools::getTplFile('register');
     } elseif (ALLOW_REGISTER && isset($_GET['register'])) {
         $this->wallabag->createNewUser($_POST['newusername'], $_POST['password4newuser'], $_POST['newuseremail']);
         Tools::redirect();
     } elseif (isset($_SERVER['REMOTE_USER'])) {
         if ($this->wallabag->store->userExists($_SERVER['REMOTE_USER'])) {
             $this->wallabag->login($this->referer);
         } else {
             $this->wallabag->messages->add('e', _('login failed: user doesn\'t exist'));
             Tools::logm('user doesn\'t exist');
             $tplFile = Tools::getTplFile('login');
             $tplVars['http_auth'] = 1;
         }
     } else {
         $tplFile = Tools::getTplFile('login');
         $tplVars['http_auth'] = 0;
         \Session::logout();
     }
     $this->file = $tplFile;
     $this->vars = array_merge($this->defaultVars, $tplVars);
 }
Example #2
0
    $poche->action($action, $url, $id);
    $tpl_file = Tools::getTplFile($view);
    $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id));
} elseif (isset($_SERVER['PHP_AUTH_USER'])) {
    if ($poche->store->userExists($_SERVER['PHP_AUTH_USER'])) {
        $poche->login($referer);
    } else {
        $poche->messages->add('e', _('login failed: user doesn\'t exist'));
        Tools::logm('user doesn\'t exist');
        $tpl_file = Tools::getTplFile('login');
        $tpl_vars['http_auth'] = 1;
    }
} elseif (isset($_SERVER['REMOTE_USER'])) {
    if ($poche->store->userExists($_SERVER['REMOTE_USER'])) {
        $poche->login($referer);
    } else {
        $poche->messages->add('e', _('login failed: user doesn\'t exist'));
        Tools::logm('user doesn\'t exist');
        $tpl_file = Tools::getTplFile('login');
        $tpl_vars['http_auth'] = 1;
    }
} else {
    $tpl_file = Tools::getTplFile('login');
    $tpl_vars['http_auth'] = 0;
    Session::logout();
}
# because messages can be added in $poche->action(), we have to add this entry now (we can add it before)
$messages = $poche->messages->display('all', FALSE);
$tpl_vars = array_merge($tpl_vars, array('messages' => $messages));
# display poche
echo $poche->tpl->render($tpl_file, $tpl_vars);