openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

LoginAction.class.php (3480B)


      1 <?php
      2 
      3 namespace cms\action;
      4 
      5 
      6 use cms\auth\Auth;
      7 use cms\auth\AuthRunner;
      8 use cms\auth\InternalAuth;
      9 use cms\base\Configuration;
     10 use cms\base\DB;
     11 use cms\base\Startup;
     12 use cms\model\User;
     13 use configuration\Config;
     14 use Exception;
     15 use language\Messages;
     16 use logger\Logger;
     17 use openid_connect\OpenIDConnectClient;
     18 use security\Password;
     19 use util\exception\ObjectNotFoundException;
     20 use util\exception\SecurityException;
     21 use util\exception\UIException;
     22 use util\exception\ValidationException;
     23 use util\Mail;
     24 use util\Session;
     25 use util\text\TextMessage;
     26 
     27 
     28 // OpenRat Content Management System
     29 // Copyright (C) 2002-2007 Jan Dankert, jandankert@jandankert.de
     30 //
     31 // This program is free software; you can redistribute it and/or
     32 // modify it under the terms of the GNU General Public License
     33 // as published by the Free Software Foundation; version 2.
     34 //
     35 // This program is distributed in the hope that it will be useful,
     36 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     37 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     38 // GNU General Public License for more details.
     39 //
     40 // You should have received a copy of the GNU General Public License
     41 // along with this program; if not, write to the Free Software
     42 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
     43 
     44 
     45 /**
     46  * Action-Klasse fuer die Start-Action
     47  * @author $Author$
     48  * @version $Revision$
     49  * @package openrat.actions
     50  */
     51 
     52 class LoginAction extends BaseAction
     53 {
     54 	public $security = Action::SECURITY_GUEST;
     55 
     56 
     57 	public function __construct()
     58     {
     59         parent::__construct();
     60     }
     61 
     62 
     63 
     64 	/**
     65 	 * get all enabled databases.
     66 	 * @return Config[]
     67 	 */
     68     protected function getAllEnabledDatabases() {
     69 
     70 		return array_filter( Configuration::subset('database')->subsets(), function($dbConfig) {
     71 			return $dbConfig->is('enabled',true);
     72 		});
     73 
     74 	}
     75 
     76 
     77 	/**
     78 	 * Gets a list of all databases.
     79 	 * @return string[] list of databases.
     80 	 */
     81 	protected function getSelectableDatabases() {
     82 
     83 		return array_map( function($dbconf) {
     84 			// Getting the first not-null information about the connection.
     85 			return array_values(array_filter( array(
     86 				$dbconf->get('description'),
     87 				$dbconf->get('label' ),
     88 				$dbconf->get('name'  ),
     89 				$dbconf->get('host'  ),
     90 				$dbconf->get('driver'),
     91 				$dbconf->get('type'  ),
     92 				'unknown')))[0];
     93 
     94 		}, $this->getAllEnabledDatabases() );
     95 
     96 	}
     97 
     98 
     99 
    100 
    101 
    102 	/**
    103 	 * Erzeugt eine Anwendungsliste.
    104      * TODO: unused at the moment
    105 	 * @deprecated
    106 	 */
    107 	function applications()
    108 	{
    109 		$conf = Configuration::rawConfig();
    110 		
    111 		// Diese Seite gilt pro Sitzung. 
    112 		$user       = Session::getUser();
    113 		$userGroups = $user->getGroups();
    114 		$this->lastModified( $user->loginDate );
    115 
    116 		// Applikationen ermitteln
    117 		$list = array();
    118 		foreach( $conf['applications'] as $id=>$app )
    119 		{
    120 			if	( !is_array($app) )
    121 				continue;
    122 				
    123 			if	( isset($app['group']) )
    124 				if	( !in_array($app['group'],$userGroups) )
    125 					continue; // Keine Berechtigung, da Benutzer nicht in Gruppe vorhanden.
    126 					
    127 			$p = array();
    128 			$p['url']         = $app['url'];
    129 			$p['description'] = @$app['description'];
    130 			if	( isset($app['param']) )
    131 			{
    132 				$p['url'] .= strpos($p['url'],'?')!==false?'&':'?';
    133 				$p['url'] .= $app['param'].'='.session_id();
    134 			}
    135 			$p['name'] = $app['name'];
    136 			
    137 			$list[] = $p;
    138 		}
    139 
    140 
    141 		$this->setTemplateVar('applications',$list);
    142 	}
    143 
    144 	
    145 	/**
    146 	 * Erzeugt eine neue Sitzung.
    147 	 */
    148 	protected function recreateSession()
    149 	{
    150 		
    151         session_regenerate_id(true);
    152 	}
    153 
    154 }
    155 
    156