fix #8131 - chinese translations
[Pman.Core] / DataObjects / Core_person_settings.php
1 <?php
2 /**
3  * Table Definition for Core_person_settings
4  */
5 class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
6
7 class Pman_Core_DataObjects_Core_person_settings extends DB_DataObject 
8 {
9     ###START_AUTOCODE
10     /* the code below is auto generated do not remove the above tag */
11
12     public $__table = 'core_person_settings';
13     public $id;
14     public $person_id;
15     public $scope;
16     public $data;
17     
18     /* the code above is auto generated do not remove the tag below */
19     ###END_AUTOCODE
20     
21     function beforeInsert($q, $roo)
22     {
23         if(!$this->hasPermission($roo)) {
24             $roo->jerr('Access Dennied');
25         }
26         
27         $o = $this->isExist();
28         
29         if(!empty($o)) {
30             $oo = clone ($o);
31             $o->setFrom(array(
32                 'data' => $this->data
33             ));
34             $o->update($oo);
35             $roo->jok('OK');
36         }
37         
38     }
39     
40     function beforeUpdate($old, $q, $roo)
41     {
42         if(!$this->hasPermission($roo)) {
43             $roo->jerr('Access Dennied');
44         }
45     }
46     
47     function beforeDelete($dependants_array, $roo)
48     {
49         if(!$this->hasPermission($roo)) {
50             $roo->jerr('Access Dennied');
51         }
52     }
53     
54     function hasPermission($roo)
55     {
56         if(
57                 !$roo->authUser ||
58                 (!empty($this->person_id) && $this->person_id != $roo->authUser->id)
59         ) {
60             return false;
61         }
62         
63         return true;
64     }
65     
66     function isExist()
67     {
68         $core_person_settings = DB_DataObject::factory('core_person_settings');
69         $core_person_settings->setFrom(array(
70             'scope' => $this->scope,
71             'person_id' => $this->person_id
72         ));
73         
74         if($core_person_settings->find(true)) {
75             return $core_person_settings;
76         }
77         
78         return false;
79     }
80     
81  }