cmc-sales/models/user.php
2010-05-04 15:52:33 +10:00

61 lines
1.2 KiB
PHP
Executable file

<?php
class User extends AppModel {
var $name = 'User';
var $belongsTo = array('Group');
var $displayField = 'username';
/* TO DO: Fix up this validation stuff
var $validate = array(
'username' => array(
'rule' => 'unique',
'required' => true,
'message' => 'Username must be unique'
),
// 'password' => array('maxlength'),
'email' => array('email'),
// 'job_title' => array('custom')
);
*/
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $hasMany = array(
'Enquiry' => array('className' => 'Enquiry',
'foreignKey' => 'user_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
)
);
var $actsAs = array('Acl' => array('requester'));
function parentNode() {
if (!$this->id && empty($this->data)) {
return null;
}
$data = $this->data;
if (empty($this->data)) {
$data = $this->read();
}
if (!$data['User']['group_id']) {
return null;
}
else {
return array('Group' => array('id' => $data['User']['group_id']));
}
}
}
?>