1 | <?php |
||
26 | class SogDashboardApi |
||
27 | { |
||
28 | /** |
||
29 | * @var Application The Silex application for the API |
||
30 | */ |
||
31 | private $app; |
||
32 | /** |
||
33 | * @var string Full URL to the Dashboard application |
||
34 | */ |
||
35 | private $dashboard_url = 'https://dashboard.studieren-ohne-grenzen.org'; |
||
36 | /** |
||
37 | * @var int The default length for a random user password |
||
38 | */ |
||
39 | private $password_length = 8; |
||
40 | |||
41 | /** |
||
42 | * Instantiates a new LdapAdapter for creating and updating relevant entities. |
||
43 | * |
||
44 | * @param array $config The configuration as e.g. stored in the config.php file |
||
45 | */ |
||
46 | public function __construct(array $config) |
||
69 | |||
70 | |||
71 | /** |
||
72 | * Create a new user in the LDAP tree. Send notifications to the user and its group admin. |
||
73 | * The account will be inactive by default. Memberships for the general group and the given $group |
||
74 | * are also requested. |
||
75 | * |
||
76 | * @param string $firstName |
||
77 | * @param string $lastName |
||
78 | * @param string $email |
||
79 | * @param string $group |
||
80 | * @return string The new username. |
||
81 | */ |
||
82 | public function createUser($firstName, $lastName, $email, $group) |
||
99 | |||
100 | /** |
||
101 | * Generate a unique username by passing it to the LDAP adapter |
||
102 | * which executes additional transformations and checks. |
||
103 | * |
||
104 | * @param string $firstName |
||
105 | * @param string $lastName |
||
106 | * @return string The unique username |
||
107 | */ |
||
108 | private function generateUsername($firstName, $lastName) |
||
112 | |||
113 | /** |
||
114 | * Shells out to a bash script to generate a sieve script for initial email forwarding. |
||
115 | * This could be improved, for sure. Note that the apache user needs the NOPASSWD: tag in sudoers(5) |
||
116 | * |
||
117 | * @param string $from The mail address for the new member |
||
118 | * @param string $to The personal mail address to forward messages to |
||
119 | */ |
||
120 | private function createSieveForwarding($from, $to) |
||
126 | |||
127 | /** |
||
128 | * Request membership in the given group for a user. |
||
129 | * |
||
130 | * @param string $uid The generated unique username for the member |
||
131 | * @param string $group The CN of the group for which to request the membership |
||
132 | * @return boolean True, if there isn't already an active request from the user for the group; false otherwise |
||
133 | */ |
||
134 | public function requestGroupMembership($uid, $group) |
||
138 | |||
139 | /** |
||
140 | * Send a mail to the user. |
||
141 | * This is send only for OpenAtrium account details, a welcome mail is send through CiviCRM! |
||
142 | * |
||
143 | * @param string $firstName |
||
144 | * @param string $username |
||
145 | * @param string $email |
||
146 | * @param string $password |
||
147 | */ |
||
148 | private function notifyNewUser($firstName, $username, $email, $password) |
||
177 | |||
178 | /** |
||
179 | * Send email to group administrator to inform about new member |
||
180 | * |
||
181 | * @param string $firstName |
||
182 | * @param string $lastName |
||
183 | * @param string $email |
||
184 | * @param string $group |
||
185 | * @return int Number of accepted recipients |
||
186 | */ |
||
187 | private function notifyNewUserAdmin($firstName, $lastName, $email, $group) |
||
201 | |||
202 | /** |
||
203 | * Update the mail-alternative field for the given UID |
||
204 | * |
||
205 | * @param string $uid The user id for which to update |
||
206 | * @param string $email The new alternative mail address |
||
207 | */ |
||
208 | public function updateAlternativeMail($uid, $email) |
||
213 | } |
||
214 |