r107430 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107429‎ | r107430 | r107431 >
Date:21:31, 27 December 2011
Author:reedy
Status:ok
Tags:
Comment:
More documentation stuff
Modified paths:
  • /trunk/extensions/LdapAuthentication/LdapAuthentication.php (modified) (history)
  • /trunk/extensions/LdapAuthentication/LdapAutoAuthentication.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LdapAuthentication/LdapAutoAuthentication.php
@@ -10,6 +10,9 @@
1111 * @return bool
1212 */
1313 public static function Authenticate( $user, &$result = null ) {
 14+ /**
 15+ * @var $wgAuth LdapAuthenticationPlugin
 16+ */
1417 global $wgAuth;
1518
1619 $wgAuth->printDebug( "Entering AutoAuthentication.", NONSENSITIVE );
@@ -72,6 +75,9 @@
7376 * @return bool
7477 */
7578 public static function attemptAddUser( $user, $mungedUsername ) {
 79+ /**
 80+ * @var $wgAuth LdapAuthenticationPlugin
 81+ */
7682 global $wgAuth;
7783
7884 if ( !$wgAuth->autoCreate() ) {
@@ -106,6 +112,9 @@
107113 * @return bool
108114 */
109115 public static function NoLogout( &$personal_urls, $title ) {
 116+ /**
 117+ * @var $wgAuth LdapAuthenticationPlugin
 118+ */
110119 global $wgAuth;
111120 $wgAuth->printDebug( "Entering NoLogout.", NONSENSITIVE );
112121
Index: trunk/extensions/LdapAuthentication/LdapAuthentication.php
@@ -142,6 +142,9 @@
143143
144144 /**
145145 * Wrapper for ldap_connect
 146+ * @param null $hostname
 147+ * @param int $port
 148+ * @return resource|false
146149 */
147150 public static function ldap_connect( $hostname=null, $port=389 ) {
148151 wfSuppressWarnings();
@@ -152,6 +155,10 @@
153156
154157 /**
155158 * Wrapper for ldap_bind
 159+ * @param $ldapconn
 160+ * @param null $dn
 161+ * @param null $password
 162+ * @return bool
156163 */
157164 public static function ldap_bind( $ldapconn, $dn=null, $password=null ) {
158165 wfSuppressWarnings();
@@ -162,6 +169,8 @@
163170
164171 /**
165172 * Wrapper for ldap_unbind
 173+ * @param $ldapconn
 174+ * @return bool
166175 */
167176 public static function ldap_unbind( $ldapconn ) {
168177 if ( $ldapconn ) {
@@ -176,6 +185,10 @@
177186
178187 /**
179188 * Wrapper for ldap_modify
 189+ * @param $ldapconn
 190+ * @param $dn
 191+ * @param $entry
 192+ * @return bool
180193 */
181194 public static function ldap_modify( $ldapconn, $dn, $entry ) {
182195 wfSuppressWarnings();
@@ -196,6 +209,9 @@
197210
198211 /**
199212 * Wrapper for ldap_delete
 213+ * @param $ldapconn
 214+ * @param $dn
 215+ * @return bool
200216 */
201217 public static function ldap_delete( $ldapconn, $dn ) {
202218 wfSuppressWarnings();
@@ -206,6 +222,15 @@
207223
208224 /**
209225 * 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
210235 */
211236 public static function ldap_search( $ldapconn, $basedn, $filter, $attributes=null, $attrsonly=null, $sizelimit=null, $timelimit=null, $deref=null ) {
212237 wfSuppressWarnings();
@@ -216,6 +241,15 @@
217242
218243 /**
219244 * 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
220254 */
221255 public static function ldap_read( $ldapconn, $basedn, $filter, $attributes=null, $attrsonly=null, $sizelimit=null, $timelimit=null, $deref=null ) {
222256 wfSuppressWarnings();
@@ -226,6 +260,15 @@
227261
228262 /**
229263 * 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
230273 */
231274 public static function ldap_list( $ldapconn, $basedn, $filter, $attributes=null, $attrsonly=null, $sizelimit=null, $timelimit=null, $deref=null ) {
232275 wfSuppressWarnings();
@@ -236,6 +279,9 @@
237280
238281 /**
239282 * Wrapper for ldap_get_entries
 283+ * @param $ldapconn
 284+ * @param $resultid
 285+ * @return array
240286 */
241287 public static function ldap_get_entries( $ldapconn, $resultid ) {
242288 wfSuppressWarnings();
@@ -246,6 +292,9 @@
247293
248294 /**
249295 * Wrapper for ldap_count_entries
 296+ * @param $ldapconn
 297+ * @param $resultid
 298+ * @return int
250299 */
251300 public static function ldap_count_entries( $ldapconn, $resultid ) {
252301 wfSuppressWarnings();
@@ -475,6 +524,8 @@
476525
477526 /**
478527 * Connect to LDAP
 528+ * @param string $domain
 529+ * @return bool
479530 */
480531 public function connect( $domain='' ) {
481532 // FIXME: $domain isn't used
@@ -536,9 +587,10 @@
537588 $this->printDebug( "Using TLS", SENSITIVE );
538589 if ( !ldap_start_tls( $this->ldapconn ) ) {
539590 $this->printDebug( "Failed to start TLS.", SENSITIVE );
540 - return;
 591+ return false;
541592 }
542593 }
 594+ return true;
543595 }
544596
545597 /**
@@ -836,12 +888,13 @@
837889 return false;
838890 }
839891
 892+ $values = array();
840893 if ( '' != $this->email ) { $values["mail"] = $this->email; }
841894 if ( '' != $this->nickname ) { $values["displayname"] = $this->nickname; }
842895 if ( '' != $this->realname ) { $values["cn"] = $this->realname; }
843896 if ( '' != $this->lang ) { $values["preferredlanguage"] = $this->lang; }
844897
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 ) ) {
846899 $this->printDebug( "Successfully modified the user's attributes", NONSENSITIVE );
847900 LdapAuthenticationPlugin::ldap_unbind( $this->ldapconn );
848901 return true;
@@ -1078,9 +1131,10 @@
10791132
10801133 /**
10811134 * When creating a user account, initialize user with information from LDAP.
 1135+ * TODO: fix setExternalID stuff
10821136 *
10831137 * @param User $user
1084 - * TODO: fix setExternalID stuff
 1138+ * @param bool $autocreate
10851139 */
10861140 public function initUser( &$user, $autocreate = false ) {
10871141 $this->printDebug( "Entering initUser", NONSENSITIVE );

Status & tagging log