openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

ProfileAction.class.php (2679B)


      1 <?php
      2 
      3 namespace cms\action;
      4 
      5 
      6 // OpenRat Content Management System
      7 // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
      8 //
      9 // This program is free software; you can redistribute it and/or
     10 // modify it under the terms of the GNU General Public License
     11 // as published by the Free Software Foundation; either version 2
     12 // of the License, or (at your option) any later version.
     13 //
     14 // This program is distributed in the hope that it will be useful,
     15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17 // GNU General Public License for more details.
     18 //
     19 // You should have received a copy of the GNU General Public License
     20 // along with this program; if not, write to the Free Software
     21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
     22 use cms\base\Configuration;
     23 use cms\base\Startup;
     24 use cms\model\BaseObject;
     25 use cms\model\User;
     26 use language\Language;
     27 use language\Messages;
     28 use logger\Logger;
     29 use security\Base2n;
     30 use util\exception\SecurityException;
     31 use util\exception\ValidationException;
     32 use util\mail\Mail;
     33 use util\Request;
     34 use util\Session;
     35 use util\UIUtils;
     36 
     37 
     38 /**
     39  * profile data of current user.
     40  */
     41 class ProfileAction extends BaseAction
     42 {
     43 	/**
     44 	 * Current user.
     45 	 *
     46 	 * Current user or null, if no user is present.
     47 	 *
     48 	 * @var User|null
     49 	 */
     50 	protected $user;
     51 
     52 	/**
     53 	 * Konstruktor.
     54 	 * Setzen der Benutzer-Objektes.
     55 	 */
     56 	function __construct()
     57 	{
     58         parent::__construct();
     59 
     60         $this->user = $this->currentUser;
     61 	}
     62 
     63 
     64     /**
     65      * Setting new language for current session.
     66      *
     67      * @param $languageISOcode string ISO coded language
     68      */
     69     protected function setLanguage($languageISOcode )
     70     {
     71 		// Overwrite configuration
     72         $conf = Request::getConfig();
     73         $language = new Language();
     74         $conf['language'] = $language->getLanguage($languageISOcode);
     75         $conf['language']['language_code'] = $languageISOcode;
     76 		Request::setConfig($conf);
     77     }
     78 
     79 
     80 	/**
     81 	 * Theme name.
     82 	 *
     83 	 * Gets the theme name of the current user, or the
     84 	 * default style if no user is present.
     85 	 *
     86 	 * @param User $user
     87 	 * @return string
     88 	 */
     89 	protected function getUserStyle($user )
     90 	{
     91 		// Gets theme for current user.
     92 		if  ( $user && Configuration::subset('style')->has($user->style))
     93 			$style = $user->style;
     94 		else
     95 			// Fallback: Default theme.
     96 			$style = Configuration::subset(['interface','style'])->get('default','');
     97 
     98 		return $style;
     99 	}
    100 
    101 
    102 	/**
    103 	 * Default permission: An authenticated user is necessary.
    104 	 *
    105 	 * @return void
    106 	 */
    107 	public function checkAccess() {
    108 		if   ( !$this->user )
    109 			throw new SecurityException();
    110 	}
    111 
    112 }