[Phpcms-plugins-cvs] admin4phpCMS/modules/user class.module_user.php,1.1,1.2
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2004-06-04 11:12:08
|
Update of /cvsroot/phpcms-plugins/admin4phpCMS/modules/user In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12823/modules/user Modified Files: class.module_user.php Log Message: several changes Index: class.module_user.php =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/user/class.module_user.php,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- class.module_user.php 30 May 2004 18:03:43 -0000 1.1 +++ class.module_user.php 4 Jun 2004 11:11:58 -0000 1.2 @@ -1,15 +1,63 @@ <?php +/** +* User- and permissionmanagment +* +* This module is based on the package PEAR::LiveUser. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +* +* @author Martin Jahn <mj...@us...> +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @copyright Copyright (c) 2004, Martin Jahn +* @version $Id$ +* @package admin4phpCMS +* @subpackage module_user +**/ -require_once 'LiveUser/LiveUser.php'; +/* +* $Log$ +* Revision 1.2 2004/06/04 11:11:58 mjahn +* several changes +* +*/ +/** +* include necessary files +**/ +include_once 'LiveUser/LiveUser.php'; +/** +* Klasse für die Benutzerverwaltung und das Rechtesystem +* +* @package admin4phpCMS +* @subpackage module_user +* @todo Get the class working correctly +**/ class module_user extends module { + /** + * @var object Benutzer- und Rechtemanagment-Objekt + * @access private + **/ + var $_USER; + function init () { $liveuserConfig = array( 'session' => array('name' => 'PHPSESSID','varname' => 'loginInfo'), 'login' => array('username' => 'handle', 'password' => 'passwd'), 'cookie' => array('name' => 'loginInfo', 'path' => '/', 'domain' => 'localhost', 'lifetime' => 60), - 'autoInit' => false, + 'autoInit' => true, 'authContainers' => array(0 => array('type' => 'XML', 'file' => dirname(__FILE__).'/Auth_XML.xml', 'loginTimeout' => 60*30, @@ -23,42 +71,132 @@ 'file' => dirname(__FILE__).'/Perm_XML.xml' ) ); - $this->USER = LiveUser::factory($liveuserConfig); - $this->USER->init(); + $this->_USER = LiveUser::factory($liveuserConfig); + // connect to actions $this->_registerAction ('doParseParam', 'parseParam'); $this->_registerAction ('doProcess', 'process'); - $this->_registerAction ('doParseMenu', 'getMenu'); - $this->_registerAction ('doGetContents', 'getContent'); + $this->_registerAction ('doParseMenuMain', 'getMenuMain'); + $this->_registerAction ('doParseStatusbar', 'getContentBar'); + $this->_registerAction ('doParseMenuSub', 'getMenuSub'); + $this->_registerAction ('doParseContent', 'getContent'); + + // provide my own actions to the eventhandler $this->_registerEvent ('USER_GET_DATA', 'doGetUserData'); $this->_registerAction ('doGetUserData', 'getUserData'); $this->_registerEvent ('USER_SET_DATA', 'doSetUserData'); $this->_registerAction ('doSetUserData', 'setUserData'); + $this->_registerEvent ('USER_GET_STATUS', 'doGetUserStatus'); + $this->_registerAction ('doGetUserStatus', 'getUserStatus'); } function parseParam (&$actiondata) { - if (isset ($actiondata['_post']['logout'])) { - $this->USER->logout; - } elseif (isset ($actiondata['_get']['logout'])) { - $this->USER->logout (); + $logout = false; + $username = ''; + $password = ''; + if (isset ($actiondata['post']['logout'])) { + $logout = true; + } elseif (isset ($actiondata['get']['logout'])) { + $logout = true; + } + $passwd = ''; + if (isset ($actiondata['post']['passwd'])) { + $passwd = $actiondata['post']['passwd']; + $logout = false; + } + $username = ''; + if (isset ($actiondata['post']['handle'])) { + $username = $actiondata['post']['handle']; + $logout = false; } + $this->_USER->init($username, $password, $logout); + + + $this->display = (isset ($actiondata['request']['moduleid']) && $actiondata['request']['moduleid'] == 'user'); + + $this->action = ''; + if (isset ($actiondata['request']['action'])) { + $this->action = $actiondata['request']['action']; + } + } function process (&$actiondata) { } - function getMenu (&$actiondata) { + function getUserStatus (&$actiondata) { + $actiondata ['loggedin'] = $this->_USER->isLoggedIn (); } - function getContent (&$actiondata) { - if ($this->USER->isLoggedIn ()) { - return true; + function getMenuMain (&$actiondata) { + $root = $actiondata['_root']; + $actiondata = array ('_type'=>'menu_main_entry', '_root'=>$root, 'name'=>'Benutzerverwaltung', 'module'=>'user', '_id'=>'usermenu', '_root'=>'mainmenu', 'id'=>'', 'class'=>''); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + } + + function getMenuSub (&$actiondata) { + if (!$this->_USER->isLoggedIn ()) { + return true; } - $actiondata = array ('id'=>'1', 'type'=>'paragraph', 'content'=>'Irgendein komischer Inhalt steht hier drin :);)'); + if (!$this->display) { + return true; + } + + $root = $actiondata['_root']; + + $actiondata = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Benutzerübersicht', 'module'=>'user', '_id'=>'useroverview', 'action'=>'', 'id'=>'', 'class'=>'', 'param'=>''); + if ($this->action == '') { + $actiondata['id'] = 'current'; + } + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + + $actiondata = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Rechteübersicht', 'module'=>'user', '_id'=>'usermenuchg', 'action'=>'rights', 'id'=>'', 'class'=>'', 'param'=>''); + if ($this->action == 'rights') { + $actiondata['id'] = 'current'; + } $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + } + + function getContent (&$actiondata) { + if (!$this->_USER->isLoggedIn ()) { + + $root = $actiondata['_root']; + + $actiondata = array ('_id'=>'benutzerlogin', '_root'=>$root, '_type'=>'headline', 'content'=>'Benutzerlogin', 'id'=>'', 'class'=>''); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + + $actiondata = array ('_id'=>'loginform', '_root'=>$root, '_type'=>'form', 'method'=>'post', 'id'=>'', 'class'=>''); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + + $actiondata = array ('_id'=>'method', '_type'=>'form_input_hidden', 'value'=>'post', 'name'=>'method','_root'=>'loginform', 'id'=>'', 'class'=>''); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + + $actiondata = array ('_id'=>'handle', '_type'=>'form_input_text', 'label'=>'Benutzername', 'value'=>'Benutzername', 'name'=>'handle','_root'=>'loginform', 'id'=>'', 'class'=>''); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + + $actiondata = array ('_id'=>'passwd', '_type'=>'form_input_password', 'value'=>'', 'label'=>'Passwort', 'name'=>'passwd','_root'=>'loginform', 'id'=>'', 'class'=>''); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + + $actiondata = array ('_id'=>'submit', '_type'=>'form_button', 'value'=>'Absenden', 'name'=>'submit','text'=>'Absenden', '_root'=>'loginform', 'id'=>'', 'class'=>''); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + return; + } + if (!$this->display) { + return true; + } } + function getContentBar (&$actiondata) { + if ($this->_USER->isLoggedIn ()) { + + $root = $actiondata['_root']; + + $actiondata = array ('_id'=>'1', '_root'=>$root, '_type'=>'paragraph', 'content'=>$this->_USER->getProperty ('handle').' (<a href="?logout=logout">abmelden</a>)'); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + } + + } function getUserData (&$actiondata) { } |