Changeset 480
- Timestamp:
- 05/13/08 00:50:52 (7 months ago)
- Location:
- trunk/app
- Files:
-
- 3 added
- 3 modified
-
controllers/messages_controller.php (modified) (3 diffs)
-
controllers/users_controller.php (modified) (3 diffs)
-
models/user.php (modified) (2 diffs)
-
views/messages/admin_general.ctp (added)
-
views/messages/listing.ctp (added)
-
views/users/edit.ctp (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/messages_controller.php
r477 r480 14 14 public $components = array('Portal', 'Security', 'Email', 'Session', 'Edublog'); 15 15 16 public function beforeFilter()17 { 18 $this->Auth->allow(array('message', 'deliver' ));16 public function beforeFilter() 17 { 18 $this->Auth->allow(array('message', 'deliver', 'listing', 'compose')); 19 19 parent::beforeFilter(); 20 20 } … … 100 100 } 101 101 102 public function listing() 103 { 104 if ( !$this->Auth->user() ): 105 $this->redirect('/users/login'); 106 return false; 107 endif; 108 109 $this->layout = 'portal'; 110 111 $this->pageTitle = 'Messages'; 112 113 $conditions = array("Message.user_id" => $this->Auth->user('id')); 114 fields = array("Message.id", "Message.title", "Message.body", "Message.created", "Message.sender", "Message.status", "User.username"); 115 $order = "Message.id DESC"; 116 $limit = 20; 117 118 $this->set('data', $this->Message->findAll($conditions, $fields, $order, $limit)); 119 120 $this->Portal->statics(); // Charge Portal components aka Sidebars 121 } 122 123 102 124 /* == PRIVATE == **/ 103 125 private function __sendMail($email) … … 113 135 $this->Email->sendAs = 'text'; // because we like to send pretty mail 114 136 //Do not pass any args to send() 115 if ( $this->Email->send() ) 116 { 137 if ( $this->Email->send() ): 117 138 return true; 118 } 119 else 120 { 121 return false; 122 } 139 else: 140 return false; 141 endif; 123 142 } 124 143 -
trunk/app/controllers/users_controller.php
r479 r480 19 19 public function beforeFilter() 20 20 { 21 if ( !empty($this->data['User'] ) ): 22 if ( strlen($this->data['User']['pwd']) < 6): 23 unset($this->data['User']['pwd']); 24 endif; 25 endif; 26 21 27 $this->Auth->allow(array('blog', 'entry','portfolio', 'edit', 'about', 'register', 'directory', 'bloggers', 'insert', 'validate', 'logout')); 22 parent::beforeFilter(); 23 24 if ( !empty($this->data['User']['pwd']) ) 25 { 26 if ( strlen($this->data['User']['pwd']) < 5) // only if pwd is big enough 27 { 28 unset($this->data['User']['pwd']); 29 } 30 } 28 29 parent::beforeFilter(); 31 30 } 32 31 33 32 public function isAuthorized() 34 33 { 35 if (isset( $this->params[Configure::read('Routing.admin')] )) 36 { 37 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ) // admin and teachers 38 { 39 return true; 40 } 41 } 34 if (isset( $this->params[Configure::read('Routing.admin')] )): 35 36 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ): // admin and teachers 37 return true; 38 endif; 39 40 endif; 41 42 42 return false; // go away !! 43 43 } … … 409 409 endif; 410 410 411 $this->User->escapeField('pwd'); 412 411 413 if ( empty($this->data['User']) ): 412 414 … … 415 417 $this->Portal->statics(); // Using Portal components 416 418 417 $this->User->unbindModel($this->User->notNow); 418 419 $this->User->unbindModel($this->User->notNow); 420 419 421 $this->data = $this->User->read(null, $this->Auth->user('id')); 420 422 -
trunk/app/models/user.php
r471 r480 54 54 55 55 public $validate = array( 56 'login' => VALID_NOT_EMPTY, 57 'pwd' => VALID_NOT_EMPTY, 58 'username' => VALID_NOT_EMPTY, 59 'name' => VALID_NOT_EMPTY, 60 'email' => VALID_EMAIL 61 ); 62 56 'login' => VALID_NOT_EMPTY, 57 'pwd' => VALID_NOT_EMPTY, 58 'username' => VALID_NOT_EMPTY, 59 'name' => VALID_NOT_EMPTY, 60 'email' => VALID_EMAIL 61 ); 62 /* 63 I will work on this later 64 public $validate = array( 65 'username' => array('rule' => 'alphanumeric', 66 'required' => true, 67 'message' => 'Please enter a username'), 68 'pwd' => array('rule' => array('confirmPassword', 'password'), 69 'message' => 'Passwords do not match'), 70 'pwd_confirm' => array('rule' => 'alphanumeric', 71 'required' => true) 72 ); 73 */ 74 75 public function confirmPassword($data) 76 { 77 $valid = false; 78 79 if ($data['password'] == Security::hash(Configure::read('Security.salt') . $this->data['User']['password_confirm'])) 80 { 81 $valid = true; 82 } 83 84 return $valid; 85 } 86 63 87 /* 64 88 * excepts : model you need … … 79 103 return true; 80 104 } 105 106 /* 107 * Remove pwd if too short 108 * 109 */ 110 public function beforeValidate() 111 { 112 113 if ( !empty($this->data['User']['pwd']) ): 114 die( debug($this->data['User']['pwd'])); 115 if ( strlen($this->data['User']['pwd']) < 6): // only if pwd is big enough 116 unset($this->data['User']['pwd']); 117 endif; 118 119 endif; 120 121 122 return true; 123 } 81 124 } 82 125 ?>
