Changeset 138

Show
Ignore:
Timestamp:
08/05/09 19:46:04 (13 months ago)
Author:
seanja
Message:

Removed getMessages from classes/scontroller.class.php
Added echo errors to the header
Fixed up the users controller based on what the documentation says

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/application/controllers/users.php

    r115 r138  
    2020                } 
    2121        } 
    22  
     22         
    2323        function login() { 
    2424                if($_POST) { 
    25                         $validate['username'] = 'minLen:1'; 
    26                         $validate['password'] = 'minLen:1|callback_passwordCheck'; 
    27                         if($this->validate($validate)){ 
     25                        $validation['username'] = 'minLen:1'; 
     26                        $validation['password'] = 'minLen:1|callback_passwordCheck'; 
     27                        $fields['username'] = 'Username'; 
     28                        $fields['password'] = 'Password'; 
     29                        $this->setValidation($validation); 
     30                        $this->setValidationFields($fields); 
     31                        if($this->validate()) { 
     32                                echo 'validated'; 
    2833                                try { 
    2934                                        $this->user->login($this->post('username'), $this->post('password')); 
     
    3237                                        $this->data['error'] = $e->getMessage(); 
    3338                                } 
     39                        } else { 
     40                                $this->data['errors'] = $this->getValidationErrors(); 
    3441                        } 
    35  
    36                 } else { 
    37                         $this->data['errors'] = $this->getValidationErrors(); 
    3842                } 
    3943                $this->template->render('login', $this->data); 
     
    4852 
    4953        function edit($id='') { 
    50                 if(!$this->user->loggedIn()){ 
     54                if(!$this->user->loggedIn()) { 
    5155                        redirect('users/login'); 
    5256                } 
    53                 if($_POST){ 
    54                          
     57                if($_POST) { 
     58 
    5559                } 
    56                 if(!$id){ 
     60                if(!$id) { 
    5761                        $this->data['editUser'] = $this->user->getUserData(); 
    5862                } else { 
    59                         if($this->user->level == 'admin'){ 
     63                        if($this->user->level == 'admin') { 
    6064                                $tempUser = new sUser($id); 
    6165                                $this->data['editUser'] = $tempUser->getUserData(); 
     
    6468                        } 
    6569                } 
    66                 if($this->user->level == 'admin'){ 
     70                if($this->user->level == 'admin') { 
    6771                        $this->data['levels'] = $this->user->getUserLevels(); 
    6872                } 
    6973                $this->template->render('edit', $this->data); 
    7074        } 
    71         protected function passwordCheck($password){ 
    72                 if($password === 'password'){ 
    73                         return false; 
     75        protected function passwordCheck($password) { 
     76                $return['valid'] = true; 
     77                $return['error'] = ''; 
     78                if($password === 'password') { 
     79                        $return['valid'] = false; 
     80                        $return['error'] = ' is password'; 
    7481                } 
    75                 return true; 
     82                return $return; 
    7683        } 
    7784} 
  • trunk/application/views/header.php

    r125 r138  
    4343        <?php echo isset($message) ? '<p class="message">'.$message.'</p>' : ''; ?> 
    4444        <?php echo isset($error) ? '<p class="error">'.$error.'</p>' : ''; ?> 
     45        <?php  
     46        if(!empty($errors)){ 
     47                foreach($errors as $error){ 
     48                        echo '<p class="error">'.sEscape::html($error).'</p>'; 
     49                } 
     50        } 
     51 
     52        ?> 
  • trunk/library/classes/scontroller.class.php

    r131 r138  
    135135                return $this->validationErrors; 
    136136        } 
    137         public function getMessages($errors){ 
    138                 var_dump($errors); 
    139         } 
    140137}