openrat-cms

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

commit 485b1d9a683c32f1fa8b93e35c13af894a4fc549
parent be112e278c3762a115e83c82e7736eb1ce5f94b9
Author: dankert <devnull@localhost>
Date:   Sun, 19 Dec 2004 20:22:32 +0100

Einzelne Korrekturen

Diffstat:
actionClasses/UserAction.class.php | 234+++++++++++++++++++++++--------------------------------------------------------
1 file changed, 68 insertions(+), 166 deletions(-)

diff --git a/actionClasses/UserAction.class.php b/actionClasses/UserAction.class.php @@ -18,33 +18,6 @@ // 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. -// --------------------------------------------------------------------------- -// $Log$ -// Revision 1.6 2004-12-15 23:23:11 dankert -// Anpassung an Session-Funktionen -// -// Revision 1.5 2004/11/28 22:46:55 dankert -// Rechte des Benutzers anzeigen -// -// Revision 1.4 2004/11/10 22:42:10 dankert -// *** empty log message *** -// -// Revision 1.3 2004/05/02 14:49:37 dankert -// Einf?gen package-name (@package) -// -// Revision 1.2 2004/05/02 14:30:27 dankert -// E-Mail versenden wenn neues Kennwort gesetzt -// -// Revision 1.1 2004/04/24 15:14:52 dankert -// Initiale Version -// -// Revision 1.2 2003/10/02 20:56:17 dankert -// Benutzer entfernen -// -// Revision 1.1 2003/09/29 18:18:21 dankert -// erste Version -// -// --------------------------------------------------------------------------- /** @@ -58,69 +31,56 @@ class UserAction extends Action var $user; var $defaultSubAction = 'edit'; + function UserAction() { - $this->user = new User( $this->getRequestId() ); - $this->user->load(); + if ( !$this->userIsAdmin() ) + die('you are not an admin'); + + if ( $this->getRequestId() != 0 ) + { + $this->user = new User( $this->getRequestId() ); + $this->user->load(); + $this->setTemplateVar('userid',$this->user->userid); + } + } function save() { - global $REQ; - - if ( $this->getRequestVar('delete') != '' ) + if ( $this->hasRequestVar('delete') ) { $this->user->delete(); - $this->callSubAction('listing'); + $this->addNotice('user',$this->user->name,'DELETED','ok'); } else { // Benutzer speichern - $this->user->name = $REQ['name']; - $this->user->fullname = $REQ['fullname']; - $this->user->isAdmin = isset($REQ['is_admin']); - $this->user->ldap_dn = $REQ['ldap_dn']; - $this->user->tel = $REQ['tel']; - $this->user->desc = $REQ['desc']; - $this->user->mail = $REQ['mail']; - $this->user->style = $REQ['style']; + $this->user->name = $this->getRequestVar('name' ); + $this->user->fullname = $this->getRequestVar('fullname'); + $this->user->isAdmin = $this->hasRequestVar('is_admin'); + $this->user->ldap_dn = $this->getRequestVar('ldap_dn' ); + $this->user->tel = $this->getRequestVar('tel' ); + $this->user->desc = $this->getRequestVar('desc' ); + $this->user->mail = $this->getRequestVar('mail' ); + $this->user->style = $this->getRequestVar('style' ); + $this->user->save(); + $this->addNotice('user',$this->user->name,'SAVED','ok'); } - $this->callSubAction('edit'); - } - - - /** - * Abspeichern des Profiles - */ - function saveProfile() - { - global $SESS; - $this->user = new User( $SESS['user']['id'] ); - $this->user->load(); - - $this->user->fullname = $this->getRequestVar('fullname'); - $this->user->tel = $this->getRequestVar('tel' ); - $this->user->desc = $this->getRequestVar('desc' ); - $this->user->mail = $this->getRequestVar('mail' ); - $this->user->style = $this->getRequestVar('style' ); - $this->user->save(); - -// $this->user->setCurrent(); - - $this->callSubAction('profile'); + $this->callSubAction('listing'); } function add() { - + $this->user = new User(); $this->user->add( $this->getRequestVar('name') ); - $this->setSessionVar('userid',$this->user->userid); + $this->addNotice('user',$this->user->name,'ADDED','ok'); - $this->callSubAction('edit'); + $this->callSubAction('listing'); } @@ -128,86 +88,71 @@ class UserAction extends Action { $this->user->addGroup( $this->getRequestVar('groupid') ); + $this->addNotice('user',$this->user->name,'ADDED','ok'); $this->callSubAction('groups'); } function delgroup() { - $this->user->delGroup( $this->getRequestVar('groupid') ); - + + $this->addNotice('user',$this->user->name,'DELETED','ok'); $this->callSubAction('groups'); } function pwchange() { - global $SESS; - - if ($this->getRequestVar('password1') != '' && $this->getRequestVar('password1') == $this->getRequestVar('password2')) + if ( $this->getRequestVar('password1') != '' && + $this->getRequestVar('password1') == $this->getRequestVar('password2') ) { - if ($SESS['user']['is_admin'] != '1') - $ok = $this->user->checkPassword( $this->getRequestVar('act_password') ); - else $ok = true; - - if ( !$ok ) - { - message('ERROR_USER_PW','old password not accepted'); - } - else + $this->user->setPassword( $this->getRequestVar('password1') ); + + // E-Mail mit dem neuen Kennwort an Benutzer senden + if ( $this->hasRequestVar('mail') && !empty($this->user->mail) ) { - $this->user->setPassword( $this->getRequestVar('password1') ); - - // E-Mail mit dem neuen Kennwort an Benutzer senden - if ( $this->getRequestVar('mail') != '' && $this->user->mail != '') - { - // Text der E-Mail zusammenfuegen - $text = wordwrap(lang('USER_MAIL_PREFIX'),70,"\n")."\n\n".$this->getRequestVar('password1')."\n\n".wordwrap(lang('USER_MAIL_SUFFFIX'),70,"\n"); - - // Mail versenden - mail($this->user->mail,lang('USER_MAIL_SUBJECT'),$text); - } + // Text der E-Mail zusammenfuegen + $text = wordwrap(lang('USER_MAIL_PREFIX'),70,"\n")."\n\n".$this->getRequestVar('password1')."\n\n".wordwrap(lang('USER_MAIL_SUFFFIX'),70,"\n"); + + // Mail versenden + mail($this->user->mail,lang('USER_MAIL_SUBJECT'),$text); } - } - else - { - message('ERROR_USER_PW','passwords not equal or blank'); + + $this->addNotice('user',$this->user->name,'SAVED','ok'); } $this->callSubAction('edit'); } - function delright() - { - if ($SESS['user']['is_admin'] != '1') die('weah'); - - $user->delRight( $this->getRequestVar('aclid') ); - - // Berechtigungen anzeigen - $this->callSubAction('rights'); - } - - - function addright() - { - global $REQ; - if ($SESS['user']['is_admin'] != '1') die('go away hacker'); - - $user->addRight( $REQ ); - - // Berechtigungen anzeigen - $this->callSubAction('rights'); - } +// function delright() +// { +// if ($SESS['user']['is_admin'] != '1') die('weah'); +// +// $user->delRight( $this->getRequestVar('aclid') ); +// +// // Berechtigungen anzeigen +// $this->callSubAction('rights'); +// } +// +// +// function addright() +// { +// global $REQ; +// if ($SESS['user']['is_admin'] != '1') die('go away hacker'); +// +// $user->addRight( $REQ ); +// +// // Berechtigungen anzeigen +// $this->callSubAction('rights'); +// } function listing() { - global $conf_php; - $list = array(); - foreach( $this->user->listAll() as $userid=>$name ) + foreach( User::listAll() as $userid=>$name ) { $list[$userid] = array(); $list[$userid]['url' ] = Html::url('main','user',$userid); @@ -219,33 +164,14 @@ class UserAction extends Action } - function profile() - { - global $SESS; - - $this->user = new User( $SESS['user']['id'] ); - $this->user->load(); - - $this->setTemplateVars( $this->user->getProperties() ); - - $this->setTemplateVar( 'allstyles',$this->getStyles() ); - - $this->forward( 'user_profile' ); - } - - /** * Eigenschaften des Benutzers anzeigen */ function edit() { - global $SESS; - - if ( !$SESS['user']['is_admin'] ) exit(); - $this->setTemplateVars( $this->user->getProperties() ); - $this->setTemplateVar( 'allstyles',$this->getStyles() ); + $this->setTemplateVar( 'allstyles',$this->user->getAvailableStyles() ); $this->forward( 'user_edit' ); } @@ -253,8 +179,7 @@ class UserAction extends Action function groups() { - - // Alle hinzuf?gbaren Gruppen ermitteln + // Alle hinzufuegbaren Gruppen ermitteln $this->setTemplateVar('groups',$this->user->getOtherGroups()); // Mitgliedschaften @@ -265,7 +190,7 @@ class UserAction extends Action /** - * ?ndern des Kennwortes + * Aendern des Kennwortes */ function pw() { @@ -304,27 +229,4 @@ class UserAction extends Action $this->forward('user_rights'); } - - - /** - * Ermitteln aller zur Verf?gung stehenden Stylesheets - */ - function getStyles() - { - global $conf_themedir; - $allstyles = array(); - $handle=opendir( $conf_themedir.'/css' ); - - while ($file = readdir ($handle)) - { - if ( eregi('\.css$',$file) ) - { - $file = eregi_replace('\.css$','',$file); - $allstyles[$file] = $file; - } - } - closedir($handle); - - return $allstyles; - } } \ No newline at end of file