[Phpcms-plugins-cvs] admin4phpCMS/modules/user class.phpcms_auth.php,NONE,1.1 layout.user.xml,1.2,1.
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2004-12-07 06:35:30
|
Update of /cvsroot/phpcms-plugins/admin4phpCMS/modules/user In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13210/modules/user Modified Files: layout.user.xml class.module_user.php Added Files: class.phpcms_auth.php Removed Files: class.auth.php Log Message: prepration of first Alpha-Preview --- class.auth.php DELETED --- Index: layout.user.xml =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/user/layout.user.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- layout.user.xml 29 Sep 2004 20:10:43 -0000 1.2 +++ layout.user.xml 7 Dec 2004 06:34:46 -0000 1.3 @@ -8,7 +8,7 @@ <ul id="userlist"> <layout:replace name="content" /> <li class="header"> - <span class="input"><img src="modules/filemanager/img/arrow.gif" width="16" height="16" alt="" class="input" /></span> + <span class="input"><img src="<layout:replace name="imgpath" default="modules/filemanager/img/" />arrow.gif" width="16" height="16" alt="" class="input" /></span> <span class="input"><button type="submit" name="submit-deluser" value="-1" title="ausgewählte Benutzereinträge entfernen">ausgewählte Benutzer entfernen</button></span> </li> </ul> @@ -21,8 +21,8 @@ <![CDATA[ <li> <span class="input"><input type="checkbox" name="select-user-<layout:replace name="id" />" value="1" title="Benutzereintrag auswählen" /></span> - <span class="input"><button type="submit" name="submit-deluser" value="<layout:replace name="username" />" title="Benutzereintrag entfernen"><img src="modules/filemanager/img/delete.gif" width="16" height="16" alt="del" /></button></span> - <span class="input"><button type="submit" name="submit-edituser" value="<layout:replace name="username" />" title="Benutzereintrag editieren" ><img src="modules/filemanager/img/edit.gif" width="16" height="16" alt="edit" /></button></span> + <span class="input"><button type="submit" name="submit-deluser" value="<layout:replace name="username" />" title="Benutzereintrag entfernen"><img src="<layout:replace name="imgpath" default="modules/filemanager/img/" />delete.gif" width="16" height="16" alt="del" /></button></span> + <span class="input"><button type="submit" name="submit-edituser" value="<layout:replace name="username" />" title="Benutzereintrag editieren" ><img src="<layout:replace name="imgpath" default="modules/filemanager/img/" />edit.gif" width="16" height="16" alt="edit" /></button></span> <layout:replace name="username" /> </li> ]]> @@ -63,10 +63,12 @@ window.onload = document.getElementById ("username").focus(); ]]> </script> - <layout:replace name="content" /> - <label><select name="username"><layout:replace name="userlist" /></select>Benutzer </label> - <label><input type="password" name="password" value="" />Passwort </label> - <button type="submit" name="login-submit" value="1">Anmelden</button> + <div> + <layout:replace name="content" /> + <label><span>Benutzer</span><select name="username"><layout:replace name="userlist" /></select></label> + <label><span>Passwort</span><input type="password" name="password" value="" /></label> + <button type="submit" name="login-submit" value="1">Anmelden</button> + </div> </fieldset> ]]> </layout:insert> @@ -82,13 +84,15 @@ window.onload = document.getElementById ("username").focus(); ]]> </script> - <layout:replace name="content" /> -<!-- <label><input type="text" id="username" name="username" />Benutzer </label> --> - <label><input type="password" name="password" value="" />Passwort </label> - <input type="hidden" name="HMAC_use_js" id="HMAC_use_js" value="false" /> - <input type="hidden" name="HMAC_key" id="HMAC_key" value="<layout:replace name="hmac_key" default="" />" /> - <input type="hidden" name="HMAC_hash" id="HMAC_hash" /> - <button type="submit" name="login-submit" value="1">Anmelden</button> + <div> + <layout:replace name="content" /> +<!-- <label><input type="text" id="username" name="username" />Benutzer </label> --> + <label><input type="password" name="password" value="" />Passwort </label> + <input type="hidden" name="HMAC_use_js" id="HMAC_use_js" value="false" /> + <input type="hidden" name="HMAC_key" id="HMAC_key" value="<layout:replace name="hmac_key" default="" />" /> + <input type="hidden" name="HMAC_hash" id="HMAC_hash" /> + <button type="submit" name="login-submit" value="1">Anmelden</button> + </div> </fieldset> ]]> </layout:insert> --- NEW FILE: class.phpcms_auth.php --- <?php /** * User- and permissionmanagment * * authentication class * * <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) 2004, Martin Jahn * @version $Id: class.phpcms_auth.php,v 1.1 2004/12/07 06:34:46 mjahn Exp $ * @package admin4phpCMS * @subpackage module_user **/ /* * $Log: class.phpcms_auth.php,v $ * Revision 1.1 2004/12/07 06:34:46 mjahn * prepration of first Alpha-Preview * * Revision 1.1 2004/09/29 20:10:43 mjahn * completed phpCMS-config-part * began the statistic part * */ /** * include necessary PEAR-packages **/ include_once ('Auth.php'); /** * @author Martin Jahn <mj...@us...> * @package admin4phpCMS */ class phpCMSAuth extends Auth { function phpCMSAuth () { $this->__construct (); } function __construct () { parent::Auth (dirname (__FILE__).'/user.db'); } /** * Assign data from login form to internal values * * This function takes the values for username and password * from $HTTP_POST_VARS/$_POST and assigns them to internal variables. * If you wish to use another source apart from $HTTP_POST_VARS/$_POST, * you have to derive this function. * * @global $HTTP_POST_VARS, $_POST * @see Auth * @return void * @access private */ function assignData() { if (isset($this->post[$this->_postUsername]) && $this->post[$this->_postUsername] != '') { $this->username = (get_magic_quotes_gpc() == 1 ? stripslashes($this->post[$this->_postUsername]) : $this->post[$this->_postUsername]); } if (isset($this->post[$this->_postPassword]) && $this->post[$this->_postPassword] != '') { $this->password = (get_magic_quotes_gpc() == 1 ? stripslashes($this->post[$this->_postPassword]) : $this->post[$this->_postPassword] ); } } /** * Has the user been authenticated? * * @access public * @return bool True if the user is logged in, otherwise false. */ function getAuth() { if ( isset($this->session['registered']) ) { return true; } return false; } /** * Add user to the storage container * * @access public * @param string Username * @param string Password * @param mixed Additional parameters * @return mixed True on success, PEAR error object on error * and AUTH_METHOD_NOT_SUPPORTED otherwise. */ function addUser($username, $password, $additional = '') { $this->_loadStorage(); return $this->storage->addUser($username, $password, $additional); } /** * Change password for user in the storage container * * @access public * @param string Username * @param string The new password * @return mixed True on success, PEAR error object on error * and AUTH_METHOD_NOT_SUPPORTED otherwise. */ function changePassword($username, $password) { $this->_loadStorage(); return $this->storage->changePassword($username, $password); } } ?> Index: class.module_user.php =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/user/class.module_user.php,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- class.module_user.php 29 Sep 2004 20:10:43 -0000 1.9 +++ class.module_user.php 7 Dec 2004 06:34:46 -0000 1.10 @@ -30,6 +30,9 @@ /* * $Log$ +* Revision 1.10 2004/12/07 06:34:46 mjahn +* prepration of first Alpha-Preview +* * Revision 1.9 2004/09/29 20:10:43 mjahn * completed phpCMS-config-part * began the statistic part @@ -59,13 +62,8 @@ /** * include the authentication-class **/ -//include_once ('Auth.php'); -include_once (dirname (__FILE__).'/class.auth.php'); - -/** -* set the filename of the user-db -**/ -define ('PASSWD_FILE', dirname (__FILE__).'/user.db'); +include_once ('Auth.php'); +define ('US_IMGPATH', MODULE_PATH.'/filemanager/img/'); /** * Class for user- and permission-managment @@ -99,15 +97,14 @@ var $_USER; var $adminAction = ''; + var $_userdata = array ('isLoggedIn'=>false); + /** * Initialization of the module * * The module registers its own events and connects his methods to some actions **/ function init () { - $this->_USER = new SaferAuth('File', PASSWD_FILE); - $this->_USER->setShowLogin (false); - // connect to actions $this->_registerAction ('doParseParam', 'parseParam'); $this->_registerAction ('doParseMenuMain', 'getMenuMain'); @@ -122,6 +119,14 @@ $this->_registerEvent ('USER_GET_STATUS', 'doGetUserStatus'); $this->_registerAction ('doGetUserStatus', 'getUserStatus'); + // get module-config from config-module + $actiondata1 = array ('module'=>'user', 'format'=>'array'); + $this->_callEvent ('CONFIG_GET', $actiondata1); + $this->CONF =& $actiondata1 ['config']; + + $this->_USER = new Auth('File', dirname (__FILE__).'/'.$this->CONF ['userfile']); + $this->_USER->setShowLogin (false); + return true; } @@ -134,7 +139,9 @@ // start the user-managaer $this->_USER->start (); - //echo ($this->_USER->getAuth() ? 'true' : 'false'); + if ($this->_USER->checkAuth()) { + $this->_userdata ['isLoggedIn'] = $this->_USER->checkAuth (); + } // load our own extra template $actiondata1 = array ('filename'=>dirname (__FILE__).'/layout.user.xml'); @@ -197,7 +204,7 @@ } // if the user is not yet logged in - if (!$this->_USER->getAuth ()) { + if (!$this->_USER->checkAuth ()) { $this->action = 'login'; } // react onto the action @@ -234,7 +241,6 @@ function processAdmin (&$actiondata) { -// $this->_USER->setMode('sha'); //check for the correct action we have to do switch ($this->adminAction) { case 'delete-user': @@ -272,7 +278,7 @@ $root = $actiondata['_root']; - if (!$this->_USER->getAuth ()) { + 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); return true; @@ -293,7 +299,7 @@ * @param array $actiondata $actiondata['_root'] must provide the id of the parental element **/ function getMenuSub (&$actiondata) { - if (!$this->_USER->getAuth ()) { + if (!$this->_USER->checkAuth ()) { return true; } @@ -332,7 +338,10 @@ $this->_callEvent ('ERROR_NOTICE', $actiondata1); } - $actiondata1 = array ('_id'=>'loginform', '_root'=>$root, '_type'=>'form', 'method'=>'post', 'action'=>'index.php'); + $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); $users =$this->_USER->listUsers (); @@ -351,7 +360,7 @@ $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); } } - + return true; } @@ -362,7 +371,7 @@ * @param array $actiondata $actiondata['_root'] must provide the id of the parental element **/ function getStatusContent (&$actiondata) { - if ($this->_USER->getAuth () == 1) { + if ($this->_USER->checkAuth () == 1) { $root = $actiondata['_root']; @@ -391,7 +400,7 @@ $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', '_type'=>'us_userlist'); + $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 (); @@ -402,7 +411,7 @@ foreach ($user as $id=>$user) { - $actiondata1 = array ('_root'=>'us_list', '_id'=>'user-'.$id, '_type'=>'us_listentry', 'id'=>$id, 'username'=>$user ['username']); + $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); } @@ -445,7 +454,7 @@ * @param array $actiondata **/ function getUserStatus (&$actiondata) { - $actiondata ['isLoggedIn'] = $this->_USER->getAuth (); + $actiondata = $this->_userdata; return true; } |