[Phpcms-plugins-cvs] admin4phpCMS/modules/user layout.user.xml,NONE,1.1 Perm_XML.xml,1.1,1.2 Auth_XM
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2004-08-25 21:17:26
|
Update of /cvsroot/phpcms-plugins/admin4phpCMS/modules/user In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2565/modules/user Modified Files: Perm_XML.xml Auth_XML.xml class.module_user.php Added Files: layout.user.xml Log Message: step 1 is taken Index: Perm_XML.xml =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/user/Perm_XML.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Perm_XML.xml 30 May 2004 18:03:43 -0000 1.1 +++ Perm_XML.xml 25 Aug 2004 21:16:45 -0000 1.2 @@ -5,28 +5,25 @@ <user userId="1" authUserId="c4ca4238a0b923820dcc509a6f75849b" type="1"> <rights>0,1,2,3,4,5,6,7,8</rights> </user> - <user userId="2" authUserId="c4ca4238a0b923820dcc509a6f75849c" type="1"> - <rights>0,3,7</rights> - </user> - <user userId="3" authUserId="c4ca4238a0b923820dcc509a6f7584ec" type="1"> - <rights>0</rights> + <user userId="2" authUserId="c4ca4238a0b923820dcc509a6f7584ec" type="1"> + <rights>0,2,4,5</rights> </user> </users> <areas> - <area id="1" defineName="onlineeditor"> - <right defineName="watching">0</right> - <right defineName="saving">1</right> - <right defineName="creating">2</right> + <area id="1" defineName="administation"> + <right defineName="view">0</right> + <right defineName="edit">1</right> </area> <area id="2" defineName="filemanager"> - <right defineName="watching">3</right> - <right defineName="creating">4</right> - <right defineName="uploading">5</right> - <right defineName="delete">6</right> + <right defineName="view-all">2</right> + <right defineName="edit">3</right> + <right defineName="uploading">4</right> </area> - <area id="3" defineName="configuration"> - <right defineName="watching">7</right> - <right defineName="change">8</right> + <area id="3" defineName="phpcms"> + <right defineName="view-all">5</right> + <right defineName="edit-config">6</right> + <right defineName="edit-menu">7</right> + <right defineName="edit-content">8</right> </area> </areas> </liveuserPermXMLSimple> \ No newline at end of file Index: Auth_XML.xml =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/user/Auth_XML.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Auth_XML.xml 30 May 2004 18:03:43 -0000 1.1 +++ Auth_XML.xml 25 Aug 2004 21:16:45 -0000 1.2 @@ -1,27 +1,11 @@ <?xml version="1.0"?> <liveuserAuthXML> <user> - <userId>c4ca4238a0b923820dcc509a6f75849b</userId> + <userId>c2f3a7b0e409ffa94d33f8569f188103</userId> <handle>Martin Jahn</handle> <password>5f2f788f5c4f000701a40d56aaff6e36</password> <currentLogin>1047564897</currentLogin> - <lastLogin>1085387296</lastLogin> - <isActive>Y</isActive> - </user> - <user> - <userId>c4ca4238a0b923820dcc509a6f75849c</userId> - <handle>tester</handle> - <password>f5d1278e8109edd94e1e4197e04873b9</password> - <currentLogin>1047564897</currentLogin> - <lastLogin>1083272950</lastLogin> - <isActive>Y</isActive> - </user> - <user> - <userId>c4ca4238a0b923820dcc509a6f75849d</userId> - <handle>test</handle> - <password>098f6bcd4621d373cade4e832627b4f6</password> - <currentLogin>1047564897</currentLogin> - <lastLogin>1083272950</lastLogin> + <lastLogin>1092043123</lastLogin> <isActive>Y</isActive> </user> <user> @@ -29,7 +13,7 @@ <handle>demo</handle> <password>fe01ce2a7fbac8fafaed7c982a04e229</password> <currentLogin>1047564897</currentLogin> - <lastLogin>1084467564</lastLogin> + <lastLogin>1092043123</lastLogin> <isActive>Y</isActive> </user> </liveuserAuthXML> --- NEW FILE: layout.user.xml --- <?xml version="1.0" encoding="iso-8859-15" standalone="yes"?> <layout name="standard"> <layout:insert name="us_userlist"> <![CDATA[ <h2>Benutzerübersicht</h2> <ul id="userlist"> <layout:replace name="username" /> </ul> ]]> </layout:insert> <layout:insert name="us_listentry"> <![CDATA[ <li> <input type="submit" name="deluser-<layout:replace name="id" />" value="D" /> <input type="submit" name="edituser-<layout:replace name="id" />" value="E" /> <layout:replace name="username" /> </li> ]]> </layout:insert> <layout:insert name="us_edituser"> <![CDATA[ <fieldset> <legend>Benutzerdaten editieren</legend> <input type="hidden" name="edit-userId" value="<layout:replace name="userId" />" /> <label><input type="text" name="edit-handle" value="<layout:replace name="handle" />" />Loginname </label> <label><input type="password" name="edit-password" value="<layout:replace name="password" />" />Passwort </label> <label><input type="checkbox" name="edit-isActive" />Aktiviert </label> </fieldset> ]]> </layout:insert> <layout:insert name="us_newuser"> <![CDATA[ <fieldset> <legend>Neuen Benutzer anlegen</legend> <label><input type="text" name="new-handle" value="Neues Login" />Loginname </label> <label><input type="password" name="new-password" value="Neues Passwort" />Passwort </label> <label><input type="checkbox" name="new-isActive" />Aktiviert </label> </fieldset> ]]> </layout:insert> <layout:insert name="us_loginform"> <![CDATA[ <fieldset class="loginform"> <legend>Am System anmelden</legend> <input type="hidden" name="method" value="<layout:replace name="method" default="post" />" /> <layout:replace name="content" /> <label><input type="text" name="handle" />Benutzer </label> <label><input type="password" name="passwd" value="" />Passwort </label> <button type="submit" name="login-submit" value="1">Anmelden</button> </fieldset> ]]> </layout:insert> </layout> Index: class.module_user.php =================================================================== RCS file: /cvsroot/phpcms-plugins/admin4phpCMS/modules/user/class.module_user.php,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- class.module_user.php 5 Aug 2004 16:38:43 -0000 1.7 +++ class.module_user.php 25 Aug 2004 21:16:46 -0000 1.8 @@ -30,6 +30,9 @@ /* * $Log$ +* Revision 1.8 2004/08/25 21:16:46 mjahn +* step 1 is taken +* * Revision 1.7 2004/08/05 16:38:43 mjahn * tweaked phpcms::cache-module output * @@ -52,7 +55,7 @@ /** * include necessary files **/ -include_once 'LiveUser/LiveUser.php'; +include_once (PATH_TO_PEAR.'LiveUser/LiveUser.php'); /** * Class for user- and permission-managment @@ -94,7 +97,7 @@ $liveuserConfig = array( 'session' => array('name' => 'PHPSESSID','varname' => 'loginInfo'), 'login' => array('username' => 'handle', 'password' => 'passwd'), - 'cookie' => array('name' => 'loginInfo', 'path' => '/', 'domain' => $_SERVER ['HTTP_HOST'], 'lifetime' => 60), + 'cookie' => array('name' => 'loginInfo', 'path' => '/', 'domain' => 'localhost', 'lifetime' => 60), 'autoInit' => true, 'authContainers' => array(0 => array('type' => 'XML', 'file' => dirname(__FILE__).'/Auth_XML.xml', @@ -112,11 +115,9 @@ $this->_USER = LiveUser::factory($liveuserConfig); // connect to actions $this->_registerAction ('doParseParam', 'parseParam'); - $this->_registerAction ('doProcess', 'process'); $this->_registerAction ('doParseMenuMain', 'getMenuMain'); - $this->_registerAction ('doParseStatusbar', 'getContentBar'); $this->_registerAction ('doParseMenuSub', 'getMenuSub'); - $this->_registerAction ('doParseContent', 'getContent'); + $this->_registerAction ('doParseStatusbar', 'getStatusContent'); // provide my own actions to the eventhandler $this->_registerEvent ('USER_GET_DATA', 'doGetUserData'); @@ -135,8 +136,15 @@ * @param array $actiondata $actiondata contains the URI-param-arrays **/ function parseParam (&$actiondata) { + + // load our own extra template + $actiondata1 = array ('filename'=>dirname (__FILE__).'/layout.user.xml'); + $this->_callEvent ('LAYOUT_ADD_TEMPLATE', $actiondata1); + + // check if the user submitted the login-form $logout = false; $username = ''; + $passwd = ''; $password = ''; if (isset ($actiondata['post']['logout'])) { $logout = true; @@ -145,7 +153,6 @@ unset ($_GET['logout']); $logout = true; } - $passwd = ''; if (isset ($actiondata['post']['passwd'])) { $passwd = $actiondata['post']['passwd']; $logout = false; @@ -155,17 +162,40 @@ $username = $actiondata['post']['handle']; $logout = false; } + + // start the user-managaer $this->_USER->init($username, $password, $logout); - + // 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']; } - return true; + + // if the user is not yet logged in + if (!$this->_USER->isLoggedIn ()) { + $this->action = 'login'; + } + // react onto the action + switch ($this->action) { + case 'login': + $this->_registerAction ('doProcess', 'processLogin'); + break; + case 'admin': + $this->_registerAction ('doProcess', 'processAdmin'); + break; + default: +// $this->_registerAction ('doProcess', 'processLogin'); + } + + $actiondata1 = array ('module'=>'user', 'format'=>'array'); + $this->_callEvent ('CONFIG_GET', $actiondata1); + $this->_CONF = $actiondata1 ['config']; + return true; } /** @@ -173,7 +203,13 @@ * * @param array $actiondata **/ - function process (&$actiondata) { + function processLogin (&$actiondata) { + $this->_registerAction ('doParseContent', 'getLoginContent'); + return true; + } + + function processAdmin (&$actiondata) { + $this->_registerAction ('doParseContent', 'getAdminContent'); return true; } @@ -184,15 +220,20 @@ * @param array $actiondata $actiondata['_root'] must provide the id of the parental element **/ function getMenuMain (&$actiondata) { + + $root = $actiondata['_root']; + if (!$this->_USER->isLoggedIn ()) { + $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; } - $root = $actiondata['_root']; - $actiondata = array ('_type'=>'menu_main_entry', '_root'=>$root, 'name'=>'Benutzerverwaltung', 'module'=>'user', '_id'=>'usermenu', '_root'=>'mainmenu', 'id'=>'', 'class'=>''); + + $actiondata1 = array ('_type'=>'menu_main_entry', '_root'=>$root, 'name'=>'Benutzerverwaltung', 'module'=>'user', '_id'=>'usermenu', '_root'=>'mainmenu', 'id'=>'', 'class'=>''); if ($this->display) { - $actiondata ['extra'] = 'class="active"'; + $actiondata1 ['extra'] = 'class="active"'; } - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); return true; } @@ -213,17 +254,12 @@ $root = $actiondata['_root']; - $actiondata = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Benutzerübersicht', 'module'=>'user', '_id'=>'useroverview'); - if ($this->action == '') { - $actiondata['extra'] = 'id="current"'; + $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', $actiondata); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - $actiondata = array ('_type'=>'menu_sub_entry', '_root'=>$root, 'name'=>'Rechteübersicht', 'module'=>'user', '_id'=>'usermenuchg', 'action'=>'rights'); - if ($this->action == 'rights') { - $actiondata['extra'] = 'id="current"'; - } - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); return true; } @@ -232,100 +268,34 @@ * * @param array $actiondata $actiondata['_root'] must provide the id of the parental element **/ - function getContent (&$actiondata) { - if (!$this->_USER->isLoggedIn ()) { + function getLoginContent (&$actiondata) { - $root = $actiondata['_root']; - - $actiondata = array ('_id'=>'benutzerlogin', '_root'=>$root, '_type'=>'headline', 'content'=>'Benutzerlogin'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); - - $actiondata = array ('_id'=>'loginform', '_root'=>$root, '_type'=>'form', 'method'=>'post', 'action'=>'index.php'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); - - if (isset ($_SERVER ['QUERY_TERM']) && is_array ($_SERVER ['QUERY_TERM'])) { - foreach ($_SERVER ['QUERY_TERM'] as $id=>$value) { - $actiondata = array ('_id'=>'query-'.$id, '_type'=>'form_input_hidden', 'value'=>$value, 'name'=>$id, '_root'=>'loginform'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); - } - } - - $actiondata = array ('_id'=>'method', '_type'=>'form_input_hidden', 'value'=>'post', 'name'=>'method','_root'=>'loginform'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + $root = $actiondata['_root']; - $actiondata = array ('_id'=>'handle', '_type'=>'form_input_text', 'label'=>'Benutzername', 'value'=>'Benutzername', 'name'=>'handle','_root'=>'loginform'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + $actiondata1 = array ('_id'=>'loginform', '_root'=>$root, '_type'=>'form', 'method'=>'post', 'action'=>'index.php'); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - $actiondata = array ('_id'=>'passwd', '_type'=>'form_input_password', 'value'=>'', 'label'=>'Passwort', 'name'=>'passwd','_root'=>'loginform'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); + $actiondata1 = array ('_id'=>'loginform-content', '_root'=>'loginform', '_type'=>'us_loginform', 'method'=>'post'); + $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata1); - $actiondata = array ('_id'=>'submit', '_type'=>'form_button', 'value'=>'Absenden', 'name'=>'submit','text'=>'Absenden', '_root'=>'loginform'); - $this->_callEvent('LAYOUT_ADD_ELEMENT', $actiondata); - return true; - } - if (!$this->display) { - return true; - } + if (isset ($_GET) && is_array ($_GET)) { - if ($this->action == '') { - - $actiondata = array ('_type'=>'form', '_id'=>'userform', '_root'=>$actiondata ['_root'], 'action'=>'#'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - $content = ''; - foreach ($this->_USER->_auth->tree->root->children as $i=>$user) { - ob_start (); - print_r($user); - $content = ob_get_contents(); - ob_end_clean (); - - $actiondata = array ('_type'=>'paragraph', '_id'=>'userform-'.$i, '_root'=>'userform'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - foreach ($user->children as $userdata) { - $actiondata = array ('_type'=>'form_input_text', '_id'=>'userform-'.$i.'-'.$userdata->name, '_root'=>'userform-'.$i, 'name'=>'userform-'.$i.'-'.$userdata->name, 'label'=>$userdata->name, 'value'=>$userdata->content); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - } - + 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); } } - if ($this->action == 'rights') { - ob_start (); - print_r($this->_USER->_perm->tree); - $content = ob_get_contents (); - ob_end_clean (); - - $actiondata = array ('_type'=>'form', '_id'=>'userform', '_root'=>$actiondata ['_root'], 'action'=>'#', 'content'=>'<pre>'.$content.'<pre>'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - - $content = ''; - foreach ($this->_USER->_perm->tree->root->children as $i=>$user) { - ob_start (); - print_r($user); - $content = ob_get_contents(); - ob_end_clean (); - - $actiondata = array ('_type'=>'paragraph', '_id'=>'userform-'.$i, '_root'=>'userform'); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - - foreach ($user->children as $userdata) { - $actiondata = array ('_type'=>'form_input_text', '_id'=>'userform-'.$i.'-'.$userdata->name, '_root'=>'userform-'.$i, 'name'=>'userform-'.$i.'-'.$userdata->name, 'label'=>$userdata->name, 'value'=>$userdata->content); - $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata); - } - - } - } return true; } + /** * Get content for statusbar * * @param array $actiondata $actiondata['_root'] must provide the id of the parental element **/ - function getContentBar (&$actiondata) { + function getStatusContent (&$actiondata) { if ($this->_USER->isLoggedIn ()) { $root = $actiondata['_root']; @@ -339,6 +309,24 @@ /** * Get content for statusbar * + * @param array $actiondata $actiondata['_root'] must provide the id of the parental element + **/ + function getAdminContent (&$actiondata) { + $this->actiondata1 = array ('_root'=>$actiondata ['_root'], '_id'=>'us_list', '_type'=>'us_userlist'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); + + $this->actiondata1 = array ('_root'=>'us_list', '_id'=>'us_list_entry-1', '_type'=>'us_listentry', 'id'=>'1', 'username'=>'Martin Jahn'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); + + $this->actiondata1 = array ('_root'=>'us_list', '_id'=>'us_list_entry-2', '_type'=>'us_listentry', 'id'=>'2', 'username'=>'demo'); + $this->_callEvent ('LAYOUT_ADD_ELEMENT', $actiondata1); + + return true; + } + + /** + * Get content for statusbar + * * This function provides the following information about the user-status * <ul> * <li><b>$actiondata['isLoggedIn']</b> is the user logged in</li> |