Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 253 lines (218 sloc) 8.923 kb
74db667 @denis-larka init
denis-larka authored
1 <?php
2 /**
3 * DataObject For Person Entity of OpenEvSys.
4 *
5 * This file is part of OpenEvsys.
6 *
7 * Copyright (C) 2009 Human Rights Information and Documentation Systems,
8 * HURIDOCS), http://www.huridocs.org/, info@huridocs.org
9 *
10 * OpenEvsys is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * OpenEvsys is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
19 *
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23
24 * @author Nilushan Silva <nilushan@respere.com>
25 *
26 * @package OpenEvsys
27 * @subpackage DataModel
28 *
29 */
30
31 //require_once ( APPROOT . 'data/DataObject.php' );
32
33 class Person extends DomainEntity{
34 /*
35 public $person_record_number;
36 public $counting_unit;
37 public $person_name;
38 public $other_names;
39 public $confidentiality;
40 public $date_of_birth;
41 public $place_of_birth;
42 public $locality_of_birth;
43 public $date_deceased;
44 public $sex;
45 public $sexual_orientation;
46 public $identification_documents;
47 public $civil_status;
48 public $dependants;
49 public $formal_education;
50 public $other_training;
51 public $health;
52 public $medical_records;
53 public $group_description;
54 public $number_of_persons_in_group;
55 public $religion;
56 public $remarks;
57 public $reliability_as_source;
58 public $reliability_as_intervening_party;
59 public $deceased;
60 public $date_of_birth_type;
61 public $date_deceased_type;
62
63 public $occupation;
64 public $local_term_for_occupation;
65 public $physical_description;
66 public $citizenship;
67 public $ethnic_background;
68 public $other_background;
69 public $general_characteristics;
70 public $language ;
71 public $local_language;
72 public $national_origin;
73
74
75 //Management Data
76 public $date_received;
77 public $date_of_entry;
78 public $entered_by ;
79 public $project_title;
80 public $comments ;
81 public $record_grouping;
82 public $date_updated ;
83 public $updated_by ;
84 public $monitoring_status;
85 */
86 public $Management;
87 public $picture;
88
89 public $person_addresses = array();
90
91 protected $managementFields = array( 'date_received', 'date_of_entry',
92 'entered_by' , 'project_title', 'comments', 'record_grouping',
93 'date_updated' , 'updated_by' , 'monitoring_status');
94
95
96 protected $mt = array('occupation' , 'local_term_for_occupation' ,
97 'physical_description','citizenship','ethnic_background' , 'other_background' , 'general_characteristics',
98 'language' , 'local_language','national_origin'
99 );
100
101 protected $supporting_doc = true;
102 protected $isAddress = true;
103 protected $picture_doc = true;
104
105 private $pkey = array('person_record_number');
106
107 public function __construct($table = false, $pkeyarr=false, $db=false, $options=array()){
108 parent::__construct('person', $pkey ,$db , $options);
109 $table = 'person';
110 }
111
112 public function LoadPicture(){
113 if($this->picture_doc == true){
114 $pictureDoc = new SupportingDocEntity(SupportingDocEntity::generateTableName('picture') );
115 $picture_data = $pictureDoc->getDocsforEntity($this->person_record_number);
116 $this->picture = $picture_data[0]->doc_id;
117 }
118 }
119
120 public function LoadAddresses(){
121 if($this->isAddress == true){
122 $address = new Address();
123 $addressEntityObjects = $address->getAddressforEntity($this->person_record_number);
124 foreach($addressEntityObjects as $add){
125 $this->person_addresses[] = $add->address_record_number;
126 }
127 }
128 }
129
130 private function DeleteAddresses(){
131 $address = new Address();
132 $addressEntityObjects = $address->getAddressforEntity($this->person_record_number);
133
134 foreach($addressEntityObjects as $add){
135 $add->Delete('person' , $this->person_record_number);
136 }
137 }
138
139 public function SaveAddresses($addresses){
140 if($this->isAddress == true){
141 $this->DeleteAddresses();
142 if( is_array($addresses)){
143 foreach($addresses as $key=>$add){
144 $address = new Address();
145 $address->person = $this->person_record_number;
146 $address->address_record_number = shn_create_uuid('address');;
147 $address->address_type = $addresses[$key]['address_type'];
148 $address->address = $addresses[$key]['address'];
149 $address->country = $addresses[$key]['country'];
150 $address->phone = $addresses[$key]['phone'];
151 $address->cellular = $addresses[$key]['cellular'];
152 $address->fax = $addresses[$key]['fax'];
153 $address->email = $addresses[$key]['email'];
154 $address->web = $addresses[$key]['web'];
155 $address->start_date = $addresses[$key]['start_date'];
156 $address->end_date = $addresses[$key]['end_date'];
157 $address->Save();
158 }
159 }
160 }
161 }
162
163 public function SavePicture(){
164 if($this->picture_doc == true){
165 $type = null;
166 $uri = shn_files_store('picture',null,&$type);
167
168 if($uri == null){
169 $uri = '';
170 }
171
172 $document_form = document_form('new');
173
174 $supporting_docs = new SupportingDocs();
175 $supporting_docs_meta = new SupportingDocsMeta();
176
177 $pictureDoc = new SupportingDocEntity(SupportingDocEntity::generateTableName('picture') );
178 $pictureDoc->record_number = $this->person_record_number;
179
180 if($_POST['picture_id'] != null){
181 $picture_id = $_POST['picture_id'];
182 if($uri != ''){
183 $supporting_docs->doc_id = $picture_id;
184 $supporting_docs->uri = $uri;
185 form_objects($document_form, $supporting_docs);
186 $supporting_docs->Delete();
187 $supporting_docs->Save();
188
189 form_objects($document_form, $supporting_docs_meta);
190 $supporting_docs_meta->title = "Picture";
191 $supporting_docs_meta->doc_id = $picture_id;
192 $supporting_docs_meta->format = $type;
193 $supporting_docs_meta->Save();
194
195 $pictureDoc->doc_id = $picture_id;
196 $pictureDoc->linked_by = $_SESSION['username'];
197 $pictureDoc->Save();
198 }
199 }
200 else{
201 $picture_id = shn_create_uuid('picture');
202
203 $supporting_docs->doc_id = $picture_id;
204 $supporting_docs->uri = $uri;
205 form_objects($document_form, $supporting_docs);
206 $supporting_docs->Save();
207
208 form_objects($document_form, $supporting_docs_meta);
209 $supporting_docs_meta->title = "Picture";
210 $supporting_docs_meta->doc_id = $picture_id;
211 $supporting_docs_meta->format = $type;
212 $supporting_docs_meta->Save();
213
214 $pictureDoc->doc_id = $picture_id;
215 $pictureDoc->linked_by = $_SESSION['username'];
216 $pictureDoc->Save();
217 }
218 }
219 }
220
221 public function SaveAll(){
222 global $global;
223 $saveType = $this->getSaveType();
224
225 //var_dump('saving event type' , $saveType);
226 if($saveType == 'create'){
227 acl_add_person($this->person_record_number);
228 //if event is marked as confidential limit it to this user and admin.
229 if($this->confidentiality == 'y')
230 acl_set_person_permissions($this->person_record_number);
231 }
232
233 if($saveType == 'update'){
234 //if event is marked as confidential limit it to this user and admin.
235 if($this->confidentiality == 'y')
236 acl_set_person_permissions($this->person_record_number);
237 if($this->confidentiality == 'n'){
238 acl_unset_person_permissions($this->person_record_number);
239 }
240 }
241 parent::SaveAll();
242 }
243
244 public function DeleteFromRecordNumber($recordNumber){
245 $return = parent::DeleteFromRecordNumber($recordNumber);
246
247 if($return){
248 //remove gacl objects for this perticuler event
249 acl_delete_person($recordNumber);
250 }
251 }
252 }
Something went wrong with that request. Please try again.