- $loaderChain = new Twig_Loader_Chain();
- $theme = $this->getTheme();
-
- # add the current theme as first to the loader chain so Twig will look there first for overridden template files
- try {
- $loaderChain->addLoader(new Twig_Loader_Filesystem(THEME . '/' . $theme));
- } catch (Twig_Error_Loader $e) {
- # @todo isInstalled() should catch this, inject Twig later
- die('The currently selected theme (' . $theme . ') does not seem to be properly installed (' . THEME . '/' . $theme .' is missing)');
- }
-
- # add all required themes to the loader chain
- $themeInfo = $this->getThemeInfo($theme);
- if (isset($themeInfo['requirements']) && is_array($themeInfo['requirements'])) {
- foreach ($themeInfo['requirements'] as $requiredTheme) {
- try {
- $loaderChain->addLoader(new Twig_Loader_Filesystem(THEME . '/' . $requiredTheme));
- } catch (Twig_Error_Loader $e) {
- # @todo isInstalled() should catch this, inject Twig later
- die('The required "' . $requiredTheme . '" theme is missing for the current theme (' . $theme . ')');
- }
- }
- }
-
- if (DEBUG_POCHE) {
- $twigParams = array();
- } else {
- $twigParams = array('cache' => CACHE);
- }
-
- $this->tpl = new Twig_Environment($loaderChain, $twigParams);
- $this->tpl->addExtension(new Twig_Extensions_Extension_I18n());
-
- # filter to display domain name of an url
- $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain');
- $this->tpl->addFilter($filter);
-
- # filter for reading time
- $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime');
- $this->tpl->addFilter($filter);
- }
-
- public function createNewUser() {
- if (isset($_GET['newuser'])){
- if ($_POST['newusername'] != "" && $_POST['password4newuser'] != ""){
- $newusername = filter_var($_POST['newusername'], FILTER_SANITIZE_STRING);
- if (!$this->store->userExists($newusername)){
- if ($this->store->install($newusername, Tools::encodeString($_POST['password4newuser'] . $newusername))) {
- Tools::logm('The new user '.$newusername.' has been installed');
- $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to <a href="?logout">logout ?</a>'),$newusername));
- Tools::redirect();
- }
- else {
- Tools::logm('error during adding new user');
- Tools::redirect();
- }
- }
- else {
- $this->messages->add('e', sprintf(_('Error : An user with the name %s already exists !'),$newusername));
- Tools::logm('An user with the name '.$newusername.' already exists !');
+ if (!empty($username) && !empty($password)){
+ $newUsername = filter_var($username, FILTER_SANITIZE_STRING);
+ $email = filter_var($email, FILTER_SANITIZE_STRING);
+ if (!$this->store->userExists($newUsername)){
+ if ($this->store->install($newUsername, Tools::encodeString($password . $newUsername), $email)) {
+ Tools::logm('The new user ' . $newUsername . ' has been installed');
+ $this->messages->add('s', sprintf(_('The new user %s has been installed. Do you want to <a href="?logout">logout ?</a>'), $newUsername));