示例#1
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();
 }
 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);
 }
示例#3
0
 static function time($nTimestamp = false, $nTimezone = false)
 {
     if ($nTimestamp === false) {
         $nTimestamp = time();
     }
     if ($nTimezone === false) {
         $nTimezone = AnwCurrentSession::getTimezone();
     }
     $nTimestamp += $nTimezone * 3600 - intval(date('Z'));
     return $nTimestamp;
 }
示例#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);
 }