Changeset 18

Show
Ignore:
Timestamp:
09/03/09 00:19:47 (12 months ago)
Author:
james
Message:

Added a bare-bones "register" method to UserController? to start #16. It's not great and lacks all of the normal checks on a register form, but it's there.

Location:
trunk
Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/controllers/UserController.php

    r16 r18  
    6060        public function register() 
    6161        { 
     62                // already logged in? 
     63                if($this->current_user->id){ 
     64                        $this->redirect_to(array('action'=>'view','id'=>$this->current_user->id)); 
     65                        exit(); 
     66                } 
    6267                 
     68                $this->title = "Register"; 
    6369                 
     70                // if there's post data 
     71                if($_POST){ 
     72 
     73                        $u = User::find_all(array('login'=>$_POST['login']));  
     74                        if($u){ 
     75                                var_dump($u); 
     76                                $this->error = 'That username is unavailable.'; 
     77                        } else { 
     78 
     79                                $user = new User; 
     80                                 
     81                                $user->email = $_POST['email']; 
     82                                $user->login = $_POST['login']; 
     83                                $user->user_level = 1; 
     84                                 
     85                                if($user->set_password($_POST['password'],$_POST['confirm_password'])){ 
     86                                        $user->save(); 
     87                                        $this->redirect_to(array('action'=>'login','result'=>'success')); 
     88                                        exit(); 
     89                                }else{ 
     90                                        $this->error = 'Your passwords did not match!'; 
     91                                } 
     92                        } 
     93                } 
    6494        } 
    6595         
  • trunk/models/Model.php

    r16 r18  
    242242                        }*/ 
    243243                 
    244                         $cols = '('.implode(',',array_keys($this->initial)).')'; 
     244                        //$cols = '('.implode(',',array_keys($this->initial)).')'; 
    245245                         
    246246                        $updates = array(); 
     
    266266                        } 
    267267                         
     268                        $cols = '('.implode(',',array_keys($data)).')'; 
     269                         
    268270                        $vals = "(".implode(",", array_map(array('Model','quote'),array_map(array($db, 'real_escape_string'), array_values($data)))).")"; 
    269271                         
     
    273275                                $update = ''; 
    274276                        } 
    275                          
     277                        //echo "INSERT INTO {$this->table} $cols VALUES $vals $update;"; 
     278                        //exit(); 
    276279                        $db->query("INSERT INTO {$this->table} $cols VALUES $vals $update;"); 
    277280                         
  • trunk/models/User.php

    r6 r18  
    1717         
    1818        protected $password; 
    19         protected $user_level;   
    2019 
    2120        /** 
  • trunk/views/snippet/view.php

    r15 r18  
    135135                        '<span class="line-number">$1</span>', 
    136136                        $comment->body)); ?></span> 
    137                 <span class="comment-collapsed"><?php echo substr($comment->body,0,50); ?>... 
     137                <span class="comment-collapsed" onclick="$(this).parent().toggleClass('collapsed');"><?php echo substr($comment->body,0,50); ?>... 
    138138                        <span class="comment-author"><?php echo $comment->user->name; ?></span> 
    139139                </span>