ProfileAction.class.php
gehe zur Dokumentation dieser Datei00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00030 class ProfileAction extends Action
00031 {
00032 var $user;
00033 var $defaultSubAction = 'edit';
00034
00035 function ProfileAction()
00036 {
00037 $this->user = Session::getUser();
00038 }
00039
00040
00044 function saveprofile()
00045 {
00046 $this->user->fullname = $this->getRequestVar('fullname');
00047 $this->user->tel = $this->getRequestVar('tel' );
00048 $this->user->desc = $this->getRequestVar('desc' );
00049 $this->user->style = $this->getRequestVar('style' );
00050
00051 if ( !empty($this->user->fullname) )
00052 {
00053 $this->user->save();
00054 $this->addNotice('user',$this->user->name,'SAVED','ok');
00055 }
00056 else
00057 {
00058 $this->addValidationError('fullname');
00059 $this->callSubAction('edit');
00060 }
00061 }
00062
00063
00064 function pwchange()
00065 {
00066 }
00067
00068
00069
00070 function mail()
00071 {
00072 }
00073
00074
00075
00076 function mailcode()
00077 {
00078 srand ((double)microtime()*1000003);
00079 $code = rand();
00080 $newMail = $this->getRequestVar('mail');
00081
00082 if ( empty($newMail) )
00083 {
00084
00085 $this->addValidationError('mail');
00086 return;
00087 }
00088 else
00089 {
00090 Session::set('mailChangeCode',$code );
00091 Session::set('mailChangeMail',$newMail);
00092
00093
00094 $mail = new Mail( $newMail,'mail_change_code' );
00095 $mail->setVar('code',$code );
00096 $mail->setVar('name',$this->user->getName());
00097
00098 if ( $mail->send() )
00099 {
00100 $this->addNotice('user',$this->user->name,'mail_sent',OR_NOTICE_OK);
00101 }
00102 else
00103 {
00104 $this->addNotice('user',$this->user->name,'mail_not_sent',OR_NOTICE_ERROR,array(),$mail->error);
00105 $this->callSubAction('mail');
00106 return;
00107 }
00108 }
00109 }
00110
00111
00112
00113 function confirmmail()
00114 {
00115 }
00116
00117
00118
00119 function savemail()
00120 {
00121 $sessionCode = Session::get('mailChangeCode');
00122 $newMail = Session::get('mailChangeMail');
00123 $inputRegisterCode = $this->getRequestVar('code');
00124
00125 if ( $sessionCode == $inputRegisterCode )
00126 {
00127
00128
00129 $this->user->mail = $newMail;
00130 $this->user->save();
00131
00132 $this->addNotice('user',$this->user->name,'SAVED',OR_NOTICE_OK);
00133 }
00134 else
00135 {
00136
00137 $this->addValidationError('code','code_not_match');
00138 $this->callSubAction('confirmmail');
00139 }
00140
00141 }
00142
00143
00144
00145 function savepw()
00146 {
00147 if ( ! $this->user->checkPassword( $this->getRequestVar('act_password') ) )
00148 {
00149 $this->addValidationError('act_password');
00150 $this->callSubAction('pwchange');
00151 }
00152 elseif ( $this->getRequestVar('password1') == '' )
00153 {
00154 $this->addValidationError('password1');
00155 $this->callSubAction('pwchange');
00156 }
00157 elseif ( $this->getRequestVar('password1') != $this->getRequestVar('password2') )
00158 {
00159 $this->addValidationError('password2','PASSWORDS_DO_NOT_MATCH');
00160 $this->callSubAction('pwchange');
00161 }
00162 else
00163 {
00164 $this->user->setPassword( $this->getRequestVar('password1') );
00165 $this->addNotice('user',$this->user->name,'SAVED','ok');
00166 }
00167 }
00168
00169
00170
00171 function edit()
00172 {
00173 $this->setTemplateVars( $this->user->getProperties() );
00174
00175 $this->setTemplateVar( 'allstyles',$this->user->getAvailableStyles() );
00176 }
00177
00178
00179
00184 function groups()
00185 {
00186 $this->setTemplateVar( 'groups',$this->user->getGroups() );
00187 }
00188
00189
00190
00195 function checkMenu( $name )
00196 {
00197 global $conf;
00198
00199 switch( $name )
00200 {
00201 case 'pwchange':
00202 return @$conf['security']['auth']['type'] == 'database'
00203 && !@$conf['security']['auth']['userdn'];
00204
00205 default:
00206 return true;
00207 }
00208 }
00209
00210 }