1 |
mlimic |
515 |
<?php |
2 |
|
|
|
3 |
mlimic |
522 |
/* |
4 |
|
|
* Processes requests received via net which are meant to initiate a |
5 |
|
|
* synchronization. |
6 |
|
|
* |
7 |
|
|
* @author Mirna Limic <[email protected]> |
8 |
|
|
* Date: 18/10/2012 |
9 |
|
|
* |
10 |
|
|
* Follow-up: |
11 |
|
|
* Bugs: |
12 |
|
|
*/ |
13 |
|
|
|
14 |
mlimic |
515 |
require_once ("./metier/metiermanager.php"); |
15 |
|
|
|
16 |
|
|
class MaintenanceManager extends MetierManager { |
17 |
|
|
|
18 |
mlimic |
522 |
/* |
19 |
|
|
* @var mixed Array containing function pointers (i.e. function names) |
20 |
|
|
* that are (dereferenced and) called to perform the synchronization tasks. |
21 |
|
|
*/ |
22 |
mlimic |
515 |
var $fptrs = array('user' => 'synchronizeUsers'); // 'UserManager' |
23 |
|
|
|
24 |
mlimic |
522 |
|
25 |
|
|
/* |
26 |
|
|
* Constructor. |
27 |
|
|
* |
28 |
|
|
* Calls its parent's constructor. |
29 |
|
|
*/ |
30 |
mlimic |
515 |
function __construct() { |
31 |
|
|
parent::__construct(); |
32 |
|
|
} |
33 |
mlimic |
522 |
|
34 |
mlimic |
515 |
|
35 |
mlimic |
522 |
/* |
36 |
|
|
* Destructor. |
37 |
|
|
* |
38 |
|
|
* Calls its parent's destructor. |
39 |
|
|
*/ |
40 |
mlimic |
515 |
function __destruct() { |
41 |
|
|
parent::__destruct(); |
42 |
|
|
} |
43 |
|
|
|
44 |
mlimic |
522 |
|
45 |
|
|
/* |
46 |
|
|
* Starts a synchronization process by calling |
47 |
|
|
* one of the functions in the fptrs array. |
48 |
|
|
* |
49 |
|
|
* @param string $module The key to be used in order to retreive the name |
50 |
|
|
* of the function that should be called. |
51 |
|
|
* @param mixed $data The data that was received as a part of the request. |
52 |
|
|
* @return string The result of processing. |
53 |
|
|
*/ |
54 |
mlimic |
515 |
function performMaintenance($module, $data) { |
55 |
|
|
|
56 |
|
|
// check that the known module is called |
57 |
|
|
if (!in_array($module, array_keys($this->fptrs))) { |
58 |
|
|
return 'Unknown module in request.'; |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
$ret = call_user_func(array($this, $this->fptrs[$module]), $data); |
62 |
|
|
return $ret; |
63 |
|
|
} |
64 |
|
|
|
65 |
mlimic |
522 |
|
66 |
|
|
/* |
67 |
|
|
* Synchronizes the users data in a DB with the user's data from the |
68 |
|
|
* directory services that communicate via LDAP. |
69 |
|
|
* |
70 |
|
|
* @param mixed $data The data that was received as a part of the request. |
71 |
|
|
* @return string The result of processing. |
72 |
|
|
*/ |
73 |
mlimic |
515 |
function synchronizeUsers($data) { |
74 |
|
|
// depending on what is in the data do the treatement |
75 |
|
|
// currently only user synchronization with ldap is supported |
76 |
|
|
$keys = array_keys($data); |
77 |
|
|
if (in_array('userToAdd', $keys) |
78 |
|
|
|| in_array('userToDelete', $keys) |
79 |
|
|
|| in_array('userToUpdate', $keys)) { |
80 |
|
|
//$this->f->synchronizeUsers($data); |
81 |
|
|
} |
82 |
|
|
return $this->OK; |
83 |
|
|
} |
84 |
|
|
} |
85 |
|
|
|
86 |
|
|
?> |