openrat-cms

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

LoginAction.class.php (3040B)


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