Show
Ignore:
Timestamp:
07/23/08 01:12:58 (4 months ago)
Author:
aarkerio
Message:

Update forums and tests

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/controllers/users_controller.php

    r637 r670  
    281281    
    282282   /** Check Passwd **/ 
    283    if (strlen($this->data['User']['pwd']) < 6) 
    284    { 
     283   if (strlen($this->data['User']['pwd']) < 6): 
    285284       $message['pwd_wrong'] = 'The password have less than 6 characters '; 
    286    } 
    287      
    288    if (strpos($this->data['User']['username'], ' '))  // no spaces    
    289    { 
     285   endif; 
     286     
     287   if (strpos($this->data['User']['username'], ' ')):  // no spaces 
    290288       $message['username_spaces'] = 'Your username should not contain spaces'; 
    291    } 
     289   endif; 
    292290     
    293291   /** username check **/ 
    294    if (strlen($this->data['User']['username']) < 5) 
    295    { 
     292   if (strlen($this->data['User']['username']) < 5): 
    296293       $message['pwd_username'] = "The username has less than 5 characters "; 
    297    } 
     294   endif; 
    298295     
    299296   /** name check **/ 
    300    if (strlen($this->data['User']['name']) < 5) 
    301    { 
     297   if (strlen($this->data['User']['name']) < 5): 
    302298       $message['pwd_username'] = "The name is too short"; 
    303    } 
    304      
    305     if (strpos($this->data['User']['pwd'], ' '))  // pwd too short 
    306     { 
     299   endif; 
     300     
     301    if (strpos($this->data['User']['pwd'], ' ')):  // pwd no spaces 
    307302       $message['username_spaces'] = "Your password should not contain spaces"; 
    308     } 
     303    endif; 
    309304     
    310305    /** description check **/ 
    311     if (strlen($this->data['User']['description']) < 5) 
    312     { 
     306    if (strlen($this->data['User']['description']) < 5): 
    313307       $message['description_too_short'] = "C'mon pal, talk us about you!"; 
    314     } 
     308    endif; 
    315309     
    316310    /** email check **/ 
    317     if ($this->Adds->validEmail($this->data['User']['email']) === false) 
    318     { 
     311    if ($this->Adds->validEmail($this->data['User']['email']) === false): 
    319312       $message['pwd_username'] = "Typed email is invalid"; 
    320     } 
     313    endif; 
    321314     
    322315    /** Check the user **/ 
    323316    $username = $this->User->field('username', array('username' => $this->data['User']['username'])); 
    324317     
    325     if ($username != null) 
    326     { 
     318    if ($username != null): 
    327319       $message['username_exist'] = 'The username already exist '; 
    328     } 
     320    endif; 
    329321     
    330322    /** Check the email **/ 
    331323    $email        = $this->User->field('email', array('email' => $this->data['User']['email'])); 
    332324     
    333     if ($email != null) 
    334     { 
     325    if ($email != null): 
    335326       $message['email_exist'] = 'The email already exist '; 
    336     } 
     327    endif; 
    337328     
    338329    // get the secret code for teachers registration process 
    339330    $code  = $this->User->Group->field('code', array('id'=>$this->data['User']['group_id'])); 
    340331     
    341     if ( $this->data['User']['code'] != $code ) 
    342     { 
     332    if ( $this->data['User']['code'] != $code ): 
    343333        $message['wrong_code'] = "The code is incorrect, please put in contact with your school webmaster."; 
    344     } 
    345      
    346     if ( count($message) > 1 ) 
    347     {   
     334    endif; 
     335     
     336    if ( count($message) > 1 ): 
    348337       $this->set('message', $message); 
    349338       $this->render('validate', 'ajax'); //if error exist, stop here 
    350        
    351     } 
    352     else 
    353     { 
     339    else: 
    354340       $this->data['User']['active']     = 0; 
    355341       $this->data['User']['name_blog']  = $this->data['User']['username'].'\'s corner';  
    356        $this->User->create(); 
    357        //exit(var_dump($this->data["User"])); 
    358        if ($this->User->save($this->data['User'])) 
    359        {   
     342        
     343       if ($this->User->save($this->data)):   
    360344        $this->data['Confirm']['user_id']  = $this->User->getLastInsertID();   // the user id 
    361345        $this->data['Confirm']['secret']   = $this->Adds->genPassword(14);     // secret confirm ID 
     
    364348         
    365349         // put the user in confirm model, this is, waiting for user confirmation trough email 
    366          if ($this->User->Confirm->save($this->data["Confirm"]))   
    367          { 
     350    if ($this->User->Confirm->save($this->data['Confirm'])): 
    368351            //Send the confirmation email 
    369             if ( $this-> _sendNewUserPwd($this->data['User']['email'], $this->data['Confirm']['secret']) )  
    370             {  
     352       if ( $this->_sendNewUserPwd($this->data['User']['email'], $this->data['Confirm']['secret']) ): 
    371353              $msg  = "<h2>You have been registered!</h2> <p>A confirmation email has been sent to: ".$this->data['User']['email']; 
    372354          $msg .= " In order to complete the registration process, please click on the link contained on the email.</p>"; 
    373               $this->set('message', array("Suceess"=>$msg));  
     355              $this->set('message', array('Sucess'=>$msg));  
    374356              $this->set('ok', true); 
    375357              $this->render('validate', 'ajax'); 
    376             } 
    377          } 
    378         } 
    379         else  
    380         { 
     358       endif; 
     359     endif; 
     360        else: 
    381361            $this->set('message', array("Error"=>"Error, something is wrong in save method")); 
    382362            $this->render('validate', 'ajax'); 
    383         } 
    384      } 
     363    endif; 
     364      endif; 
    385365   } 
    386366  }