cmc-sales/php/app/models/user.php

73 lines
1.6 KiB
PHP
Raw Normal View History

<?php
class User extends AppModel {
2011-01-11 00:52:52 -08:00
var $name = 'User';
2010-05-03 22:52:33 -07:00
2011-01-11 00:52:52 -08:00
var $displayField = 'username';
2011-03-09 23:18:26 -08:00
var $validate = array(
'first_name' => array('notEmpty'),
'email' => array('notEmpty')
2011-03-09 23:18:26 -08:00
);
var $order = 'first_name ASC';
2011-01-11 00:52:52 -08:00
/* 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')
);
2011-01-11 00:52:52 -08:00
*/
//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' => ''
2011-03-09 23:18:26 -08:00
),
'Email' => array('className'=> 'Email',
'foreignKey'=> 'user_id',
2011-01-11 00:52:52 -08:00
)
);
var $belongsTo = array(
2011-03-09 23:18:26 -08:00
'Principle' => array('className'=>'Principle',
'foreignKey' =>'principle_id',
2011-01-11 00:52:52 -08:00
),
2011-03-09 23:18:26 -08:00
'Customer' => array('className'=>'Customer',
'foreignKey' =>'customer_id',
2011-01-11 00:52:52 -08:00
)
);
2011-03-09 23:18:26 -08:00
function getPrincipleContacts($principleID) {
return $this->find('all', array('conditions'=>array('User.principle_id'=>$principleID)));
}
function getUsersList() {
return $this->find('list', array('conditions'=>array('User.type'=>'user')));
}
}
?>