Index: trunk/extensions/LdapAuthentication/LdapAutoAuthentication.php |
— | — | @@ -10,6 +10,9 @@ |
11 | 11 | * @return bool |
12 | 12 | */ |
13 | 13 | public static function Authenticate( $user, &$result = null ) { |
| 14 | + /** |
| 15 | + * @var $wgAuth LdapAuthenticationPlugin |
| 16 | + */ |
14 | 17 | global $wgAuth; |
15 | 18 | |
16 | 19 | $wgAuth->printDebug( "Entering AutoAuthentication.", NONSENSITIVE ); |
— | — | @@ -72,6 +75,9 @@ |
73 | 76 | * @return bool |
74 | 77 | */ |
75 | 78 | public static function attemptAddUser( $user, $mungedUsername ) { |
| 79 | + /** |
| 80 | + * @var $wgAuth LdapAuthenticationPlugin |
| 81 | + */ |
76 | 82 | global $wgAuth; |
77 | 83 | |
78 | 84 | if ( !$wgAuth->autoCreate() ) { |
— | — | @@ -106,6 +112,9 @@ |
107 | 113 | * @return bool |
108 | 114 | */ |
109 | 115 | public static function NoLogout( &$personal_urls, $title ) { |
| 116 | + /** |
| 117 | + * @var $wgAuth LdapAuthenticationPlugin |
| 118 | + */ |
110 | 119 | global $wgAuth; |
111 | 120 | $wgAuth->printDebug( "Entering NoLogout.", NONSENSITIVE ); |
112 | 121 | |
Index: trunk/extensions/LdapAuthentication/LdapAuthentication.php |
— | — | @@ -142,6 +142,9 @@ |
143 | 143 | |
144 | 144 | /** |
145 | 145 | * Wrapper for ldap_connect |
| 146 | + * @param null $hostname |
| 147 | + * @param int $port |
| 148 | + * @return resource|false |
146 | 149 | */ |
147 | 150 | public static function ldap_connect( $hostname=null, $port=389 ) { |
148 | 151 | wfSuppressWarnings(); |
— | — | @@ -152,6 +155,10 @@ |
153 | 156 | |
154 | 157 | /** |
155 | 158 | * Wrapper for ldap_bind |
| 159 | + * @param $ldapconn |
| 160 | + * @param null $dn |
| 161 | + * @param null $password |
| 162 | + * @return bool |
156 | 163 | */ |
157 | 164 | public static function ldap_bind( $ldapconn, $dn=null, $password=null ) { |
158 | 165 | wfSuppressWarnings(); |
— | — | @@ -162,6 +169,8 @@ |
163 | 170 | |
164 | 171 | /** |
165 | 172 | * Wrapper for ldap_unbind |
| 173 | + * @param $ldapconn |
| 174 | + * @return bool |
166 | 175 | */ |
167 | 176 | public static function ldap_unbind( $ldapconn ) { |
168 | 177 | if ( $ldapconn ) { |
— | — | @@ -176,6 +185,10 @@ |
177 | 186 | |
178 | 187 | /** |
179 | 188 | * Wrapper for ldap_modify |
| 189 | + * @param $ldapconn |
| 190 | + * @param $dn |
| 191 | + * @param $entry |
| 192 | + * @return bool |
180 | 193 | */ |
181 | 194 | public static function ldap_modify( $ldapconn, $dn, $entry ) { |
182 | 195 | wfSuppressWarnings(); |
— | — | @@ -196,6 +209,9 @@ |
197 | 210 | |
198 | 211 | /** |
199 | 212 | * Wrapper for ldap_delete |
| 213 | + * @param $ldapconn |
| 214 | + * @param $dn |
| 215 | + * @return bool |
200 | 216 | */ |
201 | 217 | public static function ldap_delete( $ldapconn, $dn ) { |
202 | 218 | wfSuppressWarnings(); |
— | — | @@ -206,6 +222,15 @@ |
207 | 223 | |
208 | 224 | /** |
209 | 225 | * Wrapper for ldap_search |
| 226 | + * @param $ldapconn |
| 227 | + * @param $basedn |
| 228 | + * @param $filter |
| 229 | + * @param null $attributes |
| 230 | + * @param null $attrsonly |
| 231 | + * @param null $sizelimit |
| 232 | + * @param null $timelimit |
| 233 | + * @param null $deref |
| 234 | + * @return resource |
210 | 235 | */ |
211 | 236 | public static function ldap_search( $ldapconn, $basedn, $filter, $attributes=null, $attrsonly=null, $sizelimit=null, $timelimit=null, $deref=null ) { |
212 | 237 | wfSuppressWarnings(); |
— | — | @@ -216,6 +241,15 @@ |
217 | 242 | |
218 | 243 | /** |
219 | 244 | * Wrapper for ldap_read |
| 245 | + * @param $ldapconn |
| 246 | + * @param $basedn |
| 247 | + * @param $filter |
| 248 | + * @param null $attributes |
| 249 | + * @param null $attrsonly |
| 250 | + * @param null $sizelimit |
| 251 | + * @param null $timelimit |
| 252 | + * @param null $deref |
| 253 | + * @return resource |
220 | 254 | */ |
221 | 255 | public static function ldap_read( $ldapconn, $basedn, $filter, $attributes=null, $attrsonly=null, $sizelimit=null, $timelimit=null, $deref=null ) { |
222 | 256 | wfSuppressWarnings(); |
— | — | @@ -226,6 +260,15 @@ |
227 | 261 | |
228 | 262 | /** |
229 | 263 | * Wrapper for ldap_list |
| 264 | + * @param $ldapconn |
| 265 | + * @param $basedn |
| 266 | + * @param $filter |
| 267 | + * @param null $attributes |
| 268 | + * @param null $attrsonly |
| 269 | + * @param null $sizelimit |
| 270 | + * @param null $timelimit |
| 271 | + * @param null $deref |
| 272 | + * @return \resource |
230 | 273 | */ |
231 | 274 | public static function ldap_list( $ldapconn, $basedn, $filter, $attributes=null, $attrsonly=null, $sizelimit=null, $timelimit=null, $deref=null ) { |
232 | 275 | wfSuppressWarnings(); |
— | — | @@ -236,6 +279,9 @@ |
237 | 280 | |
238 | 281 | /** |
239 | 282 | * Wrapper for ldap_get_entries |
| 283 | + * @param $ldapconn |
| 284 | + * @param $resultid |
| 285 | + * @return array |
240 | 286 | */ |
241 | 287 | public static function ldap_get_entries( $ldapconn, $resultid ) { |
242 | 288 | wfSuppressWarnings(); |
— | — | @@ -246,6 +292,9 @@ |
247 | 293 | |
248 | 294 | /** |
249 | 295 | * Wrapper for ldap_count_entries |
| 296 | + * @param $ldapconn |
| 297 | + * @param $resultid |
| 298 | + * @return int |
250 | 299 | */ |
251 | 300 | public static function ldap_count_entries( $ldapconn, $resultid ) { |
252 | 301 | wfSuppressWarnings(); |
— | — | @@ -475,6 +524,8 @@ |
476 | 525 | |
477 | 526 | /** |
478 | 527 | * Connect to LDAP |
| 528 | + * @param string $domain |
| 529 | + * @return bool |
479 | 530 | */ |
480 | 531 | public function connect( $domain='' ) { |
481 | 532 | // FIXME: $domain isn't used |
— | — | @@ -536,9 +587,10 @@ |
537 | 588 | $this->printDebug( "Using TLS", SENSITIVE ); |
538 | 589 | if ( !ldap_start_tls( $this->ldapconn ) ) { |
539 | 590 | $this->printDebug( "Failed to start TLS.", SENSITIVE ); |
540 | | - return; |
| 591 | + return false; |
541 | 592 | } |
542 | 593 | } |
| 594 | + return true; |
543 | 595 | } |
544 | 596 | |
545 | 597 | /** |
— | — | @@ -836,12 +888,13 @@ |
837 | 889 | return false; |
838 | 890 | } |
839 | 891 | |
| 892 | + $values = array(); |
840 | 893 | if ( '' != $this->email ) { $values["mail"] = $this->email; } |
841 | 894 | if ( '' != $this->nickname ) { $values["displayname"] = $this->nickname; } |
842 | 895 | if ( '' != $this->realname ) { $values["cn"] = $this->realname; } |
843 | 896 | if ( '' != $this->lang ) { $values["preferredlanguage"] = $this->lang; } |
844 | 897 | |
845 | | - if ( 0 != sizeof( $values ) && LdapAuthenticationPlugin::ldap_modify( $this->ldapconn, $this->userdn, $values ) ) { |
| 898 | + if ( count( $values ) && LdapAuthenticationPlugin::ldap_modify( $this->ldapconn, $this->userdn, $values ) ) { |
846 | 899 | $this->printDebug( "Successfully modified the user's attributes", NONSENSITIVE ); |
847 | 900 | LdapAuthenticationPlugin::ldap_unbind( $this->ldapconn ); |
848 | 901 | return true; |
— | — | @@ -1078,9 +1131,10 @@ |
1079 | 1132 | |
1080 | 1133 | /** |
1081 | 1134 | * When creating a user account, initialize user with information from LDAP. |
| 1135 | + * TODO: fix setExternalID stuff |
1082 | 1136 | * |
1083 | 1137 | * @param User $user |
1084 | | - * TODO: fix setExternalID stuff |
| 1138 | + * @param bool $autocreate |
1085 | 1139 | */ |
1086 | 1140 | public function initUser( &$user, $autocreate = false ) { |
1087 | 1141 | $this->printDebug( "Entering initUser", NONSENSITIVE ); |