protected function createAndGrant($sLogin, $sDisplayName, $sEmail, $sPassword)
 {
     try {
         //try to register
         $sLang = AnwCurrentSession::getLang();
         $nTimezone = AnwCurrentSession::getTimezone();
         $oUser = AnwUsers::createUser($sLogin, $sDisplayName, $sEmail, $sLang, $nTimezone, $sPassword);
         $this->grantUserAdmin($oUser);
         return;
     } catch (AnwLoginAlreadyTakenException $e) {
         $sError = $this->g_("err_loginalreadytaken");
     } catch (AnwBadLoginException $e) {
         $sError = $this->g_("err_badlogin");
     } catch (AnwDisplayNameAlreadyTakenException $e) {
         $sError = $this->g_("err_displaynamealreadytaken");
     } catch (AnwBadDisplayNameException $e) {
         $sError = $this->g_("err_baddisplayname");
     } catch (AnwEmailAlreadyTakenException $e) {
         $sError = $this->g_("err_emailalreadytaken");
     } catch (AnwBadEmailException $e) {
         $sError = $this->g_("err_bademail");
     } catch (AnwBadPasswordException $e) {
         $sError = $this->g_("err_badpassword");
     } catch (AnwBadCaptchaException $e) {
         $sError = $this->g_("err_badcaptcha");
     }
     $this->showChooseGrant($sLogin, $sDisplayName, $sEmail, "", $sError);
 }
Exemplo n.º 2
0
 private function formSettings($bUpdateDone = false, $asErrorsPrefs = array(), $asErrorsAccount = array())
 {
     $this->out .= $this->tpl()->openSettings($this->linkMe(), $bUpdateDone);
     //prefs
     $nTimezone = AnwCurrentSession::getTimezone();
     $sLang = AnwCurrentSession::getLang();
     $this->out .= $this->tpl()->showSettingsPrefs($nTimezone, $sLang, $asErrorsPrefs);
     if (AnwCurrentSession::isLoggedIn()) {
         //account settings
         if (AnwUsers::isDriverInternal()) {
             //editable
             $sLogin = AnwCurrentSession::getUser()->getLogin();
             $sEmail = AnwCurrentSession::getUser()->getEmail();
             if (self::globalCfgUsersChangeDisplayname()) {
                 $bChangeDisplaynameAllowed = true;
                 $sDisplayname = AnwCurrentSession::getUser()->getDisplayName();
             } else {
                 $bChangeDisplaynameAllowed = false;
                 $sDisplayname = AnwCurrentSession::getUser()->getDisplayName();
             }
             $this->out .= $this->tpl()->showSettingsAccountInternal($sLogin, $sDisplayname, $sEmail, $bChangeDisplaynameAllowed, $asErrorsAccount);
         } else {
             //read only
             $sLogin = AnwCurrentSession::getUser()->getLogin();
             $sDisplayname = AnwCurrentSession::getUser()->getDisplayName();
             $sEmail = AnwCurrentSession::getUser()->getEmail();
             $sEditLink = AnwUsers::getEditLink();
             $this->out .= $this->tpl()->showSettingsAccountExternal($sLogin, $sDisplayname, $sEmail, $sEditLink, $asErrorsAccount);
         }
     }
     $this->out .= $this->tpl()->closeSettings();
 }
Exemplo n.º 3
0
 protected function doPing($bAddInDirectory)
 {
     //here, url is passed in any case for verification purpose
     //but don't worry, it's stored on server side only when 'addindirectory' is true
     $sPingTarget = ANWIKI_WEBPING . 'newinstall?' . 'siteurl=' . urlencode(AnwComponent::globalCfgUrlRoot()) . '&sitelang=' . urlencode(AnwComponent::globalCfgLangDefault()) . '&lang=' . urlencode(AnwCurrentSession::getLang()) . '&addindirectory=' . ($bAddInDirectory ? '1' : '0') . '&versionid=' . urlencode(ANWIKI_VERSION_ID) . '&nocache=' . time();
     $this->out .= $this->tpl()->doPing($sPingTarget, $this->linkMe() . '&pingdone=1');
 }
Exemplo n.º 4
0
 function run()
 {
     if (!self::globalCfgUsersRegisterEnabled()) {
         AnwUtils::redirect();
     }
     $this->setTitle($this->t_('title'));
     $sError = false;
     $sLogin = "";
     $sDisplayName = "";
     $sEmail = "";
     if (AnwEnv::_POST("submit")) {
         $sLogin = AnwEnv::_POST("login", "");
         $sDisplayName = AnwEnv::_POST("displayname", "");
         $sEmail = AnwEnv::_POST("email", "");
         $sPassword = AnwEnv::_POST("password", "");
         //try to register
         try {
             $this->checkCaptcha();
             $sLang = AnwCurrentSession::getLang();
             $nTimezone = AnwCurrentSession::getTimezone();
             $oUser = AnwUsers::createUser($sLogin, $sDisplayName, $sEmail, $sLang, $nTimezone, $sPassword);
             AnwCurrentSession::login($sLogin, $sPassword, false);
             //open a public time-limited session
             $this->redirectInfo(false, $this->t_("t_created"), $this->t_("p_created"));
         } catch (AnwLoginAlreadyTakenException $e) {
             $sError = $this->g_("err_loginalreadytaken");
         } catch (AnwBadLoginException $e) {
             $sError = $this->g_("err_badlogin");
         } catch (AnwDisplayNameAlreadyTakenException $e) {
             $sError = $this->g_("err_displaynamealreadytaken");
         } catch (AnwBadDisplayNameException $e) {
             $sError = $this->g_("err_baddisplayname");
         } catch (AnwEmailAlreadyTakenException $e) {
             $sError = $this->g_("err_emailalreadytaken");
         } catch (AnwBadEmailException $e) {
             $sError = $this->g_("err_bademail");
         } catch (AnwBadPasswordException $e) {
             $sError = $this->g_("err_badpassword");
         } catch (AnwBadCaptchaException $e) {
             $sError = $this->g_("err_badcaptcha");
         }
     }
     //display register form
     $this->out .= $this->tpl()->registerForm(AnwUtils::alink("register"), $sLogin, $sDisplayName, $sEmail, $sError);
 }
Exemplo n.º 5
0
 function setAsCurrentAction()
 {
     if (self::$oInstance) {
         throw new AnwUnexpectedException("instance of AnwAction already created");
     }
     self::$oInstance = $this;
     self::$sActionLang = AnwCurrentSession::getLang();
     //export global JS variables
     $this->headJs($this->getJsConfig());
     //import some JS files
     $this->head($this->tpl()->headJsSrc(self::getGlobalUrlStaticDefault() . "lib/prototype.js"));
     $this->head($this->tpl()->headJsSrc(self::getGlobalUrlStaticDefault() . "lib/shortcut.js"));
     $this->head($this->tpl()->headJsSrc(self::getGlobalUrlStaticDefault() . "lib/scriptaculous/scriptaculous.js"));
     $this->head($this->tpl()->headJsSrc(self::getGlobalUrlStaticDefault() . "class_utils.js"));
     $this->head($this->getJsSrcGlobal("global.js"));
     //import some CSS files
     $this->head($this->getCssSrcGlobal("styles.css"));
 }
Exemplo n.º 6
0
 private static function loadTranslationsFromFile($sFileName, $sLang, $sPrefix, $sTranslationName)
 {
     $lang = array();
     //$lang is defined in the translation file
     AnwDebug::log("Loading translation file : " . $sFileName);
     (require_once $sFileName) or die("Unable to load language file : " . $sFileName);
     foreach ($lang as $sTranslationId => $sTranslationValue) {
         if ($sLang == AnwCurrentSession::getLang()) {
             //we store ANY translationid for session lang
             self::$translations[$sLang][$sPrefix][$sTranslationId] = $sTranslationValue;
         } else {
             //for other langs, we only store LOCAL translations
             if (self::isLocalTranslation($sTranslationId)) {
                 self::$translations[$sLang][$sPrefix][$sTranslationId] = $sTranslationValue;
             } else {
                 if (!isset(self::$translations[AnwCurrentSession::getLang()][$sPrefix][$sTranslationId])) {
                     self::$translations[$sLang][$sPrefix][$sTranslationId] = $sTranslationValue;
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
 protected function getoPage()
 {
     if (!self::$oPage) {
         if (AnwEnv::_GET(self::GET_PAGENAME)) {
             //read pagename from env
             $sPageName = self::getCurrentPageName();
             if (AnwPage::isValidPageName(self::getCurrentPageName())) {
                 self::$oPage = new AnwPageByName($sPageName);
             } else {
                 //warning, doing error404() here may lead to infinite recursion in some very special cases... that's why $oPage is set to the homepage here, to prevent loop.
                 self::$oPage = new AnwPageByName(self::globalCfgHomePage());
                 self::error404();
             }
         } else {
             //load homepage
             $sPageName = self::globalCfgHomePage();
             self::$oPage = new AnwPageByName($sPageName);
             //make sure to load homepage in the session language, if available
             try {
                 $sWantedLang = AnwCurrentSession::getLang();
                 if (self::$oPage->exists() && self::$oPage->getLang() != $sWantedLang) {
                     $aoPages = self::$oPage->getPageGroup()->getPages();
                     if (isset($aoPages[$sWantedLang])) {
                         self::$oPage = $aoPages[$sWantedLang];
                         self::debug("Homepage found in current session lang");
                     } else {
                         self::debug("Homepage NOT found in current session lang");
                     }
                 }
             } catch (AnwException $e) {
             }
         }
     }
     return self::$oPage;
 }
Exemplo n.º 8
0
 function selectLang($langs = null, $selectedlang = null)
 {
     $HTML = '';
     if (!$langs) {
         $langs = AnwComponent::globalCfgLangs();
     }
     if (!$selectedlang) {
         $selectedlang = AnwCurrentSession::getLang();
     }
     foreach ($langs as $lang) {
         $selected = $lang == $selectedlang ? ' selected="selected"' : "";
         $sSrcFlag = Anwi18n::srcFlag($lang);
         $HTML .= "<option value=\"" . $this->xQuote($lang) . "\"{$selected} style=\"background-image:url('{$sSrcFlag}');\">{$this->g_('lang_' . $lang)}</option>";
     }
     return $HTML;
 }
Exemplo n.º 9
0
 function run()
 {
     $sFrameTarget = ANWIKI_WEBPING . 'checkupdate?versionid=' . ANWIKI_VERSION_ID . '&lang=' . AnwCurrentSession::getLang() . '&nocache=' . time();
     $this->out .= $this->tpl()->showCheckUpdate($sFrameTarget, ANWIKI_WEBSITE);
 }