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