From b0a3a9d3741eb464add1e9df8d951bbbdb0d45b6 Mon Sep 17 00:00:00 2001
From: Ivan Dackiewicz <idackiewicz@gmail.com>
Date: Sat, 21 May 2011 20:56:30 -0300
Subject: [PATCH] Added logic check to skip pulling user data from LDAP if it's not configured.

---
 auth/cas/auth.php |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/auth/cas/auth.php b/auth/cas/auth.php
index 5690c53..17e7b7b 100644
--- a/auth/cas/auth.php
+++ b/auth/cas/auth.php
@@ -405,4 +405,38 @@ class auth_plugin_cas extends auth_plugin_ldap {
 
         return false;
     }
+    
+    /**
+     * If the ldap host isn't setted up, cas shouldn't try to retrieve 
+     * user information.
+     * This will force to manual edition
+     * 
+     * @param string $username username
+     *
+     * @return mixed array with no magic quotes or false on error
+     */
+    function get_userinfo($username) {
+        if (empty($this->config->host_url)) {
+            return array();
+        }
+        parent::get_userinfo($username);
+    }
+    
+    /**
+     * Syncronizes user fron external LDAP server to moodle user table 
+     * only if the LDAP host is setted up.
+     *
+     * Sync is now using username attribute.
+     *
+     * Syncing users removes or suspends users that dont exists anymore in external LDAP.
+     * Creates new users and updates coursecreator status of users.
+     *
+     * @param bool $do_updates will do pull in data updates from LDAP if relevant
+     */
+    function sync_users($do_updates=true) {
+        if (empty($this->config->host_url)) {
+            return array();
+        }
+        parent::sync_users($username);
+    }
 }
-- 
1.7.4.1

