Ejemplo n.º 1
0
 /**
  * Allow user to set their preferred locale via link-click.
  */
 public function profileController_setLocale_create($Sender, $locale, $TK)
 {
     if (!Gdn::Session()->UserID) {
         throw PermissionException('Garden.SignIn.Allow');
     }
     // Check intent.
     if (!Gdn::Session()->ValidateTransientKey($TK)) {
         safeRedirect($_SERVER['HTTP_REFERER']);
     }
     // If we got a valid locale, save their preference
     if (isset($locale)) {
         $locale = $this->validateLocale($locale);
         if ($locale) {
             $this->SetUserMeta(Gdn::Session()->UserID, 'Locale', $locale);
         }
     }
     $successRedirect = $_SERVER['HTTP_REFERER'];
     $target = gdn::request()->get('Target');
     if ($target) {
         $successRedirect = $target;
     }
     // Back from whence we came.
     safeRedirect($successRedirect);
 }