Thread: [Phpcms-plugins-cvs] admin4phpCMS/modules/user user4phpcms.php,NONE,1.1 class.module_user.php,1.10,1
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2005-04-07 14:09:52
|
Update of /cvsroot/phpcms-plugins/admin4phpCMS/modules/user In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15012/modules/user Modified Files: class.module_user.php Added Files: user4phpcms.php Removed Files: layout.user.xml Log Message: Commit as backup during development Index: class.module_user.php =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/user/class.module_user.php,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- class.module_user.php 7 Dec 2004 06:34:46 -0000 1.10 +++ class.module_user.php 7 Apr 2005 14:09:03 -0000 1.11 @@ -2,7 +2,7 @@ /** * User- and permissionmanagment * -* This module is based on the package PEAR::LiveUser. +* This module is based on the package PEAR::Auth * * <b>License</b> * @@ -30,6 +30,9 @@ /* * $Log$ +* Revision 1.11 2005/04/07 14:09:03 mjahn +* Commit as backup during development +* * Revision 1.10 2004/12/07 06:34:46 mjahn * prepration of first Alpha-Preview * @@ -63,8 +66,6 @@ * include the authentication-class **/ include_once ('Auth.php'); -define ('US_IMGPATH', MODULE_PATH.'/filemanager/img/'); - /** * Class for user- and permission-managment * @@ -105,11 +106,12 @@ * The module registers its own events and connects his methods to some actions **/ function init () { + + global $GLOBALS; // connect to actions $this->_registerAction ('doParseParam', 'parseParam'); - $this->_registerAction ('doParseMenuMain', 'getMenuMain'); - $this->_registerAction ('doParseMenuSub', 'getMenuSub'); - $this->_registerAction ('doParseStatusbar', 'getStatusContent'); + $this->_registerAction ('doGetMenu', 'getMenu'); + $this->_registerAction ('doGetStatus', 'getStatus'); // provide my own actions to the eventhandler $this->_registerEvent ('USER_GET_DATA', 'doGetUserData'); @@ -120,12 +122,13 @@ $this->_registerAction ('doGetUserStatus', 'getUserStatus'); // get module-config from config-module - $actiondata1 = array ('module'=>'user', 'format'=>'array'); + $actiondata1 = array ('module'=>'user'); $this->_callEvent ('CONFIG_GET', $actiondata1); $this->CONF =& $actiondata1 ['config']; $this->_USER = new Auth('File', dirname (__FILE__).'/'.$this->CONF ['userfile']); $this->_USER->setShowLogin (false); + $GLOBALS ['user4phpcms'] =& $this->_USER; return true; } @@ -141,12 +144,9 @@ $this->_USER->start (); if ($this->_USER->checkAuth()) { $this->_userdata ['isLoggedIn'] = $this->_USER->checkAuth (); + $this->_userdata ['username'] = $this->_USER->getUsername (); } - // load our own extra template - $actiondata1 = array ('filename'=>dirname (__FILE__).'/layout.user.xml'); - $this->_callEvent ('LAYOUT_ADD_TEMPLATE', $actiondata1); - // check for logout if (isset ($actiondata ['post'] ['logout'])) { if (!isset ($actiondata ['post'] ['submit-login'])) { @@ -197,31 +197,24 @@ // check if we have to display something $this->display = (isset ($actiondata['request']['moduleid']) && $actiondata['request']['moduleid'] == 'user'); - // get the wanted action from the URI - $this->action = ''; - if (isset ($actiondata['request']['action'])) { - $this->action = $actiondata['request']['action']; - } - // if the user is not yet logged in if (!$this->_USER->checkAuth ()) { $this->action = 'login'; - } - // react onto the action - switch ($this->action) { - case 'login': - $this->_registerAction ('doProcess', 'processLogin'); - break; - case 'admin': - $this->_registerAction ('doProcess', 'processAdmin'); - break; - case 'profile': - $this->_registerAction ('doProcess', 'processProfile'); - break; - default: -// $this->_registerAction ('doProcess', 'processLogin'); + $this->display = true; } + if ($this->display) { + $this->_registerAction ('doGetData', 'getData'); + $this->_registerAction ('doGetLanguage', 'getLanguage'); + + if (!isset ($this->action) || trim ($this->action) == '') { + // get the wanted action from the URI + $this->action = ''; + if (isset ($actiondata['request']['action'])) { + $this->action = $actiondata['request']['action']; + } + } + } $actiondata1 = array ('module'=>'user', 'format'=>'array'); $this->_callEvent ('CONFIG_GET', $actiondata1); $this->_CONF = $actiondata1 ['config']; @@ -274,53 +267,53 @@ * * @param array $actiondata $actiondata['_root'] must provide the id of the parental element **/ - function getMenuMain (&$actiondata) { - - $root = $actiondata['_root']; + function getMenu(&$actiondata) { if (!$this->_USER->checkAuth ()) { - $actiondata1 = array ('_type'=>'menu_main_entry', '_root'=>$root, 'name'=>'Anmeldung', 'module'=>'user', '_id'=>'usermenu', '_root'=>'mainmenu', 'extra'=>'class="active"'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); + + $actiondata [$actiondata ['tag']] ['user'] [0] = array ('name'=>'Anmeldung', 'module'=>'user', 'action'=>'login', 'extra'=>'class="current"'); return true; } - - $actiondata1 = array ('_type'=>'menu_main_entry', '_root'=>$root, 'name'=>'Benutzerverwaltung', 'module'=>'user', '_id'=>'usermenu', '_root'=>'mainmenu', 'id'=>'', 'class'=>''); + + $data = array ('name'=>'Usermanagment', 'module'=>'user', 'action'=>'profile'); + $_data = array (); + if ($this->display) { - $actiondata1 ['extra'] = 'class="active"'; + + $data ['extra'] = 'class="current"'; + + $data1 = array ('name'=>'Profile', 'module'=>'user', 'action'=>'profile'); + if ($this->action == 'profile') { + $data1 ['extra'] = 'id="current"'; + } + $_data [] = $data1; + + $data1 = array ('name'=>'Managment', 'module'=>'user', 'action'=>'admin'); + if ($this->action == 'admin') { + $data1 ['extra'] = 'id="current"'; + } + $_data [] = $data1; + + $data ['_sub_'] = $_data; } - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - return true; + + $actiondata [$actiondata ['tag']] ['user'] = array ($data); + + return true; } /** - * Get submenu of module + * Get language-array of module * - * @param array $actiondata $actiondata['_root'] must provide the id of the parental element - **/ - function getMenuSub (&$actiondata) { - if (!$this->_USER->checkAuth ()) { - return true; - } + * @param array $actiondata $actiondata['tag'] must provide the name of the + * variable + */ + function getLanguage (&$actiondata) { - if (!$this->display) { - return true; - } + $data = ''; + //$actiondata [$actiondata ['tag']] ['user'] = $data; - $root = $actiondata['_root']; - - $actiondata1 = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Benutzer-Profil', 'module'=>'user', '_id'=>'userprofile', 'action'=>'profile'); - if ($this->action == 'profile') { - $actiondata1 ['extra'] = 'id="current"'; - } - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - - $actiondata1 = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Verwaltung', 'module'=>'user', '_id'=>'useroverview', 'action'=>'admin'); - if ($this->action == 'admin') { - $actiondata1 ['extra'] = 'id="current"'; - } - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - return true; } @@ -329,38 +322,34 @@ * * @param array $actiondata $actiondata['_root'] must provide the id of the parental element **/ - function getLoginContent (&$actiondata) { - - $root = $actiondata['_root']; + function getData (&$actiondata) { - if (isset ($this->_USER) && $this->_USER->getStatus () != 0) { - $actiondata1 = array ('errortext'=>$this->_USER->getStatus ()); - $this->_callEvent ('ERROR_NOTICE', $actiondata1); - } - - $actiondata1 = array ('_id'=>'loginform', '_root'=>$root, '_type'=>'form', 'method'=>'post', 'action'=>INDEX_FILE); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - - $actiondata1 = array ('_id'=>'formhidden', '_root'=>'loginform', '_type'=>'form_input_hidden', 'name'=>'method', 'value'=>'post'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); + // react onto the action + $data = array ('action'=>$this->action); - $users =$this->_USER->listUsers (); - $list = ''; - foreach ($users as $id=>$user) { - $list .= '<option value="'.$user['username'].'">'.$user ['username'].'</option>'; + switch ($this->action) { + case 'admin':; + case 'login': + $data ['userlist'] = @$this->_USER->listUsers (); + break; + case 'profile': + $data ['userlist'] = @$this->_USER->listUsers (); + break; + default: +// $this->_registerAction ('doProcess', 'processLogin'); } - - $actiondata1 = array ('_id'=>'loginform-content', '_root'=>'loginform', '_type'=>'us_loginform', 'method'=>'post', 'userlist'=>$list); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - + if (isset ($_GET) && is_array ($_GET)) { + $data ['hidden_fields'] = array (); + foreach ($_GET as $id=>$value) { - $actiondata = array ('_id'=>'query-'.$id, '_type'=>'form_input_hidden', 'value'=>$value, 'name'=>$id, '_root'=>'loginform'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + $data ['hidden_fields'] [$value] = $id; } } + $actiondata [$actiondata ['tag']] ['user'] = $data; + return true; } @@ -370,78 +359,23 @@ * * @param array $actiondata $actiondata['_root'] must provide the id of the parental element **/ - function getStatusContent (&$actiondata) { - if ($this->_USER->checkAuth () == 1) { + function getStatus (&$actiondata) { - $root = $actiondata['_root']; + $data = array (); - $actiondata1 = array ('_id'=>'1', '_root'=>$root, '_type'=>'paragraph', 'content'=>$this->_USER->session['username'].' (<a href="?logout=logout">abmelden</a>)'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); + if (isset ($this->_USER) && $this->_USER->getStatus () != 0) { + $data [] = $this->_USER->getStatus (); } - return true; - } - /** - * Get content for admin content - * - * @param array $actiondata $actiondata['_root'] must provide the id of the parental element - **/ - function getAdminContent (&$actiondata) { - - $actiondata1 = array ('_root'=>$actiondata ['_root'], '_id'=>'container', '_type'=>'block', 'extra'=>'id="container"'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - $actiondata1 = array ('_root'=>'container', '_id'=>'us_admin_form', '_type'=>'form'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - $actiondata1 = array ('_root'=>'us_admin_form', '_id'=>'us_form1', '_type'=>'form_input_hidden', 'value'=>'admin', 'name'=>'action'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - $actiondata1 = array ('_root'=>'us_admin_form', '_id'=>'us_form2', '_type'=>'form_input_hidden', 'value'=>'user', 'name'=>'moduleid'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - $actiondata1 = array ('_root'=>'us_admin_form', '_id'=>'us_list', 'imgpath' => US_IMGPATH, '_type'=>'us_userlist'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - @$user =& $this->_USER->listUsers (); - - if (PEAR::isError ($user)) { - return true; - } - - foreach ($user as $id=>$user) { - - $actiondata1 = array ('_root'=>'us_list', '_id'=>'user-'.$id, 'imgpath' => US_IMGPATH, '_type'=>'us_listentry', 'id'=>$id, 'username'=>$user ['username']); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); + if ($this->_USER->checkAuth () == 1) { + $data [] = $this->_USER->session['username'].' (<a href="?logout=logout">abmelden</a>)'; } - $actiondata1 = array ('_root'=>'us_admin_form', '_id'=>'new-user', '_type'=>'us_newuser'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); + $actiondata [$actiondata ['tag']] ['user'] = $data; return true; } - /** - * Get content for user profile - * - * @param array $actiondata $actiondata['_root'] must provide the id of the parental element - **/ - function getProfileContent (&$actiondata) { - $items = get_object_vars ($this->_USER); - - $actiondata1 = array ('_root'=>$actiondata ['_root'], '_id'=>'profile-list', '_type'=>'ulist'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - $num = count ($this->_USER); - foreach ($this->_USER as $id => $value) { - - $actiondata1 = array ('_root'=>'profile-list', '_id'=>'profile-list-'.$id, '_type'=>'list_entry', 'content'=>$id.' = '.$value); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); - - } - - return true; - } /** * Get content for statusbar --- layout.user.xml DELETED --- --- NEW FILE: user4phpcms.php --- <?php /** * user4phpcms * * <b>License</b> * * 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) 2005, Martin Jahn * @version $Id: user4phpcms.php,v 1.1 2005/04/07 14:09:03 mjahn Exp $ * @package user4phpcms */ /* * $Log: user4phpcms.php,v $ * Revision 1.1 2005/04/07 14:09:03 mjahn * Commit as backup during development * */ /** * include the authentication-class **/ ini_set ('include_path', realpath (dirname (__FILE__).'/../../pear').'/'.PATH_SEPARATOR.ini_get ('include_path')); include_once ('Auth.php'); class user4phpcms { function username () { if ($GLOBALS ['user4phpcms']->checkAuth()) { return $GLOBALS ['user4phpcms']->checkAuth (); } } function init () { if (isset ($GLOBALS ['user4phpcms'])) { return true; } $GLOBALS ['user4phpcms'] =& new Auth('File', dirname (__FILE__).'/user.db'); $GLOBALS ['user4phpcms']->setShowLogin (false); $GLOBALS ['user4phpcms']->start (); } function checkUser () { } function _loadUserdata () { } } ?> |