| Server IP : 180.180.241.3 / Your IP : 216.73.216.35 Web Server : Microsoft-IIS/7.5 System : Windows NT NETWORK-NHRC 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586 User : IUSR ( 0) PHP Version : 5.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /AppServ/www/app/Model/ |
Upload File : |
<?php
App::uses('AppModel', 'Model');
/**
* Organization Model
*
* @property Role $Role
* @property District $District
* @property Mou $Mou
* @property Organization $Organization
* @property Contact $Contact
* @property Organization $Organization
* @property Person $Person
* @property Action $Action
* @property Activity $Activity
* @property Offer $Offer
* @property Subtopic $Subtopic
* @property Target $Target
* @property Type $Type
*/
class Organization extends AppModel {
public $actsAs = array( 'Containable' );
/**
* Display field
*
* @var string
*/
public $displayField = 'name';
//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(
'Role' => array(
'className' => 'Role',
'foreignKey' => 'role_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'District' => array(
'className' => 'District',
'foreignKey' => 'district_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
/**
* hasMany associations
*
* @var array
*/
public $hasMany = array(
'Contact' => array(
'className' => 'Contact',
'foreignKey' => 'organization_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'OrgMembership' => array(
'className' => 'OrgMembership',
'foreignKey' => 'organization_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Person' => array(
'className' => 'Person',
'foreignKey' => 'organization_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Photo' => array(
'className' => 'Photo',
'foreignKey' => 'fk_id',
'conditions' => array( 'Photo.model' => 'organization' ),
'fields' => '',
'order' => ''
),
'OrganizationProvinceWide'=> array(
'className' => 'OrganizationProvinceWide',
'foreignKey' => 'organization_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
);
/**
* hasAndBelongsToMany associations
*
* @var array
*/
public $hasAndBelongsToMany = array(
'Action' => array(
'className' => 'Action',
'joinTable' => 'actions_organizations',
'foreignKey' => 'organization_id',
'associationForeignKey' => 'action_id',
'unique' => 'keepExisting',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
),
'DistrictM2M' => array(
'className' => 'District',
'joinTable' => 'districts_organizations',
'foreignKey' => 'organization_id',
'associationForeignKey' => 'district_id',
'unique' => 'keepExisting',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
),
'Activity' => array(
'className' => 'Activity',
'joinTable' => 'activities_organizations',
'foreignKey' => 'organization_id',
'associationForeignKey' => 'activity_id',
'unique' => 'keepExisting',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
),
'Offer' => array(
'className' => 'Offer',
'joinTable' => 'offers_organizations',
'foreignKey' => 'organization_id',
'associationForeignKey' => 'offer_id',
'unique' => 'keepExisting',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
),
'Subtopic' => array(
'className' => 'Subtopic',
'joinTable' => 'organizations_subtopics',
'foreignKey' => 'organization_id',
'associationForeignKey' => 'subtopic_id',
'unique' => 'keepExisting',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
),
'Target' => array(
'className' => 'Target',
'joinTable' => 'organizations_targets',
'foreignKey' => 'organization_id',
'associationForeignKey' => 'target_id',
'unique' => 'keepExisting',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
),
'Type' => array(
'className' => 'Type',
'joinTable' => 'organizations_types',
'foreignKey' => 'organization_id',
'associationForeignKey' => 'type_id',
'unique' => 'keepExisting',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
)
);
public $validate = array(
'external_type' => array(
'rule' => 'NameUnique',
'message' => "ข้อมูลเครือข่ายองค์กรซ้ำ"
)
);
public function NameUnique()
{
$existing = $this->find('first', array(
'conditions' => array(
'name' => $this->data[$this->name]['name'],
)
));
return (count($existing) == 0);
}
}