git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@23 97e9348a-65ac-dc4b-aefc-98561f571b83
89 lines
2.5 KiB
PHP
89 lines
2.5 KiB
PHP
<?php
|
|
class Contact extends AppModel {
|
|
|
|
var $name = 'Contact';
|
|
var $validate = array(
|
|
'id' => array('numeric'),
|
|
'display_name' => array('notempty'),
|
|
'id_federal' => array('ssn'),
|
|
'id_exp' => array('date')
|
|
);
|
|
|
|
var $hasAndBelongsToMany = array(
|
|
'Lease' => array(
|
|
'className' => 'Lease',
|
|
'joinTable' => 'contacts_leases',
|
|
'foreignKey' => 'contact_id',
|
|
'associationForeignKey' => 'lease_id',
|
|
'unique' => true,
|
|
'conditions' => '',
|
|
'fields' => '',
|
|
'order' => '',
|
|
'limit' => '',
|
|
'offset' => '',
|
|
'finderQuery' => '',
|
|
'deleteQuery' => '',
|
|
'insertQuery' => ''
|
|
),
|
|
'ContactAddress' => array(
|
|
'className' => 'ContactAddress',
|
|
'joinTable' => 'contacts_methods',
|
|
'foreignKey' => 'contact_id',
|
|
'associationForeignKey' => 'method_id',
|
|
'unique' => true,
|
|
'conditions' => "ContactsMethod.method = 'POST'",
|
|
'fields' => '',
|
|
'order' => '',
|
|
'limit' => '',
|
|
'offset' => '',
|
|
'finderQuery' => '',
|
|
'deleteQuery' => '',
|
|
'insertQuery' => ''
|
|
),
|
|
'ContactPhone' => array(
|
|
'className' => 'ContactPhone',
|
|
'joinTable' => 'contacts_methods',
|
|
'foreignKey' => 'contact_id',
|
|
'associationForeignKey' => 'method_id',
|
|
'unique' => true,
|
|
'conditions' => "ContactsMethod.method = 'PHONE'",
|
|
'fields' => '',
|
|
'order' => '',
|
|
'limit' => '',
|
|
'offset' => '',
|
|
'finderQuery' => '',
|
|
'deleteQuery' => '',
|
|
'insertQuery' => ''
|
|
),
|
|
'ContactEmail' => array(
|
|
'className' => 'ContactEmail',
|
|
'joinTable' => 'contacts_methods',
|
|
'foreignKey' => 'contact_id',
|
|
'associationForeignKey' => 'method_id',
|
|
'unique' => true,
|
|
'conditions' => "ContactsMethod.method = 'EMAIL'",
|
|
'fields' => '',
|
|
'order' => '',
|
|
'limit' => '',
|
|
'offset' => '',
|
|
'finderQuery' => '',
|
|
'deleteQuery' => '',
|
|
'insertQuery' => ''
|
|
),
|
|
);
|
|
|
|
// Overriding pagination, since the controller using HABTM joins that
|
|
// result in duplicate rows. This may not be the best way to handle
|
|
// things (especially if the query return a really large number of rows,
|
|
// but it does seem to work.
|
|
function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null) {
|
|
$conditions[] ="1=1 GROUP BY Contact.id";
|
|
return $this->findAll($conditions, $fields, $order, $limit, $page, $recursive);
|
|
}
|
|
function paginateCount($conditions = null, $recursive = 0) {
|
|
$rows = $this->paginate($conditions, null, null, null, null, $recursive);
|
|
return count($rows);
|
|
}
|
|
|
|
}
|
|
?>
|