-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
people.php
67 lines (57 loc) · 2.42 KB
/
people.php
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/* People
*
* Copyright 2018 Collaborative Approach Therapy Services
*
* Manage information about people (clients, staff, external professionals)
*/
class People
{
private $oApp;
private $oPeopleDB;
// Clients, Staff, Ext are stored in one array to make it easy to multiplex the code that manages them (just change the first index)
private $raPeople = array(); // array( 'C' => array( client_id1 => array('P_first_name'=>"", ...), client_id2 => array( ...
// 'S' => array( staff_id1 => array('P_first_name' ...
// 'E' => array( ext_id1 => array('P_first_name' ...
private $extra_fields = array( 'C' => array(),
'S' => array( 'credentials', 'regnumber' ),
'E' => array() );
function __construct( SEEDAppConsole $oApp )
{
$this->oApp = $oApp;
$this->oPeopleDB = new PeopleDB( $oApp );
}
function GetClient( $k ) { return( $this->getCSE( 'C', $k ) ); }
function GetStaff( $k ) { return( $this->getCSE( 'S', $k ) ); }
function GetExt( $k ) { return( $this->getCSE( 'E', $k ) ); }
private function getCSE( $c, $kCSE )
/***********************************
Look up the person and return their array of values. If not in the array, try to load them.
*/
{
if( !isset($this->raPeople[$c][$kCSE]) ) { $this->loadCSE( $c, $kCSE ); }
return( isset($this->raPeople[$c][$kCSE]) ? $this->raPeople[$c][$kCSE] : array() );
}
private function loadCSE( $c, $kCSE )
/************************************
Load the given person from the PeopleDB
*/
{
switch( $c ) {
case 'C': $kfr = $this->oPeopleDB->GetKFR("C", $kCSE); break;
case 'S': $kfr = $this->oPeopleDB->GetKFR("PI", $kCSE); break;
case 'E': $kfr = $this->oPeopleDB->GetKFR("PE", $kCSE); break;
default: return;
}
if( $kfr ) {
$this->raPeople[$c][$kCSE] = $kfr->ValuesRA();
// unpack the P_extra fields into the array
$raExtra = SEEDCore_ParmsURL2RA( $kfr->Value('P_extra') );
unset($this->raPeople[$c][$kCSE]['P_extra']);
foreach( $this->extra_fields[$c] as $k ) {
$this->raPeople[$c][$kCSE]["P_extra_$k"] = @$raExtra[$k];
}
}
}
}
?>