@@ -755,11 +755,11 @@ discard block |
||
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
758 | - * Returns objectClass in an array |
|
759 | - * |
|
760 | - * @param string $distinguishedName The full DN of a contact |
|
761 | - * @return array |
|
762 | - */ |
|
758 | + * Returns objectClass in an array |
|
759 | + * |
|
760 | + * @param string $distinguishedName The full DN of a contact |
|
761 | + * @return array |
|
762 | + */ |
|
763 | 763 | public function getObjectClass($distinguishedName) { |
764 | 764 | if ($distinguishedName === NULL) { return false; } |
765 | 765 | if (!$this->getLdapBind()) { return false; } |
@@ -778,21 +778,21 @@ discard block |
||
778 | 778 | } |
779 | 779 | |
780 | 780 | /** |
781 | - * Find the Base DN of your domain controller |
|
782 | - * |
|
783 | - * @return string |
|
784 | - */ |
|
781 | + * Find the Base DN of your domain controller |
|
782 | + * |
|
783 | + * @return string |
|
784 | + */ |
|
785 | 785 | public function findBaseDn() { |
786 | 786 | $namingContext = $this->getRootDse(array('defaultnamingcontext')); |
787 | 787 | return $namingContext[0]['defaultnamingcontext'][0]; |
788 | 788 | } |
789 | 789 | |
790 | 790 | /** |
791 | - * Get the RootDSE properties from a domain controller |
|
792 | - * |
|
793 | - * @param string[] $attributes The attributes you wish to query e.g. defaultnamingcontext |
|
794 | - * @return array |
|
795 | - */ |
|
791 | + * Get the RootDSE properties from a domain controller |
|
792 | + * |
|
793 | + * @param string[] $attributes The attributes you wish to query e.g. defaultnamingcontext |
|
794 | + * @return array |
|
795 | + */ |
|
796 | 796 | public function getRootDse($attributes = array("*", "+")) { |
797 | 797 | if (!$this->ldapBind) { return (false); } |
798 | 798 |
@@ -54,25 +54,25 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | - * Validate a user's login credentials |
|
58 | - * |
|
59 | - * @param string $username A user's AD username |
|
60 | - * @param string $password A user's AD password |
|
61 | - * @param bool optional $prevent_rebind |
|
62 | - * @return bool |
|
63 | - */ |
|
57 | + * Validate a user's login credentials |
|
58 | + * |
|
59 | + * @param string $username A user's AD username |
|
60 | + * @param string $password A user's AD password |
|
61 | + * @param bool optional $prevent_rebind |
|
62 | + * @return bool |
|
63 | + */ |
|
64 | 64 | public function authenticate($username, $password, $preventRebind = false) { |
65 | 65 | return $this->adldap->authenticate($username, $password, $preventRebind); |
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | - * Create a user |
|
70 | - * |
|
71 | - * If you specify a password here, this can only be performed over SSL |
|
72 | - * |
|
73 | - * @param array $attributes The attributes to set to the user account |
|
74 | - * @return string|boolean |
|
75 | - */ |
|
69 | + * Create a user |
|
70 | + * |
|
71 | + * If you specify a password here, this can only be performed over SSL |
|
72 | + * |
|
73 | + * @param array $attributes The attributes to set to the user account |
|
74 | + * @return string|boolean |
|
75 | + */ |
|
76 | 76 | public function create($attributes) { |
77 | 77 | // Check for compulsory fields |
78 | 78 | if (!array_key_exists("username", $attributes)) { return "Missing compulsory field [username]"; } |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
125 | - * Account control options |
|
126 | - * |
|
127 | - * @param string[] $options The options to convert to int |
|
128 | - * @return int |
|
129 | - */ |
|
125 | + * Account control options |
|
126 | + * |
|
127 | + * @param string[] $options The options to convert to int |
|
128 | + * @return int |
|
129 | + */ |
|
130 | 130 | protected function accountControl($options) { |
131 | 131 | $val = 0; |
132 | 132 | |
@@ -158,12 +158,12 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
161 | - * Delete a user account |
|
162 | - * |
|
163 | - * @param string $username The username to delete (please be careful here!) |
|
164 | - * @param bool $isGUID Is the username a GUID or a samAccountName |
|
165 | - * @return boolean |
|
166 | - */ |
|
161 | + * Delete a user account |
|
162 | + * |
|
163 | + * @param string $username The username to delete (please be careful here!) |
|
164 | + * @param bool $isGUID Is the username a GUID or a samAccountName |
|
165 | + * @return boolean |
|
166 | + */ |
|
167 | 167 | public function delete($username, $isGUID = false) { |
168 | 168 | $userinfo = $this->info($username, array("*"), $isGUID); |
169 | 169 | $dn = $userinfo[0]['distinguishedname'][0]; |
@@ -370,13 +370,13 @@ discard block |
||
370 | 370 | } |
371 | 371 | |
372 | 372 | /** |
373 | - * Modify a user |
|
374 | - * |
|
375 | - * @param string $username The username to query |
|
376 | - * @param array $attributes The attributes to modify. Note if you set the enabled attribute you must not specify any other attributes |
|
377 | - * @param bool $isGUID Is the username passed a GUID or a samAccountName |
|
378 | - * @return string|boolean |
|
379 | - */ |
|
373 | + * Modify a user |
|
374 | + * |
|
375 | + * @param string $username The username to query |
|
376 | + * @param array $attributes The attributes to modify. Note if you set the enabled attribute you must not specify any other attributes |
|
377 | + * @param bool $isGUID Is the username passed a GUID or a samAccountName |
|
378 | + * @return string|boolean |
|
379 | + */ |
|
380 | 380 | public function modify($username, $attributes, $isGUID = false) { |
381 | 381 | if ($username === NULL) { return "Missing compulsory field [username]"; } |
382 | 382 | if (array_key_exists("password", $attributes) && !$this->adldap->getUseSSL() && !$this->adldap->getUseTLS()) { |
@@ -416,12 +416,12 @@ discard block |
||
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
419 | - * Disable a user account |
|
420 | - * |
|
421 | - * @param string $username The username to disable |
|
422 | - * @param bool $isGUID Is the username passed a GUID or a samAccountName |
|
423 | - * @return string|boolean |
|
424 | - */ |
|
419 | + * Disable a user account |
|
420 | + * |
|
421 | + * @param string $username The username to disable |
|
422 | + * @param bool $isGUID Is the username passed a GUID or a samAccountName |
|
423 | + * @return string|boolean |
|
424 | + */ |
|
425 | 425 | public function disable($username, $isGUID = false) { |
426 | 426 | if ($username === NULL) { return "Missing compulsory field [username]"; } |
427 | 427 | $attributes = array("enabled" => 0); |
@@ -432,12 +432,12 @@ discard block |
||
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
435 | - * Enable a user account |
|
436 | - * |
|
437 | - * @param string $username The username to enable |
|
438 | - * @param bool $isGUID Is the username passed a GUID or a samAccountName |
|
439 | - * @return string|boolean |
|
440 | - */ |
|
435 | + * Enable a user account |
|
436 | + * |
|
437 | + * @param string $username The username to enable |
|
438 | + * @param bool $isGUID Is the username passed a GUID or a samAccountName |
|
439 | + * @return string|boolean |
|
440 | + */ |
|
441 | 441 | public function enable($username, $isGUID = false) { |
442 | 442 | if ($username === NULL) { return "Missing compulsory field [username]"; } |
443 | 443 | $attributes = array("enabled" => 1); |
@@ -605,19 +605,19 @@ discard block |
||
605 | 605 | } |
606 | 606 | } |
607 | 607 | if ($sorted) { |
608 | - asort($usersArray); |
|
608 | + asort($usersArray); |
|
609 | 609 | } |
610 | 610 | return ($usersArray); |
611 | 611 | } |
612 | 612 | |
613 | 613 | /** |
614 | - * Move a user account to a different OU |
|
615 | - * |
|
616 | - * @param string $username The username to move (please be careful here!) |
|
617 | - * @param array $container The container or containers to move the user to (please be careful here!). |
|
618 | - * accepts containers in 1. parent 2. child order |
|
619 | - * @return string|boolean |
|
620 | - */ |
|
614 | + * Move a user account to a different OU |
|
615 | + * |
|
616 | + * @param string $username The username to move (please be careful here!) |
|
617 | + * @param array $container The container or containers to move the user to (please be careful here!). |
|
618 | + * accepts containers in 1. parent 2. child order |
|
619 | + * @return string|boolean |
|
620 | + */ |
|
621 | 621 | public function move($username, $container) { |
622 | 622 | if (!$this->adldap->getLdapBind()) { return false; } |
623 | 623 | if ($username === null) { return "Missing compulsory field [username]"; } |
@@ -151,11 +151,11 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | - * Create a group |
|
155 | - * |
|
156 | - * @param array $attributes Default attributes of the group |
|
157 | - * @return string|boolean |
|
158 | - */ |
|
154 | + * Create a group |
|
155 | + * |
|
156 | + * @param array $attributes Default attributes of the group |
|
157 | + * @return string|boolean |
|
158 | + */ |
|
159 | 159 | public function create($attributes) { |
160 | 160 | if (!is_array($attributes)) { return "Attributes must be an array"; } |
161 | 161 | if (!array_key_exists("group_name", $attributes)) { return "Missing compulsory field [group_name]"; } |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
187 | - * Delete a group account |
|
188 | - * |
|
189 | - * @param string $group The group to delete (please be careful here!) |
|
190 | - * |
|
191 | - * @return string|boolean |
|
192 | - */ |
|
187 | + * Delete a group account |
|
188 | + * |
|
189 | + * @param string $group The group to delete (please be careful here!) |
|
190 | + * |
|
191 | + * @return string|boolean |
|
192 | + */ |
|
193 | 193 | public function delete($group) { |
194 | 194 | if (!$this->adldap->getLdapBind()) { return false; } |
195 | 195 | if ($group === null) { return "Missing compulsory field [group]"; } |
@@ -53,18 +53,18 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | - * Create an Exchange account |
|
57 | - * |
|
58 | - * @param string $username The username of the user to add the Exchange account to |
|
59 | - * @param array $storageGroup The mailbox, Exchange Storage Group, for the user account, this must be a full CN |
|
60 | - * If the storage group has a different base_dn to the adLDAP configuration, set it using $base_dn |
|
61 | - * @param string $emailAddress The primary email address to add to this user |
|
62 | - * @param string $mailNickname The mail nick name. If mail nickname is blank, the username will be used |
|
63 | - * @param bool $useDefaults Indicates whether the store should use the default quota, rather than the per-mailbox quota. |
|
64 | - * @param string $baseDn Specify an alternative base_dn for the Exchange storage group |
|
65 | - * @param bool $isGUID Is the username passed a GUID or a samAccountName |
|
66 | - * @return string|boolean |
|
67 | - */ |
|
56 | + * Create an Exchange account |
|
57 | + * |
|
58 | + * @param string $username The username of the user to add the Exchange account to |
|
59 | + * @param array $storageGroup The mailbox, Exchange Storage Group, for the user account, this must be a full CN |
|
60 | + * If the storage group has a different base_dn to the adLDAP configuration, set it using $base_dn |
|
61 | + * @param string $emailAddress The primary email address to add to this user |
|
62 | + * @param string $mailNickname The mail nick name. If mail nickname is blank, the username will be used |
|
63 | + * @param bool $useDefaults Indicates whether the store should use the default quota, rather than the per-mailbox quota. |
|
64 | + * @param string $baseDn Specify an alternative base_dn for the Exchange storage group |
|
65 | + * @param bool $isGUID Is the username passed a GUID or a samAccountName |
|
66 | + * @return string|boolean |
|
67 | + */ |
|
68 | 68 | public function createMailbox($username, $storageGroup, $emailAddress, $mailNickname = NULL, $useDefaults = TRUE, $baseDn = NULL, $isGUID = false) { |
69 | 69 | if ($username === NULL) { return "Missing compulsory field [username]"; } |
70 | 70 | if ($storageGroup === NULL) { return "Missing compulsory array [storagegroup]"; } |
@@ -96,20 +96,20 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | - * Add an X400 address to Exchange |
|
100 | - * See http://tools.ietf.org/html/rfc1685 for more information. |
|
101 | - * An X400 Address looks similar to this X400:c=US;a= ;p=Domain;o=Organization;s=Doe;g=John; |
|
102 | - * |
|
103 | - * @param string $username The username of the user to add the X400 to to |
|
104 | - * @param string $country Country |
|
105 | - * @param string $admd Administration Management Domain |
|
106 | - * @param string $pdmd Private Management Domain (often your AD domain) |
|
107 | - * @param string $org Organization |
|
108 | - * @param string $surname Surname |
|
109 | - * @param string $givenName Given name |
|
110 | - * @param bool $isGUID Is the username passed a GUID or a samAccountName |
|
111 | - * @return string|boolean |
|
112 | - */ |
|
99 | + * Add an X400 address to Exchange |
|
100 | + * See http://tools.ietf.org/html/rfc1685 for more information. |
|
101 | + * An X400 Address looks similar to this X400:c=US;a= ;p=Domain;o=Organization;s=Doe;g=John; |
|
102 | + * |
|
103 | + * @param string $username The username of the user to add the X400 to to |
|
104 | + * @param string $country Country |
|
105 | + * @param string $admd Administration Management Domain |
|
106 | + * @param string $pdmd Private Management Domain (often your AD domain) |
|
107 | + * @param string $org Organization |
|
108 | + * @param string $surname Surname |
|
109 | + * @param string $givenName Given name |
|
110 | + * @param bool $isGUID Is the username passed a GUID or a samAccountName |
|
111 | + * @return string|boolean |
|
112 | + */ |
|
113 | 113 | public function addX400($username, $country, $admd, $pdmd, $org, $surname, $givenName, $isGUID = false) { |
114 | 114 | if ($username === NULL) { return "Missing compulsory field [username]"; } |
115 | 115 | |
@@ -139,14 +139,14 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
142 | - * Add an address to Exchange |
|
143 | - * |
|
144 | - * @param string $username The username of the user to add the Exchange account to |
|
145 | - * @param string $emailAddress The email address to add to this user |
|
146 | - * @param bool $default Make this email address the default address, this is a bit more intensive as we have to demote any existing default addresses |
|
147 | - * @param bool $isGUID Is the username passed a GUID or a samAccountName |
|
148 | - * @return string|boolean |
|
149 | - */ |
|
142 | + * Add an address to Exchange |
|
143 | + * |
|
144 | + * @param string $username The username of the user to add the Exchange account to |
|
145 | + * @param string $emailAddress The email address to add to this user |
|
146 | + * @param bool $default Make this email address the default address, this is a bit more intensive as we have to demote any existing default addresses |
|
147 | + * @param bool $isGUID Is the username passed a GUID or a samAccountName |
|
148 | + * @return string|boolean |
|
149 | + */ |
|
150 | 150 | public function addAddress($username, $emailAddress, $default = FALSE, $isGUID = false) { |
151 | 151 | if ($username === NULL) { return "Missing compulsory field [username]"; } |
152 | 152 | if ($emailAddress === NULL) { return "Missing compulsory fields [emailAddress]"; } |
@@ -202,15 +202,15 @@ discard block |
||
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
205 | - * Remove an address to Exchange |
|
206 | - * If you remove a default address the account will no longer have a default, |
|
207 | - * we recommend changing the default address first |
|
208 | - * |
|
209 | - * @param string $username The username of the user to add the Exchange account to |
|
210 | - * @param string $emailAddress The email address to add to this user |
|
211 | - * @param bool $isGUID Is the username passed a GUID or a samAccountName |
|
212 | - * @return string|boolean |
|
213 | - */ |
|
205 | + * Remove an address to Exchange |
|
206 | + * If you remove a default address the account will no longer have a default, |
|
207 | + * we recommend changing the default address first |
|
208 | + * |
|
209 | + * @param string $username The username of the user to add the Exchange account to |
|
210 | + * @param string $emailAddress The email address to add to this user |
|
211 | + * @param bool $isGUID Is the username passed a GUID or a samAccountName |
|
212 | + * @return string|boolean |
|
213 | + */ |
|
214 | 214 | public function deleteAddress($username, $emailAddress, $isGUID = false) { |
215 | 215 | if ($username === NULL) { return "Missing compulsory field [username]"; } |
216 | 216 | if ($emailAddress === NULL) { return "Missing compulsory fields [emailAddress]"; } |
@@ -280,14 +280,14 @@ discard block |
||
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
283 | - * Mail enable a contact |
|
284 | - * Allows email to be sent to them through Exchange |
|
285 | - * |
|
286 | - * @param string $distinguishedName The contact to mail enable |
|
287 | - * @param string $emailAddress The email address to allow emails to be sent through |
|
288 | - * @param string $mailNickname The mailnickname for the contact in Exchange. If NULL this will be set to the display name |
|
289 | - * @return string|boolean |
|
290 | - */ |
|
283 | + * Mail enable a contact |
|
284 | + * Allows email to be sent to them through Exchange |
|
285 | + * |
|
286 | + * @param string $distinguishedName The contact to mail enable |
|
287 | + * @param string $emailAddress The email address to allow emails to be sent through |
|
288 | + * @param string $mailNickname The mailnickname for the contact in Exchange. If NULL this will be set to the display name |
|
289 | + * @return string|boolean |
|
290 | + */ |
|
291 | 291 | public function contactMailEnable($distinguishedName, $emailAddress, $mailNickname = NULL) { |
292 | 292 | if ($distinguishedName === NULL) { return "Missing compulsory field [distinguishedName]"; } |
293 | 293 | if ($emailAddress === NULL) { return "Missing compulsory field [emailAddress]"; } |
@@ -241,23 +241,23 @@ |
||
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
244 | - * Get the current class version number |
|
245 | - * |
|
246 | - * @return string |
|
247 | - */ |
|
244 | + * Get the current class version number |
|
245 | + * |
|
246 | + * @return string |
|
247 | + */ |
|
248 | 248 | public function getVersion() { |
249 | 249 | return self::ADLDAP_VERSION; |
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
253 | - * Round a Windows timestamp down to seconds and remove the seconds between 1601-01-01 and 1970-01-01 |
|
254 | - * |
|
255 | - * @param long $windowsTime |
|
256 | - * @return double $unixTime |
|
257 | - */ |
|
253 | + * Round a Windows timestamp down to seconds and remove the seconds between 1601-01-01 and 1970-01-01 |
|
254 | + * |
|
255 | + * @param long $windowsTime |
|
256 | + * @return double $unixTime |
|
257 | + */ |
|
258 | 258 | public static function convertWindowsTimeToUnixTime($windowsTime) { |
259 | - $unixTime = round($windowsTime / 10000000) - 11644473600; |
|
260 | - return $unixTime; |
|
259 | + $unixTime = round($windowsTime / 10000000) - 11644473600; |
|
260 | + return $unixTime; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | // * Still work to do in this area, and new functions to write |
56 | 56 | |
57 | 57 | /** |
58 | - * Create a contact |
|
59 | - * |
|
60 | - * @param array $attributes The attributes to set to the contact |
|
61 | - * @return string|boolean |
|
62 | - */ |
|
58 | + * Create a contact |
|
59 | + * |
|
60 | + * @param array $attributes The attributes to set to the contact |
|
61 | + * @return string|boolean |
|
62 | + */ |
|
63 | 63 | public function create($attributes) { |
64 | 64 | // Check for compulsory fields |
65 | 65 | if (!array_key_exists("display_name", $attributes)) { return "Missing compulsory field [display_name]"; } |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
96 | - * Determine the list of groups a contact is a member of |
|
97 | - * |
|
98 | - * @param string $distinguishedName The full DN of a contact |
|
99 | - * @param bool $recursive Recursively check groups |
|
100 | - * @return array |
|
101 | - */ |
|
96 | + * Determine the list of groups a contact is a member of |
|
97 | + * |
|
98 | + * @param string $distinguishedName The full DN of a contact |
|
99 | + * @param bool $recursive Recursively check groups |
|
100 | + * @return array |
|
101 | + */ |
|
102 | 102 | public function groups($distinguishedName, $recursive = NULL) { |
103 | 103 | if ($distinguishedName === NULL) { return false; } |
104 | 104 | if ($recursive === NULL) { $recursive = $this->adldap->getRecursiveGroups(); } //use the default option if they haven't set it |
@@ -118,12 +118,12 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
121 | - * Get contact information. Returned in a raw array format from AD |
|
122 | - * |
|
123 | - * @param string $distinguishedName The full DN of a contact |
|
124 | - * @param array $fields Attributes to be returned |
|
125 | - * @return array |
|
126 | - */ |
|
121 | + * Get contact information. Returned in a raw array format from AD |
|
122 | + * |
|
123 | + * @param string $distinguishedName The full DN of a contact |
|
124 | + * @param array $fields Attributes to be returned |
|
125 | + * @return array |
|
126 | + */ |
|
127 | 127 | public function info($distinguishedName, $fields = NULL) |
128 | 128 | { |
129 | 129 | if ($distinguishedName === NULL) { return false; } |
@@ -195,12 +195,12 @@ discard block |
||
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
198 | - * Modify a contact |
|
199 | - * |
|
200 | - * @param string $distinguishedName The contact to query |
|
201 | - * @param array $attributes The attributes to modify. Note if you set the enabled attribute you must not specify any other attributes |
|
202 | - * @return string|boolean |
|
203 | - */ |
|
198 | + * Modify a contact |
|
199 | + * |
|
200 | + * @param string $distinguishedName The contact to query |
|
201 | + * @param array $attributes The attributes to modify. Note if you set the enabled attribute you must not specify any other attributes |
|
202 | + * @return string|boolean |
|
203 | + */ |
|
204 | 204 | public function modify($distinguishedName, $attributes) { |
205 | 205 | if ($distinguishedName === NULL) { return "Missing compulsory field [distinguishedname]"; } |
206 | 206 | |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
224 | - * Delete a contact |
|
225 | - * |
|
226 | - * @param string $distinguishedName The contact dn to delete (please be careful here!) |
|
227 | - * @return boolean |
|
228 | - */ |
|
224 | + * Delete a contact |
|
225 | + * |
|
226 | + * @param string $distinguishedName The contact dn to delete (please be careful here!) |
|
227 | + * @return boolean |
|
228 | + */ |
|
229 | 229 | public function delete($distinguishedName) { |
230 | 230 | $result = $this->folder()->delete($distinguishedName); |
231 | 231 | if ($result != true) { |
@@ -268,14 +268,14 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
271 | - * Mail enable a contact |
|
272 | - * Allows email to be sent to them through Exchange |
|
273 | - * |
|
274 | - * @param string $distinguishedName The contact to mail enable |
|
275 | - * @param string $emailAddress The email address to allow emails to be sent through |
|
276 | - * @param string $mailNickname The mailnickname for the contact in Exchange. If NULL this will be set to the display name |
|
277 | - * @return string|boolean |
|
278 | - */ |
|
271 | + * Mail enable a contact |
|
272 | + * Allows email to be sent to them through Exchange |
|
273 | + * |
|
274 | + * @param string $distinguishedName The contact to mail enable |
|
275 | + * @param string $emailAddress The email address to allow emails to be sent through |
|
276 | + * @param string $mailNickname The mailnickname for the contact in Exchange. If NULL this will be set to the display name |
|
277 | + * @return string|boolean |
|
278 | + */ |
|
279 | 279 | public function contactMailEnable($distinguishedName, $emailAddress, $mailNickname = NULL) { |
280 | 280 | return $this->adldap->exchange()->contactMailEnable($distinguishedName, $emailAddress, $mailNickname); |
281 | 281 | } |
@@ -96,13 +96,13 @@ |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | - * Check if a computer is in a group |
|
100 | - * |
|
101 | - * @param string $computerName The name of the computer |
|
102 | - * @param string $group The group to check |
|
103 | - * @param bool $recursive Whether to check recursively |
|
104 | - * @return boolean |
|
105 | - */ |
|
99 | + * Check if a computer is in a group |
|
100 | + * |
|
101 | + * @param string $computerName The name of the computer |
|
102 | + * @param string $group The group to check |
|
103 | + * @param bool $recursive Whether to check recursively |
|
104 | + * @return boolean |
|
105 | + */ |
|
106 | 106 | public function inGroup($computerName, $group, $recursive = NULL) { |
107 | 107 | if ($computerName === NULL) { return false; } |
108 | 108 | if ($group === NULL) { return false; } |
@@ -140,11 +140,11 @@ |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
143 | - * Create an organizational unit |
|
144 | - * |
|
145 | - * @param array $attributes Default attributes of the ou |
|
146 | - * @return string|boolean |
|
147 | - */ |
|
143 | + * Create an organizational unit |
|
144 | + * |
|
145 | + * @param array $attributes Default attributes of the ou |
|
146 | + * @return string|boolean |
|
147 | + */ |
|
148 | 148 | public function create($attributes) { |
149 | 149 | if (!is_array($attributes)) { return "Attributes must be an array"; } |
150 | 150 | if (!is_array($attributes["container"])) { return "Container attribute must be an array."; } |
@@ -312,27 +312,27 @@ discard block |
||
312 | 312 | array_unshift($args, $table); |
313 | 313 | array_unshift($args, $query); |
314 | 314 | return call_user_func_array(array($this, 'query'), $args); |
315 | - } |
|
315 | + } |
|
316 | 316 | |
317 | - /** |
|
318 | - * @param string $which |
|
319 | - */ |
|
320 | - public function insertOrReplace($which, $table, $datas, $options=array()) { |
|
317 | + /** |
|
318 | + * @param string $which |
|
319 | + */ |
|
320 | + public function insertOrReplace($which, $table, $datas, $options=array()) { |
|
321 | 321 | $datas = unserialize(serialize($datas)); // break references within array |
322 | 322 | $keys = $values = array(); |
323 | 323 | |
324 | 324 | if (isset($datas[0]) && is_array($datas[0])) { |
325 | - foreach ($datas as $datum) { |
|
325 | + foreach ($datas as $datum) { |
|
326 | 326 | ksort($datum); |
327 | 327 | if (! $keys) { |
328 | 328 | $keys = array_keys($datum); |
329 | 329 | } |
330 | 330 | $values[] = array_values($datum); |
331 | - } |
|
331 | + } |
|
332 | 332 | |
333 | 333 | } else { |
334 | - $keys = array_keys($datas); |
|
335 | - $values = array_values($datas); |
|
334 | + $keys = array_keys($datas); |
|
335 | + $values = array_values($datas); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | if (isset($options['ignore']) && $options['ignore']) { |
@@ -340,35 +340,35 @@ discard block |
||
340 | 340 | } |
341 | 341 | |
342 | 342 | if (isset($options['update']) && is_array($options['update']) && $options['update'] && strtolower($which) == 'insert') { |
343 | - if (array_values($options['update']) !== $options['update']) { |
|
343 | + if (array_values($options['update']) !== $options['update']) { |
|
344 | 344 | return $this->query("INSERT INTO %b %lb VALUES %? ON DUPLICATE KEY UPDATE %?", $table, $keys, $values, $options['update']); |
345 | - } else { |
|
345 | + } else { |
|
346 | 346 | $update_str = array_shift($options['update']); |
347 | 347 | $query_param = array("INSERT INTO %b %lb VALUES %? ON DUPLICATE KEY UPDATE $update_str", $table, $keys, $values); |
348 | 348 | $query_param = array_merge($query_param, $options['update']); |
349 | 349 | return call_user_func_array(array($this, 'query'), $query_param); |
350 | - } |
|
350 | + } |
|
351 | 351 | |
352 | 352 | } |
353 | 353 | |
354 | 354 | return $this->query("%l INTO %b %lb VALUES %?", $which, $table, $keys, $values); |
355 | - } |
|
355 | + } |
|
356 | 356 | |
357 | - public function insert($table, $data) { return $this->insertOrReplace('INSERT', $table, $data); } |
|
358 | - public function insertIgnore($table, $data) { return $this->insertOrReplace('INSERT', $table, $data, array('ignore' => true)); } |
|
359 | - public function replace($table, $data) { return $this->insertOrReplace('REPLACE', $table, $data); } |
|
357 | + public function insert($table, $data) { return $this->insertOrReplace('INSERT', $table, $data); } |
|
358 | + public function insertIgnore($table, $data) { return $this->insertOrReplace('INSERT', $table, $data, array('ignore' => true)); } |
|
359 | + public function replace($table, $data) { return $this->insertOrReplace('REPLACE', $table, $data); } |
|
360 | 360 | |
361 | - public function insertUpdate() { |
|
361 | + public function insertUpdate() { |
|
362 | 362 | $args = func_get_args(); |
363 | 363 | $table = array_shift($args); |
364 | 364 | $data = array_shift($args); |
365 | 365 | |
366 | 366 | if (!isset($args[0])) { // update will have all the data of the insert |
367 | - if (isset($data[0]) && is_array($data[0])) { //multiple insert rows specified -- failing! |
|
367 | + if (isset($data[0]) && is_array($data[0])) { //multiple insert rows specified -- failing! |
|
368 | 368 | $this->nonSQLError("Badly formatted insertUpdate() query -- you didn't specify the update component!"); |
369 | - } |
|
369 | + } |
|
370 | 370 | |
371 | - $args[0] = $data; |
|
371 | + $args[0] = $data; |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | if (is_array($args[0])) { |
@@ -378,31 +378,31 @@ discard block |
||
378 | 378 | } |
379 | 379 | |
380 | 380 | return $this->insertOrReplace('INSERT', $table, $data, array('update' => $update)); |
381 | - } |
|
381 | + } |
|
382 | 382 | |
383 | - public function delete() { |
|
383 | + public function delete() { |
|
384 | 384 | $args = func_get_args(); |
385 | 385 | $table = $this->formatTableName(array_shift($args)); |
386 | 386 | $where = array_shift($args); |
387 | 387 | $buildquery = "DELETE FROM $table WHERE $where"; |
388 | 388 | array_unshift($args, $buildquery); |
389 | 389 | return call_user_func_array(array($this, 'query'), $args); |
390 | - } |
|
390 | + } |
|
391 | 391 | |
392 | - public function sqleval() { |
|
392 | + public function sqleval() { |
|
393 | 393 | $args = func_get_args(); |
394 | 394 | $text = call_user_func_array(array($this, 'parseQueryParams'), $args); |
395 | 395 | return new MeekroDBEval($text); |
396 | - } |
|
396 | + } |
|
397 | 397 | |
398 | - public function columnList($table) { |
|
398 | + public function columnList($table) { |
|
399 | 399 | return $this->queryOneColumn('Field', "SHOW COLUMNS FROM $table"); |
400 | - } |
|
400 | + } |
|
401 | 401 | |
402 | - public function tableList($db = null) { |
|
402 | + public function tableList($db = null) { |
|
403 | 403 | if ($db) { |
404 | - $olddb = $this->current_db; |
|
405 | - $this->useDB($db); |
|
404 | + $olddb = $this->current_db; |
|
405 | + $this->useDB($db); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | $result = $this->queryFirstColumn('SHOW TABLES'); |
@@ -410,9 +410,9 @@ discard block |
||
410 | 410 | $this->useDB($olddb); |
411 | 411 | } |
412 | 412 | return $result; |
413 | - } |
|
413 | + } |
|
414 | 414 | |
415 | - protected function preparseQueryParams() { |
|
415 | + protected function preparseQueryParams() { |
|
416 | 416 | $args = func_get_args(); |
417 | 417 | $sql = trim(strval(array_shift($args))); |
418 | 418 | $args_all = $args; |
@@ -562,60 +562,60 @@ discard block |
||
562 | 562 | $array_types = array('ls', 'li', 'ld', 'lb', 'll', 'lt'); |
563 | 563 | |
564 | 564 | foreach ($chunkyQuery as $chunk) { |
565 | - if (is_string($chunk)) { |
|
565 | + if (is_string($chunk)) { |
|
566 | 566 | $query .= $chunk; |
567 | 567 | continue; |
568 | - } |
|
568 | + } |
|
569 | 569 | |
570 | - $type = $chunk['type']; |
|
571 | - $arg = $chunk['value']; |
|
572 | - $result = ''; |
|
570 | + $type = $chunk['type']; |
|
571 | + $arg = $chunk['value']; |
|
572 | + $result = ''; |
|
573 | 573 | |
574 | - if ($type != '?') { |
|
574 | + if ($type != '?') { |
|
575 | 575 | $is_array_type = in_array($type, $array_types, true); |
576 | 576 | if ($is_array_type && !is_array($arg)) $this->nonSQLError("Badly formatted SQL query: Expected array, got scalar instead!"); |
577 | 577 | else if (!$is_array_type && is_array($arg)) $this->nonSQLError("Badly formatted SQL query: Expected scalar, got array instead!"); |
578 | - } |
|
578 | + } |
|
579 | 579 | |
580 | - if ($type == 's') $result = $this->escape($arg); |
|
581 | - else if ($type == 'i') $result = $this->intval($arg); |
|
582 | - else if ($type == 'd') $result = doubleval($arg); |
|
583 | - else if ($type == 'b') $result = $this->formatTableName($arg); |
|
584 | - else if ($type == 'l') $result = $arg; |
|
585 | - else if ($type == 'ss') $result = $this->escape("%".str_replace(array('%', '_'), array('\%', '\_'), $arg)."%"); |
|
586 | - else if ($type == 't') $result = $this->escape($this->parseTS($arg)); |
|
580 | + if ($type == 's') $result = $this->escape($arg); |
|
581 | + else if ($type == 'i') $result = $this->intval($arg); |
|
582 | + else if ($type == 'd') $result = doubleval($arg); |
|
583 | + else if ($type == 'b') $result = $this->formatTableName($arg); |
|
584 | + else if ($type == 'l') $result = $arg; |
|
585 | + else if ($type == 'ss') $result = $this->escape("%".str_replace(array('%', '_'), array('\%', '\_'), $arg)."%"); |
|
586 | + else if ($type == 't') $result = $this->escape($this->parseTS($arg)); |
|
587 | 587 | |
588 | - else if ($type == 'ls') $result = array_map(array($this, 'escape'), $arg); |
|
589 | - else if ($type == 'li') $result = array_map(array($this, 'intval'), $arg); |
|
590 | - else if ($type == 'ld') $result = array_map('doubleval', $arg); |
|
591 | - else if ($type == 'lb') $result = array_map(array($this, 'formatTableName'), $arg); |
|
592 | - else if ($type == 'll') $result = $arg; |
|
593 | - else if ($type == 'lt') $result = array_map(array($this, 'escape'), array_map(array($this, 'parseTS'), $arg)); |
|
588 | + else if ($type == 'ls') $result = array_map(array($this, 'escape'), $arg); |
|
589 | + else if ($type == 'li') $result = array_map(array($this, 'intval'), $arg); |
|
590 | + else if ($type == 'ld') $result = array_map('doubleval', $arg); |
|
591 | + else if ($type == 'lb') $result = array_map(array($this, 'formatTableName'), $arg); |
|
592 | + else if ($type == 'll') $result = $arg; |
|
593 | + else if ($type == 'lt') $result = array_map(array($this, 'escape'), array_map(array($this, 'parseTS'), $arg)); |
|
594 | 594 | |
595 | - else if ($type == '?') $result = $this->sanitize($arg); |
|
595 | + else if ($type == '?') $result = $this->sanitize($arg); |
|
596 | 596 | |
597 | - else $this->nonSQLError("Badly formatted SQL query: Invalid MeekroDB param $type"); |
|
597 | + else $this->nonSQLError("Badly formatted SQL query: Invalid MeekroDB param $type"); |
|
598 | 598 | |
599 | - if (is_array($result)) $result = '('.implode(',', $result).')'; |
|
599 | + if (is_array($result)) $result = '('.implode(',', $result).')'; |
|
600 | 600 | |
601 | - $query .= $result; |
|
601 | + $query .= $result; |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | return $query; |
605 | - } |
|
605 | + } |
|
606 | 606 | |
607 | - /** |
|
608 | - * @param string $prepend |
|
609 | - */ |
|
610 | - protected function prependCall($function, $args, $prepend) { array_unshift($args, $prepend); return call_user_func_array($function, $args); } |
|
611 | - public function query() { $args = func_get_args(); return $this->prependCall(array($this, 'queryHelper'), $args, 'assoc'); } |
|
612 | - public function queryAllLists() { $args = func_get_args(); return $this->prependCall(array($this, 'queryHelper'), $args, 'list'); } |
|
613 | - public function queryFullColumns() { $args = func_get_args(); return $this->prependCall(array($this, 'queryHelper'), $args, 'full'); } |
|
607 | + /** |
|
608 | + * @param string $prepend |
|
609 | + */ |
|
610 | + protected function prependCall($function, $args, $prepend) { array_unshift($args, $prepend); return call_user_func_array($function, $args); } |
|
611 | + public function query() { $args = func_get_args(); return $this->prependCall(array($this, 'queryHelper'), $args, 'assoc'); } |
|
612 | + public function queryAllLists() { $args = func_get_args(); return $this->prependCall(array($this, 'queryHelper'), $args, 'list'); } |
|
613 | + public function queryFullColumns() { $args = func_get_args(); return $this->prependCall(array($this, 'queryHelper'), $args, 'full'); } |
|
614 | 614 | |
615 | - public function queryRaw() { $args = func_get_args(); return $this->prependCall(array($this, 'queryHelper'), $args, 'raw_buf'); } |
|
616 | - public function queryRawUnbuf() { $args = func_get_args(); return $this->prependCall(array($this, 'queryHelper'), $args, 'raw_unbuf'); } |
|
615 | + public function queryRaw() { $args = func_get_args(); return $this->prependCall(array($this, 'queryHelper'), $args, 'raw_buf'); } |
|
616 | + public function queryRawUnbuf() { $args = func_get_args(); return $this->prependCall(array($this, 'queryHelper'), $args, 'raw_unbuf'); } |
|
617 | 617 | |
618 | - protected function queryHelper() { |
|
618 | + protected function queryHelper() { |
|
619 | 619 | $args = func_get_args(); |
620 | 620 | $type = array_shift($args); |
621 | 621 | $db = $this->get(); |