示例#1
0
 static function rebuildSession($oUser, $bResume, $sLang, $nTimezone, $sId, $nTimeStart, $nTimeSeen, $nTimeAuth = 0)
 {
     $oSession = new AnwSession();
     $oSession->oUser = $oUser;
     $oSession->bResume = $bResume;
     if (!Anwi18n::isValidLang($sLang)) {
         $sLang = AnwComponent::globalCfgLangDefault();
     }
     $oSession->sLang = $sLang;
     if ($oUser->exists()) {
         $oSession->bLoggedIn = true;
     } else {
         $oSession->bLoggedIn = false;
     }
     $oSession->sId = $sId;
     if (!AnwUsers::isValidTimezone($nTimezone)) {
         $nTimezone = AnwComponent::globalCfgTimezoneDefault();
     }
     $oSession->nTimezone = $nTimezone;
     $oSession->nTimeStart = $nTimeStart;
     $oSession->nTimeSeen = $nTimeSeen;
     $oSession->nTimeAuth = $nTimeAuth;
     return $oSession;
 }
示例#2
0
 function changeLang($sLang, $sComment = "", $nTime = null)
 {
     if ($this->isArchive()) {
         throw new AnwUnexpectedException("Can't change the lang of an archive");
     }
     if (!$this->exists()) {
         throw new AnwUnexpectedException("A non existing page can't have it's lang changed");
     }
     if (!Anwi18n::isValidLang($sLang)) {
         throw new AnwBadLangException();
     }
     if (!$nTime) {
         $nTime = time();
     }
     $sOldLang = $this->sLang;
     if ($sLang != $sOldLang && $this->getPageGroup()->hasLang($sLang)) {
         throw new AnwLangExistsForPageGroupException();
     }
     //update some attributes
     $this->touchInfos($nTime);
     $this->sLang = $sLang;
     //get new change ID
     $nChangeType = AnwChange::TYPE_PAGE_CHANGELANG;
     $sChangeInfo = $sOldLang . " -> " . $sLang;
     $oChange = new AnwChange($nChangeType, $this, $nTime, $sComment, $sChangeInfo, "", $sOldLang);
     AnwStorage::transactionStart();
     try {
         //save
         AnwStorage::changeLangPage($this, $oChange);
         //notify change
         $this->notifyChanged();
         AnwStorage::transactionCommit();
     } catch (AnwException $e) {
         AnwStorage::transactionRollback();
         throw $e;
     }
 }
示例#3
0
 static function rebuildUser($nId, $sLogin, $sDisplayName, $sEmail, $sLang, $nTimezone)
 {
     $oUser = new AnwUserById($nId);
     if (!AnwUsers::isValidLogin($sLogin)) {
         throw new AnwBadLoginException();
     }
     $oUser->sLogin = $sLogin;
     if (!AnwUsers::isValidDisplayName($sDisplayName)) {
         throw new AnwBadDisplayNameException();
     }
     $oUser->sDisplayName = $sDisplayName;
     if (!AnwUsers::isValidEmail($sEmail)) {
         throw new AnwBadEmailException();
     }
     $oUser->sEmail = $sEmail;
     if (!Anwi18n::isValidLang($sLang)) {
         $sLang = AnwComponent::globalCfgLangDefault();
     }
     $oUser->sLang = $sLang;
     if (!AnwUsers::isValidTimezone($nTimezone)) {
         $nTimezone = AnwComponent::globalCfgTimezoneDefault();
     }
     $oUser->nTimezone = $nTimezone;
     $oUser->bExists = true;
     $oUser->bInfoLoaded = true;
     return $oUser;
 }
示例#4
0
 static function changeUserLang($oUser, $sLang)
 {
     if (!Anwi18n::isValidLang($sLang)) {
         throw new AnwBadLangException();
     }
     self::debug("Updating user lang : " . $oUser->getId());
     self::getDriver()->changeUserLang($oUser, $sLang);
     AnwPlugins::hook("user_changed_lang", $oUser, $sLang);
 }