]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/LdapAuthorization/LdapAuthorizationPlugin.php
Parse an hcard for hints, if available
[quix0rs-gnu-social.git] / plugins / LdapAuthorization / LdapAuthorizationPlugin.php
index 91a343f4087ae0dfd5c8f953c70042a6428e4be2..7f48ce5e1b0fd8b35578200fd49adb5ae4a4c24a 100644 (file)
@@ -31,7 +31,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
-require_once INSTALLDIR.'/plugins/Authorization/AuthorizationPlugin.php';
 require_once 'Net/LDAP2.php';
 
 class LdapAuthorizationPlugin extends AuthorizationPlugin
@@ -53,7 +52,6 @@ class LdapAuthorizationPlugin extends AuthorizationPlugin
     public $attributes = array();
 
     function onInitializePlugin(){
-        parent::onInitializePlugin();
         if(!isset($this->host)){
             throw new Exception("must specify a host");
         }
@@ -158,24 +156,21 @@ class LdapAuthorizationPlugin extends AuthorizationPlugin
 
     //-----the below function were copied from LDAPAuthenticationPlugin. They will be moved to a utility class soon.----\\
     function ldap_get_connection($config = null){
-        if($config == null){
-            static $ldap = null;
-            if($ldap != null){
-                return $ldap;
-            }
-            $config = $this->ldap_get_config();
+        if($config == null && isset($this->default_ldap)){
+            return $this->default_ldap;
         }
         
         //cannot use Net_LDAP2::connect() as StatusNet uses
         //PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handleError');
         //PEAR handling can be overridden on instance objects, so we do that.
-        $ldap = new Net_LDAP2($config);
+        $ldap = new Net_LDAP2(isset($config)?$config:$this->ldap_get_config());
         $ldap->setErrorHandling(PEAR_ERROR_RETURN);
         $err=$ldap->bind();
         if (Net_LDAP2::isError($err)) {
             common_log(LOG_WARNING, 'Could not connect to LDAP server: '.$err->getMessage());
             return false;
         }
+        if($config == null) $this->default_ldap=$ldap;
         return $ldap;
     }
     
@@ -211,4 +206,15 @@ class LdapAuthorizationPlugin extends AuthorizationPlugin
             return false;
         }
     }
+
+    function onPluginVersion(&$versions)
+    {
+        $versions[] = array('name' => 'LDAP Authorization',
+                            'version' => STATUSNET_VERSION,
+                            'author' => 'Craig Andrews',
+                            'homepage' => 'http://status.net/wiki/Plugin:LdapAuthorization',
+                            'rawdescription' =>
+                            _m('The LDAP Authorization plugin allows for StatusNet to handle authorization through LDAP.'));
+        return true;
+    }
 }