Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- App::uses('AppModel', 'Model');
- App::uses('AuthComponent', 'Controller/Component');
- /**
- * User Model
- *
- * @property Group $Group
- */
- class User extends AppModel {
- public $name = 'User';
- public $displayField = 'full_name';
- public function beforeSave() {
- if (isset($this->data[$this->alias]['password'])) {
- $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
- }
- return true;
- }
- /**
- * Validation rules
- *
- * @var array
- */
- public $validate = array(
- 'username' => array(
- 'notempty' => array(
- 'rule' => array('notempty'),
- 'message' => 'A username us required',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- 'password' => array(
- 'notempty' => array(
- 'rule' => array('notempty'),
- 'message' => 'A password is required',
- //'allowEmpty' => false,
- //'required' => false,
- //'last' => false, // Stop validation after this rule
- //'on' => 'create', // Limit validation to 'create' or 'update' operations
- ),
- ),
- 'role' => array(
- 'valid' => array(
- 'rule' => array('inList', array('admin', 'editor')),
- 'message' => 'Please enter a valid role',
- 'allowEmpty' => false
- )
- ),
- );
- //The Associations below have been created with all possible keys, those that are not needed can be removed
- /**
- * belongsTo associations
- *
- * @var array
- */
- public $belongsTo = array(
- 'Group' => array(
- 'className' => 'Group',
- 'foreignKey' => 'group_id',
- 'conditions' => '',
- 'fields' => '',
- 'order' => ''
- )
- );
- }
Add Comment
Please, Sign In to add comment