[go: up one dir, main page]

Menu

[r5]: / models / group.php  Maximize  Restore  History

Download this file

44 lines (35 with data), 791 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
* @package Main
*/
/**
* @package CoCoMa
*/
class Group extends AppModel {
var $name = 'Group';
var $primaryKey = 'id';
var $actsAs = array('Acl' => array('Aro'));
var $belongsTo = array(
'ParentGroup' => array(
'className' => 'Group',
'foreignKey' => 'parent_id'
)
);
function beforeSave()
{
if(empty($this->data["Group"]["parent_id"])) $this->data["Group"]["parent_id"] = NULL;
return true;
}
function parentNode(){
if (!$this->id) {
return null;
}
$data = $this->read();
if (!$data['Group']['parent_id']){
return null;
} else {
return array('model' => 'Group', 'foreign_key' => $data['Group']['parent_id']);
}
}
}
?>