commit bc175c277f74c656ff3d220d22b9d8baac955fa8
Author: Assos Assos <assos+forge@centrale-marseille.fr>
Date:   Thu Aug 16 02:18:46 2018 +0200

    Weekly update of contrib modules

diff --git a/drupal7/sites/all/modules/honeypot/honeypot.info b/drupal7/sites/all/modules/honeypot/honeypot.info
index 99be9dc7..6ce86d53 100644
--- a/drupal7/sites/all/modules/honeypot/honeypot.info
+++ b/drupal7/sites/all/modules/honeypot/honeypot.info
@@ -6,9 +6,8 @@ package = "Spam control"
 
 files[] = honeypot.test
 
-; Information added by Drupal.org packaging script on 2018-02-27
-version = "7.x-1.24"
+; Information added by Drupal.org packaging script on 2018-08-09
+version = "7.x-1.25"
 core = "7.x"
 project = "honeypot"
-datestamp = "1519706887"
-
+datestamp = "1533849190"
diff --git a/drupal7/sites/all/modules/honeypot/honeypot.install b/drupal7/sites/all/modules/honeypot/honeypot.install
index 150c68c3..c17b4cb4 100644
--- a/drupal7/sites/all/modules/honeypot/honeypot.install
+++ b/drupal7/sites/all/modules/honeypot/honeypot.install
@@ -69,7 +69,7 @@ function honeypot_uninstall() {
   }
 
   // Delete 'honeypot' directory from files directory.
-  file_unmanaged_delete_recursive(file_default_scheme() . '://honeypot');
+  file_unmanaged_delete_recursive(honeypot_file_default_scheme() . '://honeypot');
 }
 
 /**
diff --git a/drupal7/sites/all/modules/honeypot/honeypot.module b/drupal7/sites/all/modules/honeypot/honeypot.module
index 8623e308..e8137966 100644
--- a/drupal7/sites/all/modules/honeypot/honeypot.module
+++ b/drupal7/sites/all/modules/honeypot/honeypot.module
@@ -78,7 +78,7 @@ function honeypot_form_alter(&$form, &$form_state, $form_id) {
   if (variable_get('honeypot_protect_all_forms', 0) && !in_array($form_id, $unprotected_forms)) {
     // Don't protect system forms - only admins should have access, and system
     // forms may be programmatically submitted by drush and other modules.
-    if (strpos($form_id, 'system_') === FALSE && strpos($form_id, 'search_') === FALSE && strpos($form_id, 'views_exposed_form_') === FALSE) {
+    if (preg_match('/[^a-zA-Z]system_/', $form_id) === 0 && preg_match('/[^a-zA-Z]search_/', $form_id) === 0 && preg_match('/[^a-zA-Z]views_exposed_form_/', $form_id) === 0) {
       honeypot_add_form_protection($form, $form_state, array('honeypot', 'time_restriction'));
     }
   }
@@ -503,7 +503,7 @@ function honeypot_log_failure($form_id, $type) {
  *   The path to the honeypot.css file.
  */
 function honeypot_get_css_file_path() {
-  return file_default_scheme() . '://honeypot/honeypot.css';
+  return honeypot_file_default_scheme() . '://honeypot/honeypot.css';
 }
 
 /**
@@ -513,7 +513,7 @@ function honeypot_get_css_file_path() {
  *   The honeypot element class name (e.g. 'url').
  */
 function honeypot_create_css($element_name) {
-  $path = file_default_scheme() . '://honeypot';
+  $path = honeypot_file_default_scheme() . '://honeypot';
 
   if (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
     drupal_set_message(t('Unable to create Honeypot CSS directory, %path. Check the permissions on your files directory.', array('%path' => file_uri_target($path))), 'error');
@@ -592,3 +592,15 @@ function honeypot_get_time_from_signed_timestamp($signed_timestamp) {
 
   return $honeypot_time;
 }
+
+/**
+ * Gets the default file stream for honeypot.
+ *
+ * @return
+ *   'public', 'private' or any other file scheme defined as the default.
+ *
+ * @see file_default_scheme()
+ */
+function honeypot_file_default_scheme() {
+  return variable_get('honeypot_file_default_scheme', file_default_scheme());
+}
diff --git a/drupal7/sites/all/modules/honeypot/honeypot.test b/drupal7/sites/all/modules/honeypot/honeypot.test
index c0c1fffe..aab7f6e0 100644
--- a/drupal7/sites/all/modules/honeypot/honeypot.test
+++ b/drupal7/sites/all/modules/honeypot/honeypot.test
@@ -387,6 +387,39 @@ class HoneypotCssTestCase extends DrupalWebTestCase {
     // Make sure the Honeypot CSS file exists.
     $this->assertTrue(file_exists($honeypot_css));
   }
+
+  /**
+   * Test CSS file availability.
+   */
+  public function testHoneypotCssAvailability() {
+    // Public CSS file can be consumed.
+    variable_set('file_default_scheme', 'public');
+    if ($wrapper = file_stream_wrapper_get_instance_by_uri(honeypot_get_css_file_path())) {
+      $url = $wrapper->getExternalUrl();
+    }
+    $this->drupalGet($url);
+    $this->assertResponse(200);
+
+
+    // Private CSS file can not be consumed.
+    variable_set('file_default_scheme', 'private');
+    honeypot_cron();
+    if ($wrapper = file_stream_wrapper_get_instance_by_uri(honeypot_get_css_file_path())) {
+      $url = $wrapper->getExternalUrl();
+    }
+    $this->drupalGet($url);
+    $this->assertNoResponse(200);
+
+    // Site default is private, but override honeypot's to public to consume.
+    variable_set('honeypot_file_default_scheme', 'public');
+    honeypot_cron();
+    if ($wrapper = file_stream_wrapper_get_instance_by_uri(honeypot_get_css_file_path())) {
+      $url = $wrapper->getExternalUrl();
+    }
+    $this->drupalGet($url);
+    $this->assertResponse(200);
+  }
+
 }
 
 /**
@@ -444,4 +477,5 @@ class HoneypotTriggerTestCase extends DrupalWebTestCase {
     $this->drupalGet('node');
     $this->assertText(t('has been banned'), 'User banned successfully.');
   }
+
 }
diff --git a/drupal7/sites/all/modules/honeypot/tests/honeypot_test.info b/drupal7/sites/all/modules/honeypot/tests/honeypot_test.info
index d8e102b9..89aa78bc 100644
--- a/drupal7/sites/all/modules/honeypot/tests/honeypot_test.info
+++ b/drupal7/sites/all/modules/honeypot/tests/honeypot_test.info
@@ -4,9 +4,8 @@ core = 7.x
 package = Testing
 hidden = true
 
-; Information added by Drupal.org packaging script on 2018-02-27
-version = "7.x-1.24"
+; Information added by Drupal.org packaging script on 2018-08-09
+version = "7.x-1.25"
 core = "7.x"
 project = "honeypot"
-datestamp = "1519706887"
-
+datestamp = "1533849190"
diff --git a/drupal7/sites/all/modules/ldap/INSTALL.txt b/drupal7/sites/all/modules/ldap/INSTALL.txt
index c3bc12ee..96efd897 100644
--- a/drupal7/sites/all/modules/ldap/INSTALL.txt
+++ b/drupal7/sites/all/modules/ldap/INSTALL.txt
@@ -1,41 +1,64 @@
-
 ==================================================================================
-LDAP Installation instructions:
+Prerequisites
 ==================================================================================
 
-Note:  This does not automatically upgrade for Drupal 6 LDAP Integration Modules.
-	This functionality may be developed. Some notes are below.
+To set up LDAP efficiently, you need to acquire the relevant information for the
+domain you are authenticating against.
+
+Contact your organization's staff to receive the necessary information. This
+should include:
+
+* The servers available to you (hostname, port, encryption preference)
+* The binding method (service account including credentials, if necessary)
+* If applicable, the structure of the data you are trying to sync, e.g.
+sAMAccountName is the unique name attribute for your Active Directory.
+
+### Requirements
 
-1) Download the whole package of files from
-   http://drupal.org/project/ldap
+The following requirements need to be met for you to work with any of the LDAP
+modules.
+
+* PHP version 5.6.
+* PHP LDAP extension.
+
+==================================================================================
+ Installation instructions:
+==================================================================================
 
-2) Upload the LDAP files to the modules directory.
+1) Download the LDAP module as you would any other.
 
-3) Go to admin/build/modules and enable the needed modules from the
-   Lightweight Directory Access Protocal group.
+2) Go to admin/build/modules and enable the needed modules from the
+   Lightweight Directory Access Protocol group.
 
-4) Enable and configure ldap servers and configure at least one server.
+3) Enable and configure ldap servers and configure at least one server.
 
-5) Enable the other LDAP modules you need.
+4) Enable the other LDAP modules you need.
 
-6) LDAP Help is just for debugging and administrator help.  Use it if you have problems.
-Disable it in production; it adds no functionality or end user help.
+5) LDAP Help is just for debugging and administrator help. Use it if you have
+problems. Disable it in production; it adds no functionality or end user help.
 
 ==================================================================================
-Older PHP versions
+ Configuration overrides
 ==================================================================================
-These modules will NOT work If you are using PHP 4 or any other version less
-than 5.1.
+
+If you need to selectively disable LDAP functionality and cannot disable the
+modules, use configuration overrides, such as the following in settings.php and
+clearing your cache afterwards.
+
+// Disable the server you are syncing users from LDAP to Drupal.
+$conf['ldap_user_conf']['drupalAcctProvisionServer'] = 0;
+// Disable LDAP authentication.
+$conf['ldap_authentication_conf']['sids'] = [];
+// Set bind DN and bind password for service account.
+$conf['ldap_servers_overrides']['my_server']['binddn'] = 'my_dn';
+$conf['ldap_servers_overrides']['my_server']['bindpw'] = 'my_password';
+
+IMPORTANT: These overrides will change the data in your admin forms, saving them
+will save them permanently in the database.
 
 ==================================================================================
 More documentation is available at:
 
  http://drupal.org/project/ldap -- project homepage
  http://drupal.org/node/997082 - project documentation
-==================================================================================
-
-Crossgrading:
-
-Drupal 6 ldapauth -> ldap_authentication
-- get rid of authmap records associated with ldapauth with the following sql:
-DELETE FROM authmap WHERE module = 'ldapauth'
+==================================================================================
\ No newline at end of file
diff --git a/drupal7/sites/all/modules/ldap/ldap_authentication/LdapAuthenticationConfAdmin.class.php b/drupal7/sites/all/modules/ldap/ldap_authentication/LdapAuthenticationConfAdmin.class.php
index 21f9493d..5c43c51d 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authentication/LdapAuthenticationConfAdmin.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_authentication/LdapAuthenticationConfAdmin.class.php
@@ -114,9 +114,8 @@ class LdapAuthenticationConfAdmin extends LdapAuthenticationConf {
         'users of this site to be authenticated by visiting the URL ' .
         '"user/login/sso, or automatically if selecting "automated ' .
         'single sign-on" below. Set up of LDAP authentication must be ' .
-        'performed on the web server. Please review the !readme file ' .
-        'for more information.', array('!readme' =>
-        l(t('README.txt'), drupal_get_path('module', 'ldap_sso') . '/README.txt')))
+        'performed on the web server. Please review the readme file of the '.
+        'ldap_sso module for more information.')
         . '</p>';
 
       $values['ssoExcludedPathsDescription'] = '<p>' .
@@ -379,7 +378,7 @@ class LdapAuthenticationConfAdmin extends LdapAuthenticationConf {
       '#title' => t('Deny access to users without Ldap Authorization Module
         authorization mappings such as Drupal roles.
         Requires LDAP Authorization to be enabled and configured!'),
-      '#default_value' =>  $this->excludeIfNoAuthorizations,
+      '#default_value' => $this->excludeIfNoAuthorizations,
       '#description' => t($this->excludeIfNoAuthorizationsDescription, $tokens),
       '#disabled' => (boolean)(!module_exists('ldap_authorization')),
     );
diff --git a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.admin.inc b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.admin.inc
index ffd83261..a9164cb0 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.admin.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.admin.inc
@@ -5,7 +5,6 @@
  * Administrative page callbacks for the ldap_authentication module.
  */
 
-
 /**
  * form for adding, updating, and deleting a single ldap authorization mapping
  *
diff --git a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.api.php b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.api.php
index cde4a31b..c656af1d 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.api.php
+++ b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.api.php
@@ -2,43 +2,44 @@
 
 /**
  * @file
- * summary of hooks and other developer related functions
+ * Summary of hooks and other developer related functions.
  */
 
 /**
- * Allow a custom module to examine the user's ldap details
- * and refuse authentication.  See also: http://drupal.org/node/1634930
+ * Allow a custom module to check user's ldap details and refuse authentication.
  *
- *  @param array $ldap_user
- *    See README.developers.txt for structure
- *  @param string $name
- *    The drupal account name or proposed drupal account name if none exists yet
- *  @param boolean $hook_result
- *    TRUE for allow, FALSE for deny.
- *    If set to TRUE or FALSE, another module has already set this and function should
- *    be careful about overriding this.
+ * See also: http://drupal.org/node/1634930.
  *
- *  @return boolean &$hook_result passed by reference
+ * @param array $ldap_user
+ *   See README.developers.txt for structure.
+ * @param string $name
+ *   The drupal account name or proposed drupal account name if none exists yet.
+ * @param bool $hook_result
+ *   TRUE for allow, FALSE for deny.
+ *   If set to TRUE or FALSE, another module has already set this and function
+ *   should be careful about overriding this.
  */
-function hook_ldap_authentication_allowuser_results_alter($ldap_user, $name, &$hook_result) {
-
-  if ($hook_result === FALSE) { // other module has denied user, should not override
+function hook_ldap_authentication_allowuser_results_alter(array $ldap_user, $name, &$hook_result) {
+  // Other module has denied user, should not override.
+  if ($hook_result === FALSE) {
     return;
   }
-  elseif ($hook_result === TRUE) { // other module has allowed, maybe override
+  // Other module has allowed, maybe override.
+  elseif ($hook_result === TRUE) {
     if (mymodule_dissapproves($ldap_user, $name)) {
       $hook_result = FALSE;
     }
   }
-
 }
 
 /**
- * Allow a custom module to alter $ldap_user before validating user login.
+ * Allow a custom module to alter $ldap_user.
  *
- *  @param array $ldap_user
- *    See README.developers.txt for structure
+ * @param array $ldap_user
+ *   See README.developers.txt for structure.
+ * @param array $params
+ *   Array of parameters. Includes account key with the Drupal account as value.
  */
-function hook_ldap_entry_alter(&$ldap_user) {
+function hook_ldap_entry_alter(array &$ldap_user, array $params) {
   $ldap_user['mail'] = 'newmail@example.com';
 }
diff --git a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.inc b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.inc
index ac2e9d1e..58187df0 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.inc
@@ -36,7 +36,7 @@ function _ldap_authentication_login_form_alter(&$form, &$form_state, $form_id) {
 
   if (@in_array('user_login_authenticate_validate', $form['#validate']) && $auth_conf->authenticationMode) {
     $key = array_search('user_login_authenticate_validate', $form['#validate']);
-    $form['#validate'][$key] =  'ldap_authentication_core_override_user_login_authenticate_validate';
+    $form['#validate'][$key] = 'ldap_authentication_core_override_user_login_authenticate_validate';
     array_splice($form['#validate'], $key + 1, 0, 'ldap_authentication_user_login_authenticate_validate');
   }
 
@@ -207,7 +207,7 @@ function _ldap_authentication_user_login_authenticate_validate(&$form_state, $re
     elseif ($auth_conf->authenticationMode == LDAP_AUTHENTICATION_EXCLUSIVE) {
       if ($detailed_watchdog_log) {
         watchdog('ldap_authentication', '%username : Previously authenticated in exclusive mode or uid is not 1.  Clear uid
-        in form_state and attempt ldap authentication.',  $watchdog_tokens, WATCHDOG_DEBUG);
+        in form_state and attempt ldap authentication.', $watchdog_tokens, WATCHDOG_DEBUG);
       }
       $form_state['uid'] = NULL;  // passed previous authentication, but only ldap should be used so override
     }
@@ -217,7 +217,7 @@ function _ldap_authentication_user_login_authenticate_validate(&$form_state, $re
   * II. Exit if no authentication servers.
   */
   if (!$auth_conf->hasEnabledAuthenticationServers()) {
-    watchdog('ldap_authentication',  'No LDAP servers configured.', array(), WATCHDOG_ERROR);
+    watchdog('ldap_authentication', 'No LDAP servers configured.', array(), WATCHDOG_ERROR);
     form_set_error('name', 'Server Error:  No LDAP servers configured.');
     return;
   }
@@ -236,7 +236,8 @@ function _ldap_authentication_user_login_authenticate_validate(&$form_state, $re
    * IV. test credentials and if available get corresponding ldap user and ldap server
    */
   list($authentication_result, $ldap_user, $ldap_server_authenticated_on) = ldap_authentication_test_credentials($auth_conf, $sso_login, $authname, $form_state['values']['pass'], $watchdog_tokens);
-  drupal_alter('ldap_entry', $ldap_user);
+  $params['account'] = $drupal_account;
+  drupal_alter('ldap_entry', $ldap_user, $params);
   if ($authentication_result != LDAP_AUTHENTICATION_RESULT_SUCCESS) {
     ldap_authentication_fail_response($authentication_result, $auth_conf, $detailed_watchdog_log, $watchdog_tokens);
     return;
@@ -257,7 +258,7 @@ function _ldap_authentication_user_login_authenticate_validate(&$form_state, $re
     $watchdog_tokens['%account_name_attr'] = $ldap_server_authenticated_on->account_name_attr;
     $drupal_accountname = $ldap_user['attr'][ldap_server_massage_text($ldap_server_authenticated_on->account_name_attr, 'attr_name', LDAP_SERVER_MASSAGE_QUERY_ARRAY)][0];
     if (!$drupal_accountname) {
-      watchdog('ldap_authentication',  'Derived drupal username from attribute %account_name_attr returned no username for authname %authname.', $watchdog_tokens, WATCHDOG_ERROR);
+      watchdog('ldap_authentication', 'Derived drupal username from attribute %account_name_attr returned no username for authname %authname.', $watchdog_tokens, WATCHDOG_ERROR);
       return;
     }
   }
@@ -369,7 +370,7 @@ function _ldap_authentication_user_login_authenticate_validate(&$form_state, $re
 
     $watchdog_tokens['%username'] = $drupal_account->name;
     if (!$updated_account = user_save($drupal_account, $user_edit)) {
-      watchdog('ldap_authentication', 'Failed to make changes to user %username updated %changed.', $watchdog_tokens,  WATCHDOG_ERROR);
+      watchdog('ldap_authentication', 'Failed to make changes to user %username updated %changed.', $watchdog_tokens, WATCHDOG_ERROR);
     }
     elseif ($auth_conf->emailUpdate == LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_ENABLE_NOTIFY ) {
       if (isset($user_edit['mail'])) {
@@ -513,10 +514,10 @@ function ldap_authentication_corresponding_drupal_user($authname, $auth_conf, &$
     $drupal_account_is_authmapped = isset($authmaps['ldap_user']);
     $user_data = $drupal_account->data;
     if ($drupal_account->uid == 1 && $detailed_watchdog_log) {
-      watchdog('ldap_authentication',  '%username : Drupal username maps to user 1, so do not authenticate with ldap', $watchdog_tokens, WATCHDOG_DEBUG);
+      watchdog('ldap_authentication', '%username : Drupal username maps to user 1, so do not authenticate with ldap', $watchdog_tokens, WATCHDOG_DEBUG);
     }
     elseif ($detailed_watchdog_log) {
-      watchdog('ldap_authentication',  '%username : Drupal User Account found.  Continuing on to attempt ldap authentication', $watchdog_tokens, WATCHDOG_DEBUG);
+      watchdog('ldap_authentication', '%username : Drupal User Account found.  Continuing on to attempt ldap authentication', $watchdog_tokens, WATCHDOG_DEBUG);
     }
   }
   else {  // account does not exist
@@ -552,13 +553,13 @@ function ldap_authentication_test_credentials($auth_conf, $sso_login, $authname,
       $authentication_result = LDAP_AUTHENTICATION_RESULT_FAIL_CONNECT;
       $watchdog_tokens['%err_msg'] = $ldap_server->errorMsg('ldap');
       if ($detailed_watchdog_log) {
-        watchdog('ldap_authentication',  '%username : Failed connecting to %sid.  Error: %err_msg', $watchdog_tokens, WATCHDOG_DEBUG);
+        watchdog('ldap_authentication', '%username : Failed connecting to %sid.  Error: %err_msg', $watchdog_tokens, WATCHDOG_DEBUG);
       }
       $watchdog_tokens['%err_msg'] = NULL;
       continue; // next server, please
     }
     elseif ($detailed_watchdog_log) {
-      watchdog('ldap_authentication',  '%username : Success at connecting to %sid', $watchdog_tokens, WATCHDOG_DEBUG);
+      watchdog('ldap_authentication', '%username : Success at connecting to %sid', $watchdog_tokens, WATCHDOG_DEBUG);
     }
 
     $bind_success = FALSE;
@@ -576,7 +577,7 @@ function ldap_authentication_test_credentials($auth_conf, $sso_login, $authname,
       // with sso enabled this method of binding isn't valid
       foreach ($ldap_server->basedn as $basedn) {
         $search = array('%basedn', '%username');
-        $transformname =  $ldap_server->userUsernameToLdapNameTransform($authname, $watchdog_tokens);
+        $transformname = $ldap_server->userUsernameToLdapNameTransform($authname, $watchdog_tokens);
         $replace = array($basedn, $transformname);
         $userdn = str_replace($search, $replace, $ldap_server->user_dn_expression);
         $bind_success = ($ldap_server->bind($userdn, $password, FALSE) == LDAP_SUCCESS);
@@ -701,16 +702,16 @@ function ldap_authentication_test_credentials($auth_conf, $sso_login, $authname,
 
   $watchdog_tokens['%result'] = $result;
   $watchdog_tokens['%auth_result'] = $authentication_result;
-  $watchdog_tokens['%err_text'] =  _ldap_authentication_err_text($authentication_result) ;
+  $watchdog_tokens['%err_text'] = _ldap_authentication_err_text($authentication_result) ;
   if ($detailed_watchdog_log) {
-    watchdog('ldap_authentication',  '%username : Authentication result id=%result auth_result=%auth_result (%err_text)', $watchdog_tokens, WATCHDOG_DEBUG);
+    watchdog('ldap_authentication', '%username : Authentication result id=%result auth_result=%auth_result (%err_text)', $watchdog_tokens, WATCHDOG_DEBUG);
   }
 
   return array($authentication_result, $ldap_user, $ldap_server);
 }
 
 function ldap_authentication_fail_response($authentication_result, $auth_conf, $detailed_watchdog_log, &$watchdog_tokens) {
-  $watchdog_tokens['%err_text'] =  _ldap_authentication_err_text($authentication_result);
+  $watchdog_tokens['%err_text'] = _ldap_authentication_err_text($authentication_result);
  // fail scenario 1.  ldap auth exclusive and failed  throw error so no other authentication methods are allowed
   if ($auth_conf->authenticationMode == LDAP_AUTHENTICATION_EXCLUSIVE) {
     if ($detailed_watchdog_log) {
@@ -754,7 +755,7 @@ function _ldap_authentication_err_text($error) {
     break;
 
     case LDAP_AUTHENTICATION_RESULT_FAIL_FIND:
-    $msg =  t('Sorry, unrecognized username or password.');
+    $msg = t('Sorry, unrecognized username or password.');
     break;
 
     case LDAP_AUTHENTICATION_RESULT_FAIL_DISALLOWED:
@@ -762,7 +763,7 @@ function _ldap_authentication_err_text($error) {
     break;
 
     case LDAP_AUTHENTICATION_RESULT_FAIL_CREDENTIALS:
-    $msg =  t('Sorry, unrecognized username or password.');
+    $msg = t('Sorry, unrecognized username or password.');
     break;
 
     case LDAP_AUTHENTICATION_RESULT_FAIL_GENERIC:
@@ -777,4 +778,3 @@ function _ldap_authentication_err_text($error) {
 
   return $msg;
 }
-
diff --git a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.info b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.info
index 97c0617c..53fd0491 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.info
+++ b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.info
@@ -16,9 +16,8 @@ files[] = tests/ldap_authentication.test
 
 test_dependencies[] = ldap_sso:ldap_sso
 
-; Information added by Drupal.org packaging script on 2017-08-27
-version = "7.x-2.3"
+; Information added by Drupal.org packaging script on 2018-08-13
+version = "7.x-2.4"
 core = "7.x"
 project = "ldap"
-datestamp = "1503841448"
-
+datestamp = "1534201086"
diff --git a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.install b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.install
index 8b6f8c5d..1adba41f 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.install
+++ b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.install
@@ -5,7 +5,6 @@
  * Install, update and uninstall functions for the LDAP authentication module.
  */
 
-
 /**
  * Implements hook_requirements().
  */
diff --git a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.module b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.module
index 3b1409cc..d816a425 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.module
+++ b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.module
@@ -10,26 +10,26 @@
  */
 define('LDAP_AUTHENTICATION_PROJECT_TAG', 'ldap');
 
-define('LDAP_AUTHENTICATION_MIXED',        1);
-define('LDAP_AUTHENTICATION_EXCLUSIVE',    2);
+define('LDAP_AUTHENTICATION_MIXED', 1);
+define('LDAP_AUTHENTICATION_EXCLUSIVE', 2);
 define('LDAP_AUTHENTICATION_MODE_DEFAULT', 1);
 
 define('LDAP_AUTHENTICATION_EXCL_IF_NO_AUTHZ_DEFAULT', 0);
-define('LDAP_AUTHENTICATION_CONFLICT_LOG',             1);
-define('LDAP_AUTHENTICATION_CONFLICT_RESOLVE',         2);
+define('LDAP_AUTHENTICATION_CONFLICT_LOG', 1);
+define('LDAP_AUTHENTICATION_CONFLICT_RESOLVE', 2);
 define('LDAP_AUTHENTICATION_CONFLICT_RESOLVE_DEFAULT', 2);
 
-define('LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_ENABLE_NOTIFY',  1);
-define('LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_ENABLE',         2);
-define('LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_DISABLE',        3);
-define('LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_DEFAULT',        1);
+define('LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_ENABLE_NOTIFY', 1);
+define('LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_ENABLE', 2);
+define('LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_DISABLE', 3);
+define('LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_DEFAULT', 1);
 
-define('LDAP_AUTHENTICATION_EMAIL_FIELD_REMOVE',       2);
-define('LDAP_AUTHENTICATION_EMAIL_FIELD_DISABLE',      3);
-define('LDAP_AUTHENTICATION_EMAIL_FIELD_ALLOW',        4);
-define('LDAP_AUTHENTICATION_EMAIL_FIELD_DEFAULT',      3);
+define('LDAP_AUTHENTICATION_EMAIL_FIELD_REMOVE', 2);
+define('LDAP_AUTHENTICATION_EMAIL_FIELD_DISABLE', 3);
+define('LDAP_AUTHENTICATION_EMAIL_FIELD_ALLOW', 4);
+define('LDAP_AUTHENTICATION_EMAIL_FIELD_DEFAULT', 3);
 
-define('LDAP_AUTHENTICATION_EMAIL_TEMPLATE_NONE',  1);
+define('LDAP_AUTHENTICATION_EMAIL_TEMPLATE_NONE', 1);
 define('LDAP_AUTHENTICATION_EMAIL_TEMPLATE_ALWAYS', 2);
 define('LDAP_AUTHENTICATION_EMAIL_TEMPLATE_IF_EMPTY', 3);
 define('LDAP_AUTHENTICATION_EMAIL_TEMPLATE_DEFAULT', 3);
@@ -42,23 +42,23 @@ define('LDAP_AUTHENTICATION_TEMPLATE_USAGE_NEVER_UPDATE_DEFAULT', 0);
 define('LDAP_AUTHENTICATION_TEMPLATE_USAGE_RESOLVE_CONFLICT_DEFAULT', 0);
 define('LDAP_AUTHENTICATION_TEMPLATE_USAGE_PROMPT_USER_DEFAULT', 0);
 
-define('LDAP_AUTHENTICATION_PASSWORD_FIELD_SHOW',       2);
-define('LDAP_AUTHENTICATION_PASSWORD_FIELD_HIDE',       3);
-define('LDAP_AUTHENTICATION_PASSWORD_FIELD_ALLOW',      4);
-define('LDAP_AUTHENTICATION_PASSWORD_FIELD_DEFAULT',    2);
-
-define('LDAP_AUTHENTICATION_RESULT_FAIL_CONNECT',      1);
-define('LDAP_AUTHENTICATION_RESULT_FAIL_BIND',         2);
-define('LDAP_AUTHENTICATION_RESULT_FAIL_FIND',         3);
-define('LDAP_AUTHENTICATION_RESULT_FAIL_DISALLOWED',   4);
-define('LDAP_AUTHENTICATION_RESULT_FAIL_CREDENTIALS',  5);
-define('LDAP_AUTHENTICATION_RESULT_SUCCESS',           6);
-define('LDAP_AUTHENTICATION_RESULT_FAIL_GENERIC',      7);
+define('LDAP_AUTHENTICATION_PASSWORD_FIELD_SHOW', 2);
+define('LDAP_AUTHENTICATION_PASSWORD_FIELD_HIDE', 3);
+define('LDAP_AUTHENTICATION_PASSWORD_FIELD_ALLOW', 4);
+define('LDAP_AUTHENTICATION_PASSWORD_FIELD_DEFAULT', 2);
+
+define('LDAP_AUTHENTICATION_RESULT_FAIL_CONNECT', 1);
+define('LDAP_AUTHENTICATION_RESULT_FAIL_BIND', 2);
+define('LDAP_AUTHENTICATION_RESULT_FAIL_FIND', 3);
+define('LDAP_AUTHENTICATION_RESULT_FAIL_DISALLOWED', 4);
+define('LDAP_AUTHENTICATION_RESULT_FAIL_CREDENTIALS', 5);
+define('LDAP_AUTHENTICATION_RESULT_SUCCESS', 6);
+define('LDAP_AUTHENTICATION_RESULT_FAIL_GENERIC', 7);
 define('LDAP_AUTHENTICATION_RESULT_FAIL_SERVER'      , 8);
 
-define('LDAP_AUTHENTICATION_ACCT_CREATION_DEFAULT',                4);
+define('LDAP_AUTHENTICATION_ACCT_CREATION_DEFAULT', 4);
 define('LDAP_AUTHENTICATION_ACCT_CREATION_USER_SETTINGS_FOR_LDAP', 1);
-define('LDAP_AUTHENTICATION_ACCT_CREATION_LDAP_BEHAVIOR',          4);
+define('LDAP_AUTHENTICATION_ACCT_CREATION_LDAP_BEHAVIOR', 4);
 
 define('LDAP_AUTHENTICATION_HELP_LINK_TEXT_DEFAULT', 'Logon Help');
 
@@ -250,7 +250,7 @@ function ldap_authentication_check_for_email_template() {
  * Implements hook_info().
  */
 function ldap_authentication_info($field = 0) {
-  $info['name']= 'ldap_authentication';
+  $info['name'] = 'ldap_authentication';
   $info['protocol'] = 'LDAP';
 
   if ($field) {
diff --git a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.theme.inc b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.theme.inc
index 15bd646c..7f604769 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.theme.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.theme.inc
@@ -48,10 +48,10 @@ function theme_ldap_authentication_user_pass_message($variables) {
     $msg = t('This page is only useful for the site administrator.  All other users
       need to reset their passwords');
     if ($auth_conf->ldapUserHelpLinkUrl) {
-      $msg .=  ' ' . t('at') . ' ' . l(t($auth_conf->ldapUserHelpLinkText), $auth_conf->ldapUserHelpLinkUrl) . '.';
+      $msg .= ' ' . t('at') . ' ' . l(t($auth_conf->ldapUserHelpLinkText), $auth_conf->ldapUserHelpLinkUrl) . '.';
     }
     else {
-      $msg .=  ' ' . t('with one of your organizations password management sites.');
+      $msg .= ' ' . t('with one of your organizations password management sites.');
     }
   }
   else { // mixed mode
diff --git a/drupal7/sites/all/modules/ldap/ldap_authentication/tests/ldap_authentication.test b/drupal7/sites/all/modules/ldap/ldap_authentication/tests/ldap_authentication.test
index 3c994640..a78aa9ea 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authentication/tests/ldap_authentication.test
+++ b/drupal7/sites/all/modules/ldap/ldap_authentication/tests/ldap_authentication.test
@@ -5,6 +5,7 @@
  * ldap_authentication simpletests
  *
  */
+
 module_load_include('php', 'ldap_test', 'LdapTestCase.class');
 module_load_include('module', 'ldap_authentication');
 
@@ -225,7 +226,7 @@ class LdapAuthenticationTestCase extends LdapTestCase {
     );
 
     $this->drupalPost('user', $edit, t('Log in'));
-    $this->assertText(t('Sorry, unrecognized username or password'),  'User 1 failed with bad password', $testid );
+    $this->assertText(t('Sorry, unrecognized username or password'), 'User 1 failed with bad password', $testid );
     $this->drupalLogout();
 
     /** LDAP_authen.EM.ULT.drupal.goodpwd - result: failed logon **/
@@ -677,7 +678,7 @@ class LdapAuthenticationTestCase extends LdapTestCase {
         module_exists('ldap_authentication') &&
         (variable_get('ldap_simpletest', 2) > 0)
       );
-    $this->assertTrue($setup_success, ' ldap_authentication UI setup successful',  $this->testId('user interface tests'));
+    $this->assertTrue($setup_success, ' ldap_authentication UI setup successful', $this->testId('user interface tests'));
 
     $sid = 'activedirectory1';
     $sids = array('activedirectory1');
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/LdapAuthorizationConsumerAbstract.class.php b/drupal7/sites/all/modules/ldap/ldap_authorization/LdapAuthorizationConsumerAbstract.class.php
index e2e45196..c3895b92 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/LdapAuthorizationConsumerAbstract.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/LdapAuthorizationConsumerAbstract.class.php
@@ -2,86 +2,122 @@
 
 /**
  * @file
- *
- * abstract class to represent an ldap_authorization consumer behavior
+ * Abstract class to represent an ldap_authorization consumer behavior
  * such as drupal_role, og_group, etc.  each authorization comsumer
  * will extend this class with its own class named
- * LdapAuthorizationConsumer<consumer type> such as LdapAuthorizationConsumerDrupalRole
- *
+ * LdapAuthorizationConsumer<consumer type> such as LdapAuthorizationConsumerDrupalRole.
  */
 
+/**
+ *
+ */
 class LdapAuthorizationConsumerAbstract {
 
-  public $consumerType = NULL; // machine name of consumer.  e.g. og_group, drupal_role, etc.
+  /**
+   * Machine name of consumer.  e.g. og_group, drupal_role, etc.
+   */
+  public $consumerType = NULL;
 
   /**
-   * the following properties are generally populated from a
+   * The following properties are generally populated from a
    * call to hook_ldap_authorization_consumer()
    */
-  public $name;  // user interface name of consumer. e.g.  drupal role, og group
-  public $namePlural; // user interface name of consumer. e.g. drupal roles, og groups
-  public $shortName; // user interface short name of consumer. e.g. role, group
-  public $shortNamePlural; //  user interface short name of consumer plural, e.g. roles, groups
-  public $description;// e.g. roles, groups
-  public $consumerModule; // module providing consumer functionality e.g. ldap_authorization_drupal_roles
 
-  public $consumerConf; // LDAPConsumerConf object class encapuslating admin form
-  public $testLink; // link to test this consumer
-  public $editLink; // link to configure this consumer
+  /**
+   * User interface name of consumer. e.g.  drupal role, og group.
+   */
+  public $name;
+
+  /**
+   * User interface name of consumer. e.g. drupal roles, og groups.
+   */
+  public $namePlural;
+  /**
+   * User interface short name of consumer. e.g. role, group.
+   */
+  public $shortName;
+
+  /**
+   * User interface short name of consumer plural, e.g. roles, groups.
+   */
+  public $shortNamePlural;
+
+  /**
+   * E.g. roles, groups.
+   */
+  public $description;
+  /**
+   * Module providing consumer functionality e.g. ldap_authorization_drupal_roles.
+   */
+  public $consumerModule;
+
+  /**
+   * LDAPConsumerConf object class encapuslating admin form.
+   */
+  public $consumerConf;
+
+  /**
+   * Link to test this consumer.
+   */
+  public $testLink;
+
+  /**
+   * Link to configure this consumer.
+   */
+  public $editLink;
 
   public $emptyConsumer = array(
     'exists' => TRUE,
     'value' => NULL,
     'name' => NULL,
-    'map_to_string' => NULL
-    );
+    'map_to_string' => NULL,
+  );
 
-   /**
+  /**
    * @property boolean $allowConsumerObjectCreation
    *
    *  Does this consumer module support creating consumer objects
    * (drupal roles,  og groups, etc.)
-   *
    */
 
   public $allowConsumerObjectCreation = FALSE;
 
-   /**
+  /**
    * @property boolean $detailedWatchdogLog
    *
    *  should watchdog log be used for debugging, useful for non programmers
    *  who don't have php debugging enabled
-   *
    */
   public $detailedWatchdogLog = FALSE;
 
 
-   /**
+  /**
    * @property array $defaultConsumerConfProperties
    * default properties for consumer admin UI form
    */
   public $defaultConsumerConfProperties = array(
-      'onlyApplyToLdapAuthenticated' => TRUE,
-      'useMappingsAsFilter' => TRUE,
-      'synchOnLogon' => TRUE,
-      'revokeLdapProvisioned' => TRUE,
-      'regrantLdapProvisioned' => TRUE,
-      'createConsumers' => TRUE,
-      );
-
- /**
-   * Constructor Method
-   *
-   * @param string $consumer_type e.g. drupal_role, og_group
-   * @param array $params as associative array of default properties
+    'onlyApplyToLdapAuthenticated' => TRUE,
+    'useMappingsAsFilter' => TRUE,
+    'synchOnLogon' => TRUE,
+    'revokeLdapProvisioned' => TRUE,
+    'regrantLdapProvisioned' => TRUE,
+    'createConsumers' => TRUE,
+  );
+
+  /**
+   * Constructor Method.
    *
+   * @param string $consumer_type
+   *   e.g. drupal_role, og_group.
+   * @param array $params
+   *   as associative array of default properties.
    */
-  function __construct($consumer_type, $params) {
+  public function __construct($consumer_type, $params) {
     $this->consumerType = $consumer_type;
     $this->name = $params['consumer_name'];
-    $this->namePlural= $params['consumer_name_plural'];
+    $this->namePlural = $params['consumer_name_plural'];
     $this->shortName = $params['consumer_short_name'];
-    $this->shortNamePlural= $params['consumer_short_name_plural'];
+    $this->shortNamePlural = $params['consumer_short_name_plural'];
     $this->consumerModule = $params['consumer_module'];
     $this->mappingDirections = $params['consumer_mapping_directions'];
     $this->testLink = l(t('test') . ' ' . $this->name, LDAP_SERVERS_MENU_BASE_PATH . '/authorization/test/' . $this->consumerType);
@@ -90,15 +126,14 @@ class LdapAuthorizationConsumerAbstract {
     $this->consumerConf = new LdapAuthorizationConsumerConf($this);
   }
 
-
   /**
-   * function to normalize mappings
+   * Function to normalize mappings
    * should be overridden when mappings are not stored as map|authorization_id format
    * where authorization_id is the format returned by
    *   LdapAuthorizationConsumerAbstract::usersAuthorizations()
    *
-   * for example ldap_authorization_og may store mapping target as:
-   *   Campus Accounts|group-name=knitters,role-name=administrator member
+   * For example ldap_authorization_og may store mapping target as:
+   *   Campus Accounts|group-name=knitters,role-name=administrator member.
    *
    *   normalized mappings are of form such as for organic groups:
    *
@@ -136,51 +171,57 @@ class LdapAuthorizationConsumerAbstract {
   }
 
   /**
-   *
-   * create authorization consumers
+   * Create authorization consumers.
    *
    * @param string (lowercase) $consumer_id
-   * @param array $consumer as associative array with the following key/values
+   * @param array $consumer
+   *   as associative array with the following key/values
    *   'value' => NULL | mixed consumer such as drupal role name, og group entity, etc.
    *   'name' => name of consumer for UI, logging etc.
    *   'map_to_string' => string mapped to in ldap authorization.  mixed case string
    *   'exists' => TRUE indicates consumer is known to exist,
    *               FALSE indicates consumer is known to not exist,
-   *               NULL indicate consumer's existance not checked yet
-   *
+   *               NULL indicate consumer's existance not checked yet.
    */
   public function createConsumer($consumer_id, $consumer) {
-    // method must be overridden
+    // Method must be overridden.
   }
 
   /**
-   * populate consumer side of $consumers array
+   * Populate consumer side of $consumers array.
    *
-   * @param array $consumers as associative array keyed on $consumer_id with values
+   * @param array $consumers
+   *   as associative array keyed on $consumer_id with values
    *   of $consumer.  $consumer_id and $consumer have structure in LdapAuthorizationConsumerAbstractClass::createConsumer
-   *   when values are $consumer['exists'] != TRUE need to be populated by consumer object
-   * @param boolean $create_missing_consumers indicates if consumers (drupal roles, og groups, etc) should be created
-   *   if values are NULL, object will be created if
+   *   when values are $consumer['exists'] != TRUE need to be populated by consumer object.
+   * @param bool $create_missing_consumers
+   *   indicates if consumers (drupal roles, og groups, etc) should be created
+   *   if values are NULL, object will be created if.
    *
    * @return $consumers by reference
    */
-
   public function populateConsumersFromConsumerIds(&$consumers, $create_missing_consumers = FALSE) {
-    // method must be overridden
+    // Method must be overridden.
   }
 
+  /**
+   *
+   */
   public function authorizationDiff($initial, $current) {
     return array_diff($initial, $current);
   }
 
-
   /**
-   * grant authorizations to a user
+   * Grant authorizations to a user.
    *
-   * @param object $user drupal user object
-   * @param array $consumers in form of LdapAuthorizationConsumerAbstractClass::populateConsumersFromConsumerIds
-   * @param array $ldap_entry is ldap data from ldap entry which drupal user is mapped to
-   * @param boolean $user_save.  should user object be saved by authorizationGrant method
+   * @param object $user
+   *   drupal user object.
+   * @param array $consumers
+   *   in form of LdapAuthorizationConsumerAbstractClass::populateConsumersFromConsumerIds.
+   * @param array $ldap_entry
+   *   is ldap data from ldap entry which drupal user is mapped to.
+   * @param bool $user_save
+   *   should user object be saved by authorizationGrant method.
    *
    * @return array $results.  Array of form
    *   array(
@@ -190,21 +231,24 @@ class LdapAuthorizationConsumerAbstract {
    *   where 1s and 0s represent success and failure to grant
    *
    *
-   *  method may be desireable to override, if consumer benefits from adding grants as a group rather than one at a time
+   *   method may be desireable to override, if consumer benefits from adding grants as a group rather than one at a time
    */
-
   public function authorizationGrant(&$user, &$user_auth_data, $consumers, $ldap_entry = NULL, $user_save = TRUE) {
     $this->filterOffPastAuthorizationRecords($user, $user_auth_data);
     $this->grantsAndRevokes('grant', $user, $user_auth_data, $consumers, $ldap_entry, $user_save);
   }
 
   /**
-   * revoke authorizations to a user
+   * Revoke authorizations to a user.
    *
-   * @param object $user drupal user object
-   * @param array $consumers in form of LdapAuthorizationConsumerAbstractClass::populateConsumersFromConsumerIds
-   * @param array $ldap_entry is ldap data from ldap entry which drupal user is mapped to
-   * @param boolean $user_save.  should user object be saved by authorizationGrant method
+   * @param object $user
+   *   drupal user object.
+   * @param array $consumers
+   *   in form of LdapAuthorizationConsumerAbstractClass::populateConsumersFromConsumerIds.
+   * @param array $ldap_entry
+   *   is ldap data from ldap entry which drupal user is mapped to.
+   * @param bool $user_save
+   *   should user object be saved by authorizationGrant method.
    *
    * @return array $results.  Array of form
    *   array(
@@ -212,20 +256,17 @@ class LdapAuthorizationConsumerAbstract {
    *    <authz consumer id2> => 0,
    *   )
    *   where 1s and 0s represent success and failure to revoke
-   *  $user_auth_data is returned by reference
+   *   $user_auth_data is returned by reference
    *
-   *  method may be desireable to override, if consumer benefits from revoking grants as a group rather than one at a time
+   *   method may be desireable to override, if consumer benefits from revoking grants as a group rather than one at a time
    */
-
   public function authorizationRevoke(&$user, &$user_auth_data, $consumers, $ldap_entry, $user_save = TRUE) {
     $this->filterOffPastAuthorizationRecords($user, $user_auth_data);
     $this->grantsAndRevokes('revoke', $user, $user_auth_data, $consumers, $ldap_entry, $user_save);
   }
 
-
-
   /**
-   * this is a function to clear off
+   * This is a function to clear off.
    */
   public function filterOffPastAuthorizationRecords(&$user, &$user_auth_data, $time = NULL) {
     if ($time != NULL || variable_get('ldap_help_user_data_clear', 0)) {
@@ -244,36 +285,39 @@ class LdapAuthorizationConsumerAbstract {
   }
 
   /**
-   * some authorization schemes such as organic groups, require a certain order.  implement this method
-   * to sort consumer ids/authorization ids
-   *
-   * @param string $op 'grant' or 'revoke' signifying what to do with the $consumer_ids
-   * @param $consumers associative array in form of LdapAuthorizationConsumerAbstract::populateConsumersFromConsumerIds
+   * Some authorization schemes such as organic groups, require a certain order.  implement this method
+   * to sort consumer ids/authorization ids.
    *
-   * alters $consumers by reference
+   * @param string $op
+   *   'grant' or 'revoke' signifying what to do with the $consumer_ids.
+   * @param $consumers
+   *   associative array in form of LdapAuthorizationConsumerAbstract::populateConsumersFromConsumerIds
    *
+   *   alters $consumers by reference
    */
-  public function sortConsumerIds($op, &$consumers) { }
-
+  public function sortConsumerIds($op, &$consumers) {}
 
   /**
-   * attempt to flush related caches.  This will be something like og_invalidate_cache($gids)
-   *
-   * @param $consumers associative array in form of LdapAuthorizationConsumerAbstract::populateConsumersFromConsumerIds
-   *
+   * Attempt to flush related caches.  This will be something like og_invalidate_cache($gids)
    *
+   * @param $consumers
+   *   associative array in form of LdapAuthorizationConsumerAbstract::populateConsumersFromConsumerIds
    */
-  public function flushRelatedCaches($consumers = NULL) { }
+  public function flushRelatedCaches($consumers = NULL) {}
 
   /**
-   * @param string $op 'grant' or 'revoke' signifying what to do with the $consumer_ids
+   * @param string $op
+   *   'grant' or 'revoke' signifying what to do with the $consumer_ids.
    * @param drupal user object $object
-   * @param array $user_auth_data is array specific to this consumer_type.  Stored at $user->data['ldap_authorizations'][<consumer_type>]
-   * @param $consumers as associative array in form of LdapAuthorizationConsumerAbstract::populateConsumersFromConsumerIds
-   * @param array $ldap_entry, when available user's ldap entry.
-   * @param boolean $user_save indicates is user data array should be saved or not.  this depends on the implementation calling this function
+   * @param array $user_auth_data
+   *   is array specific to this consumer_type.  Stored at $user->data['ldap_authorizations'][<consumer_type>].
+   * @param $consumers
+   *   as associative array in form of LdapAuthorizationConsumerAbstract::populateConsumersFromConsumerIds
+   * @param array $ldap_entry,
+   *   when available user's ldap entry.
+   * @param bool $user_save
+   *   indicates is user data array should be saved or not.  this depends on the implementation calling this function.
    */
-
   protected function grantsAndRevokes($op, &$user, &$user_auth_data, $consumers, &$ldap_entry = NULL, $user_save = TRUE) {
 
     if (!is_array($user_auth_data)) {
@@ -305,7 +349,7 @@ class LdapAuthorizationConsumerAbstract {
       /** grants **/
       if ($op == 'grant') {
         if ($user_has_authorization && !$user_has_authorization_recorded) {
-          // grant case 1: authorization id already exists for user, but is not ldap provisioned.  mark as ldap provisioned, but don't regrant
+          // Grant case 1: authorization id already exists for user, but is not ldap provisioned.  mark as ldap provisioned, but don't regrant.
           $results[$consumer_id] = TRUE;
           $user_auth_data[$consumer_id] = array(
             'date_granted' => time(),
@@ -313,8 +357,9 @@ class LdapAuthorizationConsumerAbstract {
           );
         }
         elseif (!$user_has_authorization && $consumer['exists']) {
-          // grant case 2: consumer exists, but user is not member. grant authorization
-          $results[$consumer_id] = $this->grantSingleAuthorization($user, $consumer_id, $consumer, $user_auth_data, $user_save);  // allow consuming module to add additional data to $user_auth_data
+          // Grant case 2: consumer exists, but user is not member. grant authorization
+          // allow consuming module to add additional data to $user_auth_data.
+          $results[$consumer_id] = $this->grantSingleAuthorization($user, $consumer_id, $consumer, $user_auth_data, $user_save);
           $existing = empty($user_auth_data[$consumer_id]) ? array() : $user_auth_data[$consumer_id];
           $user_auth_data[$consumer_id] = $existing + array(
             'date_granted' => time(),
@@ -322,15 +367,15 @@ class LdapAuthorizationConsumerAbstract {
           );
         }
         elseif ($consumer['exists'] !== TRUE) {
-          // grant case 3: something is wrong. consumers should have been created before calling grantsAndRevokes
+          // Grant case 3: something is wrong. consumers should have been created before calling grantsAndRevokes.
           $results[$consumer_id] = FALSE;
         }
         elseif ($consumer['exists'] === TRUE) {
-          // grant case 4: consumer exists and user has authorization recorded. do nothing
+          // Grant case 4: consumer exists and user has authorization recorded. do nothing.
           $results[$consumer_id] = TRUE;
         }
         else {
-          // grant case 5: $consumer['exists'] has not been properly set before calling function
+          // Grant case 5: $consumer['exists'] has not been properly set before calling function.
           $results[$consumer_id] = FALSE;
           watchdog('ldap_authorization', "grantsAndRevokes consumer[exists] not properly set. consumer_id=$consumer_id, op=$op, username=%username", $watchdog_tokens, WATCHDOG_ERROR);
         }
@@ -340,17 +385,18 @@ class LdapAuthorizationConsumerAbstract {
 
         $log .= "revoking existing consumer object, ";
         if ($user_has_authorization) {
-          // revoke case 1: user has authorization, revoke it.  revokeSingleAuthorization will remove $user_auth_data[$consumer_id]
-          $results[$consumer_id] = $this->revokeSingleAuthorization($user, $consumer_id, $consumer, $user_auth_data, $user_save);  // defer to default for $user_save param
-          $log .= t(',result=') . (boolean)($results[$consumer_id]);
+          // Revoke case 1: user has authorization, revoke it.  revokeSingleAuthorization will remove $user_auth_data[$consumer_id]
+          // defer to default for $user_save param.
+          $results[$consumer_id] = $this->revokeSingleAuthorization($user, $consumer_id, $consumer, $user_auth_data, $user_save);
+          $log .= t(',result=') . (boolean) ($results[$consumer_id]);
         }
-        elseif ($user_has_authorization_recorded)  {
-          // revoke case 2: user does not have authorization, but has record of it. remove record of it.
+        elseif ($user_has_authorization_recorded) {
+          // Revoke case 2: user does not have authorization, but has record of it. remove record of it.
           unset($user_auth_data[$consumer_id]);
           $results[$consumer_id] = TRUE;
         }
         else {
-          // revoke case 3: trying to revoke something that isn't there
+          // Revoke case 3: trying to revoke something that isn't there.
           $results[$consumer_id] = TRUE;
         }
 
@@ -368,7 +414,8 @@ class LdapAuthorizationConsumerAbstract {
       $user_edit = $user->data;
       $user_edit['data']['ldap_authorizations'][$this->consumerType] = $user_auth_data;
       $user = user_save($user, $user_edit);
-      $user_auth_data = $user->data['ldap_authorizations'][$this->consumerType];  // reload this.
+      // Reload this.
+      $user_auth_data = $user->data['ldap_authorizations'][$this->consumerType];
     }
     $this->flushRelatedCaches($consumers);
 
@@ -382,85 +429,99 @@ class LdapAuthorizationConsumerAbstract {
   }
 
   /**
-   * @param drupal user object $user to have $consumer_id revoked
-   * @param string lower case $consumer_id $consumer_id such as drupal role name, og group name, etc.
-   * @param mixed $consumer.  depends on type of consumer.  Drupal roles are strings, og groups are ??
-   * @param array $user_auth_data array of $user data specific to this consumer type.
-   *   stored in $user->data['ldap_authorizations'][<consumer_type>] array
-   * @param boolean $reset signifying if caches associated with $consumer_id should be invalidated.
+   * @param drupal user object $user
+   *   to have $consumer_id revoked.
+   * @param string lower case $consumer_id
+   *   $consumer_id such as drupal role name, og group name, etc.
+   * @param mixed $consumer
+   *   depends on type of consumer.  Drupal roles are strings, og groups are ??
+   * @param array $user_auth_data
+   *   array of $user data specific to this consumer type.
+   *   stored in $user->data['ldap_authorizations'][<consumer_type>] array.
+   * @param bool $reset
+   *   signifying if caches associated with $consumer_id should be invalidated.
    *
-   * return boolen TRUE on success, FALSE on fail.  If user save is FALSE, the user object will
+   *   return boolen TRUE on success, FALSE on fail.  If user save is FALSE, the user object will
    *   not be saved and reloaded, so a returned TRUE may be misleading.
-   *   $user_auth_data should have successfully revoked consumer id removed
+   *   $user_auth_data should have successfully revoked consumer id removed.
    */
-
   public function revokeSingleAuthorization(&$user, $consumer_id, $consumer, &$user_auth_data, $user_save = FALSE, $reset = FALSE) {
-     // method must be overridden
+    // Method must be overridden.
   }
 
   /**
-   * @param stdClass $user as drupal user object to have $consumer_id granted
-   * @param string lower case $consumer_id $consumer_id such as drupal role name, og group name, etc.
-   * @param mixed $consumer.  depends on type of consumer.  Drupal roles are strings, og groups are ??
-   * @param array $user_auth_data in form
+   * @param object $user
+   *   as drupal user object to have $consumer_id granted.
+   * @param string lower case $consumer_id
+   *   $consumer_id such as drupal role name, og group name, etc.
+   * @param mixed $consumer
+   *   depends on type of consumer.  Drupal roles are strings, og groups are ??
+   * @param array $user_auth_data
+   *   in form
    *   array('my drupal role' =>
    *     'date_granted' => 1351814718,
    *     'consumer_id_mixed_case' => 'My Drupal Role',
    *     )
-   * @param boolean $reset signifying if caches associated with $consumer_id should be invalidated.
-   *  @return boolean FALSE on failure or TRUE on success
+   * @param bool $reset
+   *   signifying if caches associated with $consumer_id should be invalidated.
+   * @return boolean FALSE on failure or TRUE on success
    */
   public function grantSingleAuthorization(&$user, $consumer_id, $consumer, &$user_auth_data, $user_save = FALSE, $reset = FALSE) {
-     // method must be overridden
+    // Method must be overridden.
   }
 
   /**
-	 * Return all user consumer ids
-	 *   regardless of it they were granted by this module
-	 *
-	 * @param user object $user
-	 * @return array of consumer ids such as array('3-2','7-2'), array('admin','user_admin')
-	 */
-
+   * Return all user consumer ids
+   *   regardless of it they were granted by this module.
+   *
+   * @param user object $user
+   *
+   * @return array of consumer ids such as array('3-2','7-2'), array('admin','user_admin')
+   */
   public function usersAuthorizations(&$user) {
-    // method must be overridden
+    // Method must be overridden.
   }
 
   /**
-   * put authorization ids in displayable format
+   * Put authorization ids in displayable format.
    */
   public function convertToFriendlyAuthorizationIds($authorizations) {
     return $authorizations;
   }
 
   /**
-  * @param drupal user object $user to have $consumer_id granted
-  * @param string lower case $consumer_id $consumer_id such as drupal role name, og group name, etc.
-  * @param mixed $consumer.  depends on type of consumer.  Drupal roles are strings, og groups are ??
-  *
-  * return boolen TRUE on success, FALSE on fail.  If user save is FALSE, the user object will
-  *   not be saved and reloaded, so a returned TRUE may be misleading.
-  */
+   * @param drupal user object $user
+   *   to have $consumer_id granted.
+   * @param string lower case $consumer_id
+   *   $consumer_id such as drupal role name, og group name, etc.
+   * @param mixed $consumer
+   *   depends on type of consumer.  Drupal roles are strings, og groups are ??
+   *
+   *   return boolen TRUE on success, FALSE on fail.  If user save is FALSE, the user object will
+   *   not be saved and reloaded, so a returned TRUE may be misleading.
+   */
   public function createSingleAuthorization(&$user, $consumer_id, $consumer, &$user_auth_data) {
-     // method must be overridden
+    // Method must be overridden.
   }
 
   /**
-  * @param drupal user object $user
-  * @param string lowercase $consumer_id such as drupal role name, og group name, etc.
-  *
-  * @return boolean if an ldap_authorization_* module granted the authorization id
-  */
+   * @param drupal user object $user
+   * @param string lowercase $consumer_id
+   *   such as drupal role name, og group name, etc.
+   *
+   * @return boolean if an ldap_authorization_* module granted the authorization id
+   */
   public function hasLdapGrantedAuthorization(&$user, $consumer_id) {
     return (!empty($user->data['ldap_authorizations'][$this->consumerType][$consumer_id]));
   }
 
   /**
    * NOTE this is in mixed case, since we must rely on whatever module is storing
-   * the authorization id
+   * the authorization id.
    *
    * @param drupal user object $user
-   * @param string lowercase case $consumer_id such as drupal role name, og group name, etc.
+   * @param string lowercase case $consumer_id
+   *   such as drupal role name, og group name, etc.
    *
    * @return param boolean is user has authorization id, regardless of what module granted it.
    */
@@ -469,22 +530,21 @@ class LdapAuthorizationConsumerAbstract {
   }
 
   /**
-	 * Validate authorization mappings on LDAP Authorization OG Admin form.
-	 *
-	 * @param array $mapping single mapping in format generated in normalizeMappings method
-	 * @param array $form_values from authorization configuration form
-	 * @param boolean $clear_cache
-	 *
-	 * @return array of form array($message_type, $message_text) where message type is status, warning, or error
-	 *   and $message_text is what the user should see.
-	 *
-	 */
-
+   * Validate authorization mappings on LDAP Authorization OG Admin form.
+   *
+   * @param array $mapping
+   *   single mapping in format generated in normalizeMappings method.
+   * @param array $form_values
+   *   from authorization configuration form.
+   * @param bool $clear_cache
+   *
+   * @return array of form array($message_type, $message_text) where message type is status, warning, or error
+   *   and $message_text is what the user should see.
+   */
   public function validateAuthorizationMappingTarget($mapping, $form_values = NULL, $clear_cache = FALSE) {
     $message_type = NULL;
     $message_text = NULL;
     return array($message_type, $message_text);
   }
 
-
 }
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/LdapAuthorizationConsumerConf.class.php b/drupal7/sites/all/modules/ldap/ldap_authorization/LdapAuthorizationConsumerConf.class.php
index 589650c7..f466a90b 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/LdapAuthorizationConsumerConf.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/LdapAuthorizationConsumerConf.class.php
@@ -2,16 +2,15 @@
 
 /**
  * @file
- * class to encapsulate an ldap entry to authorization consumer ids mapping configuration
+ * Class to encapsulate an ldap entry to authorization consumer ids mapping configuration.
  *
- * this is the lightweight version of the class for use on logon etc.
+ * This is the lightweight version of the class for use on logon etc.
  * the LdapAuthorizationConsumerConfAdmin extends this class and has save,
  * iterate, etc methods.
- *
  */
 
 /**
- * LDAP Authorization Consumer Configuration
+ * LDAP Authorization Consumer Configuration.
  */
 class LdapAuthorizationConsumerConf {
 
@@ -44,16 +43,19 @@ class LdapAuthorizationConsumerConf {
   public $hasError = FALSE;
   public $errorName = NULL;
 
-
+  /**
+   *
+   */
   public function clearError() {
     $this->hasError = FALSE;
     $this->errorMsg = NULL;
     $this->errorName = NULL;
   }
-   /**
-   * Constructor Method
+
+  /**
+   * Constructor Method.
    */
-  function __construct(&$consumer, $_new = FALSE, $_sid = NULL) {
+  public function __construct(&$consumer, $_new = FALSE, $_sid = NULL) {
     $this->consumer = $consumer;
     $this->consumerType = $consumer->consumerType;
     if ($_new) {
@@ -66,10 +68,13 @@ class LdapAuthorizationConsumerConf {
         watchdog('ldap_authorization', 'failed to load existing %consumer object', array('%consumer' => $consumer->consumerType), WATCHDOG_ERROR);
       }
     }
-    // default value for deriveFromEntryAttrMatchingUserAttr set up this way for backward compatibility in 1.0 branch,
+    // Default value for deriveFromEntryAttrMatchingUserAttr set up this way for backward compatibility in 1.0 branch,
     // make deriveFromEntryAttrMatchingUserAttr default to dn in 2.0 branch.
   }
 
+  /**
+   *
+   */
   protected function loadFromDb() {
     if (module_exists('ctools')) {
       ctools_include('export');
@@ -83,7 +88,7 @@ class LdapAuthorizationConsumerConf {
     else {
       $select = db_select('ldap_authorization', 'ldap_authorization');
       $select->fields('ldap_authorization');
-      $select->condition('ldap_authorization.consumer_type',  $this->consumerType);
+      $select->condition('ldap_authorization.consumer_type', $this->consumerType);
       $server_record = $select->execute()->fetchObject();
     }
 
@@ -92,7 +97,7 @@ class LdapAuthorizationConsumerConf {
       return FALSE;
     }
 
-    foreach ($this->field_to_properties_map() as $db_field_name => $property_name ) {
+    foreach ($this->field_to_properties_map() as $db_field_name => $property_name) {
       if (isset($server_record->$db_field_name)) {
         if (in_array($db_field_name, $this->field_to_properties_serialized())) {
           $this->{$property_name} = unserialize($server_record->$db_field_name);
@@ -102,13 +107,15 @@ class LdapAuthorizationConsumerConf {
         }
       }
     }
-    $this->numericConsumerConfId = isset($server_record->numeric_consumer_conf_id)? $server_record->numeric_consumer_conf_id : NULL;
+    $this->numericConsumerConfId = isset($server_record->numeric_consumer_conf_id) ? $server_record->numeric_consumer_conf_id : NULL;
     $this->server = ldap_servers_get_servers($this->sid, NULL, TRUE);
     return TRUE;
 
   }
 
-  // direct mapping of db to object properties
+  /**
+   * Direct mapping of db to object properties.
+   */
   public static function field_to_properties_map() {
     return array(
       'sid' => 'sid',
@@ -127,20 +134,26 @@ class LdapAuthorizationConsumerConf {
     );
   }
 
+  /**
+   *
+   */
   public static function field_to_properties_serialized() {
     return array('mappings');
   }
 
   /**
-   * Destructor Method
+   * Destructor Method.
    */
-  function __destruct() {
+  public function __destruct() {
 
   }
 
   protected $_sid;
   protected $_new;
 
+  /**
+   *
+   */
   protected function linesToArray($lines) {
     $lines = trim($lines);
 
@@ -156,7 +169,9 @@ class LdapAuthorizationConsumerConf {
     return $array;
   }
 
-
+  /**
+   *
+   */
   protected function pipeListToArray($mapping_list_txt, $make_item0_lowercase = FALSE) {
     $result_array = array();
     $mappings = preg_split('/[\n\r]+/', $mapping_list_txt);
@@ -168,4 +183,5 @@ class LdapAuthorizationConsumerConf {
     }
     return $result_array;
   }
+
 }
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/LdapAuthorizationConsumerConfAdmin.class.php b/drupal7/sites/all/modules/ldap/ldap_authorization/LdapAuthorizationConsumerConfAdmin.class.php
index ad282a33..22366976 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/LdapAuthorizationConsumerConfAdmin.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/LdapAuthorizationConsumerConfAdmin.class.php
@@ -2,39 +2,41 @@
 
 /**
  * @file
- * class to encapsulate an ldap authorization ldap entry to authorization ids mapping
- *
+ * Class to encapsulate an ldap authorization ldap entry to authorization ids mapping.
  */
 
 module_load_include('php', 'ldap_authorization', 'LdapAuthorizationConsumerConf.class');
-  /**
-   * LDAP Authorization Consumer Configration Admin Class
-   */
+/**
+ * LDAP Authorization Consumer Configration Admin Class.
+ */
 class LdapAuthorizationConsumerConfAdmin extends LdapAuthorizationConsumerConf {
 
-
+  /**
+   *
+   */
   public function save() {
 
     $op = $this->inDatabase ? 'edit' : 'insert';
-    $values = new stdClass; // $this;
+    // $this;.
+    $values = new stdClass();
     $values->sid = $this->sid;
     $values->numeric_consumer_conf_id = $this->numericConsumerConfId;
     $values->consumer_type = $this->consumerType;
     $values->consumer_module = $this->consumer->consumerModule;
     $values->status = ($this->status) ? 1 : 0;
-    $values->only_ldap_authenticated = (int)$this->onlyApplyToLdapAuthenticated;
-    $values->use_first_attr_as_groupid = (int)$this->useFirstAttrAsGroupId;
+    $values->only_ldap_authenticated = (int) $this->onlyApplyToLdapAuthenticated;
+    $values->use_first_attr_as_groupid = (int) $this->useFirstAttrAsGroupId;
     $values->mappings = serialize($this->mappings);
-    $values->use_filter = (int)$this->useMappingsAsFilter;
-    $values->synch_to_ldap = (int)$this->synchToLdap;
-    $values->synch_on_logon = (int)$this->synchOnLogon;
-    $values->revoke_ldap_provisioned = (int)$this->revokeLdapProvisioned;
-    $values->create_consumers = (int)$this->createConsumers;
-    $values->regrant_ldap_provisioned = (int)$this->regrantLdapProvisioned;
+    $values->use_filter = (int) $this->useMappingsAsFilter;
+    $values->synch_to_ldap = (int) $this->synchToLdap;
+    $values->synch_on_logon = (int) $this->synchOnLogon;
+    $values->revoke_ldap_provisioned = (int) $this->revokeLdapProvisioned;
+    $values->create_consumers = (int) $this->createConsumers;
+    $values->regrant_ldap_provisioned = (int) $this->regrantLdapProvisioned;
 
     if (module_exists('ctools')) {
       ctools_include('export');
-      // Populate our object with ctool's properties
+      // Populate our object with ctool's properties.
       $object = ctools_export_crud_new('ldap_authorization');
       foreach ($object as $property => $value) {
         if (!isset($values->$property)) {
@@ -44,18 +46,23 @@ class LdapAuthorizationConsumerConfAdmin extends LdapAuthorizationConsumerConf {
       try {
         $values->export_type = NULL;
         $result = ctools_export_crud_save('ldap_authorization', $values);
-      } catch (Exception $e) {
+      }
+      catch (Exception $e) {
         $values->export_type = EXPORT_IN_DATABASE;
         $result = ctools_export_crud_save('ldap_authorization', $values);
       }
-      ctools_export_load_object_reset('ldap_authorization'); // ctools_export_crud_save doesn't invalidate cache
+      // ctools_export_crud_save doesn't invalidate cache.
+      ctools_export_load_object_reset('ldap_authorization');
     }
     else {
 
       if ($op == 'edit') {
         $result = drupal_write_record('ldap_authorization', $values, 'consumer_type');
       }
-      else { // insert
+      /**
+ *Insert.
+ */
+      else {
         $result = drupal_write_record('ldap_authorization', $values);
       }
 
@@ -72,6 +79,9 @@ class LdapAuthorizationConsumerConfAdmin extends LdapAuthorizationConsumerConf {
   public $fields;
   public $consumers;
 
+  /**
+   *
+   */
   public function delete() {
     if ($this->consumerType) {
       $this->inDatabase = FALSE;
@@ -82,6 +92,9 @@ class LdapAuthorizationConsumerConfAdmin extends LdapAuthorizationConsumerConf {
     }
   }
 
+  /**
+   *
+   */
   public function __construct(&$consumer = NULL, $new = FALSE) {
     parent::__construct($consumer, $new);
     $this->fields = $this->fields();
@@ -94,12 +107,15 @@ class LdapAuthorizationConsumerConfAdmin extends LdapAuthorizationConsumerConf {
     }
   }
 
+  /**
+   *
+   */
   public function drupalForm($server_options, $op) {
 
     $consumer_tokens = ldap_authorization_tokens($this->consumer);
     $form['intro'] = array(
-        '#type' => 'item',
-        '#markup' => t('<h1>LDAP to !consumer_name Configuration</h1>', $consumer_tokens),
+      '#type' => 'item',
+      '#markup' => t('<h1>LDAP to !consumer_name Configuration</h1>', $consumer_tokens),
     );
 
     $form['status'] = array(
@@ -126,20 +142,19 @@ class LdapAuthorizationConsumerConfAdmin extends LdapAuthorizationConsumerConf {
     $form['status']['status'] = array(
       '#type' => 'checkbox',
       '#title' => t('Enable this configuration', $consumer_tokens),
-      '#default_value' =>  $this->status,
+      '#default_value' => $this->status,
     );
 
     $form['status']['only_ldap_authenticated'] = array(
       '#type' => 'checkbox',
       '#title' => t('Only apply the following LDAP to !consumer_name configuration to users authenticated via LDAP.  One uncommon reason for disabling this is when you are using Drupal authentication, but want to leverage LDAP for authorization; for this to work the Drupal username still has to map to an LDAP entry.', $consumer_tokens),
-      '#default_value' =>  $this->onlyApplyToLdapAuthenticated,
+      '#default_value' => $this->onlyApplyToLdapAuthenticated,
     );
 
-
     if (method_exists($this->consumer, 'mappingExamples')) {
       $consumer_tokens['!examples'] = '<fieldset class="collapsible collapsed form-wrapper" id="authorization-mappings">
 <legend><span class="fieldset-legend">' . t('Examples based on current !consumer_namePlural', $consumer_tokens) . '</span></legend>
-<div class="fieldset-wrapper">'. $this->consumer->mappingExamples($consumer_tokens) . '<div class="fieldset-wrapper">
+<div class="fieldset-wrapper">' . $this->consumer->mappingExamples($consumer_tokens) . '<div class="fieldset-wrapper">
 </fieldset>';
     }
     else {
@@ -186,10 +201,9 @@ Representations of groups derived from LDAP might initially look like:
       '#default_value' => $this->useMappingsAsFilter,
       '#description' => t('If enabled, only above mapped !consumer_namePlural will be assigned (e.g. students and administrator).
         <strong>If not checked, !consumer_namePlural not mapped above also may be created and granted (e.g. gryffindor and probation students).  In some LDAPs this can lead to hundreds of !consumer_namePlural being created if "Create !consumer_namePlural if they do not exist" is enabled below.
-        </strong>', $consumer_tokens)
+        </strong>', $consumer_tokens),
     );
 
-
     $form['more'] = array(
       '#type' => 'fieldset',
       '#title' => t('Part III.  Even More Settings.'),
@@ -198,31 +212,31 @@ Representations of groups derived from LDAP might initially look like:
     );
 
     $synchronization_modes = array();
-    if ($this->synchOnLogon)  {
+    if ($this->synchOnLogon) {
       $synchronization_modes[] = 'user_logon';
     }
     $form['more']['synchronization_modes'] = array(
       '#type' => 'checkboxes',
       '#title' => t('When should !consumer_namePlural be granted/revoked from user?', $consumer_tokens),
       '#options' => array(
-          'user_logon' => t('When a user logs on.'),
+        'user_logon' => t('When a user logs on.'),
       ),
       '#default_value' => $synchronization_modes,
       '#description' => '',
     );
 
     $synchronization_actions = array();
-    if ($this->revokeLdapProvisioned)  {
+    if ($this->revokeLdapProvisioned) {
       $synchronization_actions[] = 'revoke_ldap_provisioned';
     }
-    if ($this->createConsumers)  {
+    if ($this->createConsumers) {
       $synchronization_actions[] = 'create_consumers';
     }
-    if ($this->regrantLdapProvisioned)  {
+    if ($this->regrantLdapProvisioned) {
       $synchronization_actions[] = 'regrant_ldap_provisioned';
     }
 
-    $options =  array(
+    $options = array(
       'revoke_ldap_provisioned' => t('Revoke !consumer_namePlural previously granted by LDAP Authorization but no longer valid.', $consumer_tokens),
       'regrant_ldap_provisioned' => t('Re grant !consumer_namePlural previously granted by LDAP Authorization but removed manually.', $consumer_tokens),
     );
@@ -246,16 +260,16 @@ Representations of groups derived from LDAP might initially look like:
 
     switch ($op) {
       case 'add':
-      $action = 'Add';
-      break;
+        $action = 'Add';
+        break;
 
       case 'edit':
-      $action = 'Save';
-      break;
+        $action = 'Save';
+        break;
 
       case 'delete':
-      $action = 'Delete';
-      break;
+        $action = 'Delete';
+        break;
     }
 
     $form['submit'] = array(
@@ -263,33 +277,41 @@ Representations of groups derived from LDAP might initially look like:
       '#value' => $action,
     );
 
-  return $form;
+    return $form;
   }
 
-
+  /**
+   *
+   */
   protected function loadFromForm($values, $op) {
 
   }
 
+  /**
+   *
+   */
   public function getLdapAuthorizationConsumerActions() {
     $actions = array();
-    $actions[] =  l(t('edit'), LDAP_SERVERS_MENU_BASE_PATH . '/authorization/edit/' . $this->consumerType);
+    $actions[] = l(t('edit'), LDAP_SERVERS_MENU_BASE_PATH . '/authorization/edit/' . $this->consumerType);
     if (property_exists($this, 'type')) {
       if ($this->type == 'Overridden') {
-          $actions[] = l(t('revert'), LDAP_SERVERS_MENU_BASE_PATH . '/authorization/delete/' . $this->consumerType);
+        $actions[] = l(t('revert'), LDAP_SERVERS_MENU_BASE_PATH . '/authorization/delete/' . $this->consumerType);
       }
       if ($this->type == 'Normal') {
-          $actions[] = l(t('delete'), LDAP_SERVERS_MENU_BASE_PATH . '/authorization/delete/' . $this->consumerType);
+        $actions[] = l(t('delete'), LDAP_SERVERS_MENU_BASE_PATH . '/authorization/delete/' . $this->consumerType);
       }
     }
     else {
-        $actions[] = l(t('delete'), LDAP_SERVERS_MENU_BASE_PATH . '/authorization/delete/' . $this->consumerType);
+      $actions[] = l(t('delete'), LDAP_SERVERS_MENU_BASE_PATH . '/authorization/delete/' . $this->consumerType);
     }
     $actions[] = l(t('test'), LDAP_SERVERS_MENU_BASE_PATH . '/authorization/test/' . $this->consumerType);
     return $actions;
   }
 
-  public function drupalFormValidate($op, $values)  {
+  /**
+   *
+   */
+  public function drupalFormValidate($op, $values) {
     $errors = array();
 
     if ($op == 'delete') {
@@ -309,6 +331,9 @@ Representations of groups derived from LDAP might initially look like:
     return $errors;
   }
 
+  /**
+   *
+   */
   public function validate($form_values = array()) {
     $errors = array();
 
@@ -337,6 +362,9 @@ Representations of groups derived from LDAP might initially look like:
     return $errors;
   }
 
+  /**
+   *
+   */
   protected function populateFromDrupalForm($op, $values) {
 
     $this->inDatabase = (drupal_strtolower($op) == 'edit' || drupal_strtolower($op) == 'save');
@@ -344,27 +372,31 @@ Representations of groups derived from LDAP might initially look like:
 
     $this->sid = $values['sid'];
 
-    $this->status = (bool)$values['status'];
-    $this->onlyApplyToLdapAuthenticated  = (bool)(@$values['only_ldap_authenticated']);
-    $this->useFirstAttrAsGroupId  = (bool)($values['use_first_attr_as_groupid']);
+    $this->status = (bool) $values['status'];
+    $this->onlyApplyToLdapAuthenticated = (bool) (@$values['only_ldap_authenticated']);
+    $this->useFirstAttrAsGroupId = (bool) ($values['use_first_attr_as_groupid']);
 
     $this->mappings = $this->consumer->normalizeMappings($this->pipeListToArray($values['mappings'], FALSE));
-    $this->useMappingsAsFilter  = (bool)(@$values['use_filter']);
+    $this->useMappingsAsFilter = (bool) (@$values['use_filter']);
 
-    $this->synchOnLogon = (bool)(@$values['synchronization_modes']['user_logon']);
-    $this->regrantLdapProvisioned = (bool)(@$values['synchronization_actions']['regrant_ldap_provisioned']);
-    $this->revokeLdapProvisioned = (bool)(@$values['synchronization_actions']['revoke_ldap_provisioned']);
-    $this->createConsumers = (bool)(@$values['synchronization_actions']['create_consumers']);
+    $this->synchOnLogon = (bool) (@$values['synchronization_modes']['user_logon']);
+    $this->regrantLdapProvisioned = (bool) (@$values['synchronization_actions']['regrant_ldap_provisioned']);
+    $this->revokeLdapProvisioned = (bool) (@$values['synchronization_actions']['revoke_ldap_provisioned']);
+    $this->createConsumers = (bool) (@$values['synchronization_actions']['create_consumers']);
 
   }
 
+  /**
+   *
+   */
   public function drupalFormSubmit($op, $values) {
 
     $this->populateFromDrupalForm($op, $values);
     if ($op == 'delete') {
       $this->delete();
     }
-    else { // add or edit
+    // Add or edit.
+    else {
 
       try {
         $save_result = $this->save();
@@ -377,52 +409,54 @@ Representations of groups derived from LDAP might initially look like:
     }
   }
 
-
+  /**
+   *
+   */
   public static function fields() {
 
-     /**
+    /**
      * consumer_type is tag (unique alphanumeric id) of consuming authorization such as
      *   drupal_roles, og_groups, civicrm_memberships
      */
     $fields = array(
       'numeric_consumer_conf_id' => array(
-          'schema' => array(
-            'type' => 'serial',
-            'unsigned' => TRUE,
-            'not null' => TRUE,
-            'description' => 'Primary ID field for the table.  Only used internally.',
-            'no export' => TRUE,
-          ),
+        'schema' => array(
+          'type' => 'serial',
+          'unsigned' => TRUE,
+          'not null' => TRUE,
+          'description' => 'Primary ID field for the table.  Only used internally.',
+          'no export' => TRUE,
         ),
+      ),
       'sid' => array(
         'schema' => array(
           'type' => 'varchar',
           'length' => 20,
           'not null' => TRUE,
-        )
+        ),
       ),
       'consumer_type' => array(
-         'schema' => array(
-            'type' => 'varchar',
-            'length' => 20,
-            'not null' => TRUE,
-        )
+        'schema' => array(
+          'type' => 'varchar',
+          'length' => 20,
+          'not null' => TRUE,
+        ),
       ),
-     'consumer_module' => array(
-         'schema' => array(
-            'type' => 'varchar',
-            'length' => 30,
-            'not null' => TRUE,
-        )
+      'consumer_module' => array(
+        'schema' => array(
+          'type' => 'varchar',
+          'length' => 30,
+          'not null' => TRUE,
+        ),
       ),
 
       'status' => array(
-          'schema' => array(
-            'type' => 'int',
-            'size' => 'tiny',
-            'not null' => TRUE,
-            'default' => 0,
-          )
+        'schema' => array(
+          'type' => 'int',
+          'size' => 'tiny',
+          'not null' => TRUE,
+          'default' => 0,
+        ),
       ),
       'only_ldap_authenticated' => array(
         'schema' => array(
@@ -430,7 +464,7 @@ Representations of groups derived from LDAP might initially look like:
           'size' => 'tiny',
           'not null' => TRUE,
           'default' => 1,
-        )
+        ),
       ),
 
       'use_first_attr_as_groupid' => array(
@@ -439,7 +473,7 @@ Representations of groups derived from LDAP might initially look like:
           'size' => 'tiny',
           'not null' => TRUE,
           'default' => 0,
-        )
+        ),
       ),
 
       'mappings'  => array(
@@ -449,7 +483,7 @@ Representations of groups derived from LDAP might initially look like:
           'size' => 'medium',
           'not null' => FALSE,
           'default' => NULL,
-        )
+        ),
       ),
 
       'use_filter' => array(
@@ -458,15 +492,15 @@ Representations of groups derived from LDAP might initially look like:
           'size' => 'tiny',
           'not null' => TRUE,
           'default' => 1,
-        )
+        ),
       ),
 
       'synchronization_modes' => array(
-        'form_default' =>  array('user_logon'),
+        'form_default' => array('user_logon'),
       ),
 
       'synchronization_actions' => array(
-        'form_default' =>  array('revoke_ldap_provisioned', 'create_consumers'),
+        'form_default' => array('revoke_ldap_provisioned', 'create_consumers'),
       ),
 
       'synch_to_ldap'  => array(
@@ -496,7 +530,7 @@ Representations of groups derived from LDAP might initially look like:
         ),
       ),
 
-     'create_consumers'  => array(
+      'create_consumers'  => array(
         'schema' => array(
           'type' => 'int',
           'size' => 'tiny',
@@ -505,7 +539,7 @@ Representations of groups derived from LDAP might initially look like:
         ),
       ),
 
-     'regrant_ldap_provisioned'  => array(
+      'regrant_ldap_provisioned'  => array(
         'schema' => array(
           'type' => 'int',
           'size' => 'tiny',
@@ -517,7 +551,9 @@ Representations of groups derived from LDAP might initially look like:
     return $fields;
   }
 
-
+  /**
+   *
+   */
   protected function mappingsToPipeList($mappings) {
     $result_text = "";
     foreach ($mappings as $map) {
@@ -526,5 +562,4 @@ Representations of groups derived from LDAP might initially look like:
     return $result_text;
   }
 
-
 }
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.admin.inc b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.admin.inc
index 8a4f9702..59acfea6 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.admin.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.admin.inc
@@ -5,13 +5,11 @@
  * Administrative page callbacks for the ldap_authorization module.  Consumer configuration form and index.
  */
 
-
 /**
- * index of ldap authorization configurations
+ * Index of ldap authorization configurations.
  *
  * @return string html table
  */
-
 function ldap_authorizations_admin_index() {
 
   $consumers = ldap_authorization_get_consumers(NULL, TRUE, FALSE);
@@ -33,18 +31,18 @@ function ldap_authorizations_admin_index() {
 
 }
 
-
-
 /**
- * form for adding, updating, and deleting a single ldap authorization configuration
+ * Form for adding, updating, and deleting a single ldap authorization configuration.
  *
  * @param form array $form
  * @param form state array $form_state
- * @param string $op (add, edit, or delete)
- * @param string $consumer_type e.g. drupal_roles, og_group, etc.  Only needed for adds
+ * @param string $op
+ *   (add, edit, or delete)
+ * @param string $consumer_type
+ *   e.g. drupal_roles, og_group, etc.  Only needed for adds.
+ *
  * @return drupal form array
  */
-
 function ldap_authorization_admin_form($form, &$form_state, $consumer_type, $op = NULL) {
   ldap_servers_module_load_include('php', 'ldap_authorization', 'LdapAuthorizationConsumerConfAdmin.class');
   $consumer = ldap_authorization_get_consumer_object($consumer_type);
@@ -67,7 +65,6 @@ function ldap_authorization_admin_form($form, &$form_state, $consumer_type, $op
     drupal_goto('admin/config/people/ldap/authorization');
   }
 
-
   $new = ($op == 'add');
   $consumer_conf_admin = new LdapAuthorizationConsumerConfAdmin($consumer, $new);
 
@@ -78,14 +75,12 @@ function ldap_authorization_admin_form($form, &$form_state, $consumer_type, $op
 
 }
 
-
 /**
- * validate handler for the ldap_authorization_admin_form
+ * Validate handler for the ldap_authorization_admin_form.
  */
-
 function ldap_authorization_admin_form_validate($form, &$form_state) {
 
-  list($consumer, $op, $op_past, $new)  = _ldap_authorization_admin_parse_form($form, $form_state);
+  list($consumer, $op, $op_past, $new) = _ldap_authorization_admin_parse_form($form, $form_state);
   $values = $form_state['values'];
   ldap_servers_module_load_include('php', 'ldap_authorization', 'LdapAuthorizationConsumerConfAdmin.class');
   $consumer_conf_admin = new LdapAuthorizationConsumerConfAdmin($consumer, $new);
@@ -98,17 +93,16 @@ function ldap_authorization_admin_form_validate($form, &$form_state) {
 
 }
 
-
 /**
- * submit handler function for ldap_authorization_admin_form
+ * Submit handler function for ldap_authorization_admin_form.
  */
-
 function ldap_authorization_admin_form_submit($form, &$form_state) {
-  list($consumer, $op, $op_past_tense, $new)  = _ldap_authorization_admin_parse_form($form, $form_state);
+  list($consumer, $op, $op_past_tense, $new) = _ldap_authorization_admin_parse_form($form, $form_state);
   $values = $form_state['values'];
   ldap_servers_module_load_include('php', 'ldap_authorization', 'LdapAuthorizationConsumerConfAdmin.class');
   $consumer_conf = new LdapAuthorizationConsumerConfAdmin($consumer, $new);
-  $consumer_conf->drupalFormSubmit($op, $values);  // add form data to object and save or create
+  // Add form data to object and save or create.
+  $consumer_conf->drupalFormSubmit($op, $values);
 
   if ($consumer_conf->hasError == FALSE) {
     drupal_set_message(t('LDAP Authorization %name !verb', array('!verb' => $op_past_tense, '%name' => $consumer->name)), 'status');
@@ -121,9 +115,8 @@ function ldap_authorization_admin_form_submit($form, &$form_state) {
 }
 
 /**
- * helper function for parsing ldap authorization config form
+ * Helper function for parsing ldap authorization config form.
  */
-
 function _ldap_authorization_admin_parse_form($form, &$form_state) {
   $op = drupal_strtolower($form_state['clicked_button']['#value']);
   $values = $form_state['values'];
@@ -140,19 +133,19 @@ function _ldap_authorization_admin_parse_form($form, &$form_state) {
     case 'add':
       $op_past_tense = 'Added';
       $new = TRUE;
-    break;
+      break;
 
     case 'save':
     case 'update':
     case 'edit':
       $op_past_tense = 'Updated';
       $new = FALSE;
-    break;
+      break;
 
     case 'delete':
       $op_past_tense = 'Deleted';
       $new = FALSE;
-    break;
+      break;
   }
 
   return array($consumer, $op, $op_past_tense, $new);
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.admin.test.inc b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.admin.test.inc
index 1090daa3..8042c8d3 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.admin.test.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.admin.test.inc
@@ -2,18 +2,17 @@
 
 /**
  * @file
- * form to test a ldap authorization consumer configuration
+ * Form to test a ldap authorization consumer configuration.
  */
 
 /**
- * form for adding, updating, and deleting a single ldap authorization consumer configuration
+ * Form for adding, updating, and deleting a single ldap authorization consumer configuration.
+ *
+ * @param mixed $form
+ * @param mixed $form_state
  *
- * @param <type> $form
- * @param <type> $form_state
  * @return array drupal form array
  */
-
-
 function ldap_authorization_test_form($form, &$form_state, $consumer_type) {
   $consumer = ldap_authorization_get_consumer_object($consumer_type);
   $consumer_tokens = ldap_authorization_tokens($consumer);
@@ -22,7 +21,7 @@ function ldap_authorization_test_form($form, &$form_state, $consumer_type) {
     $form['result'] = array(
       '#type' => 'item',
       '#markup' => $_SESSION['ldap_authorization_test_query']['result'],
-      );
+    );
 
     $form['pre-filtered'] = array(
       '#type' => 'fieldset',
@@ -31,8 +30,8 @@ function ldap_authorization_test_form($form, &$form_state, $consumer_type) {
       '#collapsed' => TRUE,
     );
     $form['pre-filtered']['overview'] = array(
-     '#type' => 'item',
-     '#markup' => t('Below are the "raw authorizations" and which strategy they are derived from.  If enabled, the mapping filter is applied to these.'),
+      '#type' => 'item',
+      '#markup' => t('Below are the "raw authorizations" and which strategy they are derived from.  If enabled, the mapping filter is applied to these.'),
     );
 
     if (isset($_SESSION['ldap_authorization_test_query']['maps'])) {
@@ -40,8 +39,8 @@ function ldap_authorization_test_form($form, &$form_state, $consumer_type) {
       foreach ($_SESSION['ldap_authorization_test_query']['maps'] as $map => $data) {
         $i++;
         $form['pre-filtered']['map' . $i] = array(
-         '#type' => 'item',
-         '#markup' => is_scalar($data) ?  "<h2>$map (without filter)</h2>" . $data : theme('item_list', array('items' => $data, 'type' => 'ul', 'title' => "$map (without filter)")),
+          '#type' => 'item',
+          '#markup' => is_scalar($data) ? "<h2>$map (without filter)</h2>" . $data : theme('item_list', array('items' => $data, 'type' => 'ul', 'title' => "$map (without filter)")),
         );
       }
     }
@@ -56,15 +55,15 @@ function ldap_authorization_test_form($form, &$form_state, $consumer_type) {
     if ($consumer->consumerConf->useFirstAttrAsGroupId) {
       if (isset($_SESSION['ldap_authorization_test_query']['useFirstAttrAsGroupId'])) {
         $form['use_first_attr_as_groupid']['data'] = array(
-         '#type' => 'item',
-         '#markup' => theme('item_list', array('items' => $_SESSION['ldap_authorization_test_query']['useFirstAttrAsGroupId'], 'type' => 'ul', 'title' => "Convert full dn to value of first attribute before mapping")),
+          '#type' => 'item',
+          '#markup' => theme('item_list', array('items' => $_SESSION['ldap_authorization_test_query']['useFirstAttrAsGroupId'], 'type' => 'ul', 'title' => "Convert full dn to value of first attribute before mapping")),
         );
       }
     }
     else {
       $form['use_first_attr_as_groupid']['data'] = array(
-       '#type' => 'item',
-       '#markup' => "Convert full dn to value of first attribute before mapping. NOT enabled",
+        '#type' => 'item',
+        '#markup' => "Convert full dn to value of first attribute before mapping. NOT enabled",
       );
     }
 
@@ -82,35 +81,35 @@ function ldap_authorization_test_form($form, &$form_state, $consumer_type) {
 
     $form['post mappings']['conf'] = array(
       '#type' => 'item',
-      '#markup' => 'Use Mappings as Filter = ' . (int)$consumer->consumerConf->useMappingsAsFilter .
-          theme('item_list', array(
-          'items' =>  $maps,
-          'type' => 'ul',
-          'title' => 'Configured Mappings',
-        )
+      '#markup' => 'Use Mappings as Filter = ' . (int) $consumer->consumerConf->useMappingsAsFilter .
+      theme('item_list', array(
+        'items' => $maps,
+        'type' => 'ul',
+        'title' => 'Configured Mappings',
       )
+      ),
     );
     if ($consumer->consumerConf->mappings) {
       $form['post mappings']['conf']['#markup'] =
-      'Use Mappings as Filter = ' . (int)$consumer->consumerConf->useMappingsAsFilter .
+      'Use Mappings as Filter = ' . (int) $consumer->consumerConf->useMappingsAsFilter .
           theme('item_list', array(
-          'items' =>  $maps,
-          'type' => 'ul',
-          'title' => 'Configured Mappings',
-        )
+            'items' => $maps,
+            'type' => 'ul',
+            'title' => 'Configured Mappings',
+          )
       );
     }
     else {
       $form['post mappings']['conf']['#markup'] =
       'Use Mappings as Filter = ' .
-      (int)$consumer->consumerConf->useMappingsAsFilter .
+      (int) $consumer->consumerConf->useMappingsAsFilter .
       '<br/>No Mappings Configured';
     }
 
     if (isset($_SESSION['ldap_authorization_test_query']['post mappings'])) {
       $form['post mappings']['data'] = array(
-       '#type' => 'item',
-       '#markup' => theme('item_list', array('items' => $_SESSION['ldap_authorization_test_query']['post mappings'], 'type' => 'ul', 'title' => "Results after any filtering and mappings applied")),
+        '#type' => 'item',
+        '#markup' => theme('item_list', array('items' => $_SESSION['ldap_authorization_test_query']['post mappings'], 'type' => 'ul', 'title' => "Results after any filtering and mappings applied")),
       );
     }
 
@@ -125,16 +124,15 @@ function ldap_authorization_test_form($form, &$form_state, $consumer_type) {
         '#collapsed' => TRUE,
       );
       $form[$title]['overview'] = array(
-       '#type' => 'item',
-       '#markup' => "<pre>" . print_r($data, TRUE) . "</pre>",
+        '#type' => 'item',
+        '#markup' => "<pre>" . print_r($data, TRUE) . "</pre>",
       );
     }
   }
 
-
   $form['intro'] = array(
-      '#type' => 'item',
-      '#markup' => t('<h1>Test LDAP to !consumer_name Configuration</h1>
+    '#type' => 'item',
+    '#markup' => t('<h1>Test LDAP to !consumer_name Configuration</h1>
       <p>This form will not actually grant any authorizations, its just to show
       what authorizations would be granted with this configuration.</p>', $consumer_tokens),
   );
@@ -182,9 +180,8 @@ function ldap_authorization_test_form($form, &$form_state, $consumer_type) {
   return $form;
 }
 
-
 /**
- * validate handler for the ldap_authorization_test
+ * Validate handler for the ldap_authorization_test.
  */
 function ldap_authorization_test_form_validate($form, &$form_state) {
 
@@ -196,10 +193,8 @@ function ldap_authorization_test_form_validate($form, &$form_state) {
 }
 
 /**
- * submit handler function for ldap_authorization_test
+ * Submit handler function for ldap_authorization_test.
  */
-
-
 function ldap_authorization_test_form_submit($form, &$form_state) {
   $consumer_type = $form_state['values']['consumer_type'];
   $consumer = ldap_authorization_get_consumer_object($consumer_type);
@@ -210,13 +205,14 @@ function ldap_authorization_test_form_submit($form, &$form_state) {
   $random_users = array();
   $_SESSION['ldap_authorization_test_query']['random_users'] = $form_state['values']['random_users'];
   $_SESSION['ldap_authorization_test_query']['usernames'] = $form_state['values']['usernames'];
-  if ($form_state['values']['random_users']) {  // add 10 random usernames to test
-    // not using user_load_multiple because need randomness outside of query
+  // Add 10 random usernames to test.
+  if ($form_state['values']['random_users']) {
+    // Not using user_load_multiple because need randomness outside of query.
     $select = db_select('users', 'u');
     $select->fields('u');
 
     try {
-      $random_users = $select->execute()->fetchAllAssoc('name',  PDO::FETCH_ASSOC);
+      $random_users = $select->execute()->fetchAllAssoc('name', PDO::FETCH_ASSOC);
     }
     catch (Exception $e) {
       drupal_set_message(t('db users query failed. Message = %message, query= %query',
@@ -230,7 +226,7 @@ function ldap_authorization_test_form_submit($form, &$form_state) {
   foreach ($user_names as $username) {
     if ($username) {
       if (!$user = user_load_by_name($username)) {
-        // if not existing user, create fake user assumed to be ldap authenticated
+        // If not existing user, create fake user assumed to be ldap authenticated.
         $user = new stdClass();
         $user->name = $username;
         $user->ldap_test = TRUE;
@@ -250,7 +246,7 @@ function ldap_authorization_test_form_submit($form, &$form_state) {
 
       $action = ($form_state['values']['execute_authorizations'] == 1) ? "test_query_set" : 'test_query';
       list($results[$username], $notifications[$username]) = ldap_authorizations_user_authorizations($user, $action, $consumer_type, 'logon');
-      // remove authorizations from other consumer types
+      // Remove authorizations from other consumer types.
       $results[$username] = array($consumer_type => $results[$username][$consumer_type]);
       $i++;
       if ($i == 10) {
@@ -259,7 +255,7 @@ function ldap_authorization_test_form_submit($form, &$form_state) {
     }
   }
 
-  $table =  theme('ldap_authorization_test_results', array('results' => $results, 'consumer' => $consumer, 'notifications' => $notifications));
+  $table = theme('ldap_authorization_test_results', array('results' => $results, 'consumer' => $consumer, 'notifications' => $notifications));
   $_SESSION['ldap_authorization_test_query']['result'] = $table;
   $form_state['redirect'] = LDAP_SERVERS_MENU_BASE_PATH . '/authorization/test/' . $consumer->consumerType;
 
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.api.php b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.api.php
index 0042bd4a..bebd9785 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.api.php
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.api.php
@@ -2,52 +2,49 @@
 
 /**
  * @file
- * summary of hooks and other developer related functions
+ * Summary of hooks and other developer related functions.
  */
 
 /**
- * Allow a custom module to alter ldap_authorization mappings
+ * Allow a custom module to alter ldap_authorization mappings.
+ *
+ * @param object $user
+ *   as drupal acct object.
+ * @param array $ldap_user
+ *   See ldap_authentication/README.developers.txt for structure.
+ * @param LdapServer $ldap_server
+ *   The ldap server associated with this consumer type.
+ * @param LdapAuthorizationConsumerConf $consumer_conf
+ *   The ldap consumer configuraion associated with this consumer type.
+ * @param array $proposed_ldap_authorizations
+ *   with keys of consumer ids
+ *   and values of consumers (drupal roles, og entity, etc.)
  *
- *  @param object $user as drupal acct object
- *  @param array $ldap_user
- *    See ldap_authentication/README.developers.txt for structure
- *  @param LdapServer $ldap_server
- *    The ldap server associated with this consumer type
- *  @param LdapAuthorizationConsumerConf $consumer_conf
- *    The ldap consumer configuraion associated with this consumer type
- *  @param array $proposed_ldap_authorizations with keys of consumer ids
- *    and values of consumers (drupal roles, og entity, etc.)
-
  *
- *  alters $proposed_ldap_authorizations by reference
+ *   alters $proposed_ldap_authorizations by reference.
  */
-
-
-
 function hook_ldap_authorization_maps_alter($user, $ldap_user, $ldap_server, $consumer_conf, $proposed_ldap_authorizations, $op) {
 
-
 }
 
-
 /**
  * Allow a custom module to alter ldap_authorizations after they have been determined by ldap_authorizations,
  *  but before they are granted/removed from user.
  *
- *  @param array $authorizations as proposed authorizations for user.
- *    will be in format returned by LdapAuthorizationConsumerX::populateConsumersFromConsumerIds
+ * @param array $authorizations
+ *   as proposed authorizations for user.
+ *   will be in format returned by LdapAuthorizationConsumerX::populateConsumersFromConsumerIds.
  *
- *  @param array $params with the following key/value pairs
- *    'ldap_user' => See ldap_authentication/README.developers.txt for structure
+ * @param array $params
+ *   with the following key/value pairs
+ *   'ldap_user' => See ldap_authentication/README.developers.txt for structure
  *    'ldap_server' => the LdapServer object for this consumer type
  *    'consumer' => LdapAuthorizationConsumerX object
  *    'user' => Drupal user account object
  *
- *  alters $proposed_ldap_authorizations by reference
+ *   alters $proposed_ldap_authorizations by reference.
  */
-
 function hook_ldap_authorization_authorizations_alter($authorizations, $params) {
 
-  // alter authorizations
-
+  // Alter authorizations.
 }
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.inc b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.inc
index f5ed4ac4..e9fc4c37 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.inc
@@ -2,16 +2,21 @@
 
 /**
  * @file
- *  bulk of authorization code executed to determine a users authorizations
+ * Bulk of authorization code executed to determine a users authorizations.
  */
 
-function ldap_authorization_help_watchdog() {  // remove after testing
+// Remove after testing.
+/**
+ *
+ */
 
-  $path =  drupal_get_path("module", "ldap_help");
+function ldap_authorization_help_watchdog() {
+
+  $path = drupal_get_path("module", "ldap_help");
   $_content = "";
   if (module_exists('dblog')) {
-    include_once(drupal_get_path('module', 'dblog') . '/dblog.admin.inc');
-    $_SESSION['dblog_overview_filter']['type'] = Array('ldap' => 'ldap');
+    include_once drupal_get_path('module', 'dblog') . '/dblog.admin.inc';
+    $_SESSION['dblog_overview_filter']['type'] = array('ldap' => 'ldap');
     $_content .= "<h3>" . t('LDAP Watchdog Errors and Notifications') . "</h3>";
     $overview = dblog_overview();
     $_content .= render($overview);
@@ -24,24 +29,25 @@ function ldap_authorization_help_watchdog() {  // remove after testing
     $_content .= l(t('Module enable page'), 'admin/build/modules');
   }
 
-
   return $_content;
 }
 
-
 /**
- * return all desired authorizations for a given user
+ * Return all desired authorizations for a given user.
  *
  * @param object $user
  *
- * @param string $op =
+ * @param string $op
+ *   =
  *   set -- grant authorizations (store in db) and return authorizations
  *   test_query -- don't grant authorization, just query and return authorizations.  assume user is ldap authenticated and exists
  *   test_query_set -- do grant authorizations, but also log data for debugging
- *   query -- don't grant authorization, just query and return authorizations
+ *   query -- don't grant authorization, just query and return authorizations.
  *
- * @param string $consumer_type e.g. drupal_roles
- * @param string $context  'logon', 'test_if_authorizations_granted'
+ * @param string $consumer_type
+ *   e.g. drupal_roles.
+ * @param string $context
+ *   'logon', 'test_if_authorizations_granted'.
  *
  * @return
  *
@@ -53,10 +59,7 @@ function ldap_authorization_help_watchdog() {  // remove after testing
  *   by reference $user->data[<consumer_type>][<authorization_id>] = array();
  *      e.g.   $var['drupal_role']['content_admin'] = array('rid' => 4)
  *      e.g.   $var['og_membership']['bakers club'] = array('expires' => '01/01/2012');
- *
  */
-
-
 function _ldap_authorizations_user_authorizations(&$user, $op, $consumer_type, $context) {
   $debug = FALSE;
   $detailed_watchdog_log = variable_get('ldap_help_watchdog_detail', 0);
@@ -85,10 +88,11 @@ function _ldap_authorizations_user_authorizations(&$user, $op, $consumer_type, $
    * determine if user is ldap authenticated
    */
   if ($context == 'test_if_authorizations_granted' || (($op == 'test_query_set' || $op == 'test_query') && @$user->ldap_test == TRUE)) {
-    $ldap_authenticated = $user->ldap_authenticated;  // property 'ldap_authenticated' only exists for fake user objects submitted from testing form
+    // Property 'ldap_authenticated' only exists for fake user objects submitted from testing form.
+    $ldap_authenticated = $user->ldap_authenticated;
   }
   else {
-    $ldap_authenticated = (boolean)(module_exists('ldap_authentication') && ldap_authentication_ldap_authenticated($user));
+    $ldap_authenticated = (boolean) (module_exists('ldap_authentication') && ldap_authentication_ldap_authenticated($user));
   }
   $watchdog_tokens['%ldap_authenticated'] = ($ldap_authenticated) ? 'yes' : 'no';
 
@@ -111,7 +115,7 @@ function _ldap_authorizations_user_authorizations(&$user, $op, $consumer_type, $
     $watchdog_tokens['%consumer_type'] = $consumer_type;
     $watchdog_tokens['%sid'] = $consumer->consumerConf->sid;
 
-    if (! is_object($consumer->consumerConf)) {
+    if (!is_object($consumer->consumerConf)) {
       if ($detailed_watchdog_log) {
         watchdog('ldap_authorization', '%username : consumer type  %consumer_type has no
           configuration set.', $watchdog_tokens, WATCHDOG_DEBUG);
@@ -125,7 +129,8 @@ function _ldap_authorizations_user_authorizations(&$user, $op, $consumer_type, $
     }
     if ($debug) {
       debug(t('%username : testing with consumer type %consumer_type. ldap authenticated=%ldap_authenticated'), $watchdog_tokens);
-      debug("op=$op,ldap_authenticated=$ldap_authenticated $consumer_type context=$context, consumer->consumerConf->synchOnLogon=" . (int)$consumer->consumerConf->synchOnLogon); //$debug = TRUE;
+      // $debug = TRUE;.
+      debug("op=$op,ldap_authenticated=$ldap_authenticated $consumer_type context=$context, consumer->consumerConf->synchOnLogon=" . (int) $consumer->consumerConf->synchOnLogon);
     }
 
     if ($context == 'logon' && !$consumer->consumerConf->synchOnLogon) {
@@ -155,7 +160,7 @@ function _ldap_authorizations_user_authorizations(&$user, $op, $consumer_type, $
       continue;
     }
 
-    if (! isset($servers[$consumer->consumerConf->sid])) {
+    if (!isset($servers[$consumer->consumerConf->sid])) {
       $notifications[$consumer_type][] = LDAP_AUTHORIZATION_SERVER_CONFIG_NOT_FOUND;
       if ($detailed_watchdog_log) {
         watchdog('ldap_authorization', '%username : %consumer_type ldap server %sid not enabled or found.', $watchdog_tokens, WATCHDOG_DEBUG);
@@ -178,7 +183,7 @@ function _ldap_authorizations_user_authorizations(&$user, $op, $consumer_type, $
     ldap_authorization_maps_alter_invoke($user, $ldap_user, $ldap_server, $consumer->consumerConf, $proposed_ldap_authorizations, $op);
 
     /** make sure keys of array are lower case and values are mixed case
-      and strip to first attribute is configured
+     * and strip to first attribute is configured
     */
 
     foreach ($proposed_ldap_authorizations as $key => $authorization_id) {
@@ -225,7 +230,8 @@ function _ldap_authorizations_user_authorizations(&$user, $op, $consumer_type, $
      */
 
     $filtered_ldap_authorizations = array();
-    if ($consumer->consumerConf->useMappingsAsFilter) { // filter + map
+    // Filter + map.
+    if ($consumer->consumerConf->useMappingsAsFilter) {
       foreach ($consumer->consumerConf->mappings as $mapping_filter) {
         $map_from = $mapping_filter['from'];
         $map_to = $mapping_filter['normalized'];
@@ -234,7 +240,8 @@ function _ldap_authorizations_user_authorizations(&$user, $op, $consumer_type, $
         }
       }
     }
-    else { // only map, don't filter off authorizations that have no mapping
+    // Only map, don't filter off authorizations that have no mapping.
+    else {
       $_authorizations = array_values($proposed_ldap_authorizations);
       if (is_array($consumer->consumerConf->mappings) && is_array($proposed_ldap_authorizations)) {
         foreach ($consumer->consumerConf->mappings as $mapping_filter) {
@@ -242,12 +249,12 @@ function _ldap_authorizations_user_authorizations(&$user, $op, $consumer_type, $
           $map_to = $mapping_filter['normalized'];
           $map_from_key = array_search(drupal_strtolower($map_from), array_keys($proposed_ldap_authorizations));
           if ($map_from_key !== FALSE) {
-            // remove non mapped authorization
+            // Remove non mapped authorization.
             $_authorizations = array_diff($_authorizations, array($map_from));
             $_authorizations = array_diff($_authorizations, array(drupal_strtolower($map_from)));
-            // add mapped authorization
+            // Add mapped authorization.
             $_authorizations[] = $map_to;
-            // remove map from;
+            // Remove map from;.
           }
         }
       }
@@ -255,12 +262,13 @@ function _ldap_authorizations_user_authorizations(&$user, $op, $consumer_type, $
         $filtered_ldap_authorizations[drupal_strtolower($authorization_id)] = array(
           'map_to_string' => $authorization_id,
           'exists' => NULL,
-          'value' => $authorization_id
+          'value' => $authorization_id,
         );
       }
     }
 
-    $consumer->populateConsumersFromConsumerIds($filtered_ldap_authorizations, $consumer->consumerConf->createConsumers); // set values of $filtered_ldap_authorizations to consumers
+    // Set values of $filtered_ldap_authorizations to consumers.
+    $consumer->populateConsumersFromConsumerIds($filtered_ldap_authorizations, $consumer->consumerConf->createConsumers);
     /**
      * now that we have list of consumers that are to be granted, give other modules a chance to alter it
      *
@@ -291,7 +299,13 @@ function _ldap_authorizations_user_authorizations(&$user, $op, $consumer_type, $
         $display_authorizations[] = $_consumer['map_to_string'];
       }
       $_SESSION['ldap_authorization_test_query']['post mappings'] = $display_authorizations;
-      $data = property_exists($user, 'data') ? $user->data['ldap_authorizations'][$consumer->consumerType] : array();
+      if (property_exists($user, 'data') &&
+        isset($user->data['ldap_authorizations'][$consumer->consumerType])) {
+        $data = $user->data['ldap_authorizations'][$consumer->consumerType];
+      }
+      else {
+        $data = [];
+      }
       $_SESSION['ldap_authorization_test_query']['user data'] = $data;
     }
 
@@ -313,19 +327,22 @@ function _ldap_authorizations_user_authorizations(&$user, $op, $consumer_type, $
   return array($authorizations, $notifications);
 
 }
+
 /**
- * @param object $user is a drupal user account object, need not be current user
- * @param object $consumer is instance of an authorization consumer class
- *   such as LdapAuthorizationConsumerDrupalRole
+ * @param object $user
+ *   is a drupal user account object, need not be current user.
+ * @param object $consumer
+ *   is instance of an authorization consumer class
+ *   such as LdapAuthorizationConsumerDrupalRole.
  * @param associative array of lower case authorization ids as keys and
- *    mixed case strings as values $filtered_ldap_authorizations
+ *   mixed case strings as values $filtered_ldap_authorizations
  *   all authorization ids a user is granted via ldap authorization configuration
- * @param object $ldap_entry is users ldap entry.  mapping of drupal user to
+ * @param object $ldap_entry
+ *   is users ldap entry.  mapping of drupal user to
  *   ldap entry is stored in ldap_server configuration
  *
- * returns nothing
+ *   returns nothing.
  */
-
 function _ldap_authorizations_user_authorizations_set(&$user, $consumer, $filtered_ldap_authorizations, &$ldap_entry, $watchdog_tokens, $test) {
 
   $detailed_watchdog_log = variable_get('ldap_help_watchdog_detail', 0);
@@ -352,12 +369,12 @@ function _ldap_authorizations_user_authorizations_set(&$user, $consumer, $filter
 
   $watchdog_tokens['%initial'] = join(', ', $initial_existing_ldap_authorizations);
   $watchdog_tokens['%filtered_ldap_authorizations'] = join(', ', array_keys($filtered_ldap_authorizations));
-   /**
+  /**
    * B. if regrantLdapProvisioned is false, $grants_lcase array should only be new authorizations
    */
 
   if (!$consumer->consumerConf->regrantLdapProvisioned) {
-    // if regranting disabled, filter off previously granted roles
+    // If regranting disabled, filter off previously granted roles.
     $grants = array_diff(array_keys($filtered_ldap_authorizations), $initial_existing_ldap_authorizations);
     if ($test) {
       $_SESSION['ldap_authorization_test_query']['setting_data']['Grants after regrantLdapProvisioned filter'] = $grants;
@@ -369,11 +386,12 @@ function _ldap_authorizations_user_authorizations_set(&$user, $consumer, $filter
 
   $watchdog_tokens['%grants1'] = join(', ', $grants);
 
-   /**
+  /**
    * D.  Only grant authorization consumer ids that exist
    */
 
-  $existing_grants = array(); // keys are lcase, values are mixed case
+  // Keys are lcase, values are mixed case.
+  $existing_grants = array();
   foreach ($grants as $i => $grant) {
     if (!empty($filtered_ldap_authorizations[$grant]['exists'])) {
       $existing_grants[$grant] = $filtered_ldap_authorizations[$grant];
@@ -396,7 +414,8 @@ function _ldap_authorizations_user_authorizations_set(&$user, $consumer, $filter
   if ($consumer->consumerConf->revokeLdapProvisioned) {
     $revokes_lcase = $consumer->authorizationDiff($initial_existing_ldap_authorizations, array_keys($filtered_ldap_authorizations));
     if (count($revokes_lcase)) {
-      $revokes = array(); // keys are lcase, values are mixed case
+      // Keys are lcase, values are mixed case.
+      $revokes = array();
       foreach ($revokes_lcase as $i => $revoke_lcase) {
         $revokes[$revoke_lcase] = array(
           'value' => NULL,
@@ -423,10 +442,12 @@ function _ldap_authorizations_user_authorizations_set(&$user, $consumer, $filter
   $uid = $user->uid;
   $user_edit = array('data' => $user->data);
   $user_edit['data']['ldap_authorizations'] = empty($user->data['ldap_authorizations']) ? array() : $user->data['ldap_authorizations'];
-  $consumer->sortConsumerIds('grant', $user_auth_data);  // keep in good display order
+  // Keep in good display order.
+  $consumer->sortConsumerIds('grant', $user_auth_data);
   $user_edit['data']['ldap_authorizations'][$consumer->consumerType] = $user_auth_data;
   $watchdog_tokens['%user_edit_presave'] = print_r($user_edit, TRUE);
-  if (empty($user->picture->fid)) { // see #1973352 and #935592
+  // See #1973352 and #935592.
+  if (empty($user->picture->fid)) {
     $user2 = user_load($user->uid);
     $user->picture = $user2->picture;
   }
@@ -464,12 +485,15 @@ function _ldap_authorizations_user_authorizations_set(&$user, $consumer, $filter
 
 }
 
+/**
+ *
+ */
 function _ldap_authorization_ldap_authorization_maps_alter(&$user, &$user_ldap_entry, &$ldap_server, &$consumer_conf, &$authz_ids, $op) {
 
   $detailed_watchdog_log = variable_get('ldap_help_watchdog_detail', 0);
   $watchdog_tokens = array();
 
-  // groups extracted from user's DN. such as ou=IT => group = "IT"
+  // Groups extracted from user's DN. such as ou=IT => group = "IT".
   $derive_from_dn_authorizations = array();
   if ($rdn_values = $consumer_conf->server->groupUserMembershipsFromDn($user)) {
     $derive_from_dn_authorizations = array_combine($rdn_values, $rdn_values);
@@ -481,7 +505,7 @@ function _ldap_authorization_ldap_authorization_maps_alter(&$user, &$user_ldap_e
     $_SESSION['ldap_authorization_test_query']['maps']['Derive from DN'] = ($rdn_values) ? $derive_from_dn_authorizations : t('disabled');
   }
 
-  // traditional groups (dns)
+  // Traditional groups (dns)
   $group_dns = $consumer_conf->server->groupMembershipsFromUser($user, 'group_dns');
   if (!$group_dns) {
     $group_dns = array();
@@ -501,7 +525,7 @@ function _ldap_authorization_ldap_authorization_maps_alter(&$user, &$user_ldap_e
     $watchdog_tokens['%ldap_server'] = $ldap_server->sid;
     $watchdog_tokens['%deriveFromDn'] = join(', ', $derive_from_dn_authorizations);
     $watchdog_tokens['%deriveFromGroups'] = join(', ', $group_dns);
-    $watchdog_tokens['%authz_ids'] =  join(', ', array_keys($authz_ids));
+    $watchdog_tokens['%authz_ids'] = join(', ', array_keys($authz_ids));
 
     watchdog('ldap_authorization', '%username :_ldap_authorization_ldap_authorization_maps_alter:
       <hr/>deriveFromDn authorization ids: %deriveFromDn
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.info b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.info
index b808c9ec..775c0791 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.info
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.info
@@ -19,9 +19,8 @@ configure = admin/config/people/ldap/authorization
 
 test_dependencies[] = ldap_sso:ldap_sso
 
-; Information added by Drupal.org packaging script on 2017-08-27
-version = "7.x-2.3"
+; Information added by Drupal.org packaging script on 2018-08-13
+version = "7.x-2.4"
 core = "7.x"
 project = "ldap"
-datestamp = "1503841448"
-
+datestamp = "1534201086"
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.install b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.install
index 3d35e766..2be53ed9 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.install
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.install
@@ -11,7 +11,7 @@
 function ldap_authorization_requirements($phase) {
   $requirements = array();
 
-if ($phase != "install" && db_field_exists('ldapauth', 'ldapgroups_in_dn' )) {
+  if ($phase != "install" && db_field_exists('ldapauth', 'ldapgroups_in_dn')) {
     $requirements['ldap_authorization_ldap_integration']['title'] = t('LDAP Integration LDAP Groups Upgrade Concern');
     $requirements['ldap_authorization_ldap_integration']['severity'] = REQUIREMENT_WARNING;
     $requirements['ldap_authorization_ldap_integration']['value'] = NULL;
@@ -21,7 +21,7 @@ if ($phase != "install" && db_field_exists('ldapauth', 'ldapgroups_in_dn' )) {
       See also. See http://drupal.org/node/1023016, http://drupal.org/node/1183192.
       This message will go away when the ldapauth database table is removed.');
   }
-  // check that ldapauth not installed.
+  // Check that ldapauth not installed.
   return $requirements;
 }
 
@@ -41,8 +41,6 @@ function ldap_authorization_install() {
 
 }
 
-
-
 /**
  * Implements hook_uninstall().
  */
@@ -62,10 +60,12 @@ function ldap_authorization_uninstall() {
   module_load_include('inc', 'ldap_servers', 'ldap_servers.user_data_remove');
   batch_set(ldap_severs_user_data_setup_batch());
   $batch =& batch_get();
-  
-}
 
+}
 
+/**
+ *
+ */
 function ldap_authorization_user_entity_fields() {
 
   $fields = array();
@@ -73,7 +73,6 @@ function ldap_authorization_user_entity_fields() {
   return $fields;
 }
 
-
 /**
  * Implements hook_schema().
  */
@@ -117,7 +116,7 @@ function ldap_authorization_schema() {
 }
 
 /**
- * add 'create_consumers field to ldap_authorization table
+ * Add 'create_consumers field to ldap_authorization table.
  */
 function ldap_authorization_update_7100() {
 
@@ -137,7 +136,7 @@ function ldap_authorization_update_7100() {
 }
 
 /**
- * add derive_from_attr_use_first_attr field to ldap_authorization table
+ * Add derive_from_attr_use_first_attr field to ldap_authorization table.
  */
 function ldap_authorization_update_7101() {
 
@@ -156,9 +155,8 @@ function ldap_authorization_update_7101() {
 
 }
 
-
 /**
- * Add derive_from_entry_search_all column to ldap_authorization
+ * Add derive_from_entry_search_all column to ldap_authorization.
  */
 function ldap_authorization_update_7102() {
 
@@ -178,36 +176,36 @@ function ldap_authorization_update_7102() {
 }
 
 /**
- * change derive_from_attr_attr and derive_from_entry fields to text instead of varchar 2555
+ * Change derive_from_attr_attr and derive_from_entry fields to text instead of varchar 2555.
  */
 function ldap_authorization_update_7103() {
 
   foreach (array('derive_from_dn_attr', 'derive_from_attr_attr', 'derive_from_entry_entries') as $field_name) {
     db_change_field('ldap_authorization', $field_name, $field_name, array(
-    'type' => 'text',
-    'not null' => FALSE,
+      'type' => 'text',
+      'not null' => FALSE,
     ));
   }
 
 }
 
 /**
- * change derive_from_attr_attr and derive_from_entry fields to text instead of varchar 2555
+ * Change derive_from_attr_attr and derive_from_entry fields to text instead of varchar 2555
  * applied second time because beta6 and 7 were wrong.
  */
 function ldap_authorization_update_7104() {
 
   foreach (array('derive_from_dn_attr', 'derive_from_attr_attr', 'derive_from_entry_entries') as $field_name) {
     db_change_field('ldap_authorization', $field_name, $field_name, array(
-    'type' => 'text',
-    'not null' => FALSE,
+      'type' => 'text',
+      'not null' => FALSE,
     ));
   }
 
 }
 
 /**
- * add derive_from_entry_user_ldap_attr field to allow user specification of dn or other identifier.
+ * Add derive_from_entry_user_ldap_attr field to allow user specification of dn or other identifier.
  */
 function ldap_authorization_update_7105() {
 
@@ -226,7 +224,7 @@ function ldap_authorization_update_7105() {
 }
 
 /**
- * add nested checkboxes to derive from entry and attributes strategies.
+ * Add nested checkboxes to derive from entry and attributes strategies.
  */
 function ldap_authorization_update_7106() {
 
@@ -247,14 +245,14 @@ function ldap_authorization_update_7106() {
       'not null' => TRUE,
       'default' => 0,
     ));
-    $msg .=  t('"derive_from_entry_nested" field added to ldap_authorization table');
+    $msg .= t('"derive_from_entry_nested" field added to ldap_authorization table');
   }
 
-  return ($msg) ? $msg :  t('No database changes made.');
+  return ($msg) ? $msg : t('No database changes made.');
 }
 
 /**
- * add derive_from_entry_use_first_attr field to and remove description field from ldap_authorization table
+ * Add derive_from_entry_use_first_attr field to and remove description field from ldap_authorization table.
  */
 function ldap_authorization_update_7107() {
 
@@ -272,16 +270,15 @@ function ldap_authorization_update_7107() {
 
   if (db_field_exists('ldap_authorization', 'description')) {
     db_drop_field('ldap_authorization', 'description');
-    $changes .=  t('"description" field dropped from to ldap_authorization table');
+    $changes .= t('"description" field dropped from to ldap_authorization table');
   }
 
   return ($changes) ? $changes : t('No database changes made.');
 
 }
 
-
 /**
- * add derive_from_entry_entries_attr field to allow user specification of attribute representing group in queries.
+ * Add derive_from_entry_entries_attr field to allow user specification of attribute representing group in queries.
  */
 function ldap_authorization_update_7108() {
 
@@ -301,11 +298,11 @@ function ldap_authorization_update_7108() {
 }
 
 /**
- * moving some groups related fields into ldap server module
+ * Moving some groups related fields into ldap server module.
  */
 function ldap_authorization_update_7201() {
 
-// need to merge 2 table fields (derive_from_entry_use_first_attr and derive_from_attr_use_first_attr into one field useFirstAttrAsGroupId)
+  // Need to merge 2 table fields (derive_from_entry_use_first_attr and derive_from_attr_use_first_attr into one field useFirstAttrAsGroupId)
   $results = '';
 
   if (!db_field_exists('ldap_authorization', 'useFirstAttrAsGroupId')) {
@@ -329,24 +326,23 @@ function ldap_authorization_update_7201() {
   }
 }
 
-
 /**
- * remove user ldap authorizations field.  its in $user->data now
+ * Remove user ldap authorizations field.  its in $user->data now.
  */
 function ldap_authorization_update_7202() {
 
-    $instance = array(
-      'field_name' => 'ldap_authorizations',
-      'entity_type' => 'user',
-      'bundle' => 'user',
-    );
-    field_delete_instance($instance, TRUE);
-    field_delete_field('ldap_authorizations');
+  $instance = array(
+    'field_name' => 'ldap_authorizations',
+    'entity_type' => 'user',
+    'bundle' => 'user',
+  );
+  field_delete_instance($instance, TRUE);
+  field_delete_field('ldap_authorizations');
 
 }
 
 /**
- * make all schema field names lowercase in ldap server to deal with cronic case sensitivity issues
+ * Make all schema field names lowercase in ldap server to deal with cronic case sensitivity issues.
  */
 function ldap_authorization_update_7203() {
 
@@ -368,14 +364,14 @@ function ldap_authorization_update_7203() {
 }
 
 /**
- * make all schema field names lowercase in ldap server to deal with cronic case sensitivity issues
+ * Make all schema field names lowercase in ldap server to deal with cronic case sensitivity issues.
  */
 function ldap_authorization_update_7204() {
 
   $schema = ldap_authorization_schema();
   $field_schema = $schema['ldap_authorization']['fields']['mappings'];
   if (db_field_exists('ldap_authorization', 'mappings')) {
-     db_change_field('ldap_authorization', 'mappings', 'mappings', $field_schema);
+    db_change_field('ldap_authorization', 'mappings', 'mappings', $field_schema);
   }
 
 }
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.module b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.module
index 0faa848c..cdcd4dd8 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.module
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.module
@@ -2,7 +2,7 @@
 
 /**
  * @file
- * ldap authorization module
+ * Ldap authorization module.
  */
 
 define('LDAP_AUTHORIZATION_PROJECT_TAG', 'ldap_authorization');
@@ -14,16 +14,14 @@ define('LDAP_AUTHORIZATION_SERVER_CONFIG_NOT_FOUND', 105);
 
 define('LDAP_AUTHORIZATION_NO_LDAP_SERVERS', 'ldap_authorization_no_ldap_servers');
 
-
 /**
- * this is a workaround for og 7.x-2.x bug I believe
+ * This is a workaround for og 7.x-2.x bug I believe.
  */
-
 function ldap_authorization_cleanse_empty_og_fields(&$user) {
   if (property_exists($user, 'og_user_group_ref') && is_array($user->og_user_group_ref) && count($user->og_user_group_ref) == 0) {
     unset($user->og_user_group_ref);
   }
-  if (property_exists($user, 'og_other_user_group_ref') && is_array($user->og_other_user_group_ref) && count($user->og_other_user_group_ref) == 0 ) {
+  if (property_exists($user, 'og_other_user_group_ref') && is_array($user->og_other_user_group_ref) && count($user->og_other_user_group_ref) == 0) {
     unset($user->og_other_user_group_ref);
   }
 }
@@ -49,20 +47,20 @@ function ldap_authorization_menu() {
   );
 
   $items['admin/config/people/ldap/authorization/edit/%'] = array(
-     'title' => 'Edit LDAP Authorization Configuration',
-     'page callback' => 'drupal_get_form',
-     'page arguments' => array('ldap_authorization_admin_form', 6, 'edit'),
-     'access arguments' => array('administer site configuration'),
-     'file' => 'ldap_authorization.admin.inc',
+    'title' => 'Edit LDAP Authorization Configuration',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('ldap_authorization_admin_form', 6, 'edit'),
+    'access arguments' => array('administer site configuration'),
+    'file' => 'ldap_authorization.admin.inc',
   );
 
   $items['admin/config/people/ldap/authorization/delete/%'] = array(
-     'title' => 'Delete LDAP Authorization Configuration',
-     'description' => 'Delete an ldap authorization configuration',
-     'page callback' => 'drupal_get_form',
-     'page arguments' => array('ldap_authorization_admin_form', 6, 'delete'),
-     'access arguments' => array('administer site configuration'),
-     'file' => 'ldap_authorization.admin.inc',
+    'title' => 'Delete LDAP Authorization Configuration',
+    'description' => 'Delete an ldap authorization configuration',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('ldap_authorization_admin_form', 6, 'delete'),
+    'access arguments' => array('administer site configuration'),
+    'file' => 'ldap_authorization.admin.inc',
   );
 
   $items['admin/config/people/ldap/authorization/test/%'] = array(
@@ -85,7 +83,6 @@ function ldap_authorization_menu() {
   return $items;
 }
 
-
 /**
  * Implements hook_user_login() login operation.
  */
@@ -94,13 +91,13 @@ function ldap_authorization_user_login(&$edit, $user) {
   if (variable_get('ldap_help_watchdog_detail', FALSE)) {
     foreach ($authorizations as $consumer_type => $authorization_ids) {
       $ul = theme('item_list', array('title' => $consumer_type, 'items' => array_keys($authorization_ids), 'type' => 'ul'));
-      watchdog('ldap_authentication', 'ldap_authorization_user_login.authorizations' . $ul , array(), WATCHDOG_DEBUG);
+      watchdog('ldap_authentication', 'ldap_authorization_user_login.authorizations' . $ul, array(), WATCHDOG_DEBUG);
     }
   }
 }
 
 /**
- * ldap_authorization_maps_alter_invoke invokes hook_ldap_authorization_maps_alter() in every module.
+ * Ldap_authorization_maps_alter_invoke invokes hook_ldap_authorization_maps_alter() in every module.
  *
  * We cannot use module_invoke() for this, because the arguments need to
  * be passed by reference.
@@ -108,7 +105,7 @@ function ldap_authorization_user_login(&$edit, $user) {
 function ldap_authorization_maps_alter_invoke(&$user, &$user_ldap_entry, &$ldap_server, &$consumer_conf, &$proposed_ldap_authorizations, $op) {
   foreach (module_implements('ldap_authorization_maps_alter') as $module) {
     $function = $module . '_ldap_authorization_maps_alter';
-    $function($user, $user_ldap_entry, $ldap_server, $consumer_conf, $proposed_ldap_authorizations,  $op);
+    $function($user, $user_ldap_entry, $ldap_server, $consumer_conf, $proposed_ldap_authorizations, $op);
   }
 }
 
@@ -144,7 +141,8 @@ function ldap_authorization_ldap_attributes_needed_alter(&$attribute_maps, $para
       if ($consumer_conf->server->groupUserMembershipsAttrExists) {
         $attribute_name = $consumer_conf->server->groupUserMembershipsAttr;
         if ($attribute_name) {
-          $attribute_maps[$attribute_name] = ldap_servers_set_attribute_map($attribute_name); //array($attribute_name, 0, NULL);
+          // array($attribute_name, 0, NULL);.
+          $attribute_maps[$attribute_name] = ldap_servers_set_attribute_map($attribute_name);
         }
       }
     }
@@ -155,45 +153,51 @@ function ldap_authorization_ldap_attributes_needed_alter(&$attribute_maps, $para
 /**
  * Implements hook_ldap_authorization_maps_alter().
  *
- * to suggest authorization ids to grant (drupal roles in this case)
+ * To suggest authorization ids to grant (drupal roles in this case)
  *
- * @param object $user drupal user object
+ * @param object $user
+ *   drupal user object.
  *
- * @param array $user_ldap_entry is ldap data from ldap entry which drupal user is mapped to
+ * @param array $user_ldap_entry
+ *   is ldap data from ldap entry which drupal user is mapped to.
  *
  * @param object $ldap_server
  *
- * @param array $consumer_conf .
- *
- * @param array $authz_ids.  any new authorization ids (drupal user role names in this case) in form array('rolename1', 'rolename2',....)
+ * @param array $consumer_conf
+ *   .
  *
- * @param string $op = 'set' or 'query'
+ * @param array $authz_ids
+ *   any new authorization ids (drupal user role names in this case) in form array('rolename1', 'rolename2',....)
  *
+ * @param string $op
+ *   = 'set' or 'query'.
  */
 function ldap_authorization_ldap_authorization_maps_alter(&$user, &$user_ldap_entry, &$ldap_server, &$consumer_conf, &$authz_ids, $op) {
 
   ldap_servers_module_load_include('inc', 'ldap_authorization', 'ldap_authorization');
-  _ldap_authorization_ldap_authorization_maps_alter($user, $user_ldap_entry, $ldap_server, $consumer_conf, $authz_ids,  $op);
+  _ldap_authorization_ldap_authorization_maps_alter($user, $user_ldap_entry, $ldap_server, $consumer_conf, $authz_ids, $op);
 }
 
-
+/**
+ *
+ */
 function ldap_authorization_theme() {
   return array(
     'ldap_authorization_test_results' => array(
       'variables' => array('data' => NULL),
       'render element' => 'element',
-      'file' => 'ldap_authorization.theme.inc'
+      'file' => 'ldap_authorization.theme.inc',
     ),
     'ldap_authorization_admin_index' => array(
       'variables' => array('consumers' => NULL),
       'render element' => 'element',
-      'file' => 'ldap_authorization.theme.inc'
+      'file' => 'ldap_authorization.theme.inc',
     ),
   );
 }
 
 /**
- * param string $consumer_type is machine name of consumer such as drupal_role
+ * Param string $consumer_type is machine name of consumer such as drupal_role.
  *
  * @return consumer object
  */
@@ -202,7 +206,7 @@ function ldap_authorization_get_consumer_object($consumer_type) {
   $consumer = ldap_authorization_get_consumers($consumer_type, TRUE, TRUE);
 
   if ($consumer) {
-    require_once(drupal_get_path('module', $consumer['consumer_module']) . '/' . $consumer['consumer_class_file']);
+    require_once drupal_get_path('module', $consumer['consumer_module']) . '/' . $consumer['consumer_class_file'];
     $class = $consumer['consumer_class_name'];
     $consumer_obj = new $class($consumer_type);
     $consumer_obj->detailedWatchdogLog = variable_get('ldap_help_watchdog_detail', 0);
@@ -214,9 +218,12 @@ function ldap_authorization_get_consumer_object($consumer_type) {
 }
 
 /**
- * @param string $consumer_type is machine name of consumer type such as "drupal_role"
- * @param boolean $reset signifies clear static variable
- * @param boolean $flatten signies return individual consumer not keyed on consumer type
+ * @param string $consumer_type
+ *   is machine name of consumer type such as "drupal_role".
+ * @param bool $reset
+ *   signifies clear static variable.
+ * @param bool $flatten
+ *   signies return individual consumer not keyed on consumer type.
  *
  * @return array (1) if $flatten is true, consumer configuration array
  *   otherwise (2) associative array of consumer configurations keyed on consumer type such as "drupal_role"
@@ -243,13 +250,14 @@ function ldap_authorization_get_consumers($consumer_type = NULL, $reset = FALSE,
  * so it can be called from a batch synchronization process for example
  *
  * @param drupal user object $user
- * @param string $op indicating operation such as query, set, test_query, etc.
- * @param string $consumer_type e.g. drupal_role, or og_groups
+ * @param string $op
+ *   indicating operation such as query, set, test_query, etc.
+ * @param string $consumer_type
+ *   e.g. drupal_role, or og_groups.
  * @param string $context
  *
  * @return array of form:
- * $authorizations[<consumer_type>][<authorization_id>]
- *
+ *   $authorizations[<consumer_type>][<authorization_id>]
  */
 function ldap_authorizations_user_authorizations(&$user, $op = 'query', $consumer_type = NULL, $context = NULL) {
   ldap_servers_module_load_include('inc', 'ldap_authorization', 'ldap_authorization');
@@ -270,6 +278,9 @@ function ldap_authorizations_user_authorizations(&$user, $op = 'query', $consume
   return array($new_authorizations, $notifications);
 }
 
+/**
+ *
+ */
 function ldap_authorization_help($path, $arg) {
 
   $authorization_help = t('LDAP authorization allows LDAP data such as group memberships,
@@ -291,8 +302,8 @@ function ldap_authorization_help($path, $arg) {
   }
 }
 
-/** just tokens for better watchdog and drupal_set_message arguments **/
-
+/**
+ * Just tokens for better watchdog and drupal_set_message arguments .**/
 function ldap_authorization_tokens($consumer) {
   $tokens = array();
 
@@ -311,7 +322,9 @@ function ldap_authorization_tokens($consumer) {
   return $tokens;
 }
 
-
+/**
+ *
+ */
 function ldap_authorization_get_consumer_admin_object($consumer_type, $new = NULL) {
   ldap_servers_module_load_include('php', 'ldap_authorization', 'LdapAuthorizationConsumerConfAdmin.class');
   $consumer_object = ldap_authorization_get_consumer_object($consumer_type);
@@ -319,6 +332,9 @@ function ldap_authorization_get_consumer_admin_object($consumer_type, $new = NUL
   return $consumer_conf_admin;
 }
 
+/**
+ *
+ */
 function ldap_authorization_get_consumer_conf($consumer_type, $type = 'default', $new = NULL) {
   $consumer_object = ldap_authorization_get_consumer_object($consumer_type);
   if ($type == 'admin') {
@@ -332,14 +348,12 @@ function ldap_authorization_get_consumer_conf($consumer_type, $type = 'default',
   return $consumer_conf;
 }
 
-
 /**
  * Implements hook_ldap_user_attrs_list_alter().
  */
-
 function ldap_authorization_ldap_user_attrs_list_alter(&$available_user_attrs, &$params) {
 
-  // this is a case where a field is being denied synching configuration because its not meant to be used by other modules
+  // This is a case where a field is being denied synching configuration because its not meant to be used by other modules.
   $available_user_attrs['[field.ldap_authorizations]'] = array(
     'name' => 'Field: LDAP Authorizations',
     'source' => 'LDAP Authorization modules',
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.theme.inc b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.theme.inc
index 1dcc9e40..c82ea62d 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.theme.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.theme.inc
@@ -2,14 +2,17 @@
 
 /**
  * @file
- * theming functions for the LDAP authorization module.
+ * Theming functions for the LDAP authorization module.
  */
 
+/**
+ *
+ */
 function theme_ldap_authorization_admin_index(&$variables) {
   $consumers = $variables['consumers'];
 
   $table = array(
-    'header' =>  array(t('LDAP Server ID'), t('Description'), t('Module'), t('Consumer Type'), t('Enabled'), t('Operations')),
+    'header' => array(t('LDAP Server ID'), t('Description'), t('Module'), t('Consumer Type'), t('Enabled'), t('Operations')),
     'attributes' => array('id' => 'ldap_consumer_confs', 'class' => 'data'),
     'colgroups' => array(),
     'sticky' => FALSE,
@@ -22,10 +25,10 @@ function theme_ldap_authorization_admin_index(&$variables) {
 
     if ($consumer->consumerConf->inDatabase) {
       $admin = new LdapAuthorizationConsumerConfAdmin($consumer);
-      $actions =  join(' | ', $admin->getLdapAuthorizationConsumerActions());
+      $actions = join(' | ', $admin->getLdapAuthorizationConsumerActions());
     }
     else {
-      $actions =  l(t('add'), LDAP_SERVERS_MENU_BASE_PATH . '/authorization/add/' . $consumer->consumerType);
+      $actions = l(t('add'), LDAP_SERVERS_MENU_BASE_PATH . '/authorization/add/' . $consumer->consumerType);
     }
 
     $table['rows'][] = array(
@@ -34,14 +37,16 @@ function theme_ldap_authorization_admin_index(&$variables) {
       $consumer->consumerModule,
       $consumer_type,
       ($consumer->consumerConf->status) ? t('Yes') : t('No'),
-      $actions
+      $actions,
     );
   }
   return theme('table', $table);
 
 }
 
-
+/**
+ *
+ */
 function theme_ldap_authorization_test_results($variables) {
 
   $results = $variables['results'];
@@ -69,7 +74,7 @@ function theme_ldap_authorization_test_results($variables) {
       foreach ($user_results as $consumer_type => $authorizations) {
         if (is_array($authorizations) && count($authorizations) > 0) {
           $authorizations = $consumer->convertToFriendlyAuthorizationIds($authorizations);
-          $authorizations_text =  theme('item_list', array('items' => array_values($authorizations), 'title' => NULL, 'type' => 'ul', 'attributes' => array()));
+          $authorizations_text = theme('item_list', array('items' => array_values($authorizations), 'title' => NULL, 'type' => 'ul', 'attributes' => array()));
         }
         else {
           $authorizations_text = "";
@@ -85,7 +90,7 @@ function theme_ldap_authorization_test_results($variables) {
         }
         elseif (is_array($user_notifications) && count($user_notifications) > 0) {
           foreach ($user_notifications as $i => $notification) {
-            $authorizations_text .=  ldap_authorization_map_errors($notification, $consumer_conf_link);
+            $authorizations_text .= ldap_authorization_map_errors($notification, $consumer_conf_link);
           }
         }
         $row = array($username_link, $consumer->name, $authorizations_text, $consumer_conf_link, $server_link);
@@ -98,8 +103,11 @@ function theme_ldap_authorization_test_results($variables) {
 
   return $output;
 
-  }
+}
 
+/**
+ *
+ */
 function ldap_authorization_map_errors($err_id, $consumer_conf_link) {
 
   $tokens = array('%consumer_conf_link' => $consumer_conf_link);
@@ -107,24 +115,24 @@ function ldap_authorization_map_errors($err_id, $consumer_conf_link) {
 
     case  LDAP_AUTHORIZATION_USER_LDAP_NOT_FOUND:
       $authorizations_text = t('LDAP entry for drupal user not found.', $tokens);
-    break;
+      break;
 
     case LDAP_AUTHORIZATION_USER_NOT_LDAP_AUTHENTICATED:
       $authorizations_text = t('LDAP Authorizations not applied because user is not
       authenticated via LDAP and configuration requires is (%consumer_conf_link).', $tokens);
-    break;
+      break;
 
     case LDAP_AUTHORIZATION_MAP_NOT_CONF_FOR_LOGON:
       $authorizations_text = t('LDAP Authorizations not configured to be executed on logon in  (%consumer_conf_link).', $tokens);
-    break;
+      break;
 
     case LDAP_AUTHORIZATION_NOT_APPLY_USER_1:
       $authorizations_text = t('LDAP Authorizations not applicable to user 1.', $tokens);
-    break;
+      break;
 
     case LDAP_AUTHORIZATION_SERVER_CONFIG_NOT_FOUND:
       $authorizations_text = t('Enabled LDAP server configuration not found for given ldap consumer type in (%consumer_conf_link).', $tokens);
-    break;
+      break;
 
     default:
       $authorizations_text = "Failed.";
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/LdapAuthorizationConsumerRole.class.php b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/LdapAuthorizationConsumerRole.class.php
index 104a0fbb..f587c1fc 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/LdapAuthorizationConsumerRole.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/LdapAuthorizationConsumerRole.class.php
@@ -2,14 +2,13 @@
 
 /**
  * @file
- *
- * class to represent configuration of ldap authorizations to drupal roles
- *
- *
+ * Class to represent configuration of ldap authorizations to drupal roles.
  */
 
 module_load_include('php', 'ldap_authorization', 'LdapAuthorizationConsumerAbstract.class');
-
+/**
+ *
+ */
 class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstract {
 
   public $consumerType = 'drupal_role';
@@ -22,9 +21,12 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
     'revokeLdapProvisioned' => TRUE,
     'regrantLdapProvisioned' => TRUE,
     'createConsumers' => TRUE,
-    );
+  );
 
-  function __construct($consumer_type = NULL) {
+  /**
+   *
+   */
+  public function __construct($consumer_type = NULL) {
     $params = ldap_authorization_drupal_role_ldap_authorization_consumer();
     parent::__construct('drupal_role', $params['drupal_role']);
   }
@@ -32,13 +34,13 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
   /**
    * @see LdapAuthorizationConsumerAbstract::createConsumer
    */
-
   public function createConsumer($consumer_id, $consumer) {
     $roles_by_consumer_id = $this->existingRolesByRoleName();
     $existing_role = isset($roles_by_consumer_id[$consumer_id]) ? $roles_by_consumer_id[$consumer_id] : FALSE;
 
     if ($existing_role) {
-      return FALSE; // role exists
+      // Role exists.
+      return FALSE;
     }
     elseif (drupal_strlen($consumer_id) > 63) {
       watchdog('ldap_authorization_drupal_role', 'Tried to create drupal role
@@ -49,30 +51,31 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
 
     $new_role = new stdClass();
     $new_role->name = empty($consumer['value']) ? $consumer_id : $consumer['value'];
-    if (! ($status = user_role_save($new_role))) {
-      // if role is not created, remove from array to user object doesn't have it stored as granted
+    if (!($status = user_role_save($new_role))) {
+      // If role is not created, remove from array to user object doesn't have it stored as granted.
       watchdog('user', 'failed to create drupal role %role in ldap_authorizations module', array('%role' => $new_role->name));
       return FALSE;
     }
     else {
-      $roles_by_consumer_id = $this->existingRolesByRoleName(TRUE); // flush existingRolesByRoleName cache after creating new role
+      // Flush existingRolesByRoleName cache after creating new role.
+      $roles_by_consumer_id = $this->existingRolesByRoleName(TRUE);
       watchdog('user', 'created drupal role %role in ldap_authorizations module', array('%role' => $new_role->name));
     }
     return TRUE;
   }
 
-
   /**
    * @see LdapAuthorizationConsumerAbstract::populateConsumersFromConsumerIds
    */
-
   public function populateConsumersFromConsumerIds(&$consumers, $create_missing_consumers = FALSE) {
 
     $roles_by_consumer_id = $this->existingRolesByRoleName(TRUE);
     foreach ($consumers as $consumer_id => $consumer) {
 
-      if (!$consumer['exists']) { // role marked as not existing
-        if (isset($roles_by_consumer_id[$consumer_id])) { // check if is existing
+      // Role marked as not existing.
+      if (!$consumer['exists']) {
+        // Check if is existing.
+        if (isset($roles_by_consumer_id[$consumer_id])) {
           $consumer['exists'] = TRUE;
           $consumer['value'] = $roles_by_consumer_id[$consumer_id]['role_name'];
           $consumer['name'] = $consumer['map_to_string'];
@@ -95,16 +98,20 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
     }
   }
 
-
+  /**
+   *
+   */
   public function revokeSingleAuthorization(&$user, $consumer_id, $consumer, &$user_auth_data, $user_save = FALSE, $reset = FALSE) {
 
     $role_name_lcase = $consumer_id;
     $role_name = empty($consumer['value']) ? $consumer_id : $consumer['value'];
     $rid = $this->getDrupalRoleIdFromRoleName($role_name);
     if (!$rid) {
-      $result = FALSE; // role id not found
+      // Role id not found.
+      $result = FALSE;
     }
-    elseif (!$user->roles[$rid]) { // user doesn't have role
+    // User doesn't have role.
+    elseif (!$user->roles[$rid]) {
       if (isset($user_auth_data[$consumer_id])) {
         unset($user_auth_data[$consumer_id]);
       }
@@ -124,8 +131,12 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
     if ($this->detailedWatchdogLog) {
       watchdog('ldap_authorization', 'LdapAuthorizationConsumerDrupalRole.revokeSingleAuthorization()
         revoked:  rid=%rid, role_name=%role_name for username=%username, result=%result',
-        array('%rid' => $rid, '%role_name' => $role_name, '%username' => $user->name,
-          '%result' => $result), WATCHDOG_DEBUG);
+        array(
+          '%rid' => $rid,
+          '%role_name' => $role_name,
+          '%username' => $user->name,
+          '%result' => $result,
+        ), WATCHDOG_DEBUG);
     }
 
     return $result;
@@ -133,9 +144,8 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
   }
 
   /**
-   * extends grantSingleAuthorization()
+   * Extends grantSingleAuthorization()
    */
-
   public function grantSingleAuthorization(&$user, $consumer_id, $consumer, &$user_auth_data, $user_save = FALSE, $reset = FALSE) {
 
     $role_name_lcase = $consumer_id;
@@ -162,14 +172,21 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
     if ($this->detailedWatchdogLog) {
       watchdog('ldap_authorization', 'LdapAuthorizationConsumerDrupalRole.grantSingleAuthorization()
         granted: rid=%rid, role_name=%role_name for username=%username, result=%result',
-        array('%rid' => $rid, '%role_name' => $role_name, '%username' => $user->name,
-          '%result' => $result), WATCHDOG_DEBUG);
+        array(
+          '%rid' => $rid,
+          '%role_name' => $role_name,
+          '%username' => $user->name,
+          '%result' => $result,
+        ), WATCHDOG_DEBUG);
     }
 
     return $result;
 
   }
 
+  /**
+   *
+   */
   public function usersAuthorizations(&$user) {
     $authorizations = array();
     foreach ($user->roles as $rid => $role_name_mixed_case) {
@@ -178,6 +195,9 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
     return $authorizations;
   }
 
+  /**
+   *
+   */
   public function validateAuthorizationMappingTarget($mapping, $form_values = NULL, $clear_cache = FALSE) {
 
     $has_form_values = is_array($form_values);
@@ -188,7 +208,6 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
     $roles_by_name = $this->existingRolesByRoleName();
     $pass = isset($roles_by_name[drupal_strtolower($role_name)]);
 
-
     if (!$pass) {
       $message_text = '"' . t('Drupal role') . ' ' . t('!map_to', $tokens) . '" ' . t('does not map to any existing Drupal roles.');
       if ($has_form_values) {
@@ -217,7 +236,6 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
    * @param string mixed case $role_name
    * @return integer role id
    */
-
   private function getDrupalRoleIdFromRoleName($role_name) {
     $role_ids_by_name = $this->existingRolesByRoleName();
     $role_name_lowercase = drupal_strtolower($role_name);
@@ -225,7 +243,8 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
   }
 
   /**
-   * @param boolean $reset to reset static values
+   * @param bool $reset
+   *   to reset static values.
    * @return associative array() keyed on lowercase role names with values
    *   of array('rid' => role id, 'role_name' => mixed case role name)
    */
@@ -243,13 +262,14 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
     return $roles_by_name;
   }
 
- /**
+  /**
    * @see LdapAuthorizationConsumerAbstract::normalizeMappings
    */
   public function normalizeMappings($mappings) {
 
     $new_mappings = array();
-    $roles = user_roles(TRUE); // in rid => role name format
+    // In rid => role name format.
+    $roles = user_roles(TRUE);
     $roles_by_name = array_flip($roles);
     foreach ($mappings as $i => $mapping) {
       $new_mapping = array();
@@ -257,8 +277,8 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
       $new_mapping['from'] = $mapping[0];
       $new_mapping['normalized'] = $mapping[1];
       $new_mapping['simplified'] = $mapping[1];
-      $create_consumers = (boolean)($this->allowConsumerObjectCreation && $this->consumerConf->createConsumers);
-      $new_mapping['valid'] = (boolean)(!$create_consumers && !empty($roles_by_name[$mapping[1]]));
+      $create_consumers = (boolean) ($this->allowConsumerObjectCreation && $this->consumerConf->createConsumers);
+      $new_mapping['valid'] = (boolean) (!$create_consumers && !empty($roles_by_name[$mapping[1]]));
       $new_mapping['error_message'] = ($new_mapping['valid']) ? '' : t("Role %role_name does not exist and role creation is not enabled.", array('%role' => $mapping[1]));
       $new_mappings[] = $new_mapping;
     }
@@ -266,9 +286,9 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
     return $new_mappings;
   }
 
-    /**
-	 * @see ldapAuthorizationConsumerAbstract::convertToFriendlyAuthorizationIds
-	 */
+  /**
+   * @see ldapAuthorizationConsumerAbstract::convertToFriendlyAuthorizationIds
+   */
   public function convertToFriendlyAuthorizationIds($authorizations) {
     $authorization_ids_friendly = array();
     foreach ($authorizations as $authorization_id => $authorization) {
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.info b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.info
index 35d67c28..7229d079 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.info
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.info
@@ -9,9 +9,8 @@ files[] = LdapAuthorizationConsumerRole.class.php
 files[] = ldap_authorization_drupal_role.module
 files[] = ldap_authorization_drupal_role.inc
 
-; Information added by Drupal.org packaging script on 2017-08-27
-version = "7.x-2.3"
+; Information added by Drupal.org packaging script on 2018-08-13
+version = "7.x-2.4"
 core = "7.x"
 project = "ldap"
-datestamp = "1503841448"
-
+datestamp = "1534201086"
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.install b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.install
index fbb8cd99..49e82aee 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.install
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.install
@@ -5,7 +5,6 @@
  * Install, update and uninstall functions for the LDAP authorization module.
  */
 
-
 /**
  * Implements hook_uninstall().
  */
@@ -13,4 +12,4 @@ function ldap_authorization_drupal_role_uninstall() {
   module_load_include('inc', 'ldap_servers', 'ldap_servers.user_data_remove');
   batch_set(ldap_severs_user_data_setup_batch('drupal_role'));
   $batch =& batch_get();
-}
\ No newline at end of file
+}
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.module b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.module
index 8875f613..64ce5707 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.module
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.module
@@ -1,9 +1,8 @@
 <?php
 
-/** @file
- *
- *  maps ldap data to drupal roles
- *
+/**
+ * @file
+ * Maps ldap data to drupal roles.
  */
 
 /**
@@ -11,7 +10,7 @@
  */
 function ldap_authorization_drupal_role_ldap_authorization_consumer() {
 
-  $types['drupal_role'] =  array(
+  $types['drupal_role'] = array(
     'consumer_name' => t('drupal role'),
     'consumer_name_plural' => t('drupal roles'),
     'consumer_short_name' => t('role'),
@@ -38,9 +37,7 @@ faculty|administrator
 
 /**
  * Implements hook_ldap_user_attrs_list_alter().
- *
  */
-
 function ldap_authorization_drupal_role_ldap_user_attrs_list_alter(&$available_user_attrs, &$params) {
 
   $available_user_attrs['[property.role]'] = array(
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/LdapAuthorizationConsumerOG.class.php b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/LdapAuthorizationConsumerOG.class.php
index 62c03724..913d2a95 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/LdapAuthorizationConsumerOG.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/LdapAuthorizationConsumerOG.class.php
@@ -2,10 +2,9 @@
 
 /**
  * @file
- * class for ldap authorization of organic groups
+ * Class for ldap authorization of organic groups.
  *
  * @see LdapAuthorizationConsumerAbstract for property
- *
  */
 
 if (function_exists('ldap_servers_module_load_include')) {
@@ -14,49 +13,43 @@ if (function_exists('ldap_servers_module_load_include')) {
 else {
   module_load_include('php', 'ldap_authorization', 'LdapAuthorizationConsumerAbstract.class');
 }
-
+/**
+ *
+ */
 class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
 
   public $consumerType = 'og_group';
   public $allowConsumerObjectCreation = FALSE;
-  public $ogVersion = NULL; // 1, 2, etc.
   public $defaultMembershipRid;
   public $anonymousRid;
   public $defaultConsumerConfProperties = array(
-      'onlyApplyToLdapAuthenticated' => TRUE,
-      'useMappingsAsFilter' => TRUE,
-      'synchOnLogon' => TRUE,
-      'revokeLdapProvisioned' => TRUE,
-      'regrantLdapProvisioned' => TRUE,
-      'createConsumers' => TRUE,
-      );
+    'onlyApplyToLdapAuthenticated' => TRUE,
+    'useMappingsAsFilter' => TRUE,
+    'synchOnLogon' => TRUE,
+    'revokeLdapProvisioned' => TRUE,
+    'regrantLdapProvisioned' => TRUE,
+    'createConsumers' => TRUE,
+  );
 
-  function __construct($consumer_type) {
+  /**
+   *
+   */
+  public function __construct($consumer_type) {
 
-    $this->ogVersion = ldap_authorization_og_og_version();
-    if ($this->ogVersion == 1) {
-      $this->defaultMembershipRid = ldap_authorization_og1_role_name_to_role_id(OG_AUTHENTICATED_ROLE);
-      $this->anonymousRid = ldap_authorization_og1_role_name_to_role_id(OG_ANONYMOUS_ROLE);
-    }
-    else {
-      //@todo these properties are not used in ldap og 2, but when they are their derivation needs to be examined and tested
-      // as they may be per entity rids, not global.
-      $this->defaultMembershipRid = NULL; // ldap_authorization_og_rid_from_role_name(OG_AUTHENTICATED_ROLE);
-      $this->anonymousRid = NULL; //ldap_authorization_og_rid_from_role_name(OG_ANONYMOUS_ROLE);
-    }
+    // @todo these properties are not used in ldap og 2, but when they are their derivation needs to be examined and tested
+    // as they may be per entity rids, not global.
+    // ldap_authorization_og_rid_from_role_name(OG_AUTHENTICATED_ROLE);
+    $this->defaultMembershipRid = NULL;
+    // ldap_authorization_og_rid_from_role_name(OG_ANONYMOUS_ROLE);
+    $this->anonymousRid = NULL;
 
     $params = ldap_authorization_og_ldap_authorization_consumer();
     parent::__construct('og_group', $params['og_group']);
   }
 
-  public function og1ConsumerIdParts($consumer_id) {
-    if (!is_scalar($consumer_id)) {
-      return array(NULL, NULL);
-    }
-    $parts = explode('-', $consumer_id);
-    return (count($parts) != 2) ? array(NULL, NULL) : $parts;
-  }
-
+  /**
+   *
+   */
   public function og2ConsumerIdParts($consumer_id) {
     if (!is_scalar($consumer_id)) {
       return array(NULL, NULL, NULL);
@@ -65,7 +58,6 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
     return (count($parts) != 3) ? array(NULL, NULL, NULL) : $parts;
   }
 
-
   /**
    * @see LdapAuthorizationConsumerAbstract::createConsumer
    *
@@ -73,7 +65,6 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
    * if a use case for generating og groups and roles on the
    * fly existed.
    */
-
   public function createConsumer($consumer_id, $consumer) {
     return FALSE;
   }
@@ -82,198 +73,104 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
    * @see LdapAuthorizationConsumerAbstract::normalizeMappings
    */
   public function normalizeMappings($mappings) {
-
     $new_mappings = array();
-    if ($this->ogVersion == 2) {
-      $group_entity_types = og_get_all_group_bundle();
-      foreach ($mappings as $i => $mapping) {
-        $from = $mapping[0];
-        $to = $mapping[1];
-        $to_parts = explode('(raw: ', $to);
-        $user_entered = $to_parts[0];
-        $new_mapping = array(
-          'from' => $from,
-          'user_entered' => $user_entered,
-          'valid' => TRUE,
-          'error_message' => '',
-        );
-
-        if (count($to_parts) == 2) { // has simplified and normalized part in (). update normalized part as validation
-          $to_normalized = trim($to_parts[1], ')');
-          /**
-           * users (node:35:1)
-           * node:students (node:21:1)
-           * faculty (node:33:2)
-           * node:35:1 (node:35:1)
-           * node:35 (node:35:1)
-           */
-
-          $to_simplified = $to_parts[0];
-          $to_simplified_parts = explode(':', trim($to_simplified));
-          $entity_type = (count($to_simplified_parts) == 1) ? 'node' : $to_simplified_parts[0];
-          $role = (count($to_simplified_parts) < 3) ? OG_AUTHENTICATED_ROLE : $to_simplified_parts[2];
-          $group_name = (count($to_simplified_parts) == 1) ? $to_simplified_parts[0] :  $to_simplified_parts[1];
-          list($group_entity, $group_entity_id) = ldap_authorization_og2_get_group_from_name($entity_type, $group_name);
-          $to_simplified = join(':', array($entity_type, $group_name));
-        }
-        else { // may be simplified or normalized, but not both
-          /**
-           * users
-           * node:students
-           * faculty
-           * node:35:1
-           * node:35
-           */
-          $to_parts = explode(':', trim($to));
-          $entity_type = (count($to_parts) == 1) ? 'node' : $to_parts[0];
-          $role = (count($to_parts) < 3) ? OG_AUTHENTICATED_ROLE : $to_parts[2];
-          $group_name_or_entity_id = (count($to_parts) == 1) ? $to_parts[0] :  $to_parts[1];
-          list($group_entity, $group_entity_id) = ldap_authorization_og2_get_group_from_name($entity_type, $group_name_or_entity_id);
-          if ($group_entity) { // if load by name works, $group_name_or_entity_id is group title
-            $to_simplified = join(':', array($entity_type, $group_name_or_entity_id));
-          }
-          else {
-            $to_simplified = FALSE;
-          }
-          $simplified = (boolean)($group_entity);
-          if (!$group_entity && ($group_entity = @entity_load_single($entity_type, $group_name_or_entity_id))) {
-            $group_entity_id = $group_name_or_entity_id;
-          }
-        }
-        if (!$group_entity) {
-          $new_mapping['normalized'] = FALSE;
-          $new_mapping['simplified'] = FALSE;
-          $new_mapping['valid'] = FALSE;
-          $new_mapping['error_message'] = t("cannot find matching group: !to", array('!to' => $to));
-        }
-        else {
-          $role_id = is_numeric($role) ? $role : ldap_authorization_og2_rid_from_role_name($entity_type, $group_entity->type, $group_entity_id, $role);
-          $roles = og_roles($entity_type,  isset($group_entity->type) ? $group_entity->type : NULL, 0, FALSE, TRUE);
-          $role_name = is_numeric($role) ? $roles[$role] : $role;
-          $to_normalized = join(':', array($entity_type, $group_entity_id, $role_id));
-          $to_simplified = ($to_simplified) ? $to_simplified . ':' . $role_name : $to_normalized;
-          $new_mapping['normalized'] = $to_normalized;
-          $new_mapping['simplified'] = $to_simplified;
-          if ($to == $to_normalized) {
-            /**  if not using simplified notation, do not convert to simplified.
-              this would create a situation where an og group
-              can change its title and the authorizations change when the
-              admin specified the group by entity id
-            */
-            $new_mapping['user_entered'] = $to;
-          }
-          else {
-            $new_mapping['user_entered'] = $to_simplified . ' (raw: ' . $to_normalized . ')';
-          }
-
-
-        }
+    $group_entity_types = og_get_all_group_bundle();
+    foreach ($mappings as $i => $mapping) {
+      $from = $mapping[0];
+      $to = $mapping[1];
+      $to_parts = explode('(raw: ', $to);
+      $user_entered = $to_parts[0];
+      $new_mapping = array(
+        'from' => $from,
+        'user_entered' => $user_entered,
+        'valid' => TRUE,
+        'error_message' => '',
+      );
 
-        $new_mappings[] = $new_mapping;
+      // Has simplified and normalized part in (). update normalized part as validation.
+      if (count($to_parts) == 2) {
+        $to_normalized = trim($to_parts[1], ')');
+        /**
+         * users (node:35:1)
+         * node:students (node:21:1)
+         * faculty (node:33:2)
+         * node:35:1 (node:35:1)
+         * node:35 (node:35:1)
+         */
+
+        $to_simplified = $to_parts[0];
+        $to_simplified_parts = explode(':', trim($to_simplified));
+        $entity_type = (count($to_simplified_parts) == 1) ? 'node' : $to_simplified_parts[0];
+        $role = (count($to_simplified_parts) < 3) ? OG_AUTHENTICATED_ROLE : $to_simplified_parts[2];
+        $group_name = (count($to_simplified_parts) == 1) ? $to_simplified_parts[0] : $to_simplified_parts[1];
+        list($group_entity, $group_entity_id) = ldap_authorization_og2_get_group_from_name($entity_type, $group_name);
+        $to_simplified = join(':', array($entity_type, $group_name));
       }
-    }
-    else { // og 1
-      foreach ($mappings as $i => $mapping) {
-        $new_mapping = array(
-          'from' => $mapping[0],
-          'user_entered' => $mapping[1],
-          'normalized' => NULL,
-          'simplified' => NULL,
-          'valid' => TRUE,
-          'error_message' => '',
-        );
-
-        $gid = NULL;
-        $rid = NULL;
-        $correct_syntax = "gid=43,rid=2 or group-name=students,role-name=member or node.title=students,role-name=member";
-        $incorrect_syntax = t('Incorrect mapping syntax.  Correct examples are:') . $correct_syntax;
-        $targets = explode(',', $mapping[1]);
-        if (count($targets) != 2) {
-          $new_mapping['valid'] = FALSE;
-          $new_mapping['error_message'] = $incorrect_syntax;
-          continue;
-        }
-
-        $group_target_and_value =  explode('=', $targets[0]);
-        if (count($group_target_and_value) != 2) {
-          $new_mapping['valid'] = FALSE;
-          $new_mapping['error_message'] = $incorrect_syntax;
-          continue;
-        }
-
-        list($group_target, $group_target_value) = $group_target_and_value;
-
-        $role_target_and_value = explode('=', $targets[1]);
-        if (count($role_target_and_value) != 2) {
-          $new_mapping['valid'] = FALSE;
-          $new_mapping['error_message'] = $incorrect_syntax;
-          continue;
-        }
-        list($role_target, $role_target_value) = $role_target_and_value;
-
-
-        $og_group = FALSE;
-        if ($group_target == 'gid') {
-          $gid = $group_target_value;
-        }
-        elseif ($group_target == 'group-name') {
-          list($og_group, $og_node) = ldap_authorization_og1_get_group($group_target_value, 'group_name', 'object');
-          if (is_object($og_group) && property_exists($og_group, 'gid') && $og_group->gid) {
-            $gid = $og_group->gid;
-          }
+      // May be simplified or normalized, but not both.
+      else {
+        /**
+         * users
+         * node:students
+         * faculty
+         * node:35:1
+         * node:35
+         */
+        $to_parts = explode(':', trim($to));
+        $entity_type = (count($to_parts) == 1) ? 'node' : $to_parts[0];
+        $role = (count($to_parts) < 3) ? OG_AUTHENTICATED_ROLE : $to_parts[2];
+        $group_name_or_entity_id = (count($to_parts) == 1) ? $to_parts[0] : $to_parts[1];
+        list($group_entity, $group_entity_id) = ldap_authorization_og2_get_group_from_name($entity_type, $group_name_or_entity_id);
+        // If load by name works, $group_name_or_entity_id is group title.
+        if ($group_entity) {
+          $to_simplified = join(':', array($entity_type, $group_name_or_entity_id));
         }
         else {
-          $entity_type_and_field = explode('.', $group_target);
-          if (count($entity_type_and_field) != 2) {
-            $new_mapping['valid'] = FALSE;
-            $new_mapping['error_message'] = $incorrect_syntax;
-            continue;
-          }
-          list($entity_type, $field) = $entity_type_and_field;
-
-          $query = new EntityFieldQuery();
-          $query->entityCondition('entity_type', $entity_type)
-            ->fieldCondition($field, 'value', $group_target_value, '=')
-            ->addMetaData('account', user_load(1)); // run the query as user 1
-
-          $result = $query->execute();
-          if (is_array($result) && isset($result[$entity_type]) && count($result[$entity_type]) == 1) {
-            $entities = array_keys($result[$entity_type]);
-            $gid = ldap_authorization_og1_entity_id_to_gid($entities[0]);
-          }
-
+          $to_simplified = FALSE;
         }
-        if (!$og_group && $gid) {
-          $og_group = og_load($gid);
+        $simplified = (boolean) ($group_entity);
+        if (!$group_entity && ($group_entity = @entity_load_single($entity_type, $group_name_or_entity_id))) {
+          $group_entity_id = $group_name_or_entity_id;
         }
-
-
-        if ($role_target == 'rid') {
-          $role_name = ldap_authorization_og1_role_name_from_rid($role_target_value);
-          $rid = $role_target_value;
+      }
+      if (!$group_entity) {
+        $new_mapping['normalized'] = FALSE;
+        $new_mapping['simplified'] = FALSE;
+        $new_mapping['valid'] = FALSE;
+        $new_mapping['error_message'] = t("cannot find matching group: !to", array('!to' => $to));
+      }
+      else {
+        $role_id = is_numeric($role) ? $role : ldap_authorization_og2_rid_from_role_name($entity_type, $group_entity->type, $group_entity_id, $role);
+        $roles = og_roles($entity_type, isset($group_entity->type) ? $group_entity->type : NULL, 0, FALSE, TRUE);
+        $role_name = is_numeric($role) ? $roles[$role] : $role;
+        $to_normalized = join(':', array($entity_type, $group_entity_id, $role_id));
+        $to_simplified = ($to_simplified) ? $to_simplified . ':' . $role_name : $to_normalized;
+        $new_mapping['normalized'] = $to_normalized;
+        $new_mapping['simplified'] = $to_simplified;
+        if ($to == $to_normalized) {
+          /**  if not using simplified notation, do not convert to simplified.
+           * this would create a situation where an og group
+           * can change its title and the authorizations change when the
+           * admin specified the group by entity id
+           */
+          $new_mapping['user_entered'] = $to;
         }
-        elseif ($role_target == 'role-name') {
-          $rid = ldap_authorization_og_rid_from_role_name($role_target_value);
-          $role_name = $role_target_value;
+        else {
+          $new_mapping['user_entered'] = $to_simplified . ' (raw: ' . $to_normalized . ')';
         }
 
-        $new_mapping['simplified'] = $og_group->label . ', '. $role_name;
-        $new_mapping['normalized'] = ($gid && $rid) ? ldap_authorization_og_authorization_id($gid, $rid) : FALSE;
-
-        $new_mappings[] = $new_mapping;
       }
 
+      $new_mappings[] = $new_mapping;
     }
     return $new_mappings;
   }
 
-/**
- * in organic groups 7.x-1.x, consumer ids are in form gid-rid such as 3-2, 3-3.  We want highest authorization available granted.
- * But, granting member role (2), revokes other roles such as admin in OG.  So for granting we want the order:
- * 3-1, 3-2, 3-3 such that 3-3 is retained.  For revoking, the order should not matter, but reverse sorting makes
- * intuitive sense.
- */
-
+  /**
+   * In organic groups 7.x-1.x, consumer ids are in form gid-rid such as 3-2, 3-3.  We want highest authorization available granted.
+   * But, granting member role (2), revokes other roles such as admin in OG.  So for granting we want the order:
+   * 3-1, 3-2, 3-3 such that 3-3 is retained.  For revoking, the order should not matter, but reverse sorting makes
+   * intuitive sense.
+   */
   public function sortConsumerIds($op, &$consumers) {
     if ($op == 'revoke') {
       krsort($consumers, SORT_STRING);
@@ -286,108 +183,65 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
   /**
    * @see LdapAuthorizationConsumerAbstract::populateConsumersFromConsumerIds
    */
-
   public function populateConsumersFromConsumerIds(&$consumers, $create_missing_consumers = FALSE) {
 
-    // generate a query for all og groups of interest
+    // Generate a query for all og groups of interest.
     $gids = array();
     foreach ($consumers as $consumer_id => $consumer) {
-      if (ldap_authorization_og_og_version() == 1) {
-        list($gid, $rid) = $this->og1ConsumerIdParts($consumer_id);
-        $gids[] = $gid;
-      }
-      else  {
-        list($entity_type, $gid, $rid) = explode(':', $consumer_id);
-        $gids[$entity_type][] = $gid;
-      }
+      list($entity_type, $gid, $rid) = explode(':', $consumer_id);
+      $gids[$entity_type][] = $gid;
 
     }
-    if (ldap_authorization_og_og_version() == 1) {
-      $og_group_entities = og_load_multiple($gids);
-    }
-    else {
-      foreach ($gids as $entity_type => $gid_x_entity) {
-        $og_group_entities[$entity_type] = @entity_load($entity_type, $gid_x_entity);
-      }
+
+    foreach ($gids as $entity_type => $gid_x_entity) {
+      $og_group_entities[$entity_type] = @entity_load($entity_type, $gid_x_entity);
     }
 
     foreach ($consumers as $consumer_id => $consumer) {
-      if (ldap_authorization_og_og_version() == 1) {
-        list($gid, $rid) = $this->og1ConsumerIdParts($consumer_id);
-        $consumer['exists'] = isset($og_group_entities[$gid]);
-        if ($consumer['exists']) {
-          $consumer['value'] = $og_group_entities[$gid];
-          if (empty($consumer['name']) && property_exists($og_group_entities[$gid], 'title')) {
-            $consumer['name'] = $og_group_entities[$gid]->title;
-          }
-          $consumer['name'] =  $consumer_id;
-        }
-        else {
-          $consumer['value'] = NULL;
-          $consumer['name'] = NULL;
-        }
-
-        $consumer['map_to_string'] = $consumer_id;
-      }
-      else  {
-        list($entity_type, $gid, $rid) = explode(':', $consumer_id);
-        $consumer['exists'] = isset($og_group_entities[$entity_type][$gid]);
-        $consumer['value'] = ($consumer['exists']) ? $og_group_entities[$entity_type][$gid] : NULL;
-        $consumer['map_to_string'] = $consumer_id;
-        if (
-          empty($consumer['name']) &&
-          !empty($og_group_entities[$entity_type][$gid]) &&
-          property_exists($og_group_entities[$entity_type][$gid], 'title')
-        ) {
-          $consumer['name'] = $og_group_entities[$entity_type][$gid]->title;
-        }
+      list($entity_type, $gid, $rid) = explode(':', $consumer_id);
+      $consumer['exists'] = isset($og_group_entities[$entity_type][$gid]);
+      $consumer['value'] = ($consumer['exists']) ? $og_group_entities[$entity_type][$gid] : NULL;
+      $consumer['map_to_string'] = $consumer_id;
+      if (
+        empty($consumer['name']) &&
+        !empty($og_group_entities[$entity_type][$gid]) &&
+        property_exists($og_group_entities[$entity_type][$gid], 'title')
+      ) {
+        $consumer['name'] = $og_group_entities[$entity_type][$gid]->title;
       }
 
       if (!$consumer['exists'] && $create_missing_consumers) {
-         // @todo if creation of og groups were implemented, function would be called here
-         // this would mean mapping would need to have enough info to configure a group,
-         // or settings would need to include a default group type to create (entity type,
-         // bundle, etc.)
+        // @todo if creation of og groups were implemented, function would be called here
+        // this would mean mapping would need to have enough info to configure a group,
+        // or settings would need to include a default group type to create (entity type,
+        // bundle, etc.)
       }
       $consumers[$consumer_id] = $consumer;
     }
   }
 
-
+  /**
+   *
+   */
   public function hasAuthorization(&$user, $consumer_id) {
-
-    if ($this->ogVersion == 1) {
-      $result = FALSE;
-      list($gid, $rid) = $this->og1ConsumerIdParts($consumer_id);
-      return ldap_authorization_og1_has_membership($gid, $user->uid) && ldap_authorization_og1_has_role($gid, $user->uid, $rid);
-    }
-    else {
-      return ldap_authorization_og2_has_consumer_id($consumer_id, $user->uid);
-    }
+    return ldap_authorization_og2_has_consumer_id($consumer_id, $user->uid);
   }
 
-  
+  /**
+   *
+   */
   public function flushRelatedCaches($consumers = NULL, $user = NULL) {
     if ($user) {
-      $this->usersAuthorizations($user, TRUE, FALSE); // clear user authorizations cache
-    }
-    
-    if ($this->ogVersion == 1) {
-      og_group_membership_invalidate_cache();
-    }
-    else {
-      og_membership_invalidate_cache();
+      // Clear user authorizations cache.
+      $this->usersAuthorizations($user, TRUE, FALSE);
     }
-    
+
+    og_membership_invalidate_cache();
+
     if ($consumers) {
       $gids_to_clear_cache = array();
       foreach ($consumers as $i => $consumer_id) {
-        if ($this->ogVersion == 1) { // og 7.x-1.x
-          list($gid, $rid) = $this->og1ConsumerIdParts($consumer_id);
-        }
-        else {
-          list($entity_type, $gid, $rid) = $this->og2ConsumerIdParts($consumer_id);
-        }
+        list($entity_type, $gid, $rid) = $this->og2ConsumerIdParts($consumer_id);
         $gids_to_clear_cache[$gid] = $gid;
       }
       og_invalidate_cache(array_keys($gids_to_clear_cache));
@@ -397,41 +251,26 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
     }
   }
 
- /**
-   * @param string $op 'grant' or 'revoke' signifying what to do with the $consumer_ids
+  /**
+   * @param string $op
+   *   'grant' or 'revoke' signifying what to do with the $consumer_ids.
    * @param drupal user object $object
-   * @param array $user_auth_data is array specific to this consumer_type.  Stored at $user->data['ldap_authorizations'][<consumer_type>]
-   * @param $consumers as associative array in form of LdapAuthorizationConsumerAbstract::populateConsumersFromConsumerIds
-   * @param array $ldap_entry, when available user's ldap entry.
-   * @param boolean $user_save indicates is user data array should be saved or not.  this is always overridden for og
+   * @param array $user_auth_data
+   *   is array specific to this consumer_type.  Stored at $user->data['ldap_authorizations'][<consumer_type>].
+   * @param $consumers
+   *   as associative array in form of LdapAuthorizationConsumerAbstract::populateConsumersFromConsumerIds
+   * @param array $ldap_entry,
+   *   when available user's ldap entry.
+   * @param bool $user_save
+   *   indicates is user data array should be saved or not.  this is always overridden for og.
    */
   public function authorizationDiff($existing, $desired) {
-    if ($this->ogVersion != 1) {
-      return parent::authorizationDiff($existing, $desired);
-    }
-
-    /**
-     * for og 1.5, goal is not to recognize X-2 consumer ids if X-N exist
-     * since X-2 consumer ids are granted as a prerequisite of X-N
-     */
-
-    $diff = array_diff($existing, $desired);
-    $desired_group_ids = array();
-    foreach ($desired as $i => $consumer_id) {
-      list($gid, $rid) = $this->og1ConsumerIdParts($consumer_id);
-      $desired_group_ids[$gid] = TRUE;
-    }
-    foreach ($diff as $i => $consumer_id) {
-      list($gid, $rid) = $this->og1ConsumerIdParts($consumer_id);
-      // if there are still roles in this group that are desired, do
-      // not remove default mambership role id
-      if ($rid == $this->defaultMembershipRid && !empty($desired_group_ids[$gid])) {
-        unset($diff[$i]);
-      }
-    }
-    return $diff;
+    return parent::authorizationDiff($existing, $desired);
   }
 
+  /**
+   *
+   */
   protected function grantsAndRevokes($op, &$user, &$user_auth_data, $consumers, &$ldap_entry = NULL, $user_save = TRUE) {
 
     if (!is_array($user_auth_data)) {
@@ -472,23 +311,17 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
       }
       $log = "consumer_id=$consumer_id, op=$op,";
 
-      $user_has_authorization = in_array($consumer_id, $users_authorization_consumer_ids); // does user already have authorization ?
-      $user_has_authorization_recorded = isset($user_auth_data[$consumer_id]);  // is authorization attribute to ldap_authorization_og in $user->data ?
-      
-      if ($this->ogVersion == 1) {
-        list($gid, $rid) = $this->og1ConsumerIdParts($consumer_id);
-        if ($rid == $this->anonymousRid) {
-          continue;
-        }
-      }
-      else {
-        list($entity_type, $gid, $rid) = $this->og2ConsumerIdParts($consumer_id);
-      }
-      
+      // Does user already have authorization ?
+      $user_has_authorization = in_array($consumer_id, $users_authorization_consumer_ids);
+      // Is authorization attribute to ldap_authorization_og in $user->data ?
+      $user_has_authorization_recorded = isset($user_auth_data[$consumer_id]);
+
+      list($entity_type, $gid, $rid) = $this->og2ConsumerIdParts($consumer_id);
+
       /** grants **/
       if ($op == 'grant') {
         if ($user_has_authorization && !$user_has_authorization_recorded) {
-        // grant case 1: authorization id already exists for user, but is not ldap provisioned.  mark as ldap provisioned, but don't regrant
+          // Grant case 1: authorization id already exists for user, but is not ldap provisioned.  mark as ldap provisioned, but don't regrant.
           $results[$consumer_id] = TRUE;
           $user_auth_data[$consumer_id] = array(
             'date_granted' => time(),
@@ -498,56 +331,48 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
           $log .= $consumer_id;
         }
         elseif (!$user_has_authorization && $consumer['exists']) {
-        // grant case 2: consumer exists, but user is not member. grant authorization
-          if ($this->ogVersion == 1) {
-            $og_actions['grants'][$gid][] = $rid;
-          }
-          else {
-            $og_actions['grants'][$entity_type][$gid][] = $rid;
-          }
+          // Grant case 2: consumer exists, but user is not member. grant authorization.
+          $og_actions['grants'][$entity_type][$gid][] = $rid;
           $log .= "grant case 2: consumer exists, but user is not member. grant authorization";
-          $log .= " ".$entity_type . ":" . $gid .":" . $rid;
+          $log .= " " . $entity_type . ":" . $gid . ":" . $rid;
         }
         elseif ($consumer['exists'] !== TRUE) {
-        // grant case 3: something is wrong. consumers should have been created before calling grantsAndRevokes
+          // Grant case 3: something is wrong. consumers should have been created before calling grantsAndRevokes.
           $results[$consumer_id] = FALSE;
           $log .= "grant case 3: something is wrong. consumers should have been created before calling grantsAndRevokes";
-          $log .= " ".$consumer_id;        }
+          $log .= " " . $consumer_id;
+        }
         elseif ($consumer['exists'] === TRUE) {
-        // grant case 4: consumer exists and user has authorization recorded. do nothing
+          // Grant case 4: consumer exists and user has authorization recorded. do nothing.
           $results[$consumer_id] = TRUE;
           $log .= "grant case 4: consumer exists and user has authorization recorded. do nothing";
-          $log .= " ".$consumer_id;
+          $log .= " " . $consumer_id;
         }
         else {
-        // grant case 5: $consumer['exists'] has not been properly set before calling function
+          // Grant case 5: $consumer['exists'] has not been properly set before calling function.
           $results[$consumer_id] = FALSE;
           watchdog('ldap_authorization', "grantsAndRevokes consumer[exists] not properly set. consumer_id=$consumer_id, op=$op, username=%username", $watchdog_tokens, WATCHDOG_ERROR);
-            $log .= "grantsAndRevokes consumer[exists] not properly set. consumer_id=$consumer_id, op=$op, username=%username";
-          }
-          $consumer_ids_log .= $log;      }
+          $log .= "grantsAndRevokes consumer[exists] not properly set. consumer_id=$consumer_id, op=$op, username=%username";
+        }
+        $consumer_ids_log .= $log;
+      }
       /** revokes **/
       elseif ($op == 'revoke') {
         if ($user_has_authorization) {
-          // revoke case 1: user has authorization, revoke it.  revokeSingleAuthorization will remove $user_auth_data[$consumer_id]
-          if ($this->ogVersion == 1) {
-            $og_actions['revokes'][$gid][] = $rid;
-          }
-          else {
-            $og_actions['revokes'][$entity_type][$gid][] = $rid;
-          }
+          // Revoke case 1: user has authorization, revoke it.  revokeSingleAuthorization will remove $user_auth_data[$consumer_id].
+          $og_actions['revokes'][$entity_type][$gid][] = $rid;
           $log .= "revoke case 1: user has authorization, revoke it.  revokeSingleAuthorization will remove $consumer_id";
-          $log .=" ".$entity_type . ":" . $gid .":" . $rid ;          
+          $log .= " " . $entity_type . ":" . $gid . ":" . $rid;
         }
-        elseif ($user_has_authorization_recorded)  {
-          // revoke case 2: user does not have authorization, but has record of it. remove record of it.
+        elseif ($user_has_authorization_recorded) {
+          // Revoke case 2: user does not have authorization, but has record of it. remove record of it.
           unset($user_auth_data[$consumer_id]);
           $results[$consumer_id] = TRUE;
           $log .= "revoke case 2: user does not have authorization, but has record of it. remove record of it.";
           $log .= $consumer_id;
         }
         else {
-          // revoke case 3: trying to revoke something that isn't there
+          // Revoke case 3: trying to revoke something that isn't there.
           $results[$consumer_id] = TRUE;
           $log .= "revoke case 3: trying to revoke something that isn't there";
           $log .= $consumer_id;
@@ -558,26 +383,19 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
       }
       $consumer_ids_log .= $log;
     }
-    
+
     $watchdog_tokens['%consumer_ids_log'] = $consumer_ids_log;
-    
+
     /**
      * Step #2: from array of form:
-     *   og1.5: $og_actions['grants'|'revokes'][$gid][$rid]\
-     *   og2:   $og_actions['grants'|'revokes'][$entity_type][$gid][$rid]
+     *   $og_actions['grants'|'revokes'][$entity_type][$gid][$rid]
      * - generate $user->data['ldap_authorizations'][<consumer_id>]
      * - remove and grant og memberships
      * - remove and grant og roles
      * - flush appropriate caches
      */
-    if ($this->ogVersion == 1) {
-      $this->og1Grants($og_actions, $user, $user_auth_data);
-      $this->og1Revokes($og_actions, $user, $user_auth_data);
-    }
-    else {
-      $this->og2Grants($og_actions, $user, $user_auth_data);
-      $this->og2Revokes($og_actions, $user, $user_auth_data); 
-    }
+    $this->og2Grants($og_actions, $user, $user_auth_data);
+    $this->og2Revokes($og_actions, $user, $user_auth_data);
 
     $user_edit = array('data' => $user->data);
     $user_edit['data']['ldap_authorizations'][$this->consumerType] = $user_auth_data;
@@ -588,7 +406,8 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
     $user = user_load($user->uid, TRUE);
     $user = user_save($user, $user_edit);
 
-    $user_auth_data = $user->data['ldap_authorizations'][$this->consumerType];  // reset this variable because user save hooks can impact it.
+    // Reset this variable because user save hooks can impact it.
+    $user_auth_data = $user->data['ldap_authorizations'][$this->consumerType];
 
     $this->flushRelatedCaches($consumers, $user);
 
@@ -600,43 +419,26 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
     }
   }
 
-  public function og1Grants($og_actions, &$user, &$user_auth_data) {
-    foreach ($og_actions['grants'] as $gid => $rids) {
-      $existing_roles = og_get_user_roles($gid, $user->uid);
-      if (!in_array($this->defaultMembershipRid, array_values($existing_roles))) {
-        $user->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE][] = array('gid' => $gid);
-        og_entity_presave($user, 'user');
-        $consumer_id = ldap_authorization_og_authorization_id($gid, $this->defaultMembershipRid);
-        $user_auth_data[$consumer_id] = array(
-          'date_granted' => time(),
-          'consumer_id_mixed_case' => $consumer_id,
-        );
-      }
-      foreach ($rids as $rid) {
-        if ($rid != $this->defaultMembershipRid && $rid != $this->anonymousRid) {
-          og_role_grant($gid, $user->uid, $rid);
-          $consumer_id = ldap_authorization_og_authorization_id($gid, $rid);
-          $user_auth_data[$consumer_id] = array(
-            'date_granted' => time(),
-            'consumer_id_mixed_case' => $consumer_id,
-            );
-        }
-      }
-    }
-  }
-
+  /**
+   *
+   */
   public function og2Grants($og_actions, &$user, &$user_auth_data) {
     foreach ($og_actions['grants'] as $group_entity_type => $gids) {
-      foreach ($gids as $gid => $granting_rids) { // all rids ldap believes user should be granted and attributed to ldap
-        $all_group_roles = og_roles($group_entity_type, FALSE, $gid, FALSE, TRUE); // all roles rid => role_name array w/ authen or anon roles
+      // All rids ldap believes user should be granted and attributed to ldap.
+      foreach ($gids as $gid => $granting_rids) {
+        // All roles rid => role_name array w/ authen or anon roles.
+        $all_group_roles = og_roles($group_entity_type, FALSE, $gid, FALSE, TRUE);
         $authenticated_rid = array_search(OG_AUTHENTICATED_ROLE, $all_group_roles);
         $anonymous_rid = array_search(OG_ANONYMOUS_ROLE, $all_group_roles);
-        $all_group_rids = array_keys($all_group_roles); // all rids array w/ authen or anon rids
-        $users_group_rids = array_keys(og_get_user_roles($group_entity_type, $gid, $user->uid, TRUE)); // users current rids w/authen or anon roles returned
+        // All rids array w/ authen or anon rids.
+        $all_group_rids = array_keys($all_group_roles);
+        // Users current rids w/authen or anon roles returned.
+        $users_group_rids = array_keys(og_get_user_roles($group_entity_type, $gid, $user->uid, TRUE));
         $users_group_rids = array_diff($users_group_rids, array($anonymous_rid));
-        $new_rids = array_diff($granting_rids, $users_group_rids, array($anonymous_rid)); // rids to be added without anonymous rid
+        // Rids to be added without anonymous rid.
+        $new_rids = array_diff($granting_rids, $users_group_rids, array($anonymous_rid));
 
-        // if adding OG_AUTHENTICATED_ROLE or any other role and does not currently have OG_AUTHENTICATED_ROLE, group
+        // If adding OG_AUTHENTICATED_ROLE or any other role and does not currently have OG_AUTHENTICATED_ROLE, group.
         if (!in_array($authenticated_rid, $users_group_rids) && count($new_rids) > 0) {
           $values = array(
             'entity_type' => 'user',
@@ -650,14 +452,15 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
             'date_granted' => time(),
             'consumer_id_mixed_case' => $consumer_id,
           );
-          $new_rids = array_diff($new_rids, array($authenticated_rid)); // granted on membership creation
-         
+          // Granted on membership creation.
+          $new_rids = array_diff($new_rids, array($authenticated_rid));
+
         }
         foreach ($new_rids as $i => $rid) {
           og_role_grant($group_entity_type, $gid, $user->uid, $rid);
         }
         foreach ($granting_rids as $i => $rid) {
-          // attribute to ldap regardless of if is being granted.
+          // Attribute to ldap regardless of if is being granted.
           $consumer_id = join(':', array($group_entity_type, $gid, $rid));
           $user_auth_data[$consumer_id] = array(
             'date_granted' => time(),
@@ -667,60 +470,37 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
       }
     }
   }
-  
-  
-  public function og1Revokes($og_actions, &$user, &$user_auth_data) {
-    $group_audience_gids = empty($user->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE]['gid']) ? array() : $user->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE]['gid'];
-    foreach ($og_actions['revokes'] as $gid => $rids) {
-      $existing_roles = og_get_user_roles($gid, $user->uid);
-      if (in_array($this->defaultMembershipRid, array_values($existing_roles))) {
-        // ungroup and set audience
-        foreach ($group_audience_gids as $i => $_audience_gid) {
-           if ($_audience_gid == $gid) {
-             unset($user->{OG_AUDIENCE_FIELD}[LANGUAGE_NONE][$i]);
-           }
-        }
-        og_entity_presave($user, 'user');
-        $user = og_ungroup($gid, 'user', $user, TRUE);
-        foreach (array_values($existing_roles) as $rid) {
-          $consumer_id = ldap_authorization_og_authorization_id($gid, $rid);
-          if (isset($user_auth_data[$consumer_id])) {
-            unset($user_auth_data[$consumer_id]);
-          }
-        }
-      }
-      else {
-        foreach ($existing_roles as $rid) {
-          if ($rid != $this->defaultMembershipRid && $this->defaultMembershipRid != 1) {
-            og_role_revoke($gid, $user->uid, $rid);
-            unset($user_auth_data[ldap_authorization_og_authorization_id($gid, $rid)]);
-          }
-        }
-      }
-    }
-  }
-  
+
+  /**
+   *
+   */
   public function og2Revokes($og_actions, &$user, &$user_auth_data) {
     foreach ($og_actions['revokes'] as $group_entity_type => $gids) {
-      foreach ($gids as $gid => $revoking_rids) { // $revoking_rids are all rids to be removed.  may include authen rids
-        $all_group_roles = og_roles($group_entity_type, FALSE, $gid, FALSE, TRUE); // all roles rid => role_name array w/ authen or anon roles
-        $all_group_rids = array_keys($all_group_roles); // all rids array w/ authen or anon rids
-        $users_group_rids = array_keys(og_get_user_roles($group_entity_type, $gid, $user->uid, TRUE)); // users current rids w/authen or anon roles returned
-        $remaining_rids = array_diff($users_group_rids, $revoking_rids); // rids to be left at end of revoke process
+      // $revoking_rids are all rids to be removed.  may include authen rids.
+      foreach ($gids as $gid => $revoking_rids) {
+        // All roles rid => role_name array w/ authen or anon roles.
+        $all_group_roles = og_roles($group_entity_type, FALSE, $gid, FALSE, TRUE);
+        // All rids array w/ authen or anon rids.
+        $all_group_rids = array_keys($all_group_roles);
+        // Users current rids w/authen or anon roles returned.
+        $users_group_rids = array_keys(og_get_user_roles($group_entity_type, $gid, $user->uid, TRUE));
+        // Rids to be left at end of revoke process.
+        $remaining_rids = array_diff($users_group_rids, $revoking_rids);
         $authenticated_rid = array_search(OG_AUTHENTICATED_ROLE, $all_group_roles);
-        // remove autenticated and anon rids here
+        // Remove autenticated and anon rids here.
         foreach ($revoking_rids as $i => $rid) {
-          // revoke if user has role
+          // Revoke if user has role.
           if (in_array($rid, $users_group_rids)) {
             og_role_revoke($group_entity_type, $gid, $user->uid, $rid);
           }
-          // unattribute to ldap even if user does not currently have role
+          // Unattribute to ldap even if user does not currently have role.
           unset($user_auth_data[ldap_authorization_og_authorization_id($gid, $rid, $group_entity_type)]);
         }
         // define('OG_ANONYMOUS_ROLE', 'non-member'); define('OG_AUTHENTICATED_ROLE', 'member');
-        if (in_array($authenticated_rid, $revoking_rids) || count($remaining_rids) == 0) {  // ungroup if only authenticated and anonymous role left
+        // ungroup if only authenticated and anonymous role left.
+        if (in_array($authenticated_rid, $revoking_rids) || count($remaining_rids) == 0) {
           $entity = og_ungroup($group_entity_type, $gid, 'user', $user->uid);
-          $result = (boolean)($entity);
+          $result = (boolean) ($entity);
         }
       }
     }
@@ -729,55 +509,40 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
   /**
    * @see ldapAuthorizationConsumerAbstract::usersAuthorizations
    */
-
   public function usersAuthorizations(&$user, $reset = FALSE, $return_data = TRUE) {
 
     static $users;
     if (!is_array($users)) {
-      $users = array(); // no cache exists, create static array
+      // No cache exists, create static array.
+      $users = array();
     }
     elseif ($reset && isset($users[$user->uid])) {
-      unset($users[$user->uid]); // clear users cache
+      // Clear users cache.
+      unset($users[$user->uid]);
     }
     elseif (!$return_data) {
-      return NULL; // simply clearing cache
+      // Simply clearing cache.
+      return NULL;
     }
     elseif (!empty($users[$user->uid])) {
-      return $users[$user->uid]; // return cached data
+      // Return cached data.
+      return $users[$user->uid];
     }
 
     $authorizations = array();
 
-    if ($this->ogVersion == 1) {
-      $gids = og_get_groups_by_user($user);
-      foreach ($gids as $i => $gid) {
-        $roles = og_get_user_roles($gid, $user->uid);
-        if (!empty($roles[$this->defaultMembershipRid])) { // if you aren't a member, doesn't matter what roles you have in og 1.5
-          if (isset($roles[$this->anonymousRid])) {
-            unset($roles[$this->anonymousRid]);
-          } // ignore anonymous role
-          $rids = array_values($roles);
-          asort($rids, SORT_NUMERIC); // go low to high to get default memberships first
-          foreach ($rids as $rid) {
-            $authorizations[] = ldap_authorization_og_authorization_id($gid, $rid);
-          }
-        }
-      }
-    }
-    else { // og 7.x-2.x
-      $user_entities = entity_load('user', array($user->uid));
-      $memberships = og_get_entity_groups('user', $user_entities[$user->uid]);
-      foreach ($memberships as $entity_type => $entity_memberships) {
-        foreach ($entity_memberships as $og_membership_id => $gid) {
-          $roles = og_get_user_roles($entity_type, $gid, $user->uid);
-          foreach ($roles as $rid => $discard) {
-            $authorizations[] =  ldap_authorization_og_authorization_id($gid, $rid, $entity_type);
-          }
+    $user_entities = entity_load('user', array($user->uid));
+    $memberships = og_get_entity_groups('user', $user_entities[$user->uid]);
+    foreach ($memberships as $entity_type => $entity_memberships) {
+      foreach ($entity_memberships as $og_membership_id => $gid) {
+        $roles = og_get_user_roles($entity_type, $gid, $user->uid);
+        foreach ($roles as $rid => $discard) {
+          $authorizations[] = ldap_authorization_og_authorization_id($gid, $rid, $entity_type);
         }
       }
     }
     $users[$user->uid] = $authorizations;
-    
+
     return $authorizations;
   }
 
@@ -796,8 +561,7 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
    * @see ldapAuthorizationConsumerAbstract::validateAuthorizationMappingTarget
    */
   public function validateAuthorizationMappingTarget($mapping, $form_values = NULL, $clear_cache = FALSE) {
-    // these mappings have already been through the normalizeMappings() method, so no real querying needed here.
-
+    // These mappings have already been through the normalizeMappings() method, so no real querying needed here.
     $has_form_values = is_array($form_values);
     $message_type = NULL;
     $message_text = NULL;
@@ -812,83 +576,59 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
         '!from' => $mapping['from'],
         '!user_entered' => $mapping['user_entered'],
         '!error' => $mapping['error_message'],
-        );
+      );
       $message_text = '<code>"' . t('!map_to|!user_entered', $tokens) . '"</code> ' . t('has the following error: !error.', $tokens);
     }
     return array($message_type, $message_text);
   }
 
   /**
-   * Get list of mappings based on existing Organic Groups and roles
+   * Get list of mappings based on existing Organic Groups and roles.
+   *
+   * @param array $tokens
+   *   Array of tokens and replacement values.
    *
-   * @param associative array $tokens of tokens and replacement values
-   * @return html examples of mapping values
+   * @return
+   *   HTML examples of mapping values.
    */
-
   public function mappingExamples($tokens) {
+    /**
+     * OG 7.x-2.x mappings:
+     * $entity_type = $group_type,
+     * $bundle = $group_bundle
+     * $etid = $gid where edid is nid, uid, etc.
+     *
+     * og group is: entity_type (eg node) x entity_id ($gid) eg. node:17
+     * group identifier = group_type:gid; aka entity_type:etid e.g. node:17
+     *
+     * membership identifier is:  group_type:gid:entity_type:etid
+     * in our case: group_type:gid:user:uid aka entity_type:etid:user:uid e.g. node:17:user:2
+     *
+     * roles are simply rids ((1,2,3) and names (non-member, member, and administrator member) in og_role table
+     * og_users_roles is simply uid x rid x gid
+     *
+     * .. so authorization mappings should look like:
+     *    <ldap group>|group_type:gid:rid such as staff|node:17:2
+     */
 
-    if ($this->ogVersion == 1) {
-      $groups = og_get_all_group();
-      $ogEntities = og_load_multiple($groups);
-      $OGroles = og_roles(0);
-
-      $rows = array();
-      foreach ($ogEntities as $group) {
-        foreach ($OGroles as $rid => $role) {
-          $example =   "<code>ou=IT,dc=myorg,dc=mytld,dc=edu|gid=" . $group->gid . ',rid=' . $rid . '</code><br/>' .
-            '<code>ou=IT,dc=myorg,dc=mytld,dc=edu|group-name=' . $group->label . ',role-name=' . $role . '</code>';
-          $rows[] = array(
-            $group->label,
-            $group->gid,
-            $role,
-            $example,
-          );
-        }
-      }
-
-      $variables = array(
-      'header' => array('Group Name', 'OG Group ID', 'OG Membership Type', 'example'),
-      'rows' => $rows,
-      'attributes' => array(),
-      );
-    }
-    else {
+    $og_fields = field_info_field(OG_GROUP_FIELD);
+    $rows = array();
+    $role_name = OG_AUTHENTICATED_ROLE;
 
-      /**
-       * OG 7.x-2.x mappings:
-       * $entity_type = $group_type,
-       * $bundle = $group_bundle
-       * $etid = $gid where edid is nid, uid, etc.
-       *
-       * og group is: entity_type (eg node) x entity_id ($gid) eg. node:17
-       * group identifier = group_type:gid; aka entity_type:etid e.g. node:17
-       *
-       * membership identifier is:  group_type:gid:entity_type:etid
-       * in our case: group_type:gid:user:uid aka entity_type:etid:user:uid e.g. node:17:user:2
-       *
-       * roles are simply rids ((1,2,3) and names (non-member, member, and administrator member) in og_role table
-       * og_users_roles is simply uid x rid x gid
-       *
-       * .. so authorization mappings should look like:
-       *    <ldap group>|group_type:gid:rid such as staff|node:17:2
-       */
-
-      $og_fields = field_info_field(OG_GROUP_FIELD);
-      $rows = array();
-      $role_name = OG_AUTHENTICATED_ROLE;
-
-      if (!empty($og_fields['bundles'])) {
-        foreach ($og_fields['bundles'] as $entity_type => $bundles) {
-          foreach ($bundles as $i => $bundle) {
-            $query = new EntityFieldQuery();
-            $query->entityCondition('entity_type', $entity_type)
-              ->entityCondition('bundle', $bundle)
-              ->range(0, 5)
-              ->addMetaData('account', user_load(1)); // run the query as user 1
-            $result = $query->execute();
-            if (!empty($result)) {
-              $entities = entity_load($entity_type, array_keys($result[$entity_type]));
-              $i=0;
+    if (!empty($og_fields['bundles'])) {
+      foreach ($og_fields['bundles'] as $entity_type => $bundles) {
+        foreach ($bundles as $i => $bundle) {
+          $query = new EntityFieldQuery();
+          $query->entityCondition('entity_type', $entity_type)
+            ->entityCondition('bundle', $bundle)
+            ->range(0, 5)
+          // Run the query as user 1.
+            ->addMetaData('account', user_load(1));
+          $result = $query->execute();
+          if (!empty($result)) {
+            $entities = entity_load($entity_type, array_keys($result[$entity_type]));
+            $i = 0;
+            if ($entities) {
               foreach ($entities as $entity_id => $entity) {
                 $i++;
                 $rid = ldap_authorization_og2_rid_from_role_name($entity_type, $bundle, $entity_id, OG_AUTHENTICATED_ROLE);
@@ -896,25 +636,25 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
                 $middle = ($title && $i < 3) ? $title : $entity_id;
                 $group_role_identifier = ldap_authorization_og_authorization_id($middle, $rid, $entity_type);
                 $example = "<code>ou=IT,dc=myorg,dc=mytld,dc=edu|$group_role_identifier</code>";
-                $rows[] = array("$entity_type $title - $role_name", $example);
+                $rows[] = ["$entity_type $title - $role_name", $example];
               }
             }
           }
         }
       }
-
-      $variables = array(
-        'header' => array('Group Entity - Group Title - OG Membership Type', 'example'),
-        'rows' => $rows,
-        'attributes' => array(),
-      );
     }
 
+    $variables = array(
+      'header' => array('Group Entity - Group Title - OG Membership Type', 'example'),
+      'rows' => $rows,
+      'attributes' => array(),
+    );
+
     $table = theme('table', $variables);
     $link = l(t('admin/config/people/ldap/authorization/test/og_group'), 'admin/config/people/ldap/authorization/test/og_group');
 
-$examples =
-<<<EOT
+    $examples =
+    <<<EOT
 
 <br/>
 Examples for some (or all) existing OG Group IDs can be found in the table below.
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/ldap_authorization_og.info b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/ldap_authorization_og.info
index 54da349d..499cbb6b 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/ldap_authorization_og.info
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/ldap_authorization_og.info
@@ -13,9 +13,8 @@ files[] = ldap_authorization_og.inc
 
 core = "7.x"
 
-; Information added by Drupal.org packaging script on 2017-08-27
-version = "7.x-2.3"
+; Information added by Drupal.org packaging script on 2018-08-13
+version = "7.x-2.4"
 core = "7.x"
 project = "ldap"
-datestamp = "1503841448"
-
+datestamp = "1534201086"
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/ldap_authorization_og.install b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/ldap_authorization_og.install
index 85f03ca4..a6ca5599 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/ldap_authorization_og.install
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/ldap_authorization_og.install
@@ -13,4 +13,3 @@ function ldap_authorization_og_uninstall() {
   batch_set(ldap_severs_user_data_setup_batch('og_group'));
   $batch =& batch_get();
 }
-  
\ No newline at end of file
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/ldap_authorization_og.module b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/ldap_authorization_og.module
index 682f201b..63f53f52 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/ldap_authorization_og.module
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization_og/ldap_authorization_og.module
@@ -1,17 +1,15 @@
 <?php
 
-/** @file
- *
- *  controls organic group membership based on LDAP values
- *
+/**
+ * @file
+ * Controls organic group membership based on LDAP values.
  */
 
 /**
  * Implements hook_ldap_authorization_consumer().
  */
-
 function ldap_authorization_og_ldap_authorization_consumer() {
-  $types['og_group'] =  array(
+  $types['og_group'] = array(
     'consumer_name' => t('OG group'),
     'consumer_name_plural' => t('OG groups'),
     'consumer_short_name' => t('group'),
@@ -22,133 +20,57 @@ function ldap_authorization_og_ldap_authorization_consumer() {
     'consumer_module' => 'ldap_authorization_og',
   );
 
-  if (ldap_authorization_og_og_version() == 1) {
-    $types['og_group']['consumer_mapping_directions'] =  'Mappings should be of form:<br/>
-      <code>[raw authorization id]|[og group match field]=[og group match id],[og role match field]=[og role match id]</code>
-      <br/>such as:<br/>
-      <code>
-      Student Accounts|group-name=students,role-name=member<br/>
-      cn=honors students,ou=groups,dc=hogwarts,dc=edu|gid=7,rid=28<br/>
-      </code>';
-  }
-  else {
-    $types['og_group']['consumer_mapping_directions'] =  'Mappings should be of form:<br/>
-      <code>[raw authorization id]|[og entity type]:[og entity id or title]:[og role id]</code>
-      <br/>[og entity type] is generally "node"
-      <br/>[og entity id or title] can be the groups title or entity id. <strong>Titles with ":"s in them may not be used</strong>.
-      <br/>when [og role id] is left off, default role is used.
-      <br/>such as:<br/>
-      <code>
-      Student Accounts|node:17:2<br/>
-      cn=honors students,ou=groups,dc=hogwarts,dc=edu|node:honors students<br/>
-      cn=gryffindor,ou=groups,dc=hogwarts,dc=edu|node:gryffindor:3<br/>
-      </code>';
-  }
+  $types['og_group']['consumer_mapping_directions'] = 'Mappings should be of form:<br/>
+    <code>[raw authorization id]|[og entity type]:[og entity id or title]:[og role id]</code>
+    <br/>[og entity type] is generally "node"
+    <br/>[og entity id or title] can be the groups title or entity id. <strong>Titles with ":"s in them may not be used</strong>.
+    <br/>when [og role id] is left off, default role is used.
+    <br/>such as:<br/>
+    <code>
+    Student Accounts|node:17:2<br/>
+    cn=honors students,ou=groups,dc=hogwarts,dc=edu|node:honors students<br/>
+    cn=gryffindor,ou=groups,dc=hogwarts,dc=edu|node:gryffindor:3<br/>
+    </code>';
+
   return $types;
 }
 
 /**
- * Format authorization id
+ * Format authorization id.
  *
- * @param int $gid as organic group gid
- * @param int $rid as organic group rig
- * @param array $group_entity as entity associated with organic group
+ * @param int $gid
+ *   as organic group gid.
+ * @param int $rid
+ *   as organic group rig.
+ * @param array $group_entity
+ *   as entity associated with organic group.
  *
  * @return string "normalized" authorization id such as 3-3
  */
 function ldap_authorization_og_authorization_id($gid, $rid, $entity_type = 'node') {
-  return (ldap_authorization_og_og_version() == 1) ? $gid . '-' . $rid :  join(':', array($entity_type, $gid, $rid));
-}
-
-
-function ldap_authorization_og_og_version() {
-  return (function_exists('og_action_info')) ? 2 : 1;
+  return join(':', [$entity_type, $gid, $rid]);
 }
 
 /**
- * Convert entity id to group id
  *
- * @param int $entity_id as id of entity associated with organic group
- * @return int og group id
  */
-function ldap_authorization_og1_entity_id_to_gid($entity_id) {
-
-  $gid = db_select('og', 'og')
-        ->fields('og', array('gid'))
-        ->condition('og.etid', $entity_id, '=')
-        ->range(0, 1)
-        ->execute()
-        ->fetchField();
-  return ($gid && is_scalar($gid)) ? $gid : FALSE;
-
-}
-
-/**
- * Convert entity id to group id
- *
- * @param int $entity_id as id of entity associated with organic group
- * @return int og group id
- */
-function ldap_authorization_og1_group_name_to_gid($group_name) {
-
-  $gid = db_select('og', 'og')
-        ->fields('og', array('gid'))
-        ->condition('og.label', $group_name, '=')
-        ->range(0, 1)
-        ->execute()
-        ->fetchField();
-  return ($gid && is_scalar($gid)) ? $gid : FALSE;
-
-}
-
-
-/**
- * Generic function to convert between query values and organic groups structures and attributes
- *
- * @param mixed $value signifies query value e.g. 'bakers', 7 etc.
- * @param mixed $value_type signifies query type e.g. 'group_name', 'gid', etc.
- * @param string $return signifying return type. e.g.  'object', 'label', 'name', 'gid'
- * @return mixed organic group object, gid, label, etc.
- */
-function ldap_authorization_og1_get_group($value, $value_type = 'group_name', $return = 'object') {
-
-  if ($value_type == 'gid') {
-    $group = og_load($value);
-  }
-  elseif ($value_type == 'group_name') {
-    $gid = ldap_authorization_og1_group_name_to_gid($value);
-    $group = ($gid) ? og_load($gid) : FALSE;
-  }
-
-  if (!$group || !is_object($group)) {
-    return FALSE;
-  }
-  if ($return == 'object' && is_object($group)) {
-    $group_entity = node_load($group->etid);
-    return array($group, $group_entity);
-  }
-  elseif ($return == 'label' || $return == 'name') {
-    return $group->label;
-  }
-  elseif ($return == 'gid') {
-    return $group->gid;
-  }
-  else {
-    return FALSE;
-  }
+function ldap_authorization_og_og_version() {
+  return (function_exists('og_action_info')) ? 2 : 1;
 }
 
 /**
- * Generic function to convert between query values and organic groups structures and attributes
+ * Generic function to convert between query values and organic groups structures and attributes.
  *
- * @param mixed $entity_type signifies query value e.g. 'bakers', 7 etc.
- * @param mixed $group_name signifies query type e.g. 'group_name', 'gid', etc.
+ * @param mixed $entity_type
+ *   signifies query value e.g. 'bakers', 7 etc.
+ * @param mixed $group_name
+ *   signifies query type e.g. 'group_name', 'gid', etc.
  *
  * @return mixed organic group object, gid, label, etc.
  */
 function ldap_authorization_og2_get_group_from_name($entity_type, $group_name) {
 
-  require_once(drupal_get_path('module', 'ldap_authorization_og') . '/LdapAuthorizationConsumerOG.class.php');
+  require_once drupal_get_path('module', 'ldap_authorization_og') . '/LdapAuthorizationConsumerOG.class.php';
   $group_entity = FALSE;
   $group_entity_id = FALSE;
   $query = new EntityFieldQuery();
@@ -167,38 +89,9 @@ function ldap_authorization_og2_get_group_from_name($entity_type, $group_name) {
 
 }
 
-
-function ldap_authorization_og1_has_membership($gid, $uid) {
-  return (boolean)og_get_group_membership($gid, 'user', $uid);
-}
 /**
- * Test if a user has a particular group role
  *
- * @param int $gid as og group id
- * @param int $uid as user id
- * @param string $rid as og role id
- *
- * @return boolean signifying if user has group x role
  */
-function ldap_authorization_og1_has_role($gid, $uid, $rid) {
-  $roles = og_get_user_roles($gid, $uid);
-  return (is_array($roles) && in_array($rid, array_values($roles)));
-}
-
-/** avoid excessive calls to og_roles() **/
-function ldap_authorization_og1_roles($reset = FALSE) {
-  static $roles;
-  if ($reset || !is_array($roles)) {
-    $roles = og_roles();
-  }
-  return $roles;
-}
-
-function ldap_authorization_og1_role_name_to_role_id($role_name) {
-  $roles = ldap_authorization_og1_roles();
-  return array_search($role_name, $roles); //empty($roles[$role_name]) ? FALSE : $roles[$role_name];
-}
-
 function ldap_authorization_og2_has_consumer_id($consumer_id, $uid) {
   $parts = explode(':', $consumer_id);
   $result = FALSE;
@@ -208,7 +101,7 @@ function ldap_authorization_og2_has_consumer_id($consumer_id, $uid) {
   );
   if (count($parts) == 3) {
     list($group_type, $gid, $rid) = $parts;
-    // need to make sure entity exists before calling og_get_user_roles which will throw fatal error
+    // Need to make sure entity exists before calling og_get_user_roles which will throw fatal error.
     if ($group = entity_load_single($group_type, $gid)) {
       if (og_is_group($group_type, $group)) {
         $roles = og_get_user_roles($group_type, $gid, $uid, TRUE);
@@ -225,38 +118,41 @@ function ldap_authorization_og2_has_consumer_id($consumer_id, $uid) {
   return $result;
 }
 
-// ldap_authorization_og2_has_role($og_students_node->nid, $web_user->uid, OG_AUTHENTICATED_ROLE)
+/**
+ * Ldap_authorization_og2_has_role($og_students_node->nid, $web_user->uid, OG_AUTHENTICATED_ROLE)
+ */
 function ldap_authorization_og2_has_role($group_type, $gid, $uid, $role_name) {
-  $roles = og_get_user_roles($group_type, $gid, $uid, TRUE); // array with rid as key and role name as value
+  // Array with rid as key and role name as value.
+  $roles = og_get_user_roles($group_type, $gid, $uid, TRUE);
   return (is_array($roles) && in_array($role_name, array_values($roles)));
 }
 
-
-
 /**
- * Derive og role id from role name
+ * Derive og role id from role name.
+ *
+ * @param string $role_name
+ *   as og role name.
  *
- * @param string $role_name as og role name
  * @return int og role id
  */
-
 function ldap_authorization_og_rid_from_role_name($role_name) {
   $roles = og_roles(0);
   $rids = array_flip($roles);
   return isset($rids[$role_name]) ? $rids[$role_name] : FALSE;
 }
 
-function ldap_authorization_og1_role_name_from_rid($rid) {
-  $roles = og_roles(0);
-  return isset($roles[$rid]) ? $roles[$rid] : FALSE;
-}
-
+/**
+ *
+ */
 function ldap_authorization_og2_rid_from_role_name($entity_type, $bundle, $gid, $role_name) {
   $roles = og_roles($entity_type, $bundle, 0, FALSE, TRUE);
   $roles_flipped = array_flip($roles);
   return (empty($roles_flipped[$role_name])) ? NULL : $roles_flipped[$role_name];
 }
 
+/**
+ *
+ */
 function ldap_authorization_og_get_all_group_entities() {
   $entities = array();
   $group_entity_types = og_get_all_group_bundle();
@@ -266,6 +162,7 @@ function ldap_authorization_og_get_all_group_entities() {
   }
   return $entities;
 }
+
 /**
  * Implements hook_form_alter().
  */
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/tests/BasicTests.test b/drupal7/sites/all/modules/ldap/ldap_authorization/tests/BasicTests.test
index 446f2767..44fead5a 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/tests/BasicTests.test
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/tests/BasicTests.test
@@ -2,48 +2,65 @@
 
 /**
  * @file
- * ldap_authentication simpletests
- *
+ * Ldap_authentication simpletests.
  */
-module_load_include('php', 'ldap_test', 'LdapTestCase.class');
 
+module_load_include('php', 'ldap_test', 'LdapTestCase.class');
+/**
+ *
+ */
 class LdapAuthorizationBasicTests extends LdapTestCase {
+
+  /**
+   *
+   */
   public static function getInfo() {
     return array(
       'name' => 'LDAP Authorization Basic Tests',
       'description' => 'Test ldap authorization.',
-      'group' => 'LDAP Authorization'
+      'group' => 'LDAP Authorization',
     );
   }
 
-  function __construct($test_id = NULL) {
+  /**
+   *
+   */
+  public function __construct($test_id = NULL) {
     parent::__construct($test_id);
   }
 
   public $module_name = 'ldap_authorization';
   protected $ldap_test_data;
 
-  function setUp() {
+  /**
+   *
+   */
+  public function setUp() {
     parent::setUp(array(
       'ldap_authentication',
       'ldap_authorization',
       'ldap_authorization_drupal_role',
-      'ldap_test')); // don't need any real servers, configured, just ldap_servers code base
+    // don't need any real servers, configured, just ldap_servers code base.
+      'ldap_test',
+    ));
     variable_set('ldap_simpletest', 2);
   }
 
-  function tearDown() {
+  /**
+   *
+   */
+  public function tearDown() {
     parent::tearDown();
     variable_del('ldap_help_watchdog_detail');
     variable_del('ldap_simpletest');
   }
 
   /**
-   * test install, api functions, and simple authorizations granted on logon
+   * Test install, api functions, and simple authorizations granted on logon.
    */
-  function testSimpleStuff() {
+  public function testSimpleStuff() {
 
-    // just to give warning if setup doesn't succeed.  may want to take these out at some point.
+    // Just to give warning if setup doesn't succeed.  may want to take these out at some point.
     $setup_success = (
         module_exists('ldap_authentication') &&
         module_exists('ldap_servers') &&
@@ -53,7 +70,6 @@ class LdapAuthorizationBasicTests extends LdapTestCase {
       );
     $this->assertTrue($setup_success, ' ldap_authorizations setup successful', 'LDAP Authorization: Test Setup Success');
 
-
     $api_functions = array(
       'ldap_authorization_get_consumer_object' => array(1, 1),
       'ldap_authorization_get_consumers'  => array(3, 0),
@@ -65,18 +81,16 @@ class LdapAuthorizationBasicTests extends LdapTestCase {
       $this->assertTrue(
         function_exists($api_function_name) &&
         $param_count[1] == $reflector->getNumberOfRequiredParameters() &&
-        $param_count[0] == $reflector->getNumberOfParameters()
-        , ' api function ' . $api_function_name . ' parameters and required parameters count unchanged.', 'LDAP Server: API Functions');
+        $param_count[0] == $reflector->getNumberOfParameters(), ' api function ' . $api_function_name . ' parameters and required parameters count unchanged.', 'LDAP Server: API Functions');
     }
 
-    // make sure ldap authorization doesn't break cron.
+    // Make sure ldap authorization doesn't break cron.
     $this->assertTrue(
       drupal_cron_run(),
       t('Cron can run with ldap authorization enabled.'),
       'LDAP Authorization: Cron Test'
     );
 
-
     /**
     * this is geared toward testing logon functionality
     */
@@ -122,7 +136,7 @@ class LdapAuthorizationBasicTests extends LdapTestCase {
     $this->consumerAdminConf['drupal_role']->revokeLdapProvisioned = 1;
     $this->consumerAdminConf['drupal_role']->save();
 
-    // setup:  remove hpotter from honors members
+    // setup:  remove hpotter from honors members.
     $test_data_pre_test = variable_get('ldap_test_server__' . $sid, NULL);
     $test_data = variable_get('ldap_test_server__' . $sid, NULL);
 
@@ -147,11 +161,10 @@ class LdapAuthorizationBasicTests extends LdapTestCase {
       'LDAP Authorization: Test Logon'
     );
 
-    // return test data to original state
+    // Return test data to original state.
     variable_set('ldap_test_server__' . $sid, $test_data_pre_test);
     $this->drupalGet('user/logout');
 
-
     /**
      * test regranting of removed roles (regrantLdapProvisioned = 0)
      */
@@ -191,137 +204,137 @@ class LdapAuthorizationBasicTests extends LdapTestCase {
     );
     $this->drupalGet('user/logout');
 
-}
-
-
-/**
- * authorization configuration flags tests clumped together
- */
+  }
 
-function testFlags() {
+  /**
+   * Authorization configuration flags tests clumped together.
+   */
+  public function testFlags() {
 
-  $sid = 'activedirectory1';
-  $this->prepTestData(
+    $sid = 'activedirectory1';
+    $this->prepTestData(
     LDAP_TEST_LDAP_NAME,
     array($sid),
     'provisionToDrupal',
     'default',
     'drupal_role_default'
-    );
+      );
 
-  /**
+    /**
    * LDAP_authorz.Flags.status=0: Disable ldap_authorization_drupal_role configuration and make sure no authorizations performed
    */
 
-  $user = $this->drupalCreateUser(array());
-  $hpotter = $this->testFunctions->drupalLdapUpdateUser(array('name' => 'hpotter', 'mail' =>  'hpotter@hogwarts.edu'), TRUE, $user);
-  list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'query');  // just see if the correct ones are derived.
-  $roles1 = $new_authorizations['drupal_role'];
-
- // $consumer_conf_admin = ldap_authorization_get_consumer_admin_object('drupal_role', FALSE);
-  $this->consumerAdminConf['drupal_role']->status = 0;
-  $this->consumerAdminConf['drupal_role']->save();
-
-  list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'query', 'drupal_role');  // just see if the correct ones are derived.
-  $roles2 = isset($new_authorizations['drupal_role']) ? $new_authorizations['drupal_role'] : array();
-  $correct_roles = (count($roles1) > 0 && count($roles2) == 0); // not worried about which roles here, just that some are granted
-
-  /** @FIXME: Broken test
-  $this->assertTrue(
-    $correct_roles,
-    'disable consumer configuration disallows authorizations.',
-    'LDAP_authorz.Flags.status.0'
-  );
-   */
-  if (!$correct_roles) {
-    debug('LDAP_authorz.Flags.enable.0 roles with enabled'); debug($roles1);
-    debug('LDAP_authorz.Flags.enable.0 roles with disabled'); debug($roles2);
-  }
+    $user = $this->drupalCreateUser(array());
+    $hpotter = $this->testFunctions->drupalLdapUpdateUser(array('name' => 'hpotter', 'mail' => 'hpotter@hogwarts.edu'), TRUE, $user);
+    // Just see if the correct ones are derived.
+    list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'query');
+    $roles1 = $new_authorizations['drupal_role'];
 
+    // $consumer_conf_admin = ldap_authorization_get_consumer_admin_object('drupal_role', FALSE);.
+    $this->consumerAdminConf['drupal_role']->status = 0;
+    $this->consumerAdminConf['drupal_role']->save();
 
-  /**
+    // Just see if the correct ones are derived.
+    list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'query', 'drupal_role');
+    $roles2 = isset($new_authorizations['drupal_role']) ? $new_authorizations['drupal_role'] : array();
+    // Not worried about which roles here, just that some are granted.
+    $correct_roles = (count($roles1) > 0 && count($roles2) == 0);
+
+    /** @FIXME: Broken test
+   * $this->assertTrue(
+     * $correct_roles,
+     * 'disable consumer configuration disallows authorizations.',
+     * 'LDAP_authorz.Flags.status.0'
+     * );
+   */
+    if (!$correct_roles) {
+      debug('LDAP_authorz.Flags.enable.0 roles with enabled'); debug($roles1);
+      debug('LDAP_authorz.Flags.enable.0 roles with disabled'); debug($roles2);
+    }
+
+    /**
    * LDAP_authorz.onlyLdapAuthenticated=1: create normal user and
    * apply authorization query.  should return no roles
    */
-  $this->consumerAdminConf['drupal_role']->onlyApplyToLdapAuthenticated = 1;
-  $this->consumerAdminConf['drupal_role']->status = 1;
-  $this->consumerAdminConf['drupal_role']->save();
-
-  $user = $this->drupalCreateUser(array());
-  $hgrainger = $this->testFunctions->drupalLdapUpdateUser(array('name' => 'hgrainger', 'mail' =>  'hgrainger@hogwarts.edu'), TRUE, $user);
-
-  // remove authmap in case it exists so test will work
-  db_delete('authmap')
-    ->condition('uid', $user->uid)
-    ->condition('module', 'ldap_user')
-    ->execute();
-
-  list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hgrainger, 'query');  // just see if the correct ones are derived.
-  $roles = isset($new_authorizations['drupal_role']) ? $new_authorizations['drupal_role'] : array();
-  $success = (count($roles) == 0);
-  $this->assertTrue(
-    $success,
-    ' only apply to ldap authenticated grants no roles for non ldap user.',
-    'LDAP_authorz.onlyLdapAuthenticated.1'
-  );
-  if (!$success) {
-    debug('LDAP_authorz.onlyLdapAuthenticated.1');
-    debug($roles);
-    debug($this->testFunctions->ldapUserIsAuthmapped('hgrainger'));
-    debug($new_authorizations);
-    debug($notifications);
-  }
+    $this->consumerAdminConf['drupal_role']->onlyApplyToLdapAuthenticated = 1;
+    $this->consumerAdminConf['drupal_role']->status = 1;
+    $this->consumerAdminConf['drupal_role']->save();
 
+    $user = $this->drupalCreateUser(array());
+    $hgrainger = $this->testFunctions->drupalLdapUpdateUser(array('name' => 'hgrainger', 'mail' => 'hgrainger@hogwarts.edu'), TRUE, $user);
 
-  /**
+    // Remove authmap in case it exists so test will work.
+    db_delete('authmap')
+      ->condition('uid', $user->uid)
+      ->condition('module', 'ldap_user')
+      ->execute();
+
+    // Just see if the correct ones are derived.
+    list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hgrainger, 'query');
+    $roles = isset($new_authorizations['drupal_role']) ? $new_authorizations['drupal_role'] : array();
+    $success = (count($roles) == 0);
+    $this->assertTrue(
+      $success,
+      ' only apply to ldap authenticated grants no roles for non ldap user.',
+      'LDAP_authorz.onlyLdapAuthenticated.1'
+      );
+    if (!$success) {
+      debug('LDAP_authorz.onlyLdapAuthenticated.1');
+      debug($roles);
+      debug($this->testFunctions->ldapUserIsAuthmapped('hgrainger'));
+      debug($new_authorizations);
+      debug($notifications);
+    }
+
+    /**
    * LDAP_authorz.Flags.synchOnLogon - execute logon and check that no roles are applied if disabled
    */
 
-  $this->consumerAdminConf['drupal_role']->synchOnLogon = 0;
-  $this->consumerAdminConf['drupal_role']->save();
-  $edit = array(
-    'name' => 'hgrainger',
-    'pass' => 'goodpwd',
-  );
-  $this->drupalPost('user', $edit, t('Log in'));
-  $this->assertText(
-    t('Member for'),
-    'New Ldap user with good password authenticated.',
-    'LDAP_authorz.Flags.synchOnLogon.0'
-  );
-  $this->assertTrue(
-    $this->testFunctions->ldapUserIsAuthmapped('hgrainger'),
-    'Ldap user properly authmapped.',
-    'LDAP_authorz.Flags.synchOnLogon.0'
-  );
-
-  $hgrainger = user_load_by_name('hgrainger');
-  $this->drupalGet('user/logout');
-
-  $this->consumerAdminConf['drupal_role']->synchOnLogon = 1;
-  $this->consumerAdminConf['drupal_role']->save();
-  $edit = array(
-    'name' => 'hgrainger',
-    'pass' => 'goodpwd',
-  );
-  $this->drupalPost('user', $edit, t('Log in'));
-  $this->assertText(t('Member for'), 'New Ldap user with good password authenticated.',
-    'LDAP_authorz.Flags.synchOnLogon=1');
-  $hgrainger = user_load_by_name('hgrainger');
-  $this->drupalGet('user/logout');
-
-  // create a couple roles for next 2 tests
-  $troublemaker = new stdClass();
-  $troublemaker->name = 'troublemaker';
-  user_role_save($troublemaker);
-  $troublemaker = user_role_load_by_name('troublemaker');
-
-  $superadmin = new stdClass();
-  $superadmin->name = 'superadmin';
-  user_role_save($superadmin);
-  $superadmin = user_role_load_by_name('superadmin');
-
-   /**
+    $this->consumerAdminConf['drupal_role']->synchOnLogon = 0;
+    $this->consumerAdminConf['drupal_role']->save();
+    $edit = array(
+      'name' => 'hgrainger',
+      'pass' => 'goodpwd',
+    );
+    $this->drupalPost('user', $edit, t('Log in'));
+    $this->assertText(
+      t('Member for'),
+      'New Ldap user with good password authenticated.',
+      'LDAP_authorz.Flags.synchOnLogon.0'
+      );
+    $this->assertTrue(
+      $this->testFunctions->ldapUserIsAuthmapped('hgrainger'),
+      'Ldap user properly authmapped.',
+      'LDAP_authorz.Flags.synchOnLogon.0'
+      );
+
+    $hgrainger = user_load_by_name('hgrainger');
+    $this->drupalGet('user/logout');
+
+    $this->consumerAdminConf['drupal_role']->synchOnLogon = 1;
+    $this->consumerAdminConf['drupal_role']->save();
+    $edit = array(
+      'name' => 'hgrainger',
+      'pass' => 'goodpwd',
+    );
+    $this->drupalPost('user', $edit, t('Log in'));
+    $this->assertText(t('Member for'), 'New Ldap user with good password authenticated.',
+      'LDAP_authorz.Flags.synchOnLogon=1');
+    $hgrainger = user_load_by_name('hgrainger');
+    $this->drupalGet('user/logout');
+
+    // Create a couple roles for next 2 tests.
+    $troublemaker = new stdClass();
+    $troublemaker->name = 'troublemaker';
+    user_role_save($troublemaker);
+    $troublemaker = user_role_load_by_name('troublemaker');
+
+    $superadmin = new stdClass();
+    $superadmin->name = 'superadmin';
+    user_role_save($superadmin);
+    $superadmin = user_role_load_by_name('superadmin');
+
+    /**
    * LDAP_authorz.Flags.revokeLdapProvisioned: test flag for
    *   removing manually granted roles
    *
@@ -333,37 +346,38 @@ function testFlags() {
    *
    */
 
-  $this->consumerAdminConf['drupal_role']->onlyApplyToLdapAuthenticated = 0;
-  $this->consumerAdminConf['drupal_role']->revokeLdapProvisioned = 1;
-  $this->consumerAdminConf['drupal_role']->createConsumers = 1;
-  $this->consumerAdminConf['drupal_role']->save();
-  // set correct roles manually
-  $hpotter = user_load_by_name('hpotter');
-  user_delete($hpotter->uid);
-  $user = $this->drupalCreateUser(array());
-  $hpotter = $this->testFunctions->drupalLdapUpdateUser(array('name' => 'hpotter', 'mail' =>  'hpotter@hogwarts.edu'), TRUE, $user);
-  $edit = array(
-    'name' => 'hpotter',
-    'pass' => 'goodpwd',
-  );
-  $this->drupalPost('user', $edit, t('Log in'));
-  $this->assertText(
-    t('Member for'),
-    'New Ldap user with good password authenticated.',
-    'LDAP_authorz.Flags.revokeLdapProvisioned=1'
-  );
-  $hpotter = user_load_by_name('hpotter');
-
-  // add an underserved, ldap granted drupal role superadmin
-  // and an undeserved, non ldap granted role troublemaker
-  $hpotter = user_load($hpotter->uid, TRUE);
-  $roles = $hpotter->roles;
-  $roles[$troublemaker->rid] = $troublemaker->name;
-  $roles[$superadmin->rid] = $superadmin->name;
-
-  $data = array(
-    'roles' =>  $roles,
-    'data' => array('ldap_authorizations' =>
+    $this->consumerAdminConf['drupal_role']->onlyApplyToLdapAuthenticated = 0;
+    $this->consumerAdminConf['drupal_role']->revokeLdapProvisioned = 1;
+    $this->consumerAdminConf['drupal_role']->createConsumers = 1;
+    $this->consumerAdminConf['drupal_role']->save();
+    // Set correct roles manually.
+    $hpotter = user_load_by_name('hpotter');
+    user_delete($hpotter->uid);
+    $user = $this->drupalCreateUser(array());
+    $hpotter = $this->testFunctions->drupalLdapUpdateUser(array('name' => 'hpotter', 'mail' => 'hpotter@hogwarts.edu'), TRUE, $user);
+    $edit = array(
+      'name' => 'hpotter',
+      'pass' => 'goodpwd',
+    );
+    $this->drupalPost('user', $edit, t('Log in'));
+    $this->assertText(
+      t('Member for'),
+      'New Ldap user with good password authenticated.',
+      'LDAP_authorz.Flags.revokeLdapProvisioned=1'
+      );
+    $hpotter = user_load_by_name('hpotter');
+
+    // Add an underserved, ldap granted drupal role superadmin
+    // and an undeserved, non ldap granted role troublemaker.
+    $hpotter = user_load($hpotter->uid, TRUE);
+    $roles = $hpotter->roles;
+    $roles[$troublemaker->rid] = $troublemaker->name;
+    $roles[$superadmin->rid] = $superadmin->name;
+
+    $data = array(
+      'roles' => $roles,
+      'data' => array(
+        'ldap_authorizations' =>
       array(
         'drupal_role' =>
         array(
@@ -371,22 +385,21 @@ function testFlags() {
           array('date_granted' => 1304216778),
         ),
       ),
-    ),
-  );
-  $hpotter = user_save($hpotter, $data);
-
-  // apply correct authorizations.  should remove the administrator role but not the manually created 'troublemaker' role
-  list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'set', 'drupal_role', 'logon');
+      ),
+    );
+    $hpotter = user_save($hpotter, $data);
 
-  $hpotter = user_load($hpotter->uid, TRUE);
-  $this->assertTrue(
-    (!isset($new_authorizations['drupal_role'][$superadmin->rid])),
-    ' revoke superadmin ldap granted roles when no longer deserved.',
-    'LDAP_authorz.Flags.revokeLdapProvisioned=1'
-  );
+    // Apply correct authorizations.  should remove the administrator role but not the manually created 'troublemaker' role.
+    list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'set', 'drupal_role', 'logon');
 
+    $hpotter = user_load($hpotter->uid, TRUE);
+    $this->assertTrue(
+      (!isset($new_authorizations['drupal_role'][$superadmin->rid])),
+      ' revoke superadmin ldap granted roles when no longer deserved.',
+      'LDAP_authorz.Flags.revokeLdapProvisioned=1'
+      );
 
-   /**
+    /**
    * LDAP_authorz.Flags.regrantLdapProvisioned
    * $this->regrantLdapProvisioned == 1 :
    *   Re grant !consumer_namePlural previously granted
@@ -396,83 +409,86 @@ function testFlags() {
    * - logon
    * - check if regranted
    */
-  $this->drupalGet('user/logout');
-  $this->consumerAdminConf['drupal_role']->regrantLdapProvisioned = 1;
-  $this->consumerAdminConf['drupal_role']->save();
-  $hpotter = user_load($hpotter->uid, TRUE);
-  $roles = $hpotter->roles;
-  unset($roles[$superadmin->rid]);
-  user_save($hpotter, array('roles' => $roles));
-  $hpotter = user_load($hpotter->uid, TRUE);
-  list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'set', 'drupal_role', 'logon');
-  $hpotter = user_load($hpotter->uid, TRUE);
-  $success = !in_array('administrator', array_values($hpotter->roles));
-
-  $this->assertTrue(
-    $success,
-    'regrant Ldap Provisioned roles that were manually revoked',
-    'LDAP_authorz.Flags.regrantLdapProvisioned=1'
-  );
-  if (!$success) {
-    debug('LDAP_authorz.Flags.regrantLdapProvisioned=1');
-    debug('hpotter roles'); debug($hpotter->roles);
-    debug('new_authorizations'); debug($new_authorizations);
-  }
+    $this->drupalGet('user/logout');
+    $this->consumerAdminConf['drupal_role']->regrantLdapProvisioned = 1;
+    $this->consumerAdminConf['drupal_role']->save();
+    $hpotter = user_load($hpotter->uid, TRUE);
+    $roles = $hpotter->roles;
+    unset($roles[$superadmin->rid]);
+    user_save($hpotter, array('roles' => $roles));
+    $hpotter = user_load($hpotter->uid, TRUE);
+    list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'set', 'drupal_role', 'logon');
+    $hpotter = user_load($hpotter->uid, TRUE);
+    $success = !in_array('administrator', array_values($hpotter->roles));
 
-  /**
+    $this->assertTrue(
+      $success,
+      'regrant Ldap Provisioned roles that were manually revoked',
+      'LDAP_authorz.Flags.regrantLdapProvisioned=1'
+      );
+    if (!$success) {
+      debug('LDAP_authorz.Flags.regrantLdapProvisioned=1');
+      debug('hpotter roles'); debug($hpotter->roles);
+      debug('new_authorizations'); debug($new_authorizations);
+    }
+
+    /**
   * LDAP_authorz.Flags.createConsumers=1
   */
 
-  //add new mapping to and enable create consumers
-  $this->prepTestData(LDAP_TEST_LDAP_NAME, array($sid), 'provisionToDrupal', 'default', 'drupal_role_default');
-  $this->drupalGet('user/logout');
-  $new_role = 'oompa-loompas';
-  $this->consumerAdminConf['drupal_role']->createConsumers = 1;
-  $this->consumerAdminConf['drupal_role']->mappings[] = array(
+    // Add new mapping to and enable create consumers.
+    $this->prepTestData(LDAP_TEST_LDAP_NAME, array($sid), 'provisionToDrupal', 'default', 'drupal_role_default');
+    $this->drupalGet('user/logout');
+    $new_role = 'oompa-loompas';
+    $this->consumerAdminConf['drupal_role']->createConsumers = 1;
+    $this->consumerAdminConf['drupal_role']->mappings[] = array(
       'from' => 'cn=students,ou=groups,dc=hogwarts,dc=edu',
       'user_entered' => $new_role,
       'normalized' => $new_role,
       'simplified' => $new_role,
       'valid' => TRUE,
       'error_message' => '',
+    );
+    $this->consumerAdminConf['drupal_role']->save();
+
+    $edit = array(
+      'name' => 'hpotter',
+      'pass' => 'goodpwd',
+    );
+    $this->drupalPost('user', $edit, t('Log in'));
+
+    $new_role_created = in_array($new_role, array_values(user_roles()));
+    $roles_by_name = array_flip(user_roles());
+    $hpotter = user_load_by_name('hpotter');
+    $hpotter = user_load($hpotter->uid, TRUE);
+    $role_granted = isset($hpotter->roles[$roles_by_name[$new_role]]);
+
+    $this->assertTrue(
+      ($new_role_created && $role_granted),
+      'create consumers (e.g. roles)',
+      'LDAP_authorz.Flags.createConsumers=1'
       );
-  $this->consumerAdminConf['drupal_role']->save();
-
-  $edit = array(
-    'name' => 'hpotter',
-    'pass' => 'goodpwd',
-  );
-  $this->drupalPost('user', $edit, t('Log in'));
-
-  $new_role_created = in_array($new_role, array_values(user_roles()));
-  $roles_by_name = array_flip(user_roles());
-  $hpotter = user_load_by_name('hpotter');
-  $hpotter = user_load($hpotter->uid, TRUE);
-  $role_granted = isset($hpotter->roles[$roles_by_name[$new_role]]);
-
-
-  $this->assertTrue(
-    ($new_role_created && $role_granted),
-    'create consumers (e.g. roles)',
-    'LDAP_authorz.Flags.createConsumers=1'
-  );
-
-  if (!($new_role_created && $role_granted)) {
-    debug('roles'); debug(user_roles());
-    debug('roles by name'); debug($roles_by_name);
-    debug('hpotter->roles'); debug($hpotter->roles);
-    debug("new role desired: $new_role");
-    debug("$new_role_created AND $role_granted");
-  }
 
-}
+    if (!($new_role_created && $role_granted)) {
+      debug('roles'); debug(user_roles());
+      debug('roles by name'); debug($roles_by_name);
+      debug('hpotter->roles'); debug($hpotter->roles);
+      debug("new role desired: $new_role");
+      debug("$new_role_created AND $role_granted");
+    }
+
+  }
 
+  /**
+   *
+   */
   public function testUIForms() {
     // TODO: Fix failing tests, excluding to make branch pass.
     return;
 
     $ldap_simpletest_initial = variable_get('ldap_simpletest', 2);
-    variable_del('ldap_simpletest'); // need to be out of fake server mode to test ui.
+    // Need to be out of fake server mode to test ui.
+    variable_del('ldap_simpletest');
 
     $sid = 'activedirectory1';
     $this->prepTestData(LDAP_TEST_LDAP_NAME, array($sid), 'provisionToDrupal', 'default');
@@ -486,25 +502,24 @@ function testFlags() {
     }
     $ldap_server->save('add');
 
-
     $consumer_form_data = array(
       'sid'        => array('activedirectory1', 'activedirectory1'),
       'status'     => array(TRUE, TRUE),
       'only_ldap_authenticated'    => array(FALSE, TRUE),
       'use_first_attr_as_groupid'       => array(FALSE, TRUE),
       'mappings' => array("a|b", "a|b"),
-      'use_filter' =>  array(FALSE, TRUE),
+      'use_filter' => array(FALSE, TRUE),
       'synchronization_modes[user_logon]' => array(TRUE, FALSE),
       'synchronization_actions[revoke_ldap_provisioned]' => array(TRUE, FALSE),
       'synchronization_actions[regrant_ldap_provisioned]' => array(FALSE, TRUE),
       'synchronization_actions[create_consumers]' => array(TRUE, FALSE),
     );
 
-
     $this->privileged_user = $this->drupalCreateUser(array('administer site configuration'));
     $this->drupalLogin($this->privileged_user);
     $ldap_server = ldap_servers_get_servers('activedirectory1', NULL, TRUE, TRUE);
-    $this->drupalGet('admin/config/people/ldap/servers/edit/activedirectory1');  // this is just for debugging to show the server.
+    // This is just for debugging to show the server.
+    $this->drupalGet('admin/config/people/ldap/servers/edit/activedirectory1');
     $ldap_server_admin = new LdapServerAdmin($sid);
 
     if (!is_array($ldap_server_admin->basedn)) {
@@ -516,7 +531,8 @@ function testFlags() {
 
     foreach (array(0) as $i) {
       foreach (array('drupal_role') as $consumer_type) {
-        foreach (array(1) as $ctools_enabled) {  // may want to put this back in after ctools requirement is fixed
+        // May want to put this back in after ctools requirement is fixed.
+        foreach (array(1) as $ctools_enabled) {
           $this->ldapTestId = "testUIForms.$i.$consumer_type.ctools.$ctools_enabled";
           if ($ctools_enabled) {
             module_enable(array('ctools'));
@@ -538,18 +554,16 @@ function testFlags() {
           $this->drupalPost('admin/config/people/ldap/authorization/add/' . $consumer_type, $edit, t('Add'));
           $field_to_prop_map = LdapAuthorizationConsumerConf::field_to_properties_map();
           $ldap_consumer = ldap_authorization_get_consumer_object($consumer_type);
-          $this->assertTrue(is_object($ldap_consumer), 'ldap consumer conf loaded after add-save',  $this->ldapTestId . ' Add consumer configuration');
-          // assert one ldap server exists in db table
-
-          // assert load of server has correct properties for each input
+          $this->assertTrue(is_object($ldap_consumer), 'ldap consumer conf loaded after add-save', $this->ldapTestId . ' Add consumer configuration');
+          // Assert one ldap server exists in db table
+          // Assert load of server has correct properties for each input.
           $mismatches = $this->compareFormToProperties($ldap_consumer, $consumer_form_data, $i, $field_to_prop_map, $lcase_transformed);
           if (count($mismatches)) {
             debug('mismatches between ldap server properties and form submitted values');
             debug($mismatches);
             debug($consumer_form_data);
           }
-          $this->assertTrue(count($mismatches) == 0, 'Add form for ldap consumer properties match values submitted.',  $this->ldapTestId . ' Add consumer conf');
-
+          $this->assertTrue(count($mismatches) == 0, 'Add form for ldap consumer properties match values submitted.', $this->ldapTestId . ' Add consumer conf');
 
           /** update server conf test **/
 
@@ -565,7 +579,7 @@ function testFlags() {
           unset($edit['sid']);
           $this->drupalPost('admin/config/people/ldap/authorization/edit/' . $consumer_type, $edit, t('Save'));
           $ldap_consumer = ldap_authorization_get_consumer_object($consumer_type);
-          $this->assertTrue(is_object($ldap_consumer), 'ldap consumer conf loaded after edit-save',  $this->ldapTestId . ' update consumer configuration');
+          $this->assertTrue(is_object($ldap_consumer), 'ldap consumer conf loaded after edit-save', $this->ldapTestId . ' update consumer configuration');
 
           $mismatches = $this->compareFormToProperties($ldap_consumer, $consumer_form_data, $i, $field_to_prop_map, $lcase_transformed);
           if (count($mismatches)) {
@@ -573,16 +587,16 @@ function testFlags() {
             debug($mismatches);
             debug($consumer_form_data);
           }
-          $this->assertTrue(count($mismatches) == 0, 'Update form for ldap server properties match values submitted.',  $this->ldapTestId . '.Update consumer conf');
+          $this->assertTrue(count($mismatches) == 0, 'Update form for ldap server properties match values submitted.', $this->ldapTestId . '.Update consumer conf');
 
           /** delete server conf test **/
           $this->drupalGet('admin/config/people/ldap/authorization/delete/' . $consumer_type);
           $this->drupalPost('admin/config/people/ldap/authorization/delete/' . $consumer_type, array(), t('Delete'));
           ctools_include('export');
           ctools_export_load_object_reset('ldap_authorization');
-          $consumer_conf = ldap_authorization_get_consumer_conf($consumer_type);//
+          $consumer_conf = ldap_authorization_get_consumer_conf($consumer_type);
           $pass = (is_object($consumer_conf) && $consumer_conf->inDatabase === FALSE);
-          $this->assertTrue($pass, 'Delete form for consumer conf deleted conf.',  $this->ldapTestId . '.Delete  consumer conf');
+          $this->assertTrue($pass, 'Delete form for consumer conf deleted conf.', $this->ldapTestId . '.Delete  consumer conf');
           if (!$pass) {
             debug('ldap consumer after delete. is_object=' . is_object($consumer_conf));
             debug('inDatabase?' . is_object($ldap_consumer) ? $consumer_conf->inDatabase : '?');
@@ -593,9 +607,8 @@ function testFlags() {
         }
       }
     }
-    variable_set('ldap_simpletest', $ldap_simpletest_initial); // return to fake server mode
+    // Return to fake server mode.
+    variable_set('ldap_simpletest', $ldap_simpletest_initial);
   }
 
-
-
 }
diff --git a/drupal7/sites/all/modules/ldap/ldap_authorization/tests/Og2Tests.test b/drupal7/sites/all/modules/ldap/ldap_authorization/tests/Og2Tests.test
index 408b1875..b691d2bf 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/tests/Og2Tests.test
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/tests/Og2Tests.test
@@ -1,19 +1,21 @@
 <?php
 
 /**
- * @file simpletest for Ldap Authorization OG Module, for og 7.x-2.x
+ * @file Simpletest for Ldap Authorization OG Module, for og 7.x-2.x.
  *
  * Manual testing to accompany simpletests:
  *  - logon with og authorization disabled and make sure nothing happens
  *  - logon with og authorization enabled and make sure admin and member group memberships granted
  *  - change mappings so no roles granted
- *  - logon and make sure memberships revoked
+ *  - logon and make sure memberships revoked.
  */
 
 drupal_load('module', 'ldap_test');
 module_load_include('php', 'ldap_test', 'LdapTestCase.class');
-require_once(drupal_get_path('module', 'ldap_authorization_og') . '/LdapAuthorizationConsumerOG.class.php');
-
+require_once drupal_get_path('module', 'ldap_authorization_og') . '/LdapAuthorizationConsumerOG.class.php';
+/**
+ *
+ */
 class LdapAuthorizationOg2Tests extends LdapTestCase {
 
   public $groupEntityType = 'node';
@@ -28,8 +30,11 @@ class LdapAuthorizationOg2Tests extends LdapTestCase {
   public $customOgRoles = array(
     'dungeon-master' => array('entity_type' => 'node', 'bundle_type' => 'group'),
     'time-keeper' => array('entity_type' => 'node', 'bundle_type' => 'group'),
-    );
+  );
 
+  /**
+   *
+   */
   public static function getInfo() {
     return array(
       'group' => 'LDAP Authorization',
@@ -38,36 +43,34 @@ class LdapAuthorizationOg2Tests extends LdapTestCase {
     );
   }
 
-  function __construct($test_id = NULL) {
+  /**
+   *
+   */
+  public function __construct($test_id = NULL) {
     parent::__construct($test_id);
   }
 
-  function setUp($addl_modules = array()) {
+  /**
+   *
+   */
+  public function setUp($addl_modules = array()) {
     parent::setUp(array('ldap_authentication', 'ldap_authorization', 'ldap_authorization_og'));
     variable_set('ldap_simpletest', 2);
 
-    if (ldap_authorization_og_og_version() != 2) {
-      debug('LdapAuthorizationOg2Tests must be run with OG 7.x-2.x');
-      return;
-    }
-
     $this->user1 = $this->drupalCreateUser();
     $this->groups = array();
     $this->prepTestData(LDAP_TEST_LDAP_NAME, array('activedirectory1'));
 
-
-
     // Create group and group content node types.
     $this->groupBundle = $this->drupalCreateContentType(array(
       'type' => 'group',
       'name' => 'OG Group',
-      ))->type;
+    ))->type;
 
     og_create_field(OG_GROUP_FIELD, $this->groupEntityType, $this->groupBundle);
-    og_create_field(OG_AUDIENCE_FIELD, $this->groupEntityType,  $this->groupBundle);
-
-    // create og group for each group in group csv
+    og_create_field(OG_AUDIENCE_FIELD, $this->groupEntityType, $this->groupBundle);
 
+    // Create og group for each group in group csv.
     $this->testFunctions->populateFakeLdapServerData(LDAP_TEST_LDAP_NAME, 'activedirectory1');
     $this->testFunctions->getCsvLdapData(LDAP_TEST_LDAP_NAME);
     foreach ($this->testFunctions->csvTables['groups'] as $guid => $group) {
@@ -83,10 +86,13 @@ class LdapAuthorizationOg2Tests extends LdapTestCase {
 
   }
 
+  /**
+   *
+   */
   public function createCustomRoles() {
 
     foreach ($this->customOgRoles as $og_role_name => $og_role) {
-      $role = new stdClass;
+      $role = new stdClass();
       $role->gid = 0;
       $role->group_type = $og_role['entity_type'];
       $role->group_bundle = $og_role['bundle_type'];
@@ -97,7 +103,7 @@ class LdapAuthorizationOg2Tests extends LdapTestCase {
   }
 
   /**
-   * get test data in convenient format, so tests are easier to read and write
+   * Get test data in convenient format, so tests are easier to read and write.
    */
   public function getTestData($debug = FALSE) {
     $group_nodes = array();
@@ -107,11 +113,11 @@ class LdapAuthorizationOg2Tests extends LdapTestCase {
     $roles_by_name = array();
     $consumer_ids = array();
     foreach (array('gryffindor', 'students', 'faculty', 'users', 'hufflepuff', 'slytherin') as $i => $group_name) {
-      list($group_nodes[$group_name], $group_entity_ids[$group_name]) =  ldap_authorization_og2_get_group_from_name($this->groupEntityType, $group_name);
+      list($group_nodes[$group_name], $group_entity_ids[$group_name]) = ldap_authorization_og2_get_group_from_name($this->groupEntityType, $group_name);
       $nid = $group_nodes[$group_name]->nid;
       $group_nids[$group_name] = $nid;
       $roles[$group_name] = og_roles($this->groupEntityType, $this->groupBundle, $nid, FALSE, TRUE);
-      $roles_by_name[$group_name] = array_flip( $roles[$group_name] );
+      $roles_by_name[$group_name] = array_flip($roles[$group_name]);
       foreach ($roles[$group_name] as $rid => $role_name) {
         $consumer_ids[$group_name][$role_name] = ldap_authorization_og_authorization_id($nid, $rid, 'node');
         $consumer_ids[$group_name][$rid] = ldap_authorization_og_authorization_id($nid, $rid, 'node');
@@ -124,22 +130,17 @@ class LdapAuthorizationOg2Tests extends LdapTestCase {
   }
 
   /**
-   * just make sure install succeeds and
+   * Just make sure install succeeds and.
    */
-  function testBasicFunctionsAndApi() {
+  public function testBasicFunctionsAndApi() {
     // TODO: Fix failing tests, excluding to make branch pass.
     return;
 
-    if (ldap_authorization_og_og_version() != 2) {
-      debug('LdapAuthorizationOg2Tests must be run with OG 7.x-2.x');
-      return;
-    }
-
     $this->createCustomRoles();
     $all_roles = og_roles($this->groupEntityType, $this->groupBundle, 0, FALSE, TRUE);
 
     $this->ldapTestId = $this->module_name . ': setup success';
-    // just to give warning if setup doesn't succeed.  may want to take these out at some point.
+    // Just to give warning if setup doesn't succeed.  may want to take these out at some point.
     $setup_success = (
         module_exists('ldap_authentication') &&
         module_exists('ldap_servers') &&
@@ -162,7 +163,6 @@ class LdapAuthorizationOg2Tests extends LdapTestCase {
     $this->ldapTestId = $this->module_name . ': og2 functions';
     list($group_nodes, $group_nids, $group_entity_ids, $roles_by_name, $consumer_ids) = $this->getTestData(TRUE);
 
-
     /**
      * II.0 basic granting tests to make sure og_role_grant, ldap_authorization_og_rid_from_role_name,
      *   and ldap_authorization_og2_get_group functions work
@@ -179,11 +179,12 @@ class LdapAuthorizationOg2Tests extends LdapTestCase {
     $og_faculty_membership = og_group($this->groupType, $group_nids['faculty'], $values);
 
     og_role_grant($this->groupType, $group_nids['gryffindor'], $web_user->uid, $roles_by_name['gryffindor'][OG_AUTHENTICATED_ROLE]);
-    og_role_grant($this->groupType, $group_nids['faculty'],    $web_user->uid, $roles_by_name['faculty'][OG_ADMINISTRATOR_ROLE]);
-    og_role_grant($this->groupType, $group_nids['faculty'],    $web_user->uid, $roles_by_name['faculty']['dungeon-master']);
-    og_role_grant($this->groupType, $group_nids['faculty'],    $web_user->uid, $roles_by_name['faculty'][OG_AUTHENTICATED_ROLE]);
+    og_role_grant($this->groupType, $group_nids['faculty'], $web_user->uid, $roles_by_name['faculty'][OG_ADMINISTRATOR_ROLE]);
+    og_role_grant($this->groupType, $group_nids['faculty'], $web_user->uid, $roles_by_name['faculty']['dungeon-master']);
+    og_role_grant($this->groupType, $group_nids['faculty'], $web_user->uid, $roles_by_name['faculty'][OG_AUTHENTICATED_ROLE]);
 
-    $web_user = user_load($web_user->uid, TRUE); // need to reload because of issue with og_group and og_role_grant
+    // Need to reload because of issue with og_group and og_role_grant.
+    $web_user = user_load($web_user->uid, TRUE);
     $ids = array($web_user->uid);
     $user_entity = entity_load('user', $ids);
 
@@ -206,7 +207,7 @@ class LdapAuthorizationOg2Tests extends LdapTestCase {
      * II.A. construct ldapauthorization og object and test methods.
      * (unit tests for methods and class without any ldap user context).
      */
-    //
+    // .
     $this->ldapTestId = $this->module_name . ': LdapAuthorizationConsumerOG class';
     $og_auth = new LdapAuthorizationConsumerOG('og_group');
     $this->assertTrue(is_object($og_auth), 'Successfully instantiated LdapAuthorizationConsumerOG', $this->ldapTestId);
@@ -216,10 +217,9 @@ class LdapAuthorizationOg2Tests extends LdapTestCase {
     $this->assertTrue($og_auth->hasAuthorization($web_user, ldap_authorization_og_authorization_id($group_nids['faculty'], $roles_by_name['faculty'][OG_ADMINISTRATOR_ROLE], 'node')),
       'hasAuthorization() method works for non LDAP provisioned og authorization, faculty admin role', $this->ldapTestId);
 
-
     $should_haves = array(
       $consumer_ids['gryffindor'][OG_AUTHENTICATED_ROLE] => 'gryffindor member',
-      $consumer_ids['faculty'][OG_AUTHENTICATED_ROLE] =>  'faculty member',
+      $consumer_ids['faculty'][OG_AUTHENTICATED_ROLE] => 'faculty member',
       $consumer_ids['faculty'][OG_ADMINISTRATOR_ROLE] => 'faculty admin',
       $consumer_ids['faculty']['dungeon-master'] => 'faculty dungeon master',
     );
@@ -244,7 +244,7 @@ class LdapAuthorizationOg2Tests extends LdapTestCase {
       "LdapAuthorizationConsumerOG authorizationRevoke() test revoke on member role " . $consumer_ids['faculty']['dungeon-master'], $this->ldapTestId);
 
     $web_user = user_load($web_user->uid, TRUE);
-    $consumers =  array($consumer_ids['faculty']['dungeon-master'] => $og_auth->emptyConsumer);
+    $consumers = array($consumer_ids['faculty']['dungeon-master'] => $og_auth->emptyConsumer);
     $og_auth->authorizationRevoke($web_user, $user_data, $consumers, $ldap_entry, TRUE);
     $this->assertFalse(ldap_authorization_og2_has_consumer_id($consumer_ids['faculty']['dungeon-master'], $web_user->uid),
       "LdapAuthorizationConsumerOG authorizationRevoke() test revoke on custom member role role " . $consumer_ids['faculty']['dungeon-master'], $this->ldapTestId);
@@ -253,7 +253,7 @@ class LdapAuthorizationOg2Tests extends LdapTestCase {
     $initial_user_authorizations = $og_auth->usersAuthorizations($web_user, TRUE, TRUE);
     debug("initial_user_authorizations authorizations:"); debug($initial_user_authorizations);
     debug("initial_user data:"); debug($web_user->data);
-    $og_auth->authorizationGrant($web_user, $user_data, array($consumer_ids['students'][OG_AUTHENTICATED_ROLE] =>  $og_auth->emptyConsumer), $ldap_entry, TRUE);
+    $og_auth->authorizationGrant($web_user, $user_data, array($consumer_ids['students'][OG_AUTHENTICATED_ROLE] => $og_auth->emptyConsumer), $ldap_entry, TRUE);
     $success = ldap_authorization_og2_has_consumer_id($consumer_ids['students'][OG_AUTHENTICATED_ROLE], $web_user->uid);
     $this->assertTrue($success, "LdapAuthorizationConsumerOG authorizationGrant() test grant on member role " . $consumer_ids['students'][OG_AUTHENTICATED_ROLE], $this->ldapTestId);
     if (!$success) {
@@ -261,7 +261,7 @@ class LdapAuthorizationOg2Tests extends LdapTestCase {
       debug("user authorizations:"); debug($og_auth->usersAuthorizations($web_user, TRUE));
     }
     $web_user = user_load($web_user->uid, TRUE);
-    $result = $og_auth->authorizationRevoke($web_user, $user_data, array('node:454:44334'  => $og_auth->emptyConsumer), $ldap_entry, TRUE);
+    $result = $og_auth->authorizationRevoke($web_user, $user_data, array('node:454:44334' => $og_auth->emptyConsumer), $ldap_entry, TRUE);
     $this->assertFalse($result,
       'LdapAuthorizationConsumerOG authorizationRevoke() test revoke of bogus authorization', $this->ldapTestId);
 
@@ -290,150 +290,149 @@ class LdapAuthorizationOg2Tests extends LdapTestCase {
     $test = ldap_authorization_og2_has_role($this->groupType, $group_nids['gryffindor'], $web_user->uid, OG_ADMINISTRATOR_ROLE);
     $this->assertTrue($test, 'ldap_authorization_og2_has_role() function works', $this->ldapTestId);
 
-    $test = ldap_authorization_og2_has_role($this->groupType,  $group_nids['students'], $web_user->uid, OG_ADMINISTRATOR_ROLE);
+    $test = ldap_authorization_og2_has_role($this->groupType, $group_nids['students'], $web_user->uid, OG_ADMINISTRATOR_ROLE);
     $this->assertTrue($test === FALSE, 'ldap_authorization_og2_has_role() function fails with FALSE', $this->ldapTestId);
 
   }
 
-
   /**
- * authorization configuration flags tests clumped together
- */
-
-function testFlags() {
-  // TODO: Fix failing tests, excluding to make branch pass.
-  return;
+   * Authorization configuration flags tests clumped together.
+   */
+  public function testFlags() {
+    // TODO: Fix failing tests, excluding to make branch pass.
+    return;
 
-  $sid = 'activedirectory1';
-  $this->prepTestData(
+    $sid = 'activedirectory1';
+    $this->prepTestData(
     LDAP_TEST_LDAP_NAME,
     array($sid),
     'provisionToDrupal',
     'default',
     'og_group2'
-    );
+      );
 
-  $og_group_consumer = ldap_authorization_get_consumers('og_group', TRUE, TRUE);
-  /**
+    $og_group_consumer = ldap_authorization_get_consumers('og_group', TRUE, TRUE);
+    /**
    * LDAP_authorz.Flags.status=0: Disable ldap_authorization_drupal_role configuration and make sure no authorizations performed
    */
 
-  list($props_set_display, $props_set_correctly) = $this->checkConsumerConfSetup('og_group2');
-  $this->assertTrue(
-    $props_set_correctly,
-    'Authorization Configuration set correctly in test setup',
-    'LDAP_authorz.Flags.setup.0'
-  );
-  if (!$props_set_correctly) {
-    debug('LDAP_authorz.Flags.setup.0 properties not set correctly'); debug($props_set_display);
-  }
-
-  $this->consumerAdminConf['og_group']->useFirstAttrAsGroupId = 0;
-  $this->consumerAdminConf['og_group']->status = 0;
-  $this->consumerAdminConf['og_group']->save();
-
-  $user = $this->drupalCreateUser(array());
-  $hpotter = $this->testFunctions->drupalLdapUpdateUser(array('name' => 'hpotter', 'mail' =>  'hpotter@hogwarts.edu'), TRUE, $user);
+    list($props_set_display, $props_set_correctly) = $this->checkConsumerConfSetup('og_group2');
+    $this->assertTrue(
+      $props_set_correctly,
+      'Authorization Configuration set correctly in test setup',
+      'LDAP_authorz.Flags.setup.0'
+      );
+    if (!$props_set_correctly) {
+      debug('LDAP_authorz.Flags.setup.0 properties not set correctly'); debug($props_set_display);
+    }
 
-  list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'query');  // just see if the correct ones are derived.
-  $groups1 = $new_authorizations['og_group'];
-  $this->assertTrue(
-    count($new_authorizations['og_group']) == 0,
-    'disabled consumer configuration disallows authorizations.',
-    'LDAP_authorz.Flags.status.0'
-  );
+    $this->consumerAdminConf['og_group']->useFirstAttrAsGroupId = 0;
+    $this->consumerAdminConf['og_group']->status = 0;
+    $this->consumerAdminConf['og_group']->save();
 
-  list($group_nodes, $group_nids, $group_entity_ids, $roles_by_name, $consumer_ids) = $this->getTestData(TRUE);
+    $user = $this->drupalCreateUser(array());
+    $hpotter = $this->testFunctions->drupalLdapUpdateUser(array('name' => 'hpotter', 'mail' => 'hpotter@hogwarts.edu'), TRUE, $user);
 
-  $this->consumerAdminConf['og_group']->status = 1;
-  $this->consumerAdminConf['og_group']->save();
-  list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'query', 'og_group');  // just see if the correct ones are derived.
+    // Just see if the correct ones are derived.
+    list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'query');
+    $groups1 = $new_authorizations['og_group'];
+    $this->assertTrue(
+      count($new_authorizations['og_group']) == 0,
+      'disabled consumer configuration disallows authorizations.',
+      'LDAP_authorz.Flags.status.0'
+      );
 
-  $correct_groups = !empty($new_authorizations['og_group'][$consumer_ids['students'][OG_AUTHENTICATED_ROLE]]) &&
-    !empty($new_authorizations['og_group'][$consumer_ids['gryffindor'][OG_AUTHENTICATED_ROLE]]);
-  $this->assertTrue($correct_groups, 'enabled consumer configuration allows authorizations.', 'LDAP_authorz.Flags.status.1');
-  if (!$correct_groups) {
-    debug('LDAP_authorz.Flags.enable.1 roles with enabled'); debug($new_authorizations);
-  }
+    list($group_nodes, $group_nids, $group_entity_ids, $roles_by_name, $consumer_ids) = $this->getTestData(TRUE);
 
+    $this->consumerAdminConf['og_group']->status = 1;
+    $this->consumerAdminConf['og_group']->save();
+    // Just see if the correct ones are derived.
+    list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'query', 'og_group');
+
+    $correct_groups = !empty($new_authorizations['og_group'][$consumer_ids['students'][OG_AUTHENTICATED_ROLE]]) &&
+      !empty($new_authorizations['og_group'][$consumer_ids['gryffindor'][OG_AUTHENTICATED_ROLE]]);
+    $this->assertTrue($correct_groups, 'enabled consumer configuration allows authorizations.', 'LDAP_authorz.Flags.status.1');
+    if (!$correct_groups) {
+      debug('LDAP_authorz.Flags.enable.1 roles with enabled'); debug($new_authorizations);
+    }
 
-  /**
+    /**
    * LDAP_authorz.onlyLdapAuthenticated=1: create normal user and
    * apply authorization query.  should return no roles
    */
-  $this->consumerAdminConf['og_group']->onlyApplyToLdapAuthenticated = 1;
-  $this->consumerAdminConf['og_group']->status = 1;
-  $this->consumerAdminConf['og_group']->save();
-
-  $user = $this->drupalCreateUser(array());
-  $hgrainger = $this->testFunctions->drupalLdapUpdateUser(array('name' => 'hgrainger', 'mail' =>  'hgrainger@hogwarts.edu'), TRUE, $user);
-
-  // remove old authmap in case it exists so test will work
-  db_delete('authmap')
-    ->condition('uid', $user->uid)
-    ->condition('module', 'ldap_user')
-    ->execute();
-
-  list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hgrainger, 'query');  // just see if the correct ones are derived.
-  $success = (isset($new_authorizations['og_group']) && count($new_authorizations['og_group'] ) == 0);
-  $this->assertTrue($success, ' only apply to ldap authenticated grants no roles for non ldap user.', 'LDAP_authorz.onlyLdapAuthenticated.1');
-  if (!$success) {
-    debug('LDAP_authorz.onlyLdapAuthenticated.1');
-    debug($new_authorizations);
-    debug($this->testFunctions->ldapUserIsAuthmapped('hgrainger'));
-    debug($notifications);
-  }
+    $this->consumerAdminConf['og_group']->onlyApplyToLdapAuthenticated = 1;
+    $this->consumerAdminConf['og_group']->status = 1;
+    $this->consumerAdminConf['og_group']->save();
 
+    $user = $this->drupalCreateUser(array());
+    $hgrainger = $this->testFunctions->drupalLdapUpdateUser(array('name' => 'hgrainger', 'mail' => 'hgrainger@hogwarts.edu'), TRUE, $user);
 
-  /**
+    // Remove old authmap in case it exists so test will work.
+    db_delete('authmap')
+      ->condition('uid', $user->uid)
+      ->condition('module', 'ldap_user')
+      ->execute();
+
+    // Just see if the correct ones are derived.
+    list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hgrainger, 'query');
+    $success = (isset($new_authorizations['og_group']) && count($new_authorizations['og_group']) == 0);
+    $this->assertTrue($success, ' only apply to ldap authenticated grants no roles for non ldap user.', 'LDAP_authorz.onlyLdapAuthenticated.1');
+    if (!$success) {
+      debug('LDAP_authorz.onlyLdapAuthenticated.1');
+      debug($new_authorizations);
+      debug($this->testFunctions->ldapUserIsAuthmapped('hgrainger'));
+      debug($notifications);
+    }
+
+    /**
    * LDAP_authorz.Flags.synchOnLogon - execute logon and check that no roles are applied if disabled
    */
 
-  $this->consumerAdminConf['og_group']->synchOnLogon = 0;
-  $this->consumerAdminConf['og_group']->save();
-  $edit = array(
-    'name' => 'hgrainger',
-    'pass' => 'goodpwd',
-  );
-  $this->drupalPost('user', $edit, t('Log in'));
-  $this->assertText(
-    t('Member for'),
-    'New Ldap user with good password authenticated.',
-    'LDAP_authorz.Flags.synchOnLogon.0'
-  );
-  $this->assertTrue(
-    $this->testFunctions->ldapUserIsAuthmapped('hgrainger'),
-    'Ldap user properly authmapped.',
-    'LDAP_authorz.Flags.synchOnLogon.0'
-  );
+    $this->consumerAdminConf['og_group']->synchOnLogon = 0;
+    $this->consumerAdminConf['og_group']->save();
+    $edit = array(
+      'name' => 'hgrainger',
+      'pass' => 'goodpwd',
+    );
+    $this->drupalPost('user', $edit, t('Log in'));
+    $this->assertText(
+      t('Member for'),
+      'New Ldap user with good password authenticated.',
+      'LDAP_authorz.Flags.synchOnLogon.0'
+      );
+    $this->assertTrue(
+      $this->testFunctions->ldapUserIsAuthmapped('hgrainger'),
+      'Ldap user properly authmapped.',
+      'LDAP_authorz.Flags.synchOnLogon.0'
+      );
 
-  $hgrainger = user_load_by_name('hgrainger');
-  $this->drupalGet('user/logout');
+    $hgrainger = user_load_by_name('hgrainger');
+    $this->drupalGet('user/logout');
 
-  $this->consumerAdminConf['og_group']->synchOnLogon = 1;
-  $this->consumerAdminConf['og_group']->save();
-  $edit = array(
-    'name' => 'hgrainger',
-    'pass' => 'goodpwd',
-  );
-  $this->drupalPost('user', $edit, t('Log in'));
-  $this->assertText(t('Member for'), 'New Ldap user with good password authenticated.',
-    'LDAP_authorz.Flags.synchOnLogon=1');
-  $hgrainger = user_load_by_name('hgrainger');
-  $this->drupalGet('user/logout');
-
-  // create a couple roles for next 2 tests
-  $troublemaker = new stdClass();
-  $troublemaker->name = 'troublemaker';
-  user_role_save($troublemaker);
-  $troublemaker = user_role_load_by_name('troublemaker');
-
-  $superadmin = new stdClass();
-  $superadmin->name = 'superadmin';
-  user_role_save($superadmin);
-  $superadmin = user_role_load_by_name('superadmin');
-
-   /**
+    $this->consumerAdminConf['og_group']->synchOnLogon = 1;
+    $this->consumerAdminConf['og_group']->save();
+    $edit = array(
+      'name' => 'hgrainger',
+      'pass' => 'goodpwd',
+    );
+    $this->drupalPost('user', $edit, t('Log in'));
+    $this->assertText(t('Member for'), 'New Ldap user with good password authenticated.',
+      'LDAP_authorz.Flags.synchOnLogon=1');
+    $hgrainger = user_load_by_name('hgrainger');
+    $this->drupalGet('user/logout');
+
+    // Create a couple roles for next 2 tests.
+    $troublemaker = new stdClass();
+    $troublemaker->name = 'troublemaker';
+    user_role_save($troublemaker);
+    $troublemaker = user_role_load_by_name('troublemaker');
+
+    $superadmin = new stdClass();
+    $superadmin->name = 'superadmin';
+    user_role_save($superadmin);
+    $superadmin = user_role_load_by_name('superadmin');
+
+    /**
    * LDAP_authorz.Flags.revokeLdapProvisioned: test flag for
    *   removing manually granted roles
    *
@@ -445,37 +444,38 @@ function testFlags() {
    *
    */
 
-  $this->consumerAdminConf['og_group']->onlyApplyToLdapAuthenticated = 0;
-  $this->consumerAdminConf['og_group']->revokeLdapProvisioned = 1;
-  $this->consumerAdminConf['og_group']->createConsumers = 1;
-  $this->consumerAdminConf['og_group']->save();
-  // set correct roles manually
-  $hpotter = user_load_by_name('hpotter');
-  user_delete($hpotter->uid);
-  $user = $this->drupalCreateUser(array());
-  $hpotter = $this->testFunctions->drupalLdapUpdateUser(array('name' => 'hpotter', 'mail' =>  'hpotter@hogwarts.edu'), TRUE, $user);
-  $edit = array(
-    'name' => 'hpotter',
-    'pass' => 'goodpwd',
-  );
-  $this->drupalPost('user', $edit, t('Log in'));
-  $this->assertText(
-    t('Member for'),
-    'New Ldap user with good password authenticated.',
-    'LDAP_authorz.Flags.revokeLdapProvisioned=1'
-  );
-  $hpotter = user_load_by_name('hpotter');
-
-  // add an underserved, ldap granted drupal role superadmin
-  // and an undeserved, non ldap granted role troublemaker
-  $hpotter = user_load($hpotter->uid, TRUE);
-  $roles = $hpotter->roles;
-  $roles[$troublemaker->rid] = $troublemaker->name;
-  $roles[$superadmin->rid] = $superadmin->name;
-
-  $data = array(
-    'roles' =>  $roles,
-    'data' => array('ldap_authorizations' =>
+    $this->consumerAdminConf['og_group']->onlyApplyToLdapAuthenticated = 0;
+    $this->consumerAdminConf['og_group']->revokeLdapProvisioned = 1;
+    $this->consumerAdminConf['og_group']->createConsumers = 1;
+    $this->consumerAdminConf['og_group']->save();
+    // Set correct roles manually.
+    $hpotter = user_load_by_name('hpotter');
+    user_delete($hpotter->uid);
+    $user = $this->drupalCreateUser(array());
+    $hpotter = $this->testFunctions->drupalLdapUpdateUser(array('name' => 'hpotter', 'mail' => 'hpotter@hogwarts.edu'), TRUE, $user);
+    $edit = array(
+      'name' => 'hpotter',
+      'pass' => 'goodpwd',
+    );
+    $this->drupalPost('user', $edit, t('Log in'));
+    $this->assertText(
+      t('Member for'),
+      'New Ldap user with good password authenticated.',
+      'LDAP_authorz.Flags.revokeLdapProvisioned=1'
+      );
+    $hpotter = user_load_by_name('hpotter');
+
+    // Add an underserved, ldap granted drupal role superadmin
+    // and an undeserved, non ldap granted role troublemaker.
+    $hpotter = user_load($hpotter->uid, TRUE);
+    $roles = $hpotter->roles;
+    $roles[$troublemaker->rid] = $troublemaker->name;
+    $roles[$superadmin->rid] = $superadmin->name;
+
+    $data = array(
+      'roles' => $roles,
+      'data' => array(
+        'ldap_authorizations' =>
       array(
         'og_group' =>
         array(
@@ -483,22 +483,21 @@ function testFlags() {
           array('date_granted' => 1304216778),
         ),
       ),
-    ),
-  );
-  $hpotter = user_save($hpotter, $data);
-
-  // apply correct authorizations.  should remove the administrator role but not the manually created 'troublemaker' role
-  list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'set', 'og_group', 'logon');
+      ),
+    );
+    $hpotter = user_save($hpotter, $data);
 
-  $hpotter = user_load($hpotter->uid, TRUE);
-  $this->assertTrue(
-    (!isset($new_authorizations['og_group'][$superadmin->rid])),
-    ' revoke superadmin ldap granted roles when no longer deserved.',
-    'LDAP_authorz.Flags.revokeLdapProvisioned=1'
-  );
+    // Apply correct authorizations.  should remove the administrator role but not the manually created 'troublemaker' role.
+    list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'set', 'og_group', 'logon');
 
+    $hpotter = user_load($hpotter->uid, TRUE);
+    $this->assertTrue(
+      (!isset($new_authorizations['og_group'][$superadmin->rid])),
+      ' revoke superadmin ldap granted roles when no longer deserved.',
+      'LDAP_authorz.Flags.revokeLdapProvisioned=1'
+      );
 
-   /**
+    /**
    * LDAP_authorz.Flags.regrantLdapProvisioned
    * $this->regrantLdapProvisioned == 1 :
    *   Re grant !consumer_namePlural previously granted
@@ -508,75 +507,75 @@ function testFlags() {
    * - logon
    * - check if regranted
    */
-  $this->drupalGet('user/logout');
-  $this->consumerAdminConf['og_group']->regrantLdapProvisioned = 1;
-  $this->consumerAdminConf['og_group']->save();
-  $hpotter = user_load($hpotter->uid, TRUE);
-  $roles = $hpotter->roles;
-  unset($roles[$superadmin->rid]);
-  user_save($hpotter, array('roles' => $roles));
-  $hpotter = user_load($hpotter->uid, TRUE);
-  list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'set', 'og_group', 'logon');
-  $hpotter = user_load($hpotter->uid, TRUE);
-  $success = !in_array('administrator', array_values($hpotter->roles));
-
-  $this->assertTrue(
-    $success,
-    'regrant Ldap Provisioned roles that were manually revoked',
-    'LDAP_authorz.Flags.regrantLdapProvisioned=1'
-  );
-  if (!$success) {
-    debug('LDAP_authorz.Flags.regrantLdapProvisioned=1');
-    debug('hpotter roles'); debug($hpotter->roles);
-    debug('new_authorizations'); debug($new_authorizations);
-  }
+    $this->drupalGet('user/logout');
+    $this->consumerAdminConf['og_group']->regrantLdapProvisioned = 1;
+    $this->consumerAdminConf['og_group']->save();
+    $hpotter = user_load($hpotter->uid, TRUE);
+    $roles = $hpotter->roles;
+    unset($roles[$superadmin->rid]);
+    user_save($hpotter, array('roles' => $roles));
+    $hpotter = user_load($hpotter->uid, TRUE);
+    list($new_authorizations, $notifications) = ldap_authorizations_user_authorizations($hpotter, 'set', 'og_group', 'logon');
+    $hpotter = user_load($hpotter->uid, TRUE);
+    $success = !in_array('administrator', array_values($hpotter->roles));
 
-  /**
+    $this->assertTrue(
+      $success,
+      'regrant Ldap Provisioned roles that were manually revoked',
+      'LDAP_authorz.Flags.regrantLdapProvisioned=1'
+      );
+    if (!$success) {
+      debug('LDAP_authorz.Flags.regrantLdapProvisioned=1');
+      debug('hpotter roles'); debug($hpotter->roles);
+      debug('new_authorizations'); debug($new_authorizations);
+    }
+
+    /**
   * LDAP_authorz.Flags.createConsumers=1
   */
 
-  if (!empty($og_group_consumer['allowConsumerObjectCreation']) && $og_group_consumer['allowConsumerObjectCreation']) {
-    //@todo.  this needs to be finished when creation of og groups is added to ldap authorization og functionality
-
-    //add new mapping to and enable create consumers
-    $this->prepTestData('hogwarts', array($sid), 'provisionToDrupal', 'default', 'drupal_role_default');
-    $this->drupalGet('user/logout');
-    $new_role = 'oompa-loompas';
-    $this->consumerAdminConf['og_group']->createConsumers = 1;
-    $this->consumerAdminConf['og_group']->mappings[] = array(
-      'from' => 'cn=students,ou=groups,dc=hogwarts,dc=edu',
-      'user_entered' => $new_role,
-      'normalized' => 'node:' . $new_role . ':' . OG_AUTHENTICATED_ROLE,
-      'simplified' => $new_role,
-      'valid' => TRUE,
-      'error_message' => '',
+    if (!empty($og_group_consumer['allowConsumerObjectCreation']) && $og_group_consumer['allowConsumerObjectCreation']) {
+      // @todo.  this needs to be finished when creation of og groups is added to ldap authorization og functionality
+
+      // Add new mapping to and enable create consumers.
+      $this->prepTestData('hogwarts', array($sid), 'provisionToDrupal', 'default', 'drupal_role_default');
+      $this->drupalGet('user/logout');
+      $new_role = 'oompa-loompas';
+      $this->consumerAdminConf['og_group']->createConsumers = 1;
+      $this->consumerAdminConf['og_group']->mappings[] = array(
+        'from' => 'cn=students,ou=groups,dc=hogwarts,dc=edu',
+        'user_entered' => $new_role,
+        'normalized' => 'node:' . $new_role . ':' . OG_AUTHENTICATED_ROLE,
+        'simplified' => $new_role,
+        'valid' => TRUE,
+        'error_message' => '',
       );
 
-    $this->consumerAdminConf['og_group']->save();
+      $this->consumerAdminConf['og_group']->save();
 
-    $edit = array(
-      'name' => 'hpotter',
-      'pass' => 'goodpwd',
-    );
-    $this->drupalPost('user', $edit, t('Log in'));
-
-    $new_role_created = in_array($new_role, array_values(user_roles()));
-    $roles_by_name = array_flip(user_roles());
-    $hpotter = user_load_by_name('hpotter');
-    $hpotter = user_load($hpotter->uid, TRUE);
-    $role_granted = isset($hpotter->roles[$roles_by_name[$new_role]]);
-    debug('roles'); debug(user_roles());
-    debug('roles by name'); debug($roles_by_name);
-    debug('hpotter->roles'); debug($hpotter->roles);
-    debug("$new_role_created AND $role_granted");
+      $edit = array(
+        'name' => 'hpotter',
+        'pass' => 'goodpwd',
+      );
+      $this->drupalPost('user', $edit, t('Log in'));
+
+      $new_role_created = in_array($new_role, array_values(user_roles()));
+      $roles_by_name = array_flip(user_roles());
+      $hpotter = user_load_by_name('hpotter');
+      $hpotter = user_load($hpotter->uid, TRUE);
+      $role_granted = isset($hpotter->roles[$roles_by_name[$new_role]]);
+      debug('roles'); debug(user_roles());
+      debug('roles by name'); debug($roles_by_name);
+      debug('hpotter->roles'); debug($hpotter->roles);
+      debug("$new_role_created AND $role_granted");
+
+      $this->assertTrue(
+            ($new_role_created && $role_granted),
+            'create consumers (e.g. roles)',
+            'LDAP_authorz.Flags.createConsumers=1'
+          );
+    }
 
-    $this->assertTrue(
-      ($new_role_created && $role_granted),
-      'create consumers (e.g. roles)',
-      'LDAP_authorz.Flags.createConsumers=1'
-    );
   }
 
 }
-
-}
\ No newline at end of file
diff --git a/drupal7/sites/all/modules/ldap/ldap_feeds/FeedsDrupalUserLdapEntryFetcher.inc b/drupal7/sites/all/modules/ldap/ldap_feeds/FeedsDrupalUserLdapEntryFetcher.inc
index 629957f6..e6710831 100644
--- a/drupal7/sites/all/modules/ldap/ldap_feeds/FeedsDrupalUserLdapEntryFetcher.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_feeds/FeedsDrupalUserLdapEntryFetcher.inc
@@ -110,7 +110,7 @@ class FeedsDrupalUserLdapEntryFetcher extends FeedsFetcher {
     $form['filterLdapAuthenticated'] = array(
       '#type' => 'checkbox',
       '#title' => t('Only return ldap authenticated users.'),
-      '#default_value' =>  $this->config['filterLdapAuthenticated'],
+      '#default_value' => $this->config['filterLdapAuthenticated'],
       '#description' => t('If checked, only users who are associated with ldap accounts will be returned.'),
     );
 
@@ -129,7 +129,7 @@ class FeedsDrupalUserLdapEntryFetcher extends FeedsFetcher {
    */
   public function sourceForm($source_config) {
     $tokens = array(
-      '!edit_link' => l(t('Edit Feed'), 'admin/structure/feeds/edit/' . $this->id),
+      '!edit_link' => l(t('Edit Feed'), 'admin/structure/feeds/' . $this->id),
     );
 
     $form_state = array();
diff --git a/drupal7/sites/all/modules/ldap/ldap_feeds/FeedsLdapQueryFetcher.inc b/drupal7/sites/all/modules/ldap/ldap_feeds/FeedsLdapQueryFetcher.inc
index a7e682be..a7b91f84 100644
--- a/drupal7/sites/all/modules/ldap/ldap_feeds/FeedsLdapQueryFetcher.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_feeds/FeedsLdapQueryFetcher.inc
@@ -5,7 +5,6 @@
  * FeedsLdapQueryFetcher
  */
 
-
 /**
  * FeedsLdapQueryFetcherResult
  */
@@ -101,7 +100,7 @@ class FeedsLdapQueryFetcher extends FeedsFetcher {
   public function sourceForm($source_config) {
 
     $tokens = array(
-      '!edit_link' => l(t('Edit Feed'), 'admin/structure/feeds/edit/' . $this->id),
+      '!edit_link' => l(t('Edit Feed'), 'admin/structure/feeds/' . $this->id),
     );
 
     $form_state = array();
diff --git a/drupal7/sites/all/modules/ldap/ldap_feeds/ldap_feeds.info b/drupal7/sites/all/modules/ldap/ldap_feeds/ldap_feeds.info
index ba61f95b..d7df020c 100644
--- a/drupal7/sites/all/modules/ldap/ldap_feeds/ldap_feeds.info
+++ b/drupal7/sites/all/modules/ldap/ldap_feeds/ldap_feeds.info
@@ -12,9 +12,8 @@ configure = admin/structure/feeds
 core = 7.x
 php = 5.2
 
-; Information added by Drupal.org packaging script on 2017-08-27
-version = "7.x-2.3"
+; Information added by Drupal.org packaging script on 2018-08-13
+version = "7.x-2.4"
 core = "7.x"
 project = "ldap"
-datestamp = "1503841448"
-
+datestamp = "1534201086"
diff --git a/drupal7/sites/all/modules/ldap/ldap_feeds/ldap_feeds.module b/drupal7/sites/all/modules/ldap/ldap_feeds/ldap_feeds.module
index 1ccd7cfd..b41c8aed 100644
--- a/drupal7/sites/all/modules/ldap/ldap_feeds/ldap_feeds.module
+++ b/drupal7/sites/all/modules/ldap/ldap_feeds/ldap_feeds.module
@@ -1,5 +1,9 @@
 <?php
 
+/**
+ * @file
+ */
+
 /**
  * Implements hook_ctools_plugin_api().
  */
@@ -32,7 +36,8 @@ function ldap_feeds_feeds_plugins() {
     'name' => 'Drupal User LDAP Entry Fetcher',
     'description' => 'Fetches one entry for each LDAP authenticated user.  Fetches both LDAP entry attributes such as
     <code>cn, dn,</code> etc.
-      and Drupal user data such as <code>uid, name, mail, created, status, language, </code>and <code>signature</code>.',
+      and Drupal user data such as <code>uid, name, mail, created, status, language, </code>and <code>signature</code>.
+      Make sure to add dn in your LDAP query for this parser, if you use custom attributes.',
     'handler' => array(
       'parent' => 'FeedsFetcher', // This is the key name, not the class name.
       'class' => 'FeedsDrupalUserLdapEntryFetcher',
diff --git a/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.examples.inc b/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.examples.inc
index 56e63706..7c669b88 100644
--- a/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.examples.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.examples.inc
@@ -18,17 +18,17 @@ function ldap_help_examples() {
   drupal_add_library('system', 'drupal.collapse');
   $sample_ldaps = array(
    'activedirectory' => 'activedirectory1',
-   'openldap' =>  'openldap1',
+   'openldap' => 'openldap1',
   );
 
 
   $form = array();
-  foreach ($sample_ldaps as  $ldap_type =>  $sample_ldap_id) {
+  foreach ($sample_ldaps as  $ldap_type => $sample_ldap_id) {
 
     $sample_ldap_id = $sample_ldaps[$ldap_type];
     $test_functions->populateFakeLdapServerData(LDAP_TEST_LDAP_NAME, $sample_ldap_id);
     $data = $test_functions->data['ldap_servers'][$sample_ldap_id]['ldap'];
-    $form[$sample_ldap_id] =  array(
+    $form[$sample_ldap_id] = array(
         '#type' => 'fieldset',
         '#title' => $ldap_type,
         '#description' => '',
@@ -37,7 +37,7 @@ function ldap_help_examples() {
         '#collapsed' => TRUE,
       );
     foreach (array('people', 'groups') as $ou) {
-      $form[$sample_ldap_id][$ou] =  array(
+      $form[$sample_ldap_id][$ou] = array(
         '#type' => 'fieldset',
         '#title' => "ou=$ou",
         '#description' => '',
@@ -62,14 +62,14 @@ function ldap_help_examples() {
           $li[]  = theme('item_list', array('items' => $values , 'type' => 'ul', 'title' => $attr));
         }
       }
-      $form[$sample_ldap_id][$ou][$dn] =  array(
+      $form[$sample_ldap_id][$ou][$dn] = array(
         '#type' => 'fieldset',
         '#attributes' => array('class' => array('collapsible', 'collapsed')),
         '#title' => $dn,
         '#collapsible' => TRUE,
         '#collapsed' => TRUE,
       );
-      $form[$sample_ldap_id][$ou][$dn][] =  array(
+      $form[$sample_ldap_id][$ou][$dn][] = array(
         '#markup' => theme('item_list', array('items' => $li , 'type' => 'ul', 'title' => '')),
       );
 
diff --git a/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.info b/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.info
index dada297b..9f459df9 100644
--- a/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.info
+++ b/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.info
@@ -5,9 +5,9 @@ core = 7.x
 
 dependencies[] = ldap_servers
 dependencies[] = ldap_test
-; Information added by Drupal.org packaging script on 2017-08-27
-version = "7.x-2.3"
+
+; Information added by Drupal.org packaging script on 2018-08-13
+version = "7.x-2.4"
 core = "7.x"
 project = "ldap"
-datestamp = "1503841448"
-
+datestamp = "1534201086"
diff --git a/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.install b/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.install
index f3a8bd87..ada185fb 100644
--- a/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.install
+++ b/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.install
@@ -5,7 +5,6 @@
  * LDAP Help Install File
  */
 
-
 /**
  * Implements hook_uninstall().
  */
diff --git a/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.module b/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.module
index d1409b09..9378f16f 100644
--- a/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.module
+++ b/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.module
@@ -6,7 +6,6 @@
  *
  */
 
-
 /**
  * Implements hook_menu().
  */
diff --git a/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.resources.inc b/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.resources.inc
index fef50eba..11598f4e 100644
--- a/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.resources.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.resources.inc
@@ -5,6 +5,7 @@
  * The ldap_help resources are just links.
  *
  */
+
 function ldap_help_main() {
 
   $text = <<<EOT
diff --git a/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.status.inc b/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.status.inc
index 4b11a169..31b4fa8a 100644
--- a/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.status.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.status.inc
@@ -17,29 +17,29 @@ function ldap_help_status($return = 'html') {
   $phpinfo = ldap_help_parsePHPModules();
   $status['server'] = ldap_help_get_server($phpinfo, $info);
   $reporting_text = _ldap_help_parse_status_to_text($status['server'], $heading);
-  $content =  "<h3>$heading</h3>" . theme('status_report', array('requirements' => $status['server'])); //  . ldap_help_phpinfo();
+  $content = "<h3>$heading</h3>" . theme('status_report', array('requirements' => $status['server'])); //  . ldap_help_phpinfo();
 
   $status['user_settings'] = ldap_help_get_user_settings();
-  $content .=  "<h3>User Settings</h3>" . theme('status_report', array('requirements' => $status['user_settings']));
+  $content .= "<h3>User Settings</h3>" . theme('status_report', array('requirements' => $status['user_settings']));
 
   if (module_exists('ldap_servers')) {
     list($status['ldap_servers'], $servers) = ldap_help_get_ldap_servers();
-    $content .=  "<h3>General Settings</h3>" . theme('status_report', array('requirements' => $status['ldap_servers']));
+    $content .= "<h3>General Settings</h3>" . theme('status_report', array('requirements' => $status['ldap_servers']));
 
     foreach ($servers as $sid => $server) {
-      $content .=  "<h3>Server: " . $server[1]['value'] . "</h3>" . theme('status_report', array('requirements' => $server));
+      $content .= "<h3>Server: " . $server[1]['value'] . "</h3>" . theme('status_report', array('requirements' => $server));
     }
   }
 
   if (module_exists('ldap_authentication')) {
     $status['ldap_authentication'] = ldap_help_get_ldap_authentication();
-    $content .=  "<h3>LDAP Authentication Settings</h3>" . theme('status_report', array('requirements' => $status['ldap_authentication']));
+    $content .= "<h3>LDAP Authentication Settings</h3>" . theme('status_report', array('requirements' => $status['ldap_authentication']));
   }
   if (module_exists('ldap_authorization')) {
     $status['ldap_authorizations'] = ldap_help_get_ldap_authorization();
     if (count($status['ldap_authorizations'])) {
       foreach ($status['ldap_authorizations'] as $sid => $mapping) {
-        $content .=  "<h3>LDAP Authorization Mapping</h3>" . theme('status_report', array('requirements' => $mapping));
+        $content .= "<h3>LDAP Authorization Mapping</h3>" . theme('status_report', array('requirements' => $mapping));
       }
     }
   }
@@ -135,33 +135,33 @@ function ldap_help_get_server($phpinfo, &$info) {
   $status[] = array('title' => 'Drupal', 'value' => VERSION , 'severity' => "0");
 
   foreach ( $ldapmodules as $ldapmodule) {
-    $status[] =  array('title' => $ldapmodule, 'value' => $info[$ldapmodule]['text'], 'severity' => "0");
+    $status[] = array('title' => $ldapmodule, 'value' => $info[$ldapmodule]['text'], 'severity' => "0");
   }
   return $status;
 }
 
 function ldap_help_get_ldapauth(&$info) {
 
-  $status[] =  array(
+  $status[] = array(
     'title' => 'Authentication mode',
-    value =>   $info['ldapauth']['login_process_text'] ,
+    value => $info['ldapauth']['login_process_text'] ,
   'severity' => "0");
 
-  $status[] =  array(
+  $status[] = array(
     'title' => 'Conflict Resolve Feature',
-    value =>   $info['ldapauth']['login_conflict_text'],
+    value => $info['ldapauth']['login_conflict_text'],
   'severity' => "0");
 
   $info['ldapauth']['ldapauth_disable_pass_change_text'] = (LDAPAUTH_FORGET_PASSWORDS == TRUE) ? "Do not " : "Do";
   $info['ldapauth']['ldapauth_disable_pass_change_text'] .= 'store users\' passwords during sessions.';
 
-  $status[] =  array('title' => 'Security Options', value => $info['ldapauth']['ldapauth_disable_pass_change_text'], 'severity' => "0");
+  $status[] = array('title' => 'Security Options', value => $info['ldapauth']['ldapauth_disable_pass_change_text'], 'severity' => "0");
 
   $info['ldapauth']['ldapauth_disable_pass_change_text'] = (LDAPAUTH_DISABLE_PASS_CHANGE == TRUE) ? "R" : "Do not R";
   $info['ldapauth']['ldapauth_disable_pass_change_text'] .= 'emove password change fields from user edit form';
   $info['ldapauth']['ldapauth_alter_email_field_text'] = 'ldapauth_alter_email_field: ' . LDAPAUTH_ALTER_EMAIL_FIELD ;
 
-  $status[] =  array('title' => 'LDAP UI Options', value => $info['ldapauth']['ldapauth_disable_pass_change_text'] . "<br/>" . $info['ldapauth']['ldapauth_alter_email_field_text'], 'severity' => "0");
+  $status[] = array('title' => 'LDAP UI Options', value => $info['ldapauth']['ldapauth_disable_pass_change_text'] . "<br/>" . $info['ldapauth']['ldapauth_alter_email_field_text'], 'severity' => "0");
 
   return $status;
 }
@@ -192,7 +192,7 @@ function _ldap_help_parse_status_to_text($status, $heading, $replacements = arra
    // array("\r\n","\r\n","\r\n","\r\n","\r\n"),$item['value'] );
     $item['value'] = str_replace(array_keys($replacements), array_values($replacements), $item['value'] );
     $item['title'] = str_replace(array_keys($replacements), array_values($replacements), $item['title'] );
-    $content .=   $item['title'] . $name_val_del . $item['value'] . $var_del;
+    $content .= $item['title'] . $name_val_del . $item['value'] . $var_del;
   }
   return $content;
 }
@@ -216,10 +216,10 @@ function ldap_help_parsePHPModules() {
   $s = preg_replace('/<td[^>]*>([^<]+)<\/td>/', "<info>\\1</info>", $s);
   $vtmp = preg_split('/(<h2>[^<]+<\/h2>)/', $s, -1, PREG_SPLIT_DELIM_CAPTURE);
   $vmodules = array();
-  for ($i=1; $i<count($vtmp); $i++) {
+  for ($i = 1; $i < count($vtmp); $i++) {
     if (preg_match('/<h2>([^<]+)<\/h2>/', $vtmp[$i], $vmat)) {
       $vname = trim($vmat[1]);
-      $vtmp2 = explode("\n", $vtmp[$i+1]);
+      $vtmp2 = explode("\n", $vtmp[$i + 1]);
       foreach ($vtmp2 AS $vone) {
         $vpat = '<info>([^<]+)<\/info>';
         $vpat3 = "/$vpat\s*$vpat\s*$vpat/";
@@ -292,7 +292,7 @@ function ldap_help_get_ldap_servers() {
       );
     }
 
-  $ldaps = (strpos(drupal_strtolower($server_object->address), 'ldaps') !== FALSE) ?  'y' : 'n';
+  $ldaps = (strpos(drupal_strtolower($server_object->address), 'ldaps') !== FALSE) ? 'y' : 'n';
   $servers[$sid][] = array(
     'title' => 'ldaps in address',
     'value' => $ldaps,
@@ -443,7 +443,7 @@ function ldap_help_parse_form($form, $items) {
             break;
         }
         if ($items[$fieldset_name][$field_name] == 'empty') {
-          $value = ((boolean)trim($value)) ?  'populated': 'empty';
+          $value = ((boolean)trim($value)) ? 'populated' : 'empty';
         }
         $status[] = array(
           'title' => $field_name,
diff --git a/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.watchdog.inc b/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.watchdog.inc
index 77c7d33c..fae5c724 100644
--- a/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.watchdog.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_help/ldap_help.watchdog.inc
@@ -5,9 +5,10 @@
  * The ldap_help watchdog is just a filtered watchdog summary.
  *
  */
+
 function ldap_help_watchdog() {
 
-  $path =  drupal_get_path("module", "ldap_help");
+  $path = drupal_get_path("module", "ldap_help");
   $_content = "";
   if (module_exists('dblog')) {
     include_once(drupal_get_path('module', 'dblog') . '/dblog.admin.inc');
diff --git a/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/README.txt b/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/README.txt
index 5c5419bc..9007078b 100644
--- a/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/README.txt
+++ b/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/README.txt
@@ -89,5 +89,3 @@ Running the Script
       
 4. From the ldap_test_script, type:
    php test.php
-
-
diff --git a/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/config.inc b/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/config.inc
index 17ccc2a6..1ec7a1a5 100644
--- a/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/config.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/config.inc
@@ -65,7 +65,7 @@ function ldap_help_config() {
           'simple_user' => array(
             'delete_if_exists' => TRUE,
             'find_filter' => "distinguishedName=cn=ed-drupal-user-17,$provision_root",
-            'dn' =>  "cn=ed-drupal-user-17, $provision_root",
+            'dn' => "cn=ed-drupal-user-17, $provision_root",
             'attr' => array(
               "displayName" => "Drupal User",
               "cn" => 'ed-drupal-user-17',
@@ -77,22 +77,22 @@ function ldap_help_config() {
               'mail' => 'ed-drupal-user-17@blah.com',
               'givenName' => 'Drupal',
               'sn' => 'User',
-              'distinguishedName' =>  "cn=ed-drupal-user-17,$provision_root",
+              'distinguishedName' => "cn=ed-drupal-user-17,$provision_root",
             ),
           ),
           'simple_group' => array(
             'delete_if_exists' => TRUE,
             'find_filter' => "distinguishedName=cn=ed-drupal-group2,$provision_root",
-            'dn' =>  "cn=ed-drupal-group2,$provision_root",
+            'dn' => "cn=ed-drupal-group2,$provision_root",
             'attr' => array(
               "cn" => 'ed-drupal-group2',
               "sAMAccountName" => 'ed-drupal-group2',
-              'instanceType' =>  '4',
+              'instanceType' => '4',
               "objectClass" => array(
                 "top", "group",
               ),
               'name' => 'ed-drupal-group2',
-              'distinguishedName' =>  "cn=ed-drupal-group2,$provision_root",
+              'distinguishedName' => "cn=ed-drupal-group2,$provision_root",
             ),
           ),
         ),
diff --git a/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/functions.inc b/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/functions.inc
index 0e8b4a50..6c5cfc6d 100644
--- a/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/functions.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/functions.inc
@@ -184,10 +184,10 @@ function ldap_help_parsePHPModules() {
 }
 
 function ldap_help_encodePassword($password) {
-  $password="\"" . $password . "\"";
-  $encoded="";
-  for ($i=0; $i <strlen($password); $i++) {
-    $encoded .="{$password{$i}}\000";
+  $password = "\"" . $password . "\"";
+  $encoded = "";
+  for ($i = 0; $i < strlen($password); $i++) {
+    $encoded .= "{$password{$i}}\000";
   }
   return $encoded;
 }
diff --git a/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/test.php b/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/test.php
index 056c5c27..b7327661 100644
--- a/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/test.php
+++ b/drupal7/sites/all/modules/ldap/ldap_help/ldap_test_script/test.php
@@ -7,7 +7,6 @@
  * see README.txt for instructions
  */
 
-
 require_once('functions.inc');
 
 $config = ldap_help_config();
@@ -108,16 +107,16 @@ foreach ($config['servers'] as $sid => $server) {
           ldap_help_display('no entries found');
         }
         else {
-          for ($j=0; $j<$entry_count; $j++) {
+          for ($j = 0; $j < $entry_count; $j++) {
             $entry = $entries[$j];
             $attr_count = $entry['count'];
             ldap_help_display(NULL, "\nsearch results, entry[$j]:");
             ldap_help_display('  dn[' . $j . ']', $entry['dn']);
-            for ($i=0; $i<$attr_count; $i++) {
+            for ($i = 0; $i < $attr_count; $i++) {
               $attr_name = $entry[$i];
               if (in_array($attr_name, $query['show_attr'])) {
                 $values_count = $entry[$attr_name]['count'];
-                for ($k=0; $k<$values_count; $k++) {
+                for ($k = 0; $k < $values_count; $k++) {
                   ldap_help_display('  ' . $attr_name . '[' . $k . ']', $entry[$attr_name][$k]);
                 }
               }
diff --git a/drupal7/sites/all/modules/ldap/ldap_query/LdapQuery.class.php b/drupal7/sites/all/modules/ldap/ldap_query/LdapQuery.class.php
index 98df2e9e..4ed4344f 100644
--- a/drupal7/sites/all/modules/ldap/ldap_query/LdapQuery.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_query/LdapQuery.class.php
@@ -61,7 +61,7 @@ class LdapQuery {
     else {
       $select = db_select('ldap_query')
         ->fields('ldap_query')
-        ->condition('ldap_query.qid',  $qid)
+        ->condition('ldap_query.qid', $qid)
         ->execute();
       foreach ($select as $record) {
         $query_records[$record->qid] = $record;
diff --git a/drupal7/sites/all/modules/ldap/ldap_query/LdapQueryAdmin.class.php b/drupal7/sites/all/modules/ldap/ldap_query/LdapQueryAdmin.class.php
index 6ea39b6e..2e28ca07 100644
--- a/drupal7/sites/all/modules/ldap/ldap_query/LdapQueryAdmin.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_query/LdapQueryAdmin.class.php
@@ -6,8 +6,6 @@
  *
  */
 
-
-
 module_load_include('php', 'ldap_query', 'LdapQuery.class');
 
 class LdapQueryAdmin extends LdapQuery {
@@ -143,7 +141,7 @@ class LdapQueryAdmin extends LdapQuery {
   public function getActions() {
     $switch = ($this->status ) ? 'disable' : 'enable';
     $actions = array();
-    $actions[] =  l(t('edit'), LDAP_QUERY_MENU_BASE_PATH . '/query/edit/' . $this->qid);
+    $actions[] = l(t('edit'), LDAP_QUERY_MENU_BASE_PATH . '/query/edit/' . $this->qid);
     if (property_exists($this, 'type')) {
       if ($this->type == 'Overridden') {
           $actions[] = l(t('revert'), LDAP_QUERY_MENU_BASE_PATH . '/query/delete/' . $this->qid);
diff --git a/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.admin.inc b/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.admin.inc
index 5503af84..39e04b2e 100644
--- a/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.admin.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.admin.inc
@@ -28,7 +28,7 @@ function ldap_query_index() {
 function ldap_query_list($qid = NULL, $actions = FALSE) {
 
   $ldap_queries = ldap_query_get_queries($qid, 'all');
-  $variables =  array(
+  $variables = array(
     'ldap_queries' => $ldap_queries,
     'action' => TRUE,
     'type' => 'table',
@@ -165,7 +165,7 @@ function ldap_query_admin_delete_submit($form, &$form_state) {
     if ($result = $ldap_query->delete($qid)) {
       $tokens = array('%name' => $ldap_query->name, '!qid' => $qid);
       drupal_set_message(t('LDAP Server %name (query id = !qid) has been deleted.', $tokens), 'status');
-      watchdog('ldap', 'LDAP Query deleted: %name (qid = !qid) ', $tokens);
+      watchdog('ldap_query', 'LDAP Query deleted: %name (qid = !qid) ', $tokens);
     }
     else {
       drupal_set_message(t('LDAP Query delete failed.'), 'warning');
@@ -214,7 +214,7 @@ function ldap_query_admin_enable_disable($form, &$form_state, $action = NULL, $q
     );
     return confirm_form(
       $form,
-      t('Are you sure you want to') . t($action) . ' ' . t('the LDAP query named <em><strong>%name</strong></em>?', array('%name' =>  $ldap_query->name)),
+      t('Are you sure you want to') . t($action) . ' ' . t('the LDAP query named <em><strong>%name</strong></em>?', array('%name' => $ldap_query->name)),
       LDAP_QUERY_MENU_BASE_PATH . '/query/list',
       t('<p></p>'),
       t($action),
@@ -241,7 +241,7 @@ function ldap_query_admin_enable_disable_submit($form, &$form_state) {
     $tokens = array('%name' => $values['name'], '!qid' => $qid, '!action' => t($values['action']) . 'd');
     drupal_set_message(t('LDAP Query Configuration %name (query id = !qid) has been !action.', $tokens));
     $message = t('LDAP Query !action: %name (qid = !qid) ', $tokens);
-    watchdog('ldap', $message);
+    watchdog('ldap_query', $message);
 
   }
 
diff --git a/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.info b/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.info
index 8c4ddb59..3840384f 100644
--- a/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.info
+++ b/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.info
@@ -17,9 +17,8 @@ files[] = tests/ldap_query.test
 
 configure = admin/config/people/ldap/query
 
-; Information added by Drupal.org packaging script on 2017-08-27
-version = "7.x-2.3"
+; Information added by Drupal.org packaging script on 2018-08-13
+version = "7.x-2.4"
 core = "7.x"
 project = "ldap"
-datestamp = "1503841448"
-
+datestamp = "1534201086"
diff --git a/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.install b/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.install
index 7f970186..92a433a7 100644
--- a/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.install
+++ b/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.install
@@ -5,7 +5,6 @@
  * Install, update and uninstall functions for the LDAP API module.
  */
 
-
 /**
  * Implements hook_install().
  */
diff --git a/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.module b/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.module
index 4fb87e41..1cb54242 100644
--- a/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.module
+++ b/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.module
@@ -1,5 +1,9 @@
 <?php
 
+/**
+ * @file
+ */
+
 define('LDAP_QUERY_MENU_BASE_PATH', 'admin/config/people/ldap');
 define('LDAP_QUERY_INDEX_BASE_PATH', 'admin/config/people/ldap/query');
 define('LDAP_QUERY_MENU_BASE_PATH_PARTS', 4); // for argument offsets
diff --git a/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.theme.inc b/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.theme.inc
index 22220bef..62bb582f 100644
--- a/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.theme.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_query/ldap_query.theme.inc
@@ -35,7 +35,7 @@ function theme_ldap_query_list($variables) {
 
   if (count($ldap_queries)) {
     foreach ($ldap_queries as $qid => $ldap_query ) {
-      $row =  array(
+      $row = array(
         $ldap_query->name,
         $ldap_query->base_dn_str,
         $ldap_query->filter,
@@ -110,7 +110,7 @@ function theme_ldap_query_results($variables) {
   }
 
   $table = array(
-    'header' =>  array('DN'),
+    'header' => array('DN'),
     'attributes' => array('id' => 'ldap_query_resultset', 'class' => 'data'),
     'colgroups' => array(),
     'sticky' => FALSE,
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/LdapServer.class.php b/drupal7/sites/all/modules/ldap/ldap_servers/LdapServer.class.php
index 6d320a13..4b79af1c 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/LdapServer.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/LdapServer.class.php
@@ -13,17 +13,17 @@
  * TODO describe preconditions for ldap_entry
  */
 function pretty_print_ldap_entry($ldap_entry) {
-  $m=array();
-  for ($i=0; $i < $ldap_entry['count']; $i++) {
-    $k=$ldap_entry[$i];
-    $v=$ldap_entry[$k];
+  $m = array();
+  for ($i = 0; $i < $ldap_entry['count']; $i++) {
+    $k = $ldap_entry[$i];
+    $v = $ldap_entry[$k];
     if(is_array($v)) {
-      $m2=array();
-      $max=$v['count']>3 ? 3 : $v['count'];
-      for ($j=0; $j < $max; $j++) {
+      $m2 = array();
+      $max = $v['count'] > 3 ? 3 : $v['count'];
+      for ($j = 0; $j < $max; $j++) {
 	$m2[] = $v[$j];
       }
-      $v="(".join(", ", $m2).")";
+      $v = "(".join(", ", $m2).")";
     }
     $m[] = $k . ": " . $v;
   }
@@ -106,9 +106,11 @@ class LdapServer {
   public $connection;
 
 
-
-
-  // direct mapping of db to object properties
+  /**
+   * Direct mapping of db to object properties
+   *
+   * @return array
+   */
   public static function field_to_properties_map() {
     return array(
     'sid' => 'sid',
@@ -144,7 +146,7 @@ class LdapServer {
     'grp_memb_attr_match_user_attr' => 'groupMembershipsAttrMatchingUserAttr',
     'grp_derive_from_dn' => 'groupDeriveFromDn',
     'grp_derive_from_dn_attr' => 'groupDeriveFromDnAttr',
-    'grp_test_grp_dn' =>  'groupTestGroupDn',
+    'grp_test_grp_dn' => 'groupTestGroupDn',
     'grp_test_grp_dn_writeable' => 'groupTestGroupDnWriteable',
 
     'search_pagination' => 'searchPagination',
@@ -156,8 +158,10 @@ class LdapServer {
 
   /**
    * Constructor Method
+   *
+   * @param $sid
    */
-  function __construct($sid) {
+  public function __construct($sid) {
     if (!is_scalar($sid)) {
       return;
     }
@@ -176,7 +180,7 @@ class LdapServer {
     else {
       $select = db_select('ldap_servers')
         ->fields('ldap_servers')
-        ->condition('ldap_servers.sid',  $sid)
+        ->condition('ldap_servers.sid', $sid)
         ->execute();
       foreach ($select as $record) {
         if ($record->sid == $sid) {
@@ -204,7 +208,11 @@ class LdapServer {
   }
 
   /**
-   * this method sets properties that don't directly map from db record.  it is split out so it can be shared with ldapServerTest.class.php
+   * This method sets properties that don't directly map from db record.
+   *
+   * It is split out so it can be shared with ldapServerTest.class.php
+   *
+   * @param $bindpw
    */
   protected function initDerivedProperties($bindpw) {
 
@@ -223,7 +231,7 @@ class LdapServer {
         $this->basedn = array();
         $token = is_scalar($basedn_unserialized) ? $basedn_unserialized : print_r($basedn_unserialized, TRUE);
         debug("basednb desearialization error". $token);
-        watchdog('ldap_server', 'Failed to deserialize LdapServer::basedn of !basedn', array('!basedn' => $token), WATCHDOG_ERROR);
+        watchdog('ldap_servers', 'Failed to deserialize LdapServer::basedn of !basedn', array('!basedn' => $token), WATCHDOG_ERROR);
       }
 
     }
@@ -236,6 +244,16 @@ class LdapServer {
       $this->bindpw = ($bindpw == '') ? '' : ldap_servers_decrypt($bindpw);
     }
 
+    $bind_overrides = variable_get('ldap_servers_overrides', []);
+    if (isset($bind_overrides[$this->sid])) {
+      if (isset($bind_overrides[$this->sid]['binddn'])) {
+        $this->binddn = $bind_overrides[$this->sid]['binddn'];
+      }
+      if (isset($bind_overrides[$this->sid]['bindpw'])) {
+        $this->bindpw = $bind_overrides[$this->sid]['bindpw'];
+      }
+    }
+
     $this->paginationEnabled = (boolean)(ldap_servers_php_supports_pagination() && $this->searchPagination);
 
     $this->queriableWithoutUserCredentials = (boolean)(
@@ -247,32 +265,34 @@ class LdapServer {
     $this->groupGroupEntryMembershipsConfigured = ($this->groupMembershipsAttrMatchingUserAttr && $this->groupMembershipsAttr);
     $this->groupUserMembershipsConfigured = ($this->groupUserMembershipsAttrExists && $this->groupUserMembershipsAttr);
   }
+
   /**
    * Destructor Method
    */
-  function __destruct() {
+  public function __destruct() {
     // Close the server connection to be sure.
     $this->disconnect();
   }
 
-
   /**
    * Invoke Method
    */
-  function __invoke() {
+  public function __invoke() {
     $this->connect();
     $this->bind();
   }
 
-
-
   /**
    * Connect Method
    */
-  function connect() {
+  public function connect() {
+    if (!function_exists('ldap_connect')) {
+      watchdog('ldap_servers', 'PHP LDAP extension not found, aborting.');
+      return LDAP_NOT_SUPPORTED;
+    }
 
     if (!$con = ldap_connect($this->address, $this->port)) {
-      watchdog('user', 'LDAP Connect failure to ' . $this->address . ':' . $this->port);
+      watchdog('ldap_servers', 'LDAP Connect failure to ' . $this->address . ':' . $this->port);
       return LDAP_CONNECT_ERROR;
     }
 
@@ -283,20 +303,20 @@ class LdapServer {
     if ($this->tls) {
       ldap_get_option($con, LDAP_OPT_PROTOCOL_VERSION, $vers);
       if ($vers == -1) {
-        watchdog('user', 'Could not get LDAP protocol version.');
+        watchdog('ldap_servers', 'Could not get LDAP protocol version.');
         return LDAP_PROTOCOL_ERROR;
       }
       if ($vers != 3) {
-        watchdog('user', 'Could not start TLS, only supported by LDAP v3.');
+        watchdog('ldap_servers', 'Could not start TLS, only supported by LDAP v3.');
         return LDAP_CONNECT_ERROR;
       }
       elseif (!function_exists('ldap_start_tls')) {
-        watchdog('user', 'Could not start TLS. It does not seem to be supported by this PHP setup.');
+        watchdog('ldap_servers', 'Could not start TLS. It does not seem to be supported by this PHP setup.');
         return LDAP_CONNECT_ERROR;
       }
       elseif (!ldap_start_tls($con)) {
-        $msg =  t("Could not start TLS. (Error %errno: %error).", array('%errno' => ldap_errno($con), '%error' => ldap_error($con)));
-        watchdog('user', $msg);
+        $msg = t("Could not start TLS. (Error %errno: %error).", array('%errno' => ldap_errno($con), '%error' => ldap_error($con)));
+        watchdog('ldap_servers', $msg);
         return LDAP_CONNECT_ERROR;
       }
     }
@@ -318,11 +338,11 @@ class LdapServer {
    * @return
    *   Result of bind; TRUE if successful, FALSE otherwise.
    */
-  function bind($userdn = NULL, $pass = NULL, $anon_bind = FALSE) {
+  public function bind($userdn = NULL, $pass = NULL, $anon_bind = FALSE) {
 
     // Ensure that we have an active server connection.
     if (!$this->connection) {
-      watchdog('ldap', "LDAP bind failure for user %user. Not connected to LDAP server.", array('%user' => $userdn));
+      watchdog('ldap_servers', "LDAP bind failure for user %user. Not connected to LDAP server.", array('%user' => $userdn));
       return LDAP_CONNECT_ERROR;
     }
 
@@ -332,7 +352,7 @@ class LdapServer {
     if ($anon_bind === TRUE) {
       if (@!ldap_bind($this->connection)) {
         if ($this->detailedWatchdogLog) {
-          watchdog('ldap', "LDAP anonymous bind error. Error %errno: %error", array('%errno' => ldap_errno($this->connection), '%error' => ldap_error($this->connection)));
+          watchdog('ldap_servers', "LDAP anonymous bind error. Error %errno: %error", array('%errno' => ldap_errno($this->connection), '%error' => ldap_error($this->connection)));
         }
         return ldap_errno($this->connection);
       }
@@ -347,12 +367,12 @@ class LdapServer {
       }
 
       if (drupal_strlen($pass) == 0 || drupal_strlen($userdn) == 0) {
-        watchdog('ldap', "LDAP bind failure for user userdn=%userdn, pass=%pass.", array('%userdn' => $userdn, '%pass' => $pass));
+        watchdog('ldap_servers', "LDAP bind failure for user userdn=%userdn, pass=%pass.", array('%userdn' => $userdn, '%pass' => $pass));
         return LDAP_LOCAL_ERROR;
       }
       if (@!ldap_bind($this->connection, $userdn, $pass)) {
         if ($this->detailedWatchdogLog) {
-          watchdog('ldap', "LDAP bind failure for user %user. Error %errno: %error", array('%user' => $userdn, '%errno' => ldap_errno($this->connection), '%error' => ldap_error($this->connection)));
+          watchdog('ldap_servers', "LDAP bind failure for user %user. Error %errno: %error", array('%user' => $userdn, '%errno' => ldap_errno($this->connection), '%error' => ldap_error($this->connection)));
         }
         return ldap_errno($this->connection);
       }
@@ -364,10 +384,10 @@ class LdapServer {
   /**
    * Disconnect (unbind) from an active LDAP server.
    */
-  function disconnect() {
+  public function disconnect() {
     if (!$this->connection) {
       // never bound or not currently bound, so no need to disconnect
-      //watchdog('ldap', 'LDAP disconnect failure from '. $this->server_addr . ':' . $this->port);
+      //watchdog('ldap_servers', 'LDAP disconnect failure from '. $this->server_addr . ':' . $this->port);
     }
     else {
       ldap_unbind($this->connection);
@@ -375,6 +395,9 @@ class LdapServer {
     }
   }
 
+  /**
+   *
+   */
   public function connectAndBindIfNotAlready() {
     if (! $this->connection) {
       $this->connect();
@@ -382,19 +405,17 @@ class LdapServer {
     }
   }
 
-/**
- * does dn exist for this server?
- * [ ] Finished
- * [ ] Test Coverage.  Test ID:
- * [ ] Case insensitive
- *
- * @param string $dn
- * @param enum $return = 'boolean' or 'ldap_entry'
- * @param array $attributes in same form as ldap_read $attributes parameter
- *
- * @param return FALSE or ldap entry array
- */
-  function dnExists($dn, $return = 'boolean', $attributes = NULL) {
+  /**
+   * does dn exist for this server?
+   *
+   *
+   * @param string $dn
+   * @param enum $return = 'boolean' or 'ldap_entry'
+   * @param array $attributes in same form as ldap_read $attributes parameter
+   *
+   * @return bool|array
+   */
+  public function dnExists($dn, $return = 'boolean', $attributes = NULL) {
 
     $params = array(
       'base_dn' => $dn,
@@ -435,19 +456,16 @@ class LdapServer {
     return ldap_count_entries($this->connection, $ldap_result);
   }
 
-
-
   /**
    * create ldap entry.
    *
    * @param array $attributes should follow the structure of ldap_add functions
    *   entry array: http://us.php.net/manual/en/function.ldap-add.php
-        $attributes["attribute1"] = "value";
-        $attributes["attribute2"][0] = "value1";
-        $attributes["attribute2"][1] = "value2";
+   *     $attributes["attribute1"] = "value";
+   *     $attributes["attribute2"][0] = "value1";
+   *     $attributes["attribute2"][1] = "value2";
    * @return boolean result
    */
-
   public function createLdapEntry($attributes, $dn = NULL) {
 
     if (!$this->connection) {
@@ -470,24 +488,31 @@ class LdapServer {
     if (!$result) {
       $error = "LDAP Server ldap_add(%dn) Error Server ID = %sid, LDAP Err No: %ldap_errno LDAP Err Message: %ldap_err2str ";
       $tokens = array('%dn' => $dn, '%sid' => $this->sid, '%ldap_errno' => ldap_errno($this->connection), '%ldap_err2str' => ldap_err2str(ldap_errno($this->connection)));
-      watchdog('ldap_server', $error, $tokens, WATCHDOG_ERROR);
+      watchdog('ldap_servers', $error, $tokens, WATCHDOG_ERROR);
     }
 
     return $result;
   }
 
-
-
-/**
- * given 2 ldap entries, old and new, removed unchanged values to avoid security errors and incorrect date modifieds
- *
- * @param ldap entry array $new_entry in form <attribute> => <value>
- * @param ldap entry array $old_entry in form <attribute> => array('count' => N, array(<value>,...<value>
- *
- * @return ldap array with no values that have NOT changed
- */
-
-  static public function removeUnchangedAttributes($new_entry, $old_entry) {
+  /**
+   * Compares 2 LDAP entries and returns the difference.
+   *
+   * Given 2 ldap entries, old and new, removes unchanged values to avoid
+   * security errors and incorrect date modified.
+   *
+   * @param array $new_entry
+   *   LDAP entry array in form <attribute> => <value>, or
+   *   <attribute> => array(<value1>, <value2>, ...).
+   * @param array $old_entry
+   *   LDAP entry in form <attribute> =>
+   *   array('count' => N, <value1>, <value2>, ...).
+   *
+   * @return array
+   *   The $new_entry with unchanged attributes removed.
+   *
+   * @see \LdapServer::modifyLdapEntry()
+   */
+  public static function removeUnchangedAttributes($new_entry, $old_entry) {
 
     foreach ($new_entry as $key => $new_val) {
       $old_value = FALSE;
@@ -513,27 +538,23 @@ class LdapServer {
         unset($new_entry[$key]); // don't change values that aren't changing to avoid false permission constraints
       }
     }
+
     return $new_entry;
   }
 
-
-
-
-
   /**
    * modify attributes of ldap entry
    *
    * @param string $dn DN of entry
    * @param array $attributes should follow the structure of ldap_add functions
    *   entry array: http://us.php.net/manual/en/function.ldap-add.php
-        $attributes["attribute1"] = "value";
-        $attributes["attribute2"][0] = "value1";
-        $attributes["attribute2"][1] = "value2";
-
-    @return TRUE on success FALSE on error
+   *     $attributes["attribute1"] = "value";
+   *     $attributes["attribute2"][0] = "value1";
+   *     $attributes["attribute2"][1] = "value2";
+   *
+   * @return TRUE on success FALSE on error
    */
-
-  function modifyLdapEntry($dn, $attributes = array(), $old_attributes = FALSE) {
+  public function modifyLdapEntry($dn, $attributes = array(), $old_attributes = FALSE) {
 
     $this->connectAndBindIfNotAlready();
 
@@ -542,13 +563,13 @@ class LdapServer {
       if (!$result) {
         $error = "LDAP Server ldap_read(%dn) in LdapServer::modifyLdapEntry() Error Server ID = %sid, LDAP Err No: %ldap_errno LDAP Err Message: %ldap_err2str ";
         $tokens = array('%dn' => $dn, '%sid' => $this->sid, '%ldap_errno' => ldap_errno($this->connection), '%ldap_err2str' => ldap_err2str(ldap_errno($this->connection)));
-        watchdog('ldap_server', $error, $tokens, WATCHDOG_ERROR);
+        watchdog('ldap_servers', $error, $tokens, WATCHDOG_ERROR);
         return FALSE;
       }
 
       $entries = ldap_get_entries($this->connection, $result);
       if (is_array($entries) && $entries['count'] == 1) {
-        $old_attributes =  $entries[0];
+        $old_attributes = $entries[0];
       }
     }
 
@@ -577,7 +598,7 @@ class LdapServer {
         if (!$result) {
           $error = "LDAP Server ldap_mod_del(%dn) in LdapServer::modifyLdapEntry() Error Server ID = %sid, LDAP Err No: %ldap_errno LDAP Err Message: %ldap_err2str ";
           $tokens = array('%dn' => $dn, '%sid' => $this->sid, '%ldap_errno' => ldap_errno($this->connection), '%ldap_err2str' => ldap_err2str(ldap_errno($this->connection)));
-          watchdog('ldap_server', $error, $tokens, WATCHDOG_ERROR);
+          watchdog('ldap_servers', $error, $tokens, WATCHDOG_ERROR);
           return FALSE;
         }
       }
@@ -598,7 +619,7 @@ class LdapServer {
       if (!$result) {
         $error = "LDAP Server ldap_modify(%dn) in LdapServer::modifyLdapEntry() Error Server ID = %sid, LDAP Err No: %ldap_errno LDAP Err Message: %ldap_err2str ";
         $tokens = array('%dn' => $dn, '%sid' => $this->sid, '%ldap_errno' => ldap_errno($this->connection), '%ldap_err2str' => ldap_err2str(ldap_errno($this->connection)));
-        watchdog('ldap_server', $error, $tokens, WATCHDOG_ERROR);
+        watchdog('ldap_servers', $error, $tokens, WATCHDOG_ERROR);
         return FALSE;
       }
     }
@@ -614,7 +635,6 @@ class LdapServer {
    *
    * @return boolean result per ldap_delete
    */
-
   public function delete($dn) {
     if (!$this->connection) {
       $this->connect();
@@ -624,7 +644,7 @@ class LdapServer {
     if (!$result) {
       $error = "LDAP Server delete(%dn) in LdapServer::delete() Error Server ID = %sid, LDAP Err No: %ldap_errno LDAP Err Message: %ldap_err2str ";
       $tokens = array('%dn' => $dn, '%sid' => $this->sid, '%ldap_errno' => ldap_errno($this->connection), '%ldap_err2str' => ldap_err2str(ldap_errno($this->connection)));
-      watchdog('ldap_server', $error, $tokens, WATCHDOG_ERROR);
+      watchdog('ldap_servers', $error, $tokens, WATCHDOG_ERROR);
     }
     return $result;
   }
@@ -640,12 +660,10 @@ class LdapServer {
    *
    * @remaining params mimick ldap_search() function params
    *
-   * @return
-   *   An array of matching entries->attributes (will have 0
-   *   elements if search returns no results),
-   *   or FALSE on error on any of the basedn queries
+   * @return array
+   *   An array of matching entries->attributes (will have 0 elements if search
+   *   returns no results), or FALSE on error on any of the basedn queries.
    */
-
   public function searchAllBaseDns(
     $filter,
     $attributes = array(),
@@ -678,15 +696,15 @@ class LdapServer {
 
   }
 
-
   /**
    * Perform an LDAP search.
+   *
    * @param string $basedn
    *   The search base. If NULL, we use $this->basedn. should not be esacaped
-   *
    * @param string $filter
-   *   The search filter. such as sAMAccountName=jbarclay.  attribute values (e.g. jbarclay) should be esacaped before calling
-
+   *   The search filter. such as sAMAccountName=jbarclay.  attribute values
+   * (e.g. jbarclay) should be esacaped before calling
+   *
    * @param array $attributes
    *   List of desired attributes. If omitted, we only return "dn".
    *
@@ -697,8 +715,7 @@ class LdapServer {
    *   elements if search returns no results),
    *   or FALSE on error.
    */
-
-  function search($base_dn = NULL, $filter, $attributes = array(),
+  public function search($base_dn = NULL, $filter, $attributes = array(),
     $attrsonly = 0, $sizelimit = 0, $timelimit = 0, $deref = NULL, $scope = LDAP_SCOPE_SUBTREE) {
 
      /**
@@ -708,7 +725,6 @@ class LdapServer {
       * -- http://sgehrig.wordpress.com/2009/11/06/reading-paged-ldap-results-with-php-is-a-show-stopper/
       */
 
-
     if ($base_dn == NULL) {
       if (count($this->basedn) == 1) {
         $base_dn = $this->basedn[0];
@@ -718,7 +734,7 @@ class LdapServer {
       }
     }
 
-    $attr_display =  is_array($attributes) ? join(',', $attributes) : 'none';
+    $attr_display = is_array($attributes) ? join(',', $attributes) : 'none';
     $query = 'ldap_search() call: ' . join(",\n", array(
       'base_dn: ' . $base_dn,
       'filter = ' . $filter,
@@ -731,7 +747,7 @@ class LdapServer {
       )
     );
     if ($this->detailed_watchdog_log) {
-      watchdog('ldap_server', $query, array());
+      watchdog('ldap_servers', $query, array());
     }
 
     // When checking multiple servers, there's a chance we might not be connected yet.
@@ -765,10 +781,10 @@ class LdapServer {
         return (is_array($entries)) ? $entries : FALSE;
       }
       elseif ($this->ldapErrorNumber()) {
-        $watchdog_tokens =  array('%basedn' => $ldap_query_params['base_dn'], '%filter' => $ldap_query_params['filter'],
+        $watchdog_tokens = array('%basedn' => $ldap_query_params['base_dn'], '%filter' => $ldap_query_params['filter'],
           '%attributes' => print_r($ldap_query_params['attributes'], TRUE), '%errmsg' => $this->errorMsg('ldap'),
           '%errno' => $this->ldapErrorNumber());
-        watchdog('ldap', "LDAP ldap_search error. basedn: %basedn| filter: %filter| attributes:
+        watchdog('ldap_servers', "LDAP ldap_search error. basedn: %basedn| filter: %filter| attributes:
           %attributes| errmsg: %errmsg| ldap err no: %errno|", $watchdog_tokens);
         return FALSE;
       }
@@ -778,7 +794,6 @@ class LdapServer {
     }
   }
 
-
   /**
    * execute a paged ldap query and return entries as one aggregated array
    *
@@ -786,16 +801,16 @@ class LdapServer {
    *   a particular set of pages is desired
    *
    * @param array $ldap_query_params of form:
-      'base_dn' => base_dn,
-      'filter' =>  filter,
-      'attributes' => attributes,
-      'attrsonly' => attrsonly,
-      'sizelimit' => sizelimit,
-      'timelimit' => timelimit,
-      'deref' => deref,
-      'scope' => scope,
-
-      (this array of parameters is primarily passed on to ldapQuery() method)
+   *   'base_dn' => base_dn,
+   *   'filter' =>  filter,
+   *   'attributes' => attributes,
+   *   'attrsonly' => attrsonly,
+   *   'sizelimit' => sizelimit,
+   *   'timelimit' => timelimit,
+   *   'deref' => deref,
+   *   'scope' => scope,
+   *
+   *   (this array of parameters is primarily passed on to ldapQuery() method)
    *
    * @return array of ldap entries or FALSE on error.
    *
@@ -803,13 +818,12 @@ class LdapServer {
   public function pagedLdapQuery($ldap_query_params) {
 
     if (!($this->searchPagination && $this->paginationEnabled)) {
-      watchdog('ldap', "LDAP server pagedLdapQuery() called when functionality not available in php install or
+      watchdog('ldap_servers', "LDAP server pagedLdapQuery() called when functionality not available in php install or
         not enabled in ldap server configuration.  error. basedn: %basedn| filter: %filter| attributes:
          %attributes| errmsg: %errmsg| ldap err no: %errno|", $watchdog_tokens);
       RETURN FALSE;
     }
 
-    $paged_entries = array();
     $page_token = '';
     $page = 0;
     $estimated_entries = 0;
@@ -831,10 +845,10 @@ class LdapServer {
           $aggregated_entries_count = count($aggregated_entries);
         }
         elseif ($this->ldapErrorNumber()) {
-          $watchdog_tokens =  array('%basedn' => $ldap_query_params['base_dn'], '%filter' => $ldap_query_params['filter'],
+          $watchdog_tokens = array('%basedn' => $ldap_query_params['base_dn'], '%filter' => $ldap_query_params['filter'],
             '%attributes' => print_r($ldap_query_params['attributes'], TRUE), '%errmsg' => $this->errorMsg('ldap'),
             '%errno' => $this->ldapErrorNumber());
-          watchdog('ldap', "LDAP ldap_search error. basedn: %basedn| filter: %filter| attributes:
+          watchdog('ldap_servers', "LDAP ldap_search error. basedn: %basedn| filter: %filter| attributes:
             %attributes| errmsg: %errmsg| ldap err no: %errno|", $watchdog_tokens);
           RETURN FALSE;
         }
@@ -850,7 +864,7 @@ class LdapServer {
         // false positive error thrown.  do not set result limit error when $sizelimit specified
       }
       elseif ($this->hasError()) {
-        watchdog('ldap_server', 'ldap_control_paged_result_response() function error. LDAP Error: %message, ldap_list() parameters: %query',
+        watchdog('ldap_servers', 'ldap_control_paged_result_response() function error. LDAP Error: %message, ldap_list() parameters: %query',
           array('%message' => $this->errorMsg('ldap'), '%query' => $ldap_query_params['query_display']),
           WATCHDOG_ERROR);
       }
@@ -880,7 +894,7 @@ class LdapServer {
    *
    * @return array of ldap entries
    */
-  function ldapQuery($scope, $params) {
+  public function ldapQuery($scope, $params) {
 
     $this->connectAndBindIfNotAlready();
 
@@ -892,7 +906,7 @@ class LdapServer {
           // false positive error thrown.  do not return result limit error when $sizelimit specified
         }
         elseif ($this->hasError()) {
-          watchdog('ldap_server', 'ldap_search() function error. LDAP Error: %message, ldap_search() parameters: %query',
+          watchdog('ldap_servers', 'ldap_search() function error. LDAP Error: %message, ldap_search() parameters: %query',
             array('%message' => $this->errorMsg('ldap'), '%query' => $params['query_display']),
             WATCHDOG_ERROR);
         }
@@ -905,7 +919,7 @@ class LdapServer {
           // false positive error thrown.  do not result limit error when $sizelimit specified
         }
         elseif ($this->hasError()) {
-          watchdog('ldap_server', 'ldap_read() function error.  LDAP Error: %message, ldap_read() parameters: %query',
+          watchdog('ldap_servers', 'ldap_read() function error.  LDAP Error: %message, ldap_read() parameters: %query',
             array('%message' => $this->errorMsg('ldap'), '%query' => @$params['query_display']),
             WATCHDOG_ERROR);
         }
@@ -918,7 +932,7 @@ class LdapServer {
           // false positive error thrown.  do not result limit error when $sizelimit specified
         }
         elseif ($this->hasError()) {
-          watchdog('ldap_server', 'ldap_list() function error. LDAP Error: %message, ldap_list() parameters: %query',
+          watchdog('ldap_servers', 'ldap_list() function error. LDAP Error: %message, ldap_list() parameters: %query',
             array('%message' => $this->errorMsg('ldap'), '%query' => $params['query_display']),
             WATCHDOG_ERROR);
         }
@@ -931,14 +945,17 @@ class LdapServer {
    * @param array $dns Mixed Case
    * @return array $dns Lower Case
    */
-
   public function dnArrayToLowerCase($dns) {
     return array_keys(array_change_key_case(array_flip($dns), CASE_LOWER));
   }
 
   /**
-   * @param binary or string $puid as returned from ldap_read or other ldap function
+   * userUserEntityFromPuid.
    *
+   * @param string $puid
+   *   Binary or string as returned from ldap_read or other ldap function.
+   *
+   * @return mixed
    */
   public function userUserEntityFromPuid($puid) {
 
@@ -959,8 +976,8 @@ class LdapServer {
       }
       else {
         $uids = join(',', $uids);
-        $tokens = array('%uids' => $uids, '%puid' => $puid, '%sid' =>  $this->sid, '%ldap_user_puid_property' =>  $this->unique_persistent_attr);
-        watchdog('ldap_server', 'multiple users (uids: %uids) with same puid (puid=%puid, sid=%sid, ldap_user_puid_property=%ldap_user_puid_property)', $tokens, WATCHDOG_ERROR);
+        $tokens = array('%uids' => $uids, '%puid' => $puid, '%sid' => $this->sid, '%ldap_user_puid_property' => $this->unique_persistent_attr);
+        watchdog('ldap_servers', 'multiple users (uids: %uids) with same puid (puid=%puid, sid=%sid, ldap_user_puid_property=%ldap_user_puid_property)', $tokens, WATCHDOG_ERROR);
         return FALSE;
       }
     }
@@ -970,7 +987,13 @@ class LdapServer {
 
   }
 
-  function userUsernameToLdapNameTransform($drupal_username, &$watchdog_tokens) {
+  /**
+   * @param $drupal_username
+   * @param $watchdog_tokens
+   *
+   * @return string
+   */
+  public function userUsernameToLdapNameTransform($drupal_username, &$watchdog_tokens) {
     if ($this->ldapToDrupalUserPhp && module_exists('php')) {
       global $name;
       $old_name_value = $name;
@@ -983,7 +1006,7 @@ class LdapServer {
       $watchdog_tokens['%ldap_username'] = $ldap_username;
       $name = $old_name_value;  // important because of global scope of $name
       if ($this->detailedWatchdogLog) {
-        watchdog('ldap_server', '%drupal_user_name tansformed to %ldap_username by applying code <code>%code</code>', $watchdog_tokens, WATCHDOG_DEBUG);
+        watchdog('ldap_servers', '%drupal_user_name tansformed to %ldap_username by applying code <code>%code</code>', $watchdog_tokens, WATCHDOG_DEBUG);
       }
     }
     else {
@@ -1001,10 +1024,13 @@ class LdapServer {
   }
 
 
- /**
-   * @param ldap entry array $ldap_entry
+  /**
+   * userUsernameFromLdapEntry.
+   *
+   * @param array $ldap_entry
    *
-   * @return string user's username value
+   * @return string
+   *   user's username value
    */
   public function userUsernameFromLdapEntry($ldap_entry) {
 
@@ -1022,10 +1048,13 @@ class LdapServer {
     return $accountname;
   }
 
- /**
-   * @param string $dn ldap dn
+  /**
+   * userUsernameFromDn.
    *
-   * @return mixed string user's username value of FALSE
+   * @param string $dn
+   *
+   * @return mixed
+   *   string user's username value of FALSE
    */
   public function userUsernameFromDn($dn) {
 
@@ -1060,83 +1089,96 @@ class LdapServer {
   }
 
 	/**
-	 * @param ldap entry array $ldap_entry
+	 * @param array $ldap_entry
 	 *
-	 * @return drupal file object image user's thumbnail or FALSE if none present or ERROR happens.
+	 * @return object|bool
+   *   Drupal file object image user's thumbnail or FALSE if none present or
+   *   ERROR happens.
 	 */
 	public function userPictureFromLdapEntry($ldap_entry, $drupal_username = FALSE) {
 		if ($ldap_entry && $this->picture_attr) {
 			//Check if ldap entry has been provisioned.
 
-			$thumb = isset($ldap_entry[$this->picture_attr][0]) ? $ldap_entry[$this->picture_attr][0] : FALSE;
-			if(!$thumb){
+			$image_data = isset($ldap_entry[$this->picture_attr][0]) ? $ldap_entry[$this->picture_attr][0] : FALSE;
+			if (!$image_data) {
 				return FALSE;
 			}
 
-			//Create md5 check.
-			$md5thumb = md5($thumb);
+			$md5thumb = md5($image_data);
 
 			/**
-			 * If existing account already has picture check if it has changed if so remove old file and create the new one
-		   * If picture is not set but account has md5 something is wrong exit.
+			 * If the existing account already has picture check if it has changed. If
+       * so remove the old file and create the new one. If a picture is not set
+       * but the account has an md5 hash, something is wrong and we exit.
 			 */
 			if ($drupal_username && $account = user_load_by_name($drupal_username)) {
-        if ($account->uid == 0 || $account->uid == 1){
+        if ($account->uid == 0 || $account->uid == 1) {
           return FALSE;
         }
-        if (isset($account->picture)){
-          // Check if image has changed
-          if (isset($account->data['ldap_user']['init']['thumb5md']) && $md5thumb === $account->data['ldap_user']['init']['thumb5md']){
-            //No change return same image
+        if (isset($account->picture)) {
+          // Check if image has changed.
+          if (isset($account->data['ldap_user']['init']['thumb5md']) && $md5thumb === $account->data['ldap_user']['init']['thumb5md']) {
+            // No change, return same image.
+            $account->picture->md5Sum = $md5thumb;
             return $account->picture;
           }
           else {
-            //Image is different check wether is obj/str and remove fileobject
-            if (is_object($account->picture)){
+            // Image is different, remove file object.
+            if (is_object($account->picture)) {
               file_delete($account->picture, TRUE);
             }
-            elseif (is_string($account->picture)){
+            elseif (is_string($account->picture)) {
               $file = file_load(intval($account->picture));
               file_delete($file, TRUE);
             }
           }
         }
         elseif (isset($account->data['ldap_user']['init']['thumb5md'])) {
-          watchdog('ldap_server', "Some error happened during thumbnailPhoto sync");
+          watchdog('ldap_servers', "Some error happened during thumbnailPhoto sync.");
           return FALSE;
         }
       }
-			//Create tmp file to get image format.
-			$filename = uniqid();
-			$fileuri = file_directory_temp() .'/'. $filename;
-			$size = file_put_contents($fileuri, $thumb);
-			$info = image_get_info($fileuri);
-			unlink($fileuri);
-			// create file object
-			$file = file_save_data($thumb, 'public://' . variable_get('user_picture_path') .'/'. $filename .'.'. $info['extension']);
-			$file->md5Sum = $md5thumb;
-			// standard Drupal validators for user pictures
-			$validators = array(
-					'file_validate_is_image' => array(),
-					'file_validate_image_resolution' => array(variable_get('user_picture_dimensions', '85x85')),
-					'file_validate_size' => array(variable_get('user_picture_file_size', '30') * 1024),
-			);
-			$errors = file_validate($file ,$validators);
-			if (empty($errors)) {
-				return $file;
-			}
-      else {
-				foreach ($errors as $err => $err_val){
-					watchdog('ldap_server', "Error storing picture: %$err", array("%$err" => $err_val), WATCHDOG_ERROR);
-				}
-				return FALSE;
-			}
-		}
+      return $this->savePictureData($image_data, $md5thumb);
+    }
+    return FALSE;
 	}
 
 
   /**
-   * @param ldap entry array $ldap_entry
+   * @param $image_data
+   * @param $md5thumb
+   */
+  private function savePictureData($image_data, $md5thumb) {
+    //Create tmp file to get image format.
+    $filename = uniqid();
+    $fileuri = file_directory_temp() . '/' . $filename;
+    $size = file_put_contents($fileuri, $image_data);
+    $info = image_get_info($fileuri);
+    unlink($fileuri);
+    // create file object
+    $file = file_save_data($image_data, file_default_scheme() . '://' . variable_get('user_picture_path') . '/' . $filename . '.' . $info['extension']);
+    $file->md5Sum = $md5thumb;
+    // standard Drupal validators for user pictures
+    $validators = [
+      'file_validate_is_image' => [],
+      'file_validate_image_resolution' => [variable_get('user_picture_dimensions', '85x85')],
+      'file_validate_size' => [variable_get('user_picture_file_size', '30') * 1024],
+    ];
+    $errors = file_validate($file, $validators);
+    if (empty($errors)) {
+      return $file;
+    }
+    else {
+      foreach ($errors as $err => $err_val) {
+        watchdog('ldap_servers', "Error storing picture: %error", ["%error" => $err_val], WATCHDOG_ERROR);
+      }
+      return FALSE;
+    }
+  }
+
+
+  /**
+   * @param array $ldap_entry
    *
    * @return string user's PUID or permanent user id (within ldap), converted from binary, if applicable
    */
@@ -1159,7 +1201,7 @@ class LdapServer {
     }
   }
 
-   /**
+  /**
    *  @param mixed $user
    *    - drupal user object (stdClass Object)
    *    - ldap entry of user (array)
@@ -1167,7 +1209,7 @@ class LdapServer {
    *    - drupal username of user (string)
    *
    *  @return array $ldap_user_entry (with top level keys of 'dn', 'mail', 'sid' and 'attr' )
-  */
+   */
   public function user_lookup($user) {
     return $this->userUserToExistingLdapEntry($user);
   }
@@ -1206,7 +1248,7 @@ class LdapServer {
    *   'attr' => single ldap entry array in form returned from ldap_search() extension, e.g.
    *   'dn' => dn of entry
    */
-  function userUserNameToExistingLdapEntry($drupal_user_name, $ldap_context = NULL) {
+  public function userUserNameToExistingLdapEntry($drupal_user_name, $ldap_context = NULL) {
 
     $watchdog_tokens = array('%drupal_user_name' => $drupal_user_name);
     $ldap_username = $this->userUsernameToLdapNameTransform($drupal_user_name, $watchdog_tokens);
@@ -1252,7 +1294,7 @@ class LdapServer {
       else {
         if ($this->bind_method == LDAP_SERVERS_BIND_METHOD_ANON_USER) {
           $result = array(
-            'dn' =>  $match['dn'],
+            'dn' => $match['dn'],
             'mail' => $this->userEmailFromLdapEntry($match),
             'attr' => $match,
             'sid' => $this->sid,
@@ -1275,7 +1317,7 @@ class LdapServer {
       foreach ($match[$name_attr] as $value) {
         if (drupal_strtolower(trim($value)) == drupal_strtolower($ldap_username)) {
           $result = array(
-            'dn' =>  $match['dn'],
+            'dn' => $match['dn'],
             'mail' => $this->userEmailFromLdapEntry($match),
             'attr' => $match,
             'sid' => $this->sid,
@@ -1306,8 +1348,6 @@ class LdapServer {
     return (is_array($group_dns) && in_array(drupal_strtolower($group_dn), $this->dnArrayToLowerCase($group_dns)));
   }
 
-
-
   /**
    * NOT TESTED
    * add a group entry
@@ -1475,7 +1515,7 @@ class LdapServer {
 
   }
 
-/**
+  /**
    *   NOT IMPLEMENTED
    * recurse through all child groups and add members.
    *
@@ -1488,7 +1528,6 @@ class LdapServer {
    * @param int $max_levels as max recursion allowed
    *
    */
-
   public function groupMembersResursive($current_member_entries, &$all_member_dns, &$tested_group_ids, $level, $max_levels, $object_classes = FALSE) {
 
     if (!$this->groupGroupEntryMembershipsConfigured || !is_array($current_member_entries) || count($current_member_entries) == 0) {
@@ -1523,7 +1562,7 @@ class LdapServer {
           };
           $ors = array();
           foreach ($member_ids as $i => $member_id) {
-            $ors[] =  $this->groupMembershipsAttr . '=' . ldap_pear_escape_filter_value($member_id); // @todo this would be replaced by query template
+            $ors[] = $this->groupMembershipsAttr . '=' . ldap_pear_escape_filter_value($member_id); // @todo this would be replaced by query template
           }
 
           if (count($ors)) {
@@ -1548,7 +1587,6 @@ class LdapServer {
   }
 
 
- /**
   /**
    *  get list of all groups that a user is a member of.
    *
@@ -1569,7 +1607,6 @@ class LdapServer {
    *
    *  @return array of groups dns in mixed case or FALSE on error
    */
-
   public function groupMembershipsFromUser($user, $return = 'group_dns', $nested = NULL) {
 
     $group_dns = FALSE;
@@ -1618,7 +1655,6 @@ class LdapServer {
    *
    *  @return array of group dns
    */
-
   public function groupUserMembershipsFromUserAttr($user, $nested = NULL) {
 
     if (!$this->groupUserMembershipsConfigured) {
@@ -1656,13 +1692,13 @@ class LdapServer {
         else {
           $member_value = ldap_servers_get_first_rdn_value_from_dn($member_group_dn, $this->groupMembershipsAttrMatchingUserAttr);
         }
-        $ors[] =  $this->groupMembershipsAttr . '=' . ldap_pear_escape_filter_value($member_value);
+        $ors[] = $this->groupMembershipsAttr . '=' . ldap_pear_escape_filter_value($member_value);
       }
     }
 
     if ($nested && count($ors)) {
       $count = count($ors);
-      for ($i=0; $i < $count; $i=$i+LDAP_SERVER_LDAP_QUERY_CHUNK) { // only 50 or so per query
+      for ($i = 0; $i < $count; $i = $i + LDAP_SERVER_LDAP_QUERY_CHUNK) { // only 50 or so per query
         $current_ors = array_slice($ors, $i, LDAP_SERVER_LDAP_QUERY_CHUNK);
         $or = '(|(' . join(")(", $current_ors) . '))';  // e.g. (|(cn=group1)(cn=group2)) or   (|(dn=cn=group1,ou=blah...)(dn=cn=group2,ou=blah...))
         $query_for_parent_groups = '(&(objectClass=' . $this->groupObjectClass . ')' . $or . ')';
@@ -1758,7 +1794,6 @@ class LdapServer {
    *
    * @return FALSE for error or misconfiguration, otherwise TRUE.  results are passed by reference.
    */
-
   public function groupMembershipsFromEntryRecursive($current_group_entries, &$all_group_dns, &$tested_group_ids, $level, $max_levels) {
 
     if (!$this->groupGroupEntryMembershipsConfigured || !is_array($current_group_entries) || count($current_group_entries) == 0) {
@@ -1777,21 +1812,21 @@ class LdapServer {
         $member_id = ldap_servers_get_first_rdn_value_from_dn($group_entry['dn'], $this->groupMembershipsAttrMatchingUserAttr);
 	if(!$member_id) {
 	  if ($this->detailed_watchdog_log) {
-	     watchdog('ldap_server', 'group_entry: %ge', array('%ge'=>pretty_print_ldap_entry($group_entry)));
+	     watchdog('ldap_servers', 'group_entry: %ge', array('%ge' => pretty_print_ldap_entry($group_entry)));
 	  }
 	  // group not identified by simple checks yet!
 
 	  // examine the entry and see if it matches the configured groupObjectClass
-	  $goc=$group_entry['objectclass']; // TODO do we need to ensure such entry is there?
+	  $goc = $group_entry['objectclass']; // TODO do we need to ensure such entry is there?
 	  if(is_array($goc)) {              // TODO is it always an array?
 	    foreach($goc as $g) {
-	      $g=drupal_strtolower($g);
+	      $g = drupal_strtolower($g);
 	      if($g == $this->groupObjectClass) {
 		// found a group, current user must be member in it - so:
 		if ($this->detailed_watchdog_log) {
-		  watchdog('ldap_server', 'adding %mi', array('%mi'=>$member_id));
+		  watchdog('ldap_servers', 'adding %mi', array('%mi' => $member_id));
 		}
-		$member_id=$group_entry['dn'];
+		$member_id = $group_entry['dn'];
 		break;
 	      }
 	    }
@@ -1803,13 +1838,13 @@ class LdapServer {
         $tested_group_ids[] = $member_id;
         $all_group_dns[] = $group_entry['dn'];
         // add $group_id (dn, cn, uid) to query
-        $ors[] =  $this->groupMembershipsAttr . '=' .  ldap_pear_escape_filter_value($member_id);
+        $ors[] = $this->groupMembershipsAttr . '=' .  ldap_pear_escape_filter_value($member_id);
       }
     }
 
     if ($level < $max_levels && count($ors)) {
       $count = count($ors);
-      for ($i=0; $i < $count; $i=$i+LDAP_SERVER_LDAP_QUERY_CHUNK) { // only 50 or so per query
+      for ($i = 0; $i < $count; $i = $i + LDAP_SERVER_LDAP_QUERY_CHUNK) { // only 50 or so per query
         $current_ors = array_slice($ors, $i, LDAP_SERVER_LDAP_QUERY_CHUNK);
         $or = '(|(' . join(")(", $current_ors) . '))';  // e.g. (|(cn=group1)(cn=group2)) or   (|(dn=cn=group1,ou=blah...)(dn=cn=group2,ou=blah...))
         $query_for_parent_groups = '(&(objectClass=' . $this->groupObjectClass . ')' . $or . ')';
@@ -1827,8 +1862,8 @@ class LdapServer {
   }
 
 
- /**
-   *  get "groups" from derived from DN.  Has limited usefulness
+  /**
+   * Get "groups" from derived from DN.  Has limited usefulness
    *
    *  @param mixed
    *    - drupal user object (stdClass Object)
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/LdapServerAdmin.class.php b/drupal7/sites/all/modules/ldap/ldap_servers/LdapServerAdmin.class.php
index dabde534..7b322178 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/LdapServerAdmin.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/LdapServerAdmin.class.php
@@ -81,11 +81,11 @@ class LdapServerAdmin extends LdapServer {
     $this->groupNested = trim($values['grp_nested']);
 
     $this->groupUserMembershipsAttrExists = trim($values['grp_user_memb_attr_exists']);
-    $this->groupUserMembershipsAttr =  drupal_strtolower(trim($values['grp_user_memb_attr']));
+    $this->groupUserMembershipsAttr = drupal_strtolower(trim($values['grp_user_memb_attr']));
 
     $this->groupMembershipsAttr = drupal_strtolower(trim($values['grp_memb_attr']));
 
-    $this->groupMembershipsAttrMatchingUserAttr =  drupal_strtolower(trim($values['grp_memb_attr_match_user_attr']));
+    $this->groupMembershipsAttrMatchingUserAttr = drupal_strtolower(trim($values['grp_memb_attr_match_user_attr']));
 
     $this->groupDeriveFromDn = trim($values['grp_derive_from_dn']);
     $this->groupDeriveFromDnAttr = drupal_strtolower(trim($values['grp_derive_from_dn_attr']));
@@ -183,7 +183,7 @@ class LdapServerAdmin extends LdapServer {
   public function getLdapServerActions() {
     $switch = ($this->status ) ? 'disable' : 'enable';
     $actions = array();
-    $actions[] =  l(t('edit'), LDAP_SERVERS_MENU_BASE_PATH . '/servers/edit/' . $this->sid);
+    $actions[] = l(t('edit'), LDAP_SERVERS_MENU_BASE_PATH . '/servers/edit/' . $this->sid);
     if (property_exists($this, 'type')) {
       if ($this->type == 'Overridden') {
           $actions[] = l(t('revert'), LDAP_SERVERS_MENU_BASE_PATH . '/servers/delete/' . $this->sid);
@@ -282,7 +282,7 @@ class LdapServerAdmin extends LdapServer {
 
   if (!function_exists('ldap_set_rebind_proc')) {
     $form['server']['followrefs']['#disabled'] = TRUE;
-    $form['server']['followrefs']['#description'] =  t('This functionality is disabled because the function ldap_set_rebind_proc can not be found on this server.  Perhaps your version of php does not have this function.  See php.net/manual/en/function.ldap-set-rebind-proc.php') . $form['server']['followrefs']['#description'];
+    $form['server']['followrefs']['#description'] = t('This functionality is disabled because the function ldap_set_rebind_proc can not be found on this server.  Perhaps your version of php does not have this function.  See php.net/manual/en/function.ldap-set-rebind-proc.php') . $form['server']['followrefs']['#description'];
   }
 
   $form['server']['tls']['#required'] = FALSE;
@@ -366,25 +366,25 @@ class LdapServerAdmin extends LdapServer {
 
 
     if (!is_numeric($this->port)) {
-      $errors['port'] =  t('The TCP/IP port must be an integer.');
+      $errors['port'] = t('The TCP/IP port must be an integer.');
     }
 
     if ($this->bind_method == LDAP_SERVERS_BIND_METHOD_USER && !$this->user_dn_expression) {
-      $errors['user_dn_expression'] =  t('When using "Bind with Users Credentials", Expression for user DN is required');
+      $errors['user_dn_expression'] = t('When using "Bind with Users Credentials", Expression for user DN is required');
     }
 
     if ($this->mail_attr && $this->mail_template) {
-      $errors['mail_attr'] =  t('Mail attribute or Mail Template may be used.  Not both.');
+      $errors['mail_attr'] = t('Mail attribute or Mail Template may be used.  Not both.');
     }
 
     if ($this->bind_method == LDAP_SERVERS_BIND_METHOD_SERVICE_ACCT && !$this->binddn) {
-      $errors['binddn'] =  t('When using "Bind with Service Account", Bind DN is required.');
+      $errors['binddn'] = t('When using "Bind with Service Account", Bind DN is required.');
     }
     if ($op == 'add') {
       if ($this->bind_method == LDAP_SERVERS_BIND_METHOD_SERVICE_ACCT &&
         (($op == 'add' && !$this->bindpw_new) || ($op != 'add' && !$this->bindpw))
       ) {
-        $errors['bindpw'] =  t('When using "Bind with Service Account", Bind password is required.');
+        $errors['bindpw'] = t('When using "Bind with Service Account", Bind password is required.');
       }
     }
 
@@ -414,13 +414,13 @@ protected function warnings($op, $has_errors = NULL) {
       $defaults = ldap_servers_ldaps_option_array();
       if (isset($defaults['user']['user_attr']) && ($this->user_attr != $defaults['user']['user_attr'])) {
         $tokens = array('%name' => $defaults['name'], '%default' => $defaults['user']['user_attr'], '%user_attr' => $this->user_attr);
-        $warnings['user_attr'] =  t('The standard UserName attribute in %name is %default.  You have %user_attr. This may be correct
+        $warnings['user_attr'] = t('The standard UserName attribute in %name is %default.  You have %user_attr. This may be correct
           for your particular LDAP.', $tokens);
       }
 
       if (isset($defaults['user']['mail_attr']) && $this->mail_attr && ($this->mail_attr != $defaults['user']['mail_attr'])) {
         $tokens = array('%name' => $defaults['name'], '%default' => $defaults['user']['mail_attr'], '%mail_attr' => $this->mail_attr);
-        $warnings['mail_attr'] =  t('The standard mail attribute in %name is %default.  You have %mail_attr.  This may be correct
+        $warnings['mail_attr'] = t('The standard mail attribute in %name is %default.  You have %mail_attr.  This may be correct
           for your particular LDAP.', $tokens);
       }
     }
@@ -429,7 +429,7 @@ protected function warnings($op, $has_errors = NULL) {
    // }
 
     if (!$this->mail_attr && !$this->mail_template) {
-      $warnings['mail_attr'] =  t('Mail attribute or Mail Template should be used for most user account functionality.');
+      $warnings['mail_attr'] = t('Mail attribute or Mail Template should be used for most user account functionality.');
     }
 
    // commented out validation because too many false positives present usability errors.
@@ -583,11 +583,11 @@ public function drupalFormSubmit($op, $values) {
         ),
       ),
 
-      'ldap_type' =>  array(
+      'ldap_type' => array(
         'form' => array(
           'fieldset' => 'server',
           '#type' => 'select',
-          '#options' =>  ldap_servers_ldaps_option_array(),
+          '#options' => ldap_servers_ldaps_option_array(),
           '#title' => t('LDAP Server Type'),
           '#description' => t('This field is informative.  It\'s purpose is to assist with default values and give validation warnings.'),
         ),
@@ -910,7 +910,7 @@ public function drupalFormSubmit($op, $values) {
         ),
       ),
 
-      'ldap_to_drupal_user' =>  array(
+      'ldap_to_drupal_user' => array(
         'form' => array(
           'fieldset' => 'users',
           '#disabled' => (!module_exists('php')),
@@ -933,7 +933,7 @@ public function drupalFormSubmit($op, $values) {
         ),
       ),
 
-     'testing_drupal_username' =>  array(
+     'testing_drupal_username' => array(
         'form' => array(
           'fieldset' => 'users',
           '#type' => 'textfield',
@@ -948,7 +948,7 @@ public function drupalFormSubmit($op, $values) {
         ),
       ),
 
-     'testing_drupal_user_dn' =>  array(
+     'testing_drupal_user_dn' => array(
         'form' => array(
           'fieldset' => 'users',
           '#type' => 'textfield',
@@ -978,7 +978,7 @@ public function drupalFormSubmit($op, $values) {
         ),
       ),
 
-     'grp_object_cat' =>  array(
+     'grp_object_cat' => array(
         'form' => array(
           'fieldset' => 'groups',
           '#type' => 'textfield',
@@ -1042,7 +1042,7 @@ public function drupalFormSubmit($op, $values) {
         ),
       ),
 
-      'grp_user_memb_attr' =>  array(
+      'grp_user_memb_attr' => array(
         'form' => array(
           'fieldset' => 'groups',
           '#type' => 'textfield',
@@ -1065,7 +1065,7 @@ public function drupalFormSubmit($op, $values) {
         ),
       ),
 
-      'grp_memb_attr' =>  array(
+      'grp_memb_attr' => array(
         'form' => array(
           'fieldset' => 'groups',
           '#type' => 'textfield',
@@ -1085,7 +1085,7 @@ public function drupalFormSubmit($op, $values) {
         ),
       ),
 
-      'grp_memb_attr_match_user_attr' =>  array(
+      'grp_memb_attr_match_user_attr' => array(
         'form' => array(
           'fieldset' => 'groups',
           '#type' => 'textfield',
@@ -1128,7 +1128,7 @@ public function drupalFormSubmit($op, $values) {
         ),
       ),
 
-      'grp_derive_from_dn_attr' =>  array(
+      'grp_derive_from_dn_attr' => array(
         'form' => array(
           'fieldset' => 'groups',
           '#type' => 'textfield',
@@ -1151,7 +1151,7 @@ public function drupalFormSubmit($op, $values) {
         ),
       ),
 
-     'grp_test_grp_dn' =>  array(
+     'grp_test_grp_dn' => array(
         'form' => array(
           'fieldset' => 'groups',
           '#type' => 'textfield',
@@ -1171,7 +1171,7 @@ public function drupalFormSubmit($op, $values) {
         ),
       ),
 
-     'grp_test_grp_dn_writeable' =>  array(
+     'grp_test_grp_dn_writeable' => array(
         'form' => array(
           'fieldset' => 'groups',
           '#type' => 'textfield',
@@ -1206,7 +1206,7 @@ public function drupalFormSubmit($op, $values) {
         ),
       ),
 
-     'search_page_size' =>  array(
+     'search_page_size' => array(
         'form' => array(
           'fieldset' => 'pagination',
           '#type' => 'textfield',
@@ -1232,7 +1232,7 @@ public function drupalFormSubmit($op, $values) {
         ),
       ),
 
-      'weight' =>  array(
+      'weight' => array(
         'schema' => array(
           'type' => 'int',
           'not null' => FALSE,
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.admin.css b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.admin.css
index 454a41df..0202022b 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.admin.css
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.admin.css
@@ -1,9 +1,12 @@
 
+
+/* Used in /admin/config/people/ldap/user. */
 table.ldap-provision-todrupal input.convert, table.ldap-provision-toldap input.convert {
   background-image: url('/themes/seven/images/list-item.png');
   background-repeat: no-repeat;
 }
 
+/* Used in admin/config/people/ldap/servers/edit/$sid. */
 div.ldap-pwd-abscent {
   background-image:url('/misc/message-16-error.png');
   background-repeat:no-repeat;
@@ -19,16 +22,22 @@ div.ldap-pwd-present  {
   padding-left: 20px;
   border: solid 1px #beb;
   }
-  
+
+/* Used in /admin/config/people/ldap/user. */
 table th.mixedcase, .mixedcase {
   text-transform: none;
 }
-  
+
+/* Unknown overrides in dblog. */
 form#dblog-filter-form div#edit-type-wrapper,
-table#admin-dblog th img
-{ display: none;}
-code.export-summary {font-weight: normal;}
+table#admin-dblog th img {
+  display: none;
+}
+code.export-summary {
+  font-weight: normal;
+}
 
 table#admin-dblog th a,
-table#admin-dblog th {text-decoration: none; color: #000000;}
-th code {}
+table#admin-dblog th {
+  text-decoration: none; color: #000000;
+}
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.admin.inc b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.admin.inc
index 8f5e397e..23ee1d8e 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.admin.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.admin.inc
@@ -23,7 +23,7 @@ function ldap_servers_edit_index() {
  */
 function ldap_servers_servers_list($sid = NULL, $actions = FALSE) {
 
-  $variables =  array(
+  $variables = array(
     'ldap_servers' => $ldap_server = ldap_servers_get_servers($sid, 'all'),
     'action' => TRUE,
     'type' => 'table',
@@ -168,7 +168,7 @@ function ldap_servers_admin_delete_submit($form, &$form_state) {
     if ($result = $ldap_server->delete($sid)) {
       $tokens = array('%name' => $ldap_server->name, '!sid' => $sid);
       drupal_set_message(t('LDAP Server %name (server id = !sid) has been deleted.', $tokens), 'status');
-      watchdog('ldap', 'LDAP Server deleted: %name (sid = !sid) ', $tokens);
+      watchdog('ldap_servers', 'LDAP Server deleted: %name (sid = !sid) ', $tokens);
     }
     else {
       drupal_set_message(t('LDAP Server delete failed.'), 'warning');
@@ -217,7 +217,7 @@ function ldap_servers_admin_enable_disable($form, &$form_state, $action = NULL,
     );
     return confirm_form(
       $form,
-      t('Are you sure you want to') . t($action) . ' ' . t('the LDAP server named <em><strong>%name</strong></em>?', array('%name' =>  $ldap_server->name)),
+      t('Are you sure you want to') . t($action) . ' ' . t('the LDAP server named <em><strong>%name</strong></em>?', array('%name' => $ldap_server->name)),
       LDAP_SERVERS_MENU_BASE_PATH . '/servers/list',
       t('<p></p>'),
       t($action),
@@ -244,7 +244,7 @@ function ldap_servers_admin_enable_disable_submit($form, &$form_state) {
     $tokens = array('%name' => $values['name'], '!sid' => $sid, '!action' => t($values['action']) . 'd');
     drupal_set_message(t('LDAP Server Configuration %name (server id = !sid) has been !action.', $tokens));
     $message = t('LDAP Server !action: %name (sid = !sid) ', $tokens);
-    watchdog('ldap', $message);
+    watchdog('ldap_servers', $message);
 
   }
 
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.api.php b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.api.php
index 9eba9120..51587090 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.api.php
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.api.php
@@ -5,7 +5,6 @@
  * Hooks provided by ldap_servers module
  */
 
-
 /**
  * Allows other modules to periodically affect an ldap associated user
  * or its corresponding ldap entry.
@@ -136,7 +135,7 @@ function hook_ldap_attributes_needed_alter(&$attributes, $params) {
           $attributes[$ldap_server->mail_attr] = ldap_servers_set_attribute_map(); // set default values for an attribute, force data_type
         }
 
-        ldap_servers_token_extract_attributes($attributes,  $ldap_server_obj->mail_template);
+        ldap_servers_token_extract_attributes($attributes, $ldap_server_obj->mail_template);
         $attributes[$ldap_server->unique_persistent_attr] = ldap_servers_set_attribute_map(@$attributes[$ldap_server->unique_persistent_attr]);
 
       break;
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.functions.inc b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.functions.inc
index 625fa738..041a178d 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.functions.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.functions.inc
@@ -255,9 +255,9 @@ function ldap_server_massage_text($value, $value_type, $context) {
        foreach ($values as $key => $val) {
             // Escaping of filter meta characters
             $val = str_replace('\\', '\5c', $val);
-            $val = str_replace('*',  '\2a', $val);
-            $val = str_replace('(',  '\28', $val);
-            $val = str_replace(')',  '\29', $val);
+            $val = str_replace('*', '\2a', $val);
+            $val = str_replace('(', '\28', $val);
+            $val = str_replace(')', '\29', $val);
 
             // ASCII < 32 escaping
             $val = ldap_pear_asc2hex32($val);
@@ -322,14 +322,14 @@ function ldap_server_massage_text($value, $value_type, $context) {
         foreach ($values as $key => $val) {
             // Escaping of filter meta characters
             $val = str_replace('\\', '\\\\', $val);
-            $val = str_replace(',',    '\,', $val);
-            $val = str_replace('+',    '\+', $val);
-            $val = str_replace('"',    '\"', $val);
-            $val = str_replace('<',    '\<', $val);
-            $val = str_replace('>',    '\>', $val);
-            $val = str_replace(';',    '\;', $val);
-            $val = str_replace('#',    '\#', $val);
-            $val = str_replace('=',    '\=', $val);
+            $val = str_replace(',', '\,', $val);
+            $val = str_replace('+', '\+', $val);
+            $val = str_replace('"', '\"', $val);
+            $val = str_replace('<', '\<', $val);
+            $val = str_replace('>', '\>', $val);
+            $val = str_replace(';', '\;', $val);
+            $val = str_replace('#', '\#', $val);
+            $val = str_replace('=', '\=', $val);
 
             // ASCII < 32 escaping
             $val = ldap_pear_asc2hex32($val);
@@ -375,14 +375,14 @@ function ldap_server_massage_text($value, $value_type, $context) {
         foreach ($values as $key => $val) {
             // strip slashes from special chars
             $val = str_replace('\\\\', '\\', $val);
-            $val = str_replace('\,',    ',', $val);
-            $val = str_replace('\+',    '+', $val);
-            $val = str_replace('\"',    '"', $val);
-            $val = str_replace('\<',    '<', $val);
-            $val = str_replace('\>',    '>', $val);
-            $val = str_replace('\;',    ';', $val);
-            $val = str_replace('\#',    '#', $val);
-            $val = str_replace('\=',    '=', $val);
+            $val = str_replace('\,', ',', $val);
+            $val = str_replace('\+', '+', $val);
+            $val = str_replace('\"', '"', $val);
+            $val = str_replace('\<', '<', $val);
+            $val = str_replace('\>', '>', $val);
+            $val = str_replace('\;', ';', $val);
+            $val = str_replace('\#', '#', $val);
+            $val = str_replace('\=', '=', $val);
 
             // Translate hex code into ascii
             $values[$key] = ldap_pear_hex2asc($val);
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.info b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.info
index 33428463..343fddda 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.info
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.info
@@ -3,6 +3,7 @@ description = Implements LDAP Server Configuration
 package = Lightweight Directory Access Protocol
 dependencies[] = ctools
 core = 7.x
+php = 5.4
 
 files[] = LdapServer.class.php
 files[] = LdapServerAdmin.class.php
@@ -17,9 +18,8 @@ files[] = ldap_servers.theme.inc
 files[] = tests/ldap_servers.test
 configure = admin/config/people/ldap/servers
 
-; Information added by Drupal.org packaging script on 2017-08-27
-version = "7.x-2.3"
+; Information added by Drupal.org packaging script on 2018-08-13
+version = "7.x-2.4"
 core = "7.x"
 project = "ldap"
-datestamp = "1503841448"
-
+datestamp = "1534201086"
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.install b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.install
index a6a9423f..94b4a958 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.install
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.install
@@ -5,7 +5,6 @@
  * Install, update and uninstall functions for the LDAP API module.
  */
 
-
 /**
  * Implements hook_install().
  */
@@ -61,7 +60,7 @@ function ldap_servers_requirements($phase) {
   if ($phase == 'runtime') {
     $requirements['ldap_servers_enabled'] = array(
       'title' => $t('LDAP Server status'),
-      'value' =>  $t('Disabled'),
+      'value' => $t('Disabled'),
       'severity' => REQUIREMENT_WARNING,
     );
 
@@ -77,7 +76,7 @@ function ldap_servers_requirements($phase) {
         );
         $requirements[$server_req_key] = array(
           'title' => $t('LDAP Server status: @sid (@host)', $server_tokens),
-          'value' =>  $t('Connection: Failed, check logs for details.', $server_tokens),
+          'value' => $t('Connection: Failed, check logs for details.', $server_tokens),
           'severity' => REQUIREMENT_ERROR,
         );
 
@@ -229,7 +228,7 @@ function ldap_servers_update_7102() {
     $msg = t('"bind_method" field added to ldap_servers table');
   }
 
-  return ($msg) ? $msg :  t('No database changes made.');
+  return ($msg) ? $msg : t('No database changes made.');
 }
 
 /**
@@ -246,7 +245,7 @@ function ldap_servers_update_7103() {
     $msg = t('"group_object_category" field added to ldap_servers table');
   }
 
-  return ($msg) ? $msg :  t('No database changes made.');
+  return ($msg) ? $msg : t('No database changes made.');
 }
 
 
@@ -287,7 +286,7 @@ function ldap_servers_update_7104() {
 
 
 
-  return ($msg) ? $msg :  t('No database changes made.');
+  return ($msg) ? $msg : t('No database changes made.');
 }
 
 /**
@@ -300,7 +299,7 @@ function ldap_servers_update_7105() {
     $msg = t('LDAP User module enabled.  Some authentication and authorization functionality shifted to LDAP User module.');
   }
 
-  return ($msg) ? $msg :  t('LDAP User module was already enabled.  No action taken.');
+  return ($msg) ? $msg : t('LDAP User module was already enabled.  No action taken.');
 }
 
 
@@ -320,7 +319,7 @@ function ldap_servers_update_7106() {
     $msg = t('"account_name_attr" field added to ldap_servers table');
   }
 
-  return ($msg) ? $msg :  t('No database changes made.');
+  return ($msg) ? $msg : t('No database changes made.');
 }
 
 /**
@@ -331,7 +330,7 @@ function ldap_servers_update_7107() {
     db_drop_field('ldap_servers', 'allow_conflicting_drupal_accts');
     $msg = t('"allow_conflicting_drupal_accts" field removed from ldap_servers table');
   }
-  return ($msg) ? $msg :  t('No database changes made.');
+  return ($msg) ? $msg : t('No database changes made.');
 }
 
 
@@ -896,4 +895,4 @@ function ldap_servers_install_update_schema($schema, &$change_log) {
       }
     }
   }
-}
\ No newline at end of file
+}
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.module b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.module
index 6317762a..71e925e0 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.module
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.module
@@ -1,5 +1,9 @@
 <?php
 
+/**
+ * @file
+ */
+
 define('LDAP_SERVER_LDAP_QUERY_CHUNK', 50);
 define('LDAP_SERVERS_MAXFILTER_ORS', 30);
 define('LDAP_SERVER_LDAP_QUERY_RECURSION_LIMIT', 10);
@@ -139,14 +143,16 @@ define('LDAP_MORE_RESULTS_TO_RETURN', 0x5f);
 define('LDAP_CLIENT_LOOP', 0x60);
 define('LDAP_REFERRAL_LIMIT_EXCEEDED', 0x61);
 
-require_once('ldap_servers.functions.inc');
-require_once('ldap_servers.tokens.inc');
+module_load_include('inc', 'ldap_servers', 'ldap_servers.functions');
+module_load_include('inc', 'ldap_servers', 'ldap_servers.tokens');
 
 /**
  * Implements hook_init().
  */
 function ldap_servers_init() {
-  drupal_add_css(drupal_get_path('module', 'ldap_servers') . '/ldap_servers.admin.css', 'module');
+  if (strpos(current_path(), 'admin/config/people/ldap') === 0) {
+    drupal_add_css(drupal_get_path('module', 'ldap_servers') . '/ldap_servers.admin.css', 'module');
+  }
 }
 
 /**
@@ -378,7 +384,7 @@ function ldap_servers_ldap_user_attrs_list_alter(&$available_user_attrs, &$param
         }
       }
 
-      $available_user_attrs['[field.ldap_user_puid_sid]'] =  array(
+      $available_user_attrs['[field.ldap_user_puid_sid]'] = array(
         'name' => t('Field: sid providing PUID'),
         'configurable_to_drupal' => 0,
         'configurable_to_ldap' => 1,
@@ -391,7 +397,7 @@ function ldap_servers_ldap_user_attrs_list_alter(&$available_user_attrs, &$param
         'prov_module' => 'ldap_user',
       ) + $available_user_attrs['[field.ldap_user_puid_sid]'];
 
-      $available_user_attrs['[field.ldap_user_puid]'] =  array(
+      $available_user_attrs['[field.ldap_user_puid]'] = array(
         'name' => t('Field: PUID', $tokens),
         'configurable_to_drupal' => 0,
         'configurable_to_ldap' => 1,
@@ -410,7 +416,7 @@ function ldap_servers_ldap_user_attrs_list_alter(&$available_user_attrs, &$param
         'name' => t('Field: PUID Attribute', $tokens),
         'configurable_to_drupal' => 0,
         'configurable_to_ldap' => 1,
-        'source' =>  $ldap_server->unique_persistent_attr ,
+        'source' => $ldap_server->unique_persistent_attr ,
         'notes' => 'configure at ' . $server_edit_path,
         'direction' => LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER,
         'enabled' => TRUE,
@@ -455,7 +461,7 @@ function ldap_servers_ldap_user_attrs_list_alter(&$available_user_attrs, &$param
       if (!isset($available_user_attrs['[property.mail]']) || !is_array($available_user_attrs['[property.mail]'])) {
         $available_user_attrs['[property.mail]'] = array();
       }
-      $available_user_attrs['[property.mail]'] =  array(
+      $available_user_attrs['[property.mail]'] = array(
         'name' => 'Property: Email',
         'source' => ($ldap_server->mail_template) ? $ldap_server->mail_template : '[' . $ldap_server->mail_attr . ']',
         'direction' => LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER,
@@ -899,31 +905,31 @@ function ldap_servers_ldap_servers_types() {
 
   $path = drupal_get_path('module', 'ldap_servers') . '/ldap_types';
 
-  $types['default'] =  array(
+  $types['default'] = array(
     'class' => t('LdapTypeDefault'),
     'directory_path' => $path,
     'name' => 'Default LDAP',
   );
 
-  $types['ad'] =  array(
+  $types['ad'] = array(
     'class' => t('LdapTypeActiveDirectory'),
     'directory_path' => $path,
     'name' => 'Active Directory',
   );
 
-  $types['novell_edir'] =  array(
+  $types['novell_edir'] = array(
     'class' => t('LdapTypeNovell'),
     'directory_path' => $path,
     'name' => 'Novell',
   );
 
-  $types['openldap'] =  array(
+  $types['openldap'] = array(
     'class' => t('LdapTypeOpenLdap'),
     'directory_path' => $path,
     'name' => 'Open LDAP',
   );
 
-  $types['opendir'] =  array(
+  $types['opendir'] = array(
     'class' => t('LdapTypeOpenDirectory'),
     'directory_path' => $path,
     'name' => 'Apple Open Directory',
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.settings.inc b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.settings.inc
index 2bf9d4a6..3e76ebdd 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.settings.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.settings.inc
@@ -22,7 +22,7 @@ function ldap_servers_settings() {
     *   ... thus default needs to be "No Encryption" to avoid confusion.
     */
 
-  $form['previous_encryption'] = array('#type' => 'hidden',  '#default_value' => variable_get('ldap_servers_encryption', LDAP_SERVERS_ENC_TYPE_CLEARTEXT));
+  $form['previous_encryption'] = array('#type' => 'hidden', '#default_value' => variable_get('ldap_servers_encryption', LDAP_SERVERS_ENC_TYPE_CLEARTEXT));
   $form['encryption'] = array('#type' => 'fieldset', '#title' => t('Encryption'));
   $form['encryption']['ldap_servers_encryption'] = array(
     '#type' => 'select',
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.test_form.inc b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.test_form.inc
index a8756333..29a0b0dc 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.test_form.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.test_form.inc
@@ -1,5 +1,9 @@
 <?php
 
+/**
+ * @file
+ */
+
 module_load_include('inc', 'ldap_servers', 'ldap_servers.functions');
 
 /**
@@ -87,7 +91,7 @@ function ldap_servers_test_form($form, &$form_state, $op = NULL, $sid = NULL) {
     '#description' => t('This is optional and used for testing this server\'s group configuration.'),
   );
 
-  if ($ldap_server->bind_method ==  LDAP_SERVERS_BIND_METHOD_ANON_USER) {
+  if ($ldap_server->bind_method == LDAP_SERVERS_BIND_METHOD_ANON_USER) {
     $form['testing_drupal_userpw'] = array(
       '#type' => 'password',
       '#title' => t('Testing Drupal User Password'),
@@ -136,14 +140,26 @@ function ldap_servers_test_form($form, &$form_state, $op = NULL, $sid = NULL) {
           dpm("Drupal user entity for: $user_name");
           dpm($user_entity);
         }
-       dpm("Test Group LDAP Entry");
-       dpm($test_data['group_entry'][0]);
+        if (isset($test_data['group_entry'][0])) {
+          dpm("Test Group LDAP Entry");
+          dpm($test_data['group_entry'][0]);
+        }
       }
     }
   }
   return $form;
 }
 
+function ldap_servers_string_binary_check($input) {
+  if (preg_match('~[^\x20-\x7E\t\r\n]~', $input) > 0) {
+    $truncatedString = truncate_utf8($input, 200);
+    return t('Binary (excerpt): @excerpt', ['@excerpt' => $truncatedString]);
+  }
+  else {
+    return $input;
+  }
+}
+
 /**
  * Validate hook for the LDAP server form.
  */
@@ -186,7 +202,7 @@ function ldap_servers_test_form_submit($form, &$form_state) {
 
   if ($ldap_server->bind_method == LDAP_SERVERS_BIND_METHOD_SERVICE_ACCT) {
     $results_tables['basic'][] = array(t('Binding with DN for non-anonymous search (%bind_dn).  Using password ',
-      array('%bind_dn' =>  $ldap_server->binddn)) . ' ' . $bindpw_type);
+      array('%bind_dn' => $ldap_server->binddn)) . ' ' . $bindpw_type);
   }
   else {
     $results_tables['basic'][] = array(t('Binding with null DN for anonymous search.'));
@@ -215,13 +231,13 @@ function ldap_servers_test_form_submit($form, &$form_state) {
 
     // 3. add group
     $result = $ldap_server->groupAddGroup($group_create_test_dn, $group_create_test_attr);
-    $result = ($result)  ? "PASS" : 'FAIL';
+    $result = ($result) ? "PASS" : 'FAIL';
     $attr = serialize($group_create_test_attr);
     $results_tables['group1'][] = array("LdapServer::groupAddGroup($group_create_test_dn, $attr)", $result);
 
     // 4. call to all members in an empty group returns emtpy array, not FALSE
     $result = $ldap_server->groupAllMembers($group_create_test_dn);
-    $result = (is_array($result) && count($result) == 0)  ? 'PASS' : 'FAIL';
+    $result = (is_array($result) && count($result) == 0) ? 'PASS' : 'FAIL';
     $results_tables['group1'][] = array("LdapServer::groupAllMembers($group_create_test_dn) returns empty array for empty group ", $result);
 
     // 5. add member to group
@@ -243,7 +259,7 @@ function ldap_servers_test_form_submit($form, &$form_state) {
 
     $only_if_group_empty = TRUE;
     $result = $ldap_server->groupRemoveGroup($group_create_test_dn, $only_if_group_empty);
-    $result = ($ldap_server->dnExists($group_create_test_dn, 'ldap_entry', array('cn', 'member'))) ?  "FAIL" : 'PASS';
+    $result = ($ldap_server->dnExists($group_create_test_dn, 'ldap_entry', array('cn', 'member'))) ? "FAIL" : 'PASS';
     $results_tables['group1'][] = array("LdapServer::groupRemoveGroup($group_create_test_dn, $only_if_group_empty)", $result);
   }
 
@@ -260,10 +276,10 @@ function ldap_servers_test_form_submit($form, &$form_state) {
           $mapping[] = "$key = " . $value[0];
         }
       }
-      $results_tables['basic'][] =  array(theme_item_list(array('items' => $mapping, 'title' => t('Attributes available to anonymous search', array('%bind_dn' =>  $ldap_server->binddn)) , 'type' => 'ul', 'attributes' => array())));
+      $results_tables['basic'][] = array(theme_item_list(array('items' => $mapping, 'title' => t('Attributes available to anonymous search', array('%bind_dn' => $ldap_server->binddn)) , 'type' => 'ul', 'attributes' => array())));
     }
     $results_tables['basic'][] = array(t('Binding with DN (%bind_dn).  Using supplied password ',
-      array('%bind_dn' =>  $ldap_user['dn'])));
+      array('%bind_dn' => $ldap_user['dn'])));
     $result = $ldap_server->bind($ldap_user['dn'], $values['testing_drupal_userpw'], FALSE);
     if ($result == LDAP_SUCCESS) {
       $results_tables['basic'][] = array(t('Successfully bound to server'), 'PASS');
@@ -295,7 +311,7 @@ function ldap_servers_test_form_submit($form, &$form_state) {
 
         if ($ldap_server->groupUserMembershipsConfigured) {
           $groupusermembershipsfromuserattr = $ldap_server->groupUserMembershipsFromUserAttr($user, $nested);
-          $count =  count($groupusermembershipsfromuserattr);
+          $count = count($groupusermembershipsfromuserattr);
           $result = theme('item_list', array('items' => $groupusermembershipsfromuserattr, 'type' => 'ul'));
         }
         else {
@@ -338,7 +354,7 @@ function ldap_servers_test_form_submit($form, &$form_state) {
 
   $tokens = ($ldap_user && isset($ldap_user['attr'])) ? ldap_servers_token_tokenize_entry($ldap_user['attr'], 'all') : array();
   foreach ($tokens as $key => $value) {
-    $results_tables['tokens'][] = array($key, $value);
+    $results_tables['tokens'][] = array($key, ldap_servers_string_binary_check($value));
   }
   $form_state['ldap_server_test_data'] = array(
     'username' => $values['testing_drupal_username'],
@@ -352,7 +368,7 @@ function ldap_servers_test_form_submit($form, &$form_state) {
   if (isset($group_entry) ) {
     $form_state['ldap_server_test_data']['group_entry'] = $group_entry;
   }
-  
+
 }
 
 /**
@@ -375,7 +391,7 @@ function ldap_servers_test_binding_credentials(&$ldap_server, $bindpw, &$results
   if (!$errors) {
     $bind_result = $ldap_server->bind($ldap_server->binddn, $bindpw, FALSE);
     if ($bind_result == LDAP_SUCCESS) {
-      $results_tables['basic'][] =  array(t('Successfully bound to server'));
+      $results_tables['basic'][] = array(t('Successfully bound to server'));
     }
     else {
       $results_tables['basic'][] = array(t('Failed to bind to server. ldap error #') . $bind_result . ' ' . $ldap_server->errorMsg('ldap')) ;
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.theme.inc b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.theme.inc
index d665c7b0..28eb34dc 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.theme.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.theme.inc
@@ -34,7 +34,7 @@ function theme_ldap_servers_list($variables) {
   }
   if (count($ldap_servers)) {
     foreach ($ldap_servers as $sid => $ldap_server ) {
-      $row =  array(
+      $row = array(
         $ldap_server->name,
         $ldap_server->ldap_type,
         ($ldap_server->status == 1) ? "Yes" : "No",
@@ -140,7 +140,7 @@ function theme_ldap_server_ldap_entry_table($variables) {
         else {
           $token = "";
         }
-        $rows[] = array('data' => array($key, $i, $value2, $token));
+        $rows[] = array('data' => array($key, $i, ldap_servers_string_binary_check($value2), $token));
       }
     }
   }
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.tokens.inc b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.tokens.inc
index 53367bd7..38a09079 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.tokens.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.tokens.inc
@@ -96,7 +96,7 @@ function ldap_servers_token_replace($resource, $text, $resource_type = 'ldap_ent
  *
  * by reference return add ldap attribute triplet $attribute_maps[<attr_name>] = (<attr_name>, <ordinal>, <data_type>) to $attributes
  */
-function ldap_servers_token_extract_attributes(&$attribute_maps,  $text) {
+function ldap_servers_token_extract_attributes(&$attribute_maps, $text) {
   $tokens = ldap_servers_token_tokens_needed_for_template($text);
   foreach ($tokens as $token) {
     $token = str_replace(array(LDAP_SERVERS_TOKEN_PRE, LDAP_SERVERS_TOKEN_POST), array('', ''), $token);
@@ -164,15 +164,21 @@ should return tokens such as:
     [cn] = jdoe
     [cn:0] = jdoe
     [cn:last] => jdoe
+    [cn:reverse:0] = jdoe
     [ou] = campus accounts
     [ou:0] = campus accounts
     [ou:1] = toledo campus
     [ou:last] = toledo campus
+    [ou:reverse:0] = toledo campus
+    [ou:reverse:1] = campus accounts
     [dc] = ad
     [dc:0] = ad
     [dc:1] = myuniversity
     [dc:2] = edu
     [dc:last] = edu
+    [dc:reverse:0] = edu
+    [dc:reverse:1] = myuniversity
+    [dc:reverse:2] = ad
 
     -- from other attributes
     [mail] = jdoe@myuniversity.edu
@@ -237,6 +243,15 @@ function ldap_servers_token_tokenize_entry($ldap_entry, $token_keys = 'all', $pr
     $parts_count[$attr_name]++;
   }
 
+  // Add the parts in reverse order to reflect the hierarchy.
+  foreach ($parts_count as $part => $count) {
+    $part = strtolower($part);
+    for ($i = 0; $i < $count; $i++) {
+      $reverse_position = $count - $i - 1;
+      $tokens[$pre . $part . LDAP_SERVERS_TOKEN_DEL . 'reverse' . LDAP_SERVERS_TOKEN_DEL . $reverse_position . $post] = $tokens[$pre . $part . LDAP_SERVERS_TOKEN_DEL . $i . $post];
+    }
+  }
+
   foreach ($parts_count as $attr_name => $count) {
     $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . LDAP_SERVERS_TOKEN_DEL . 'last' . $post] = $parts_last_value[$attr_name];
   }
@@ -253,8 +268,8 @@ function ldap_servers_token_tokenize_entry($ldap_entry, $token_keys = 'all', $pr
         $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . LDAP_SERVERS_TOKEN_DEL . 'last' . $post] = check_plain($attr_value[0]);
       }
       elseif (is_array($attr_value) && $attr_value['count'] > 1) {
-        $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . LDAP_SERVERS_TOKEN_DEL . 'last' . $post] = check_plain($attr_value[$attr_value['count']-1]);
-        for ($i=0; $i<$attr_value['count']; $i++) {
+        $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . LDAP_SERVERS_TOKEN_DEL . 'last' . $post] = check_plain($attr_value[$attr_value['count'] - 1]);
+        for ($i = 0; $i < $attr_value['count']; $i++) {
           $tokens[$pre . ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_TOKEN_REPLACE) . LDAP_SERVERS_TOKEN_DEL . $i . $post] = check_plain($attr_value[$i]);
         }
       }
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.user_data_remove.inc b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.user_data_remove.inc
index b61a2371..b30c172c 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.user_data_remove.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.user_data_remove.inc
@@ -5,7 +5,6 @@
 * collection of functions related to removing user data
 */
 
-
 function ldap_severs_user_data_setup_batch($consumer_type = NULL) {
 
   $max_uid = db_query("SELECT max(uid) FROM {users}")->fetchField();
@@ -58,7 +57,7 @@ function ldap_servers_empty_user_data($start, $step, $consumer_type, &$context)
 
 function ldap_authorization_generate_users() {
   $response = "";
-  for ($i=1; $i<1000; $i++) {
+  for ($i = 1; $i < 1000; $i++) {
     $name = "user" . $i;
     if ($account = user_load_by_name($name)) {
       user_delete($account->uid);
@@ -75,4 +74,4 @@ function ldap_authorization_generate_users() {
   }
   return $response;
   
-}
\ No newline at end of file
+}
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_types/LdapTypeNovell.class.php b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_types/LdapTypeNovell.class.php
index 1e5d8248..899780cc 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_types/LdapTypeNovell.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_types/LdapTypeNovell.class.php
@@ -6,7 +6,6 @@
  *
  */
 
-
 ldap_servers_module_load_include('php', 'ldap_servers', 'ldap_types/LdapTypeAbstract.class');
 
 class LdapTypeNovell extends LdapTypeAbstract {
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/tests/ldap_servers.test b/drupal7/sites/all/modules/ldap/ldap_servers/tests/ldap_servers.test
index 37c7cc5b..7abc5820 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/tests/ldap_servers.test
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/tests/ldap_servers.test
@@ -5,7 +5,6 @@
  * simpletest for ldap servers
  */
 
-
 if (function_exists('ldap_servers_module_load_include')) {
   ldap_servers_module_load_include('php', 'ldap_test', 'LdapTestCase.class');
 }
@@ -98,7 +97,7 @@ class LdapServersTestCase extends LdapTestCase {
 
         // test parent function groupMembershipsFromUser
         $groups = $ldap_server->groupMembershipsFromUser($ldap_module_user_entry, 'group_dns', $nested);
-        $count =  count($groups);
+        $count = count($groups);
         $diff1 = array_diff($groups_desired, $groups);
         $diff2 = array_diff($groups, $groups_desired);
         $pass = (count($diff1) == 0 && count($diff2) == 0 && $count == $desired_count);
@@ -181,7 +180,7 @@ class LdapServersTestCase extends LdapTestCase {
     $this->assertTrue( $house0 == $ldap_entry['house'][0], t("[house:0] token worked ($house0) on ldap_servers_token_replace()."), $this->ldapTestId);
 
     $mixed = ldap_servers_token_replace($ldap_entry, 'thisold[house:0]');
-    $this->assertTrue( $mixed  == 'thisold' . $ldap_entry['house'][0], t("thisold[house:0] token worked ($mixed) on ldap_servers_token_replace()."), $this->ldapTestId);
+    $this->assertTrue( $mixed == 'thisold' . $ldap_entry['house'][0], t("thisold[house:0] token worked ($mixed) on ldap_servers_token_replace()."), $this->ldapTestId);
 
     $compound = ldap_servers_token_replace($ldap_entry, '[samaccountname:0][house:0]');
     $this->assertTrue( $compound == $ldap_entry['sAMAccountName'][0] . $ldap_entry['house'][0], t("[samaccountname:0][house:0] compound token worked ($mixed) on ldap_servers_token_replace()."), $this->ldapTestId);
@@ -317,8 +316,8 @@ class LdapServersTestCase extends LdapTestCase {
       $field_to_prop_map = LdapServer::field_to_properties_map();
       $field_to_prop_map['bindpw'] = 'bindpw';
       $ldap_servers = ldap_servers_get_servers(NULL, 'all', FALSE, TRUE);
-      $this->assertTrue(count(array_keys($ldap_servers)) == 1, 'Add form for ldap server added server.',  $this->ldapTestId . ' Add Server');
-      $this->assertText('LDAP Server Server server1 added', 'Add form confirmation message',  $this->ldapTestId . ' Add Server');
+      $this->assertTrue(count(array_keys($ldap_servers)) == 1, 'Add form for ldap server added server.', $this->ldapTestId . ' Add Server');
+      $this->assertText('LDAP Server Server server1 added', 'Add form confirmation message', $this->ldapTestId . ' Add Server');
       // assert one ldap server exists in db table
 
       // assert load of server has correct properties for each input
@@ -329,7 +328,7 @@ class LdapServersTestCase extends LdapTestCase {
         debug($ldap_servers);
         debug($server_data['server1']);
       }
-      $this->assertTrue(count($mismatches) == 0, 'Add form for ldap server properties match values submitted.',  $this->ldapTestId . ' Add Server');
+      $this->assertTrue(count($mismatches) == 0, 'Add form for ldap server properties match values submitted.', $this->ldapTestId . ' Add Server');
 
 
       /** update server conf test **/
@@ -346,7 +345,7 @@ class LdapServersTestCase extends LdapTestCase {
       unset($edit['sid']);
       $this->drupalPost('admin/config/people/ldap/servers/edit/server1', $edit, t('Update'));
       $ldap_servers = ldap_servers_get_servers(NULL, 'all', FALSE, TRUE);
-      $this->assertTrue(count(array_keys($ldap_servers)) == 1, 'Update form for ldap server didnt delete or add another server.',  $this->ldapTestId . '.Update Server');
+      $this->assertTrue(count(array_keys($ldap_servers)) == 1, 'Update form for ldap server didnt delete or add another server.', $this->ldapTestId . '.Update Server');
       // assert confirmation message without error
       // assert one ldap server exists in db table
       // assert load of server has correct properties for each input
@@ -355,7 +354,7 @@ class LdapServersTestCase extends LdapTestCase {
       if (count($mismatches)) {
         debug('mismatches between ldap server properties and form submitted values'); debug($mismatches);
       }
-      $this->assertTrue(count($mismatches) == 0, 'Update form for ldap server properties match values submitted.',  $this->ldapTestId . '.Update Server');
+      $this->assertTrue(count($mismatches) == 0, 'Update form for ldap server properties match values submitted.', $this->ldapTestId . '.Update Server');
 
       /** delete server conf test **/
       $this->drupalGet('admin/config/people/ldap/servers/delete/server1');
@@ -363,7 +362,7 @@ class LdapServersTestCase extends LdapTestCase {
 
       $ldap_servers = ldap_servers_get_servers(NULL, 'all', FALSE, TRUE);
 
-      $this->assertTrue(count(array_keys($ldap_servers)) == 0, 'Delete form for ldap server deleted server.',  $this->ldapTestId . '.Delete Server');
+      $this->assertTrue(count(array_keys($ldap_servers)) == 0, 'Delete form for ldap server deleted server.', $this->ldapTestId . '.Delete Server');
 
       variable_set('ldap_simpletest', $ldap_simpletest_initial); // return to fake server mode
     }
diff --git a/drupal7/sites/all/modules/ldap/ldap_test/LdapServerTest.class.php b/drupal7/sites/all/modules/ldap/ldap_test/LdapServerTest.class.php
index a60ce8eb..f7ffb3ae 100644
--- a/drupal7/sites/all/modules/ldap/ldap_test/LdapServerTest.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_test/LdapServerTest.class.php
@@ -109,7 +109,7 @@ class LdapServerTest extends LdapServer {
     }
 
     $watchdog_tokens = array('%user' => $userdn, '%errno' => $ldap_errno, '%error' => $ldap_error);
-    watchdog('ldap', "LDAP bind failure for user %user. Error %errno: %error", $watchdog_tokens);
+    watchdog('ldap_servers', "LDAP bind failure for user %user. Error %errno: %error", $watchdog_tokens);
     return $ldap_errno;
 
   }
@@ -238,7 +238,7 @@ class LdapServerTest extends LdapServer {
           // cn=jdoe,ou=campus accounts,dc=ad,dc=myuniversity,dc=edu
           //$pos = strpos($dn_lcase, $base_dn);
           $substring = strrev(substr(strrev($dn_lcase), 0, strlen($base_dn)));
-          $cascmp =  strcasecmp($base_dn, $substring);
+          $cascmp = strcasecmp($base_dn, $substring);
           if ($cascmp !== 0) {
 
             continue; // not in basedn
@@ -279,7 +279,7 @@ class LdapServerTest extends LdapServer {
           $filter_value = $subquery[1];
 
           $substring = strrev(substr(strrev($dn_lcase), 0, strlen($base_dn)));
-          $cascmp =  strcasecmp($base_dn, $substring);
+          $cascmp = strcasecmp($base_dn, $substring);
           if ($cascmp !== 0) {
             $match = FALSE;
             break; // not in basedn
diff --git a/drupal7/sites/all/modules/ldap/ldap_test/LdapTestFunctions.class.php b/drupal7/sites/all/modules/ldap/ldap_test/LdapTestFunctions.class.php
index 5eb5b415..41c987bb 100644
--- a/drupal7/sites/all/modules/ldap/ldap_test/LdapTestFunctions.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_test/LdapTestFunctions.class.php
@@ -183,7 +183,7 @@ public function removeRoleFromUser($user, $role_name) {
 
     if ($clones) {
       $clonable_user = $this->csvTables['users'][101];
-      for ($i=0; $i < $clones; $i++) {
+      for ($i = 0; $i < $clones; $i++) {
         $user = $clonable_user;
         $cn = "clone" . $i;
         $dn = 'cn=' . $cn . ',' . $this->csvTables['conf'][$test_ldap_id]['userbasedn'];
@@ -254,8 +254,8 @@ public function removeRoleFromUser($user, $role_name) {
     if ($server_properties['groupUserMembershipsAttrExists']) {
       $member_attr = $server_properties['groupUserMembershipsAttr'];
       foreach ($this->csvTables['memberships'] as $gid => $membership) {
-        $group_dn =  $this->data['ldap_servers_by_guid'][$sid][$membership['group_guid']]['dn'];
-        $user_dn =  $this->data['ldap_servers_by_guid'][$sid][$membership['member_guid']]['dn'];
+        $group_dn = $this->data['ldap_servers_by_guid'][$sid][$membership['group_guid']]['dn'];
+        $user_dn = $this->data['ldap_servers_by_guid'][$sid][$membership['member_guid']]['dn'];
         $this->ldapData['ldap_servers'][$sid][$user_dn][$member_attr][] = $group_dn;
         if (isset($this->ldapData['ldap_servers'][$sid][$user_dn][$member_attr]['count'])) {
           unset($this->ldapData['ldap_servers'][$sid][$user_dn][$member_attr]['count']);
@@ -265,8 +265,8 @@ public function removeRoleFromUser($user, $role_name) {
       }
     }
 
-    $this->data['ldap_servers'][$sid]['ldap'] =  $this->ldapData['ldap_servers'][$sid];
-    $this->data['ldap_servers'][$sid]['csv'] =  $this->csvTables;
+    $this->data['ldap_servers'][$sid]['ldap'] = $this->ldapData['ldap_servers'][$sid];
+    $this->data['ldap_servers'][$sid]['csv'] = $this->csvTables;
     variable_set('ldap_test_server__' . $sid, $this->data['ldap_servers'][$sid]);
     $current_sids = variable_get('ldap_test_servers', array());
     $current_sids[] = $sid;
@@ -338,8 +338,8 @@ public function removeRoleFromUser($user, $role_name) {
   public function addLDAPUserToLDAPArraysFromAttributes($user, $sid, $dn, $attributes, $ldap_type, $user_attr) {
 
     if ($ldap_type == 'activedirectory') {
-      $attributes[$user_attr] =  array(0 => $user['cn'], 'count' => 1);
-      $attributes['distinguishedname'] =  array( 0 => $dn, 'count' => 1);
+      $attributes[$user_attr] = array(0 => $user['cn'], 'count' => 1);
+      $attributes['distinguishedname'] = array( 0 => $dn, 'count' => 1);
     }
     elseif ($ldap_type == 'openldap') {
 
diff --git a/drupal7/sites/all/modules/ldap/ldap_test/ldap_authentication.conf.inc b/drupal7/sites/all/modules/ldap/ldap_test/ldap_authentication.conf.inc
index fc35b7f4..bc6f383e 100644
--- a/drupal7/sites/all/modules/ldap/ldap_test/ldap_authentication.conf.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_test/ldap_authentication.conf.inc
@@ -16,11 +16,11 @@ function ldap_test_ldap_authentication_data() {
       'loginUIPasswordTxt' => 'Hogwards LDAP Password',
       'ldapUserHelpLinkUrl' => 'https://passwords.hogwarts.edu/',
       'ldapUserHelpLinkText' => 'Hogwarts IT Password Support Page',
-      'allowOnlyIfTextInDn' =>  NULL,
-      'excludeIfTextInDn' =>  NULL,
-      'allowTestPhp' =>  NULL,
-      'excludeIfNoAuthorizations' =>  LDAP_AUTHENTICATION_EXCL_IF_NO_AUTHZ_DEFAULT,
-      'ssoEnabled' =>  FALSE,
+      'allowOnlyIfTextInDn' => NULL,
+      'excludeIfTextInDn' => NULL,
+      'allowTestPhp' => NULL,
+      'excludeIfNoAuthorizations' => LDAP_AUTHENTICATION_EXCL_IF_NO_AUTHZ_DEFAULT,
+      'ssoEnabled' => FALSE,
     );
 
   $conf['MixedModeUserLogon'] = $conf['default'];
diff --git a/drupal7/sites/all/modules/ldap/ldap_test/ldap_authorization.conf.inc b/drupal7/sites/all/modules/ldap/ldap_test/ldap_authorization.conf.inc
index b6549488..66767e0c 100644
--- a/drupal7/sites/all/modules/ldap/ldap_test/ldap_authorization.conf.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_test/ldap_authorization.conf.inc
@@ -39,7 +39,7 @@ $conf['og_group2']['og_group'] = array(
     array(
       'from' => 'cn=faculty,ou=groups,dc=hogwarts,dc=edu',
       'user_entered' => 'faculty',
-      'normalized' =>  'node:faculty:' . $OG_AUTHENTICATED_ROLE,
+      'normalized' => 'node:faculty:' . $OG_AUTHENTICATED_ROLE,
       'simplified' => '',
       'valid' => '',
       'error_message' => '',
diff --git a/drupal7/sites/all/modules/ldap/ldap_test/ldap_test.info b/drupal7/sites/all/modules/ldap/ldap_test/ldap_test.info
index 68a61487..31a747e3 100644
--- a/drupal7/sites/all/modules/ldap/ldap_test/ldap_test.info
+++ b/drupal7/sites/all/modules/ldap/ldap_test/ldap_test.info
@@ -18,9 +18,8 @@ files[] = LdapServerTest.class.php
 files[] = LdapTestFunctions.class.php
 files[] = LdapUserTestCase.class.php
 
-; Information added by Drupal.org packaging script on 2017-08-27
-version = "7.x-2.3"
+; Information added by Drupal.org packaging script on 2018-08-13
+version = "7.x-2.4"
 core = "7.x"
 project = "ldap"
-datestamp = "1503841448"
-
+datestamp = "1534201086"
diff --git a/drupal7/sites/all/modules/ldap/ldap_test/ldap_test.module b/drupal7/sites/all/modules/ldap/ldap_test/ldap_test.module
index b1a3efb3..4565ab11 100644
--- a/drupal7/sites/all/modules/ldap/ldap_test/ldap_test.module
+++ b/drupal7/sites/all/modules/ldap/ldap_test/ldap_test.module
@@ -9,4 +9,3 @@
 define('LDAP_TEST_USER_ORPHAN_CLONE_COUNT', 7);  // number of cloned drupal users (clone0, clone1, etc) to make for tests
 define('LDAP_TEST_USER_ORPHAN_CLONE_REMOVE_COUNT', 2); // number of cloned drupal users to delete in orphan check
 define('LDAP_TEST_LDAP_NAME', 'hogwarts');
-
diff --git a/drupal7/sites/all/modules/ldap/ldap_test/ldap_user.conf.inc b/drupal7/sites/all/modules/ldap/ldap_test/ldap_user.conf.inc
index 2b2b7359..c2f09885 100644
--- a/drupal7/sites/all/modules/ldap/ldap_test/ldap_user.conf.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_test/ldap_user.conf.inc
@@ -186,7 +186,7 @@ $conf['ad_authentication'] = array(
             'prov_events' => array(LDAP_USER_EVENT_CREATE_LDAP_ENTRY, LDAP_USER_EVENT_SYNCH_TO_LDAP_ENTRY),
           ),
           '[cn]' => array(
-            'sid' =>  'activedirectory1',
+            'sid' => 'activedirectory1',
             'ldap_attr' => '[cn]',
             'user_attr' => '[property.name]',
             'convert' => 0,
diff --git a/drupal7/sites/all/modules/ldap/ldap_test/test_ldap/hogwarts/documentation.notes.txt b/drupal7/sites/all/modules/ldap/ldap_test/test_ldap/hogwarts/documentation.notes.txt
index 1e09599f..0da409d1 100644
--- a/drupal7/sites/all/modules/ldap/ldap_test/test_ldap/hogwarts/documentation.notes.txt
+++ b/drupal7/sites/all/modules/ldap/ldap_test/test_ldap/hogwarts/documentation.notes.txt
@@ -132,4 +132,3 @@ cn=slytherin,ou=groups,dc=hogwarts,dc=edu
   adumbledore
   mmcgonagall
   spomana
-
diff --git a/drupal7/sites/all/modules/ldap/ldap_test/test_ldap/hogwarts/hogwarts_x_openldap1.entries.php b/drupal7/sites/all/modules/ldap/ldap_test/test_ldap/hogwarts/hogwarts_x_openldap1.entries.php
index d7b92f9b..8ca40aeb 100644
--- a/drupal7/sites/all/modules/ldap/ldap_test/test_ldap/hogwarts/hogwarts_x_openldap1.entries.php
+++ b/drupal7/sites/all/modules/ldap/ldap_test/test_ldap/hogwarts/hogwarts_x_openldap1.entries.php
@@ -7,7 +7,6 @@
  *
  */
 
-
 $entries = array(
     'cn=hpotter,ou=people,dc=hogwarts,dc=edu' =>
     array(
diff --git a/drupal7/sites/all/modules/ldap/ldap_user/LdapUserConf.class.php b/drupal7/sites/all/modules/ldap/ldap_user/LdapUserConf.class.php
index dec94636..5d21a946 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/LdapUserConf.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_user/LdapUserConf.class.php
@@ -311,7 +311,7 @@ class LdapUserConf {
     if (!$sid || !$this->drupalAcctProvisionServer) {
       return FALSE;
     }
-    elseif ($this->ldapEntryProvisionServer == $sid) {
+    elseif ($this->drupalAcctProvisionServer == $sid) {
       return TRUE;
     }
     else {
@@ -350,7 +350,7 @@ class LdapUserConf {
         if (count(array_intersect($prov_events, $detail['prov_events']))) {
           // Add the attribute to our array.
           if ($detail['ldap_attr']) {
-            ldap_servers_token_extract_attributes($required_attributes,  $detail['ldap_attr']);
+            ldap_servers_token_extract_attributes($required_attributes, $detail['ldap_attr']);
           }
         }
       }
@@ -451,7 +451,7 @@ class LdapUserConf {
     }
     $this->synchMapping = $available_user_attrs;
 
-    cache_set('ldap_user_synch_mapping',  $this->synchMapping);
+    cache_set('ldap_user_synch_mapping', $this->synchMapping);
   }
 
   /**
@@ -619,7 +619,7 @@ class LdapUserConf {
         }
         if (!$ldap_user_prov_entry_exists) {
           $user_entity->ldap_user_prov_entries[LANGUAGE_NONE][] = array(
-            'value' =>  $ldap_user_prov_entry,
+            'value' => $ldap_user_prov_entry,
           );
 
           // Save the field without calling user_save()
@@ -776,8 +776,8 @@ class LdapUserConf {
    *   $user_edit data returned by reference
    *
    */
-  public function synchToDrupalAccount($drupal_user, &$user_edit, $prov_event = LDAP_USER_EVENT_SYNCH_TO_DRUPAL_USER, $ldap_user = NULL,  $save = FALSE) {
-    
+  public function synchToDrupalAccount($drupal_user, &$user_edit, $prov_event = LDAP_USER_EVENT_SYNCH_TO_DRUPAL_USER, $ldap_user = NULL, $save = FALSE) {
+
     $debug = array(
       'account' => $drupal_user,
       'user_edit' => $user_edit,
@@ -980,7 +980,7 @@ class LdapUserConf {
     /**
      * 4. call drupal_alter() to allow other modules to alter $ldap_user
      */
-
+    $params['account'] = $account;
     drupal_alter('ldap_entry', $ldap_user_entry, $params);
 
     return array($ldap_user_entry, $result);
@@ -1074,7 +1074,7 @@ class LdapUserConf {
       else { // create drupal account
         $this->entryToUserEdit($ldap_user, $user_edit, $ldap_server, LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER, array(LDAP_USER_EVENT_CREATE_DRUPAL_USER));
         if ($save) {
-          $watchdog_tokens = array('%drupal_username' =>  $user_edit['name']);
+          $watchdog_tokens = array('%drupal_username' => $user_edit['name']);
           if (empty($user_edit['name'])) {
             drupal_set_message(t('User account creation failed because of invalid, empty derived Drupal username.'), 'error');
             watchdog('ldap_user',
@@ -1198,17 +1198,6 @@ class LdapUserConf {
     }
 
     $drupal_username = $ldap_server->userUsernameFromLdapEntry($ldap_user['attr']);
-		if ($this->isSynched('[property.picture]', $prov_events, $direction)){
-
-			$picture = $ldap_server->userPictureFromLdapEntry($ldap_user['attr'], $drupal_username);
-
-			if ($picture){
-				$edit['picture'] = $picture;
-				if(isset($picture->md5Sum)){
-					$edit['data']['ldap_user']['init']['thumb5md'] = $picture->md5Sum;
-				}
-			}
-		}
 
     if ($this->isSynched('[property.name]', $prov_events, $direction) && !isset($edit['name']) && $drupal_username) {
       $edit['name'] = $drupal_username;
@@ -1243,6 +1232,18 @@ class LdapUserConf {
       );
     }
 
+    if ($this->isSynched('[property.picture]', $prov_events, $direction)) {
+      $picture = $ldap_server->userPictureFromLdapEntry($ldap_user['attr'], $drupal_username);
+      if ($picture) {
+        if (in_array(LDAP_USER_EVENT_CREATE_DRUPAL_USER, $prov_events)) {
+          $edit['picture'] = $picture->fid;
+        } else {
+          $edit['picture'] = $picture;
+        }
+        $edit['data']['ldap_user']['init']['thumb5md'] = $picture->md5Sum;
+      }
+    }
+
     /**
      * basic $user ldap fields
      */
diff --git a/drupal7/sites/all/modules/ldap/ldap_user/LdapUserConfAdmin.class.php b/drupal7/sites/all/modules/ldap/ldap_user/LdapUserConfAdmin.class.php
index 84df561f..70abb0ad 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/LdapUserConfAdmin.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_user/LdapUserConfAdmin.class.php
@@ -321,16 +321,16 @@ the top of this form.
 
       if ($direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER) {
         $parent_fieldset = 'basic_to_drupal';
-        $description =  t('Provisioning from LDAP to Drupal Mappings:');
+        $description = t('Provisioning from LDAP to Drupal Mappings:');
       }
       elseif ($direction == LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY) {
         $parent_fieldset = 'basic_to_ldap';
-        $description =   t('Provisioning from Drupal to LDAP Mappings:');
+        $description = t('Provisioning from Drupal to LDAP Mappings:');
       }
 
       $form[$parent_fieldset]['mappings__' . $direction] = array(
         '#type' => 'fieldset',
-        '#title' =>  $description,
+        '#title' => $description,
         '#collapsible' => TRUE,
         '#collapsed' => FALSE,
         '#description' => '',
@@ -372,7 +372,7 @@ EOT;
       if ($direction == LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY) { // add some password notes
         $form[$parent_fieldset]['password_notes'] = array(
           '#type' => 'fieldset',
-          '#title' =>  t('Password Notes'),
+          '#title' => t('Password Notes'),
           '#collapsible' => TRUE,
           '#collapsed' => TRUE,
           'directions' => array(
@@ -382,7 +382,7 @@ EOT;
         );
         $form[$parent_fieldset]['source_drupal_token_notes'] = array(
           '#type' => 'fieldset',
-          '#title' =>  t('Source Drupal User Tokens and Corresponding Target LDAP Tokens'),
+          '#title' => t('Source Drupal User Tokens and Corresponding Target LDAP Tokens'),
           '#collapsible' => TRUE,
           '#collapsed' => TRUE,
           'directions' => array(
@@ -416,7 +416,17 @@ EOT;
   return $form;
 }
 
-
+  /**
+   * @param $sid
+   * @param $orphan_handling
+   */
+  private function checkPuidOrphans($sid, $orphan_handling) {
+    $ldap_server = ldap_servers_get_servers($sid, NULL, TRUE);
+    if ($ldap_server && empty($ldap_server->unique_persistent_attr)
+      && $orphan_handling != 'ldap_user_orphan_do_not_check') {
+      drupal_set_message(t('You\'ve configured the orphan check but are missing the required persistent user ID property.'), 'error');
+    }
+  }
 
 /**
  * validate submitted form
@@ -430,6 +440,8 @@ EOT;
     $this->populateFromDrupalForm($values, $storage);
     list($errors, $warnings) = $this->validate($values);
 
+    $this->checkPuidOrphans($values['drupalAcctProvisionServer'], $values['orphanedDrupalAcctBehavior']);
+
     // since failed mapping rows in form, don't populate ->ldapUserSynchMappings, need to validate these from values
     foreach ($values as $field => $value) {
       $parts = explode('__', $field);
@@ -457,7 +469,7 @@ EOT;
         }
         if ($direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER && $row_mappings['user_attr'] == 'user_tokens') {
           $input_name = join('__', array('sm', 'user_attr', $i));
-          $errors[$input_name] =  t('User tokens not allowed when mapping to Drupal user.  Location: !row_descriptor', $tokens);
+          $errors[$input_name] = t('User tokens not allowed when mapping to Drupal user.  Location: !row_descriptor', $tokens);
         }
         if (!$row_mappings['ldap_attr']) {
           $input_name = join('__', array('sm', 'ldap_attr', $i));
@@ -490,19 +502,19 @@ EOT;
     $has_drupal_acct_prov_settings_options  = (count(array_filter($this->drupalAcctProvisionTriggers)) > 0);
 
     if (!$has_drupal_acct_prov_servers && $has_drupal_acct_prov_settings_options) {
-      $warnings['drupalAcctProvisionServer'] =  t('No Servers are enabled to provide provisioning to Drupal, but Drupal Account Provisioning Options are selected.', $tokens);
+      $warnings['drupalAcctProvisionServer'] = t('No Servers are enabled to provide provisioning to Drupal, but Drupal Account Provisioning Options are selected.', $tokens);
     }
     if ($has_drupal_acct_prov_servers && !$has_drupal_acct_prov_settings_options) {
-      $warnings['drupalAcctProvisionTriggers'] =  t('Servers are enabled to provide provisioning to Drupal, but no Drupal Account Provisioning Options are selected.  This will result in no synching happening.', $tokens);
+      $warnings['drupalAcctProvisionTriggers'] = t('Servers are enabled to provide provisioning to Drupal, but no Drupal Account Provisioning Options are selected.  This will result in no synching happening.', $tokens);
     }
 
     $has_ldap_prov_servers = (boolean)($this->ldapEntryProvisionServer);
     $has_ldap_prov_settings_options = (count(array_filter($this->ldapEntryProvisionTriggers)) > 0);
     if (!$has_ldap_prov_servers && $has_ldap_prov_settings_options) {
-      $warnings['ldapEntryProvisionServer'] =  t('No Servers are enabled to provide provisioning to ldap, but LDAP Entry Options are selected.', $tokens);
+      $warnings['ldapEntryProvisionServer'] = t('No Servers are enabled to provide provisioning to ldap, but LDAP Entry Options are selected.', $tokens);
     }
     if ($has_ldap_prov_servers && !$has_ldap_prov_settings_options) {
-      $warnings['ldapEntryProvisionTriggers'] =  t('Servers are enabled to provide provisioning to ldap, but no LDAP Entry Options are selected.  This will result in no synching happening.', $tokens);
+      $warnings['ldapEntryProvisionTriggers'] = t('Servers are enabled to provide provisioning to ldap, but no LDAP Entry Options are selected.  This will result in no synching happening.', $tokens);
     }
 
     if (isset($this->ldapUserSynchMappings)) {
@@ -560,7 +572,7 @@ EOT;
 
             if (count(array_keys($ldap_attribute_maps_in_token)) != 1) {
               $token_field_id = join('__', array('sm', 'user_tokens', $row_id));
-              $errors[$token_field_id] =  t('When provisioning to ldap, ldap attribute column must be singular token such as [cn]. %ldap_attr is not.
+              $errors[$token_field_id] = t('When provisioning to ldap, ldap attribute column must be singular token such as [cn]. %ldap_attr is not.
                 Do not use compound tokens such as "[displayName] [sn]" or literals such as "physics". Location: !row_descriptor', $tokens);
             }
 
@@ -571,20 +583,20 @@ EOT;
           $user_tokens_field_id = join('__', array('sm', 'user_tokens', $row_id));
 
           if (!$mapping['ldap_attr']) {
-            $errors[$ldap_attr_field_id] =  t('No LDAP Attribute given in !row_descriptor', $tokens);
+            $errors[$ldap_attr_field_id] = t('No LDAP Attribute given in !row_descriptor', $tokens);
           }
           if ($mapping['user_attr'] == 'user_tokens' && !$mapping['user_tokens']) {
-            $errors[$user_tokens_field_id] =  t('User tokens selected in !row_descriptor, but user tokens column empty.', $tokens);
+            $errors[$user_tokens_field_id] = t('User tokens selected in !row_descriptor, but user tokens column empty.', $tokens);
           }
 
           if (isset($mapping['prov_events']) && count($mapping['prov_events']) == 0) {
-            $warnings[$first_context_field_id] =  t('No synchronization events checked in !row_descriptor.
+            $warnings[$first_context_field_id] = t('No synchronization events checked in !row_descriptor.
               This field will not be synchronized until some are checked.', $tokens);
           }
         }
       }
       if ($to_ldap_entries_mappings_exist && !isset($mappings['[dn]'])) {
-        $errors['mappings__' . $synch_direction] =  t('Mapping rows exist for provisioning to ldap, but no ldap attribute is targetted for [dn].
+        $errors['mappings__' . $synch_direction] = t('Mapping rows exist for provisioning to ldap, but no ldap attribute is targetted for [dn].
           One row must map to [dn].  This row will have a user token like cn=[property.name],ou=users,dc=ldap,dc=mycompany,dc=com');
       }
     }
@@ -599,7 +611,7 @@ EOT;
    */
   protected function populateFromDrupalForm($values, $storage) {
     $this->drupalAcctProvisionServer = ($values['drupalAcctProvisionServer'] == 'none') ? 0 : $values['drupalAcctProvisionServer'];
-    $this->ldapEntryProvisionServer = ($values['ldapEntryProvisionServer']  == 'none') ? 0 : $values['ldapEntryProvisionServer'];
+    $this->ldapEntryProvisionServer = ($values['ldapEntryProvisionServer'] == 'none') ? 0 : $values['ldapEntryProvisionServer'];
 
     $this->drupalAcctProvisionTriggers = $values['drupalAcctProvisionTriggers'];
     $this->ldapEntryProvisionTriggers = $values['ldapEntryProvisionTriggers'];
@@ -787,7 +799,7 @@ EOT;
     }
 
     // 3. leave 4 rows for adding more mappings
-    for ($i=0; $i<4; $i++) {
+    for ($i = 0; $i < 4; $i++) {
       $this->addSynchFormRow($form, 'add', $direction, NULL, $user_attr_options, $row);
       $row++;
     }
@@ -821,18 +833,18 @@ EOT;
       '#disabled' => ($action == 'add' || $action == 'nonconfigurable'),
     );
 
-    $id =  $id_prefix . 'sm__convert__' . $row;
+    $id = $id_prefix . 'sm__convert__' . $row;
     $form[$id] = array(
       '#id' => $id,
       '#row' => $row,
       '#col' => ($direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER) ? 2 : 3,
       '#type' => 'checkbox',
-      '#default_value' =>  isset($mapping['convert']) ? $mapping['convert'] : '',
+      '#default_value' => isset($mapping['convert']) ? $mapping['convert'] : '',
       '#disabled' => ($action == 'nonconfigurable'),
       '#attributes' => array('class' => array('convert')),
     );
 
-    $id =  $id_prefix . 'sm__ldap_attr__' . $row;
+    $id = $id_prefix . 'sm__ldap_attr__' . $row;
     $col = ($direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER) ? 1 : 4;
     if ($action == 'nonconfigurable') {
       $form[$id] = array(
@@ -857,7 +869,7 @@ EOT;
       );
     }
 
-    $user_attr_input_id =  $id_prefix . 'sm__user_attr__' . $row;
+    $user_attr_input_id = $id_prefix . 'sm__user_attr__' . $row;
     $col = ($direction == LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER) ? 3 : 1;
     if ($action == 'nonconfigurable') {
       $form[$user_attr_input_id] = array(
@@ -880,11 +892,11 @@ EOT;
     }
 
     if ($direction == LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY) {
-      $id =  $id_prefix . 'sm__user_tokens__' . $row;
+      $id = $id_prefix . 'sm__user_tokens__' . $row;
       $form[$id] = array(
         '#id' => $id,
         '#row' => $row,
-        '#col' =>  2,
+        '#col' => 2,
         '#type' => 'textfield',
         '#default_value' => isset($mapping['user_tokens']) ? $mapping['user_tokens'] : '',
         '#size' => 40,
@@ -917,7 +929,7 @@ EOT;
 
     foreach ($synchEvents as $prov_event => $prov_event_name) {
       $col++;
-      $id =  $id_prefix . join('__', array('sm', $prov_event, $row));
+      $id = $id_prefix . join('__', array('sm', $prov_event, $row));
       $form[$id] = array(
         '#id' => $id ,
         '#type' => 'checkbox',
@@ -1016,7 +1028,7 @@ EOT;
     $values['orphanedDrupalAcctBehaviorDescription'] = t('It is highly recommended to use the "Perform no action, but email list of orphaned accounts" for some time before considering switching to "Disable the account" options.');
 
 
-    $values['manualAccountConflictOptions'] =  array(
+    $values['manualAccountConflictOptions'] = array(
       LDAP_USER_MANUAL_ACCT_CONFLICT_REJECT => t('Reject manual creation of Drupal accounts that conflict with LDAP Accounts. This only applies to accounts created on user logon;  Account conflicts can still be generated by manually creating users that conflict with ldap users and these users will have their data synched with LDAP data.'),
       LDAP_USER_MANUAL_ACCT_CONFLICT_LDAP_ASSOCIATE => t('Associate manually created Drupal accounts with related LDAP Account if one exists.'),
       LDAP_USER_MANUAL_ACCT_CONFLICT_SHOW_OPTION_ON_FORM => t('Show option on user create form to determine how account conflict is resolved.'),
diff --git a/drupal7/sites/all/modules/ldap/ldap_user/README.developers.txt b/drupal7/sites/all/modules/ldap/ldap_user/README.developers.txt
index 08809fcd..209c47d0 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/README.developers.txt
+++ b/drupal7/sites/all/modules/ldap/ldap_user/README.developers.txt
@@ -184,6 +184,3 @@ which is populated by various ldap and possibly other modules.
   LDAP_USER_EVENT_SYNCH_TO_LDAP_ENTRY
   LDAP_USER_EVENT_CREATE_LDAP_ENTRY
   LDAP_USER_EVENT_LDAP_ASSOCIATE_DRUPAL_ACCT
-
-
-
diff --git a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.admin.inc b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.admin.inc
index 50e216ae..409a1e1a 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.admin.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.admin.inc
@@ -6,7 +6,6 @@
  *
  */
 
-
 /**
  * form for adding, updating, and deleting a single ldap authorization mapping
  */
diff --git a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.cron.inc b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.cron.inc
index 35e92b8b..88e1f4f7 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.cron.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.cron.inc
@@ -13,12 +13,7 @@
  * @param LdapUserConf $ldap_user_conf
  *
  * @return boolean FALSE on error or incompletion or TRUE otherwise
- *
- *  @todo need to avoid sending repeated emails
- *
- *
  */
-
 function _ldap_user_orphans($ldap_user_conf) {
 
   // return TRUE; // this is untested code
@@ -40,6 +35,9 @@ function _ldap_user_orphans($ldap_user_conf) {
 
   $query = new EntityFieldQuery();
   $query->entityCondition('entity_type', 'user')
+    ->fieldCondition('ldap_user_puid_sid', 'value', 'NULL', '!=')
+    ->fieldCondition('ldap_user_puid_property', 'value', 'NULL', '!=')
+    ->fieldCondition('ldap_user_puid', 'value', 'NULL', '!=')
     ->fieldCondition('ldap_user_current_dn', 'value', 'NULL', '!=')
     ->propertyCondition('uid', $last_uid_checked, '>')
     ->propertyOrderBy('uid', 'ASC')
@@ -47,7 +45,6 @@ function _ldap_user_orphans($ldap_user_conf) {
     ->addMetaData('account', user_load(1)); // run the query as user 1
   $result = $query->execute();
 
-  $drupal_users = array();
   $email_list = array();
   $ldap_servers = ldap_servers_get_servers(NULL, 'enabled');
   $watchdogs_sids_missing_watchdogged = array();
@@ -73,125 +70,143 @@ function _ldap_user_orphans($ldap_user_conf) {
 
   $batches = floor($user_count / LDAP_SERVERS_MAXFILTER_ORS) + 1;
   // e.g. 175 users and  50 max ldap query ors will yield 4 batches
-  for ($batch=1; $batch <= $batches; $batch++) { // e.g. 1,2,3,4
-    $filters = array();
-    $drupal_users = array();
-    /**
-     * 1. populate $drupal_users[$sid][$puid_attr][$puid]['exists']  = TRUE
-     *
-     * e.g.  first batch $i=0; $i<50; $i++
-     *       2nd batch   $i=50; $i<100; $i++
-     *       4th batch   $i=150; $i<175; $i++
-     */
-    $start = ($batch - 1)* LDAP_SERVERS_MAXFILTER_ORS; // e.g 0, 50, 100
-    $end_plus_1 = min(($batch)* LDAP_SERVERS_MAXFILTER_ORS, $user_count); // e.g. 50, 100, 150
-    $batch_uids = array_slice($uids, $start, ($end_plus_1 - $start)); // e.g. 50, 50; 100, 50
-    $accounts = entity_load('user', $batch_uids);
-
-    foreach ($accounts as $uid => $user) {
-      $sid = @$user->ldap_user_puid_sid[LANGUAGE_NONE][0]['value'];
-      $puid = @$user->ldap_user_puid[LANGUAGE_NONE][0]['value'];
-      $puid_attr = @$user->ldap_user_puid_property[LANGUAGE_NONE][0]['value'];
-      if ($sid && $puid && $puid_attr) {
-        if ($ldap_servers[$sid]->unique_persistent_attr_binary) {
-          $filters[$sid][$puid_attr][] = "($puid_attr=" . ldap_servers_binary_filter($puid) . ")";
-        }
-        else {
-          $filters[$sid][$puid_attr][] = "($puid_attr=$puid)";
-        }
-        $drupal_users[$sid][$puid_attr][$puid]['uid'] = $uid;
-        $drupal_users[$sid][$puid_attr][$puid]['exists'] = FALSE;
+  for ($batch = 1; $batch <= $batches; $batch++) {
+    $email_list = _ldap_user_orphan_process_batch($ldap_user_conf, $batch, $user_count, $uids, $ldap_servers, $watchdogs_sids_missing_watchdogged, $query, $email_list);
+  }
+
+  if (count($email_list) > 0) {
+    $site_email = variable_get('site_mail', FALSE);
+    $params = array('accounts' => $email_list);
+    if ($site_email) {
+      drupal_mail(
+        'ldap_user',
+        'orphaned_accounts',
+        $site_email,
+        language_default(),
+        $params
+      );
+    }
+  }
+
+  return TRUE;
+}
+
+/**
+ * @param $ldap_user_conf
+ * @param $batch
+ * @param $user_count
+ * @param $uids
+ * @param $ldap_servers
+ * @param $watchdogs_sids_missing_watchdogged
+ * @param $query
+ * @param $email_list
+ *
+ * @return array
+ * @throws \Exception
+ */
+function _ldap_user_orphan_process_batch($ldap_user_conf, $batch, $user_count, $uids, $ldap_servers, $watchdogs_sids_missing_watchdogged, $query, $email_list) {
+  $filters = [];
+  $drupal_users = array();
+  /**
+   * 1. populate $drupal_users[$sid][$puid_attr][$puid]['exists']  = TRUE
+   *
+   * e.g.  first batch $i=0; $i<50; $i++
+   *       2nd batch   $i=50; $i<100; $i++
+   *       4th batch   $i=150; $i<175; $i++
+   */
+  $start = ($batch - 1) * LDAP_SERVERS_MAXFILTER_ORS; // e.g 0, 50, 100
+  $end_plus_1 = min(($batch) * LDAP_SERVERS_MAXFILTER_ORS, $user_count); // e.g. 50, 100, 150
+  $batch_uids = array_slice($uids, $start, ($end_plus_1 - $start)); // e.g. 50, 50; 100, 50
+  $accounts = entity_load('user', $batch_uids);
+
+  foreach ($accounts as $uid => $user) {
+    $sid = @$user->ldap_user_puid_sid[LANGUAGE_NONE][0]['value'];
+    $puid = @$user->ldap_user_puid[LANGUAGE_NONE][0]['value'];
+    $puid_attr = @$user->ldap_user_puid_property[LANGUAGE_NONE][0]['value'];
+    if ($sid && $puid && $puid_attr) {
+      if ($ldap_servers[$sid]->unique_persistent_attr_binary) {
+        $filters[$sid][$puid_attr][] = "($puid_attr=" . ldap_servers_binary_filter($puid) . ")";
       }
       else {
-        // user with missing ldap data fields
-        // perhaps should be watchdogged?
+        $filters[$sid][$puid_attr][] = "($puid_attr=$puid)";
       }
+      $drupal_users[$sid][$puid_attr][$puid]['uid'] = $uid;
+      $drupal_users[$sid][$puid_attr][$puid]['exists'] = FALSE;
+    }
+    else {
+      // user with missing ldap data fields
+      // perhaps should be watchdogged?
     }
+  }
 
-    //2. set $drupal_users[$sid][$puid_attr][$puid]['exists'] to FALSE
-    // if entry doesn't exist
-    foreach ($filters as $sid => $puid_attrs) {
-      if (!isset($ldap_servers[$sid])) {
-        if (!isset($watchdogs_sids_missing_watchdogged[$sid])) {
-          watchdog(
-            'ldap_user',
-            'Server %sid not enabled, but needed to remove orphaned ldap users',
-            array('%sid' => $sid),
-            WATCHDOG_ERROR
-          );
-          $watchdogs_sids_missing_watchdogged[$sid] = TRUE;
-        }
-        continue;
+  //2. set $drupal_users[$sid][$puid_attr][$puid]['exists'] to FALSE
+  // if entry doesn't exist
+  foreach ($filters as $sid => $puid_attrs) {
+    if (!isset($ldap_servers[$sid])) {
+      if (!isset($watchdogs_sids_missing_watchdogged[$sid])) {
+        watchdog(
+          'ldap_user',
+          'Server %sid not enabled, but needed to remove orphaned ldap users',
+          ['%sid' => $sid],
+          WATCHDOG_ERROR
+        );
+        $watchdogs_sids_missing_watchdogged[$sid] = TRUE;
       }
-      foreach ($puid_attrs as $puid_attr => $ors) {
-        // query should look like (|(guid=3243243)(guid=3243243)(guid=3243243))
-        $ldap_filter = '(|' . join("", $ors) . ')';
-        $ldap_entries = $ldap_servers[$sid]->searchAllBaseDns($ldap_filter, array($puid_attr));
-        if ($ldap_entries === FALSE) {
-          unset($drupal_users[$sid]); // if query has error, don't remove ldap entries!
-          watchdog(
-            'ldap_user',
-            'ldap server %sid had error while querying to
+      continue;
+    }
+    foreach ($puid_attrs as $puid_attr => $ors) {
+      // query should look like (|(guid=3243243)(guid=3243243)(guid=3243243))
+      $ldap_filter = '(|' . join("", $ors) . ')';
+      $ldap_entries = $ldap_servers[$sid]->searchAllBaseDns($ldap_filter, [$puid_attr]);
+      if ($ldap_entries === FALSE) {
+        unset($drupal_users[$sid]); // if query has error, don't remove ldap entries!
+        watchdog(
+          'ldap_user',
+          'ldap server %sid had error while querying to
             deal with orphaned ldap user entries.  Please check that the ldap
             server is configured correctly.  Query; %query',
-            array('%sid' => $sid, '%query' => serialize($query)),
-            WATCHDOG_ERROR);
-          continue;
-        }
+          ['%sid' => $sid, '%query' => serialize($query)],
+          WATCHDOG_ERROR);
+        continue;
+      }
 
-        unset($ldap_entries['count']);
+      unset($ldap_entries['count']);
 
-        foreach ($ldap_entries as $i => $ldap_entry) {
-          $puid = $ldap_servers[$sid]->userPuidFromLdapEntry($ldap_entry);
-          $drupal_users[$sid][$puid_attr][$puid]['exists'] = TRUE;
-        }
+      foreach ($ldap_entries as $i => $ldap_entry) {
+        $puid = $ldap_servers[$sid]->userPuidFromLdapEntry($ldap_entry);
+        $drupal_users[$sid][$puid_attr][$puid]['exists'] = TRUE;
       }
     }
-   //3. we now have $drupal_users[$sid][$puid_attr][$puid]['exists'] = FALSE | TRUE;
-    if ($ldap_user_conf->orphanedDrupalAcctBehavior == 'ldap_user_orphan_email') {
-      global $base_url;
-    }
-    $check_time = time();
-    foreach ($drupal_users as $sid => $puid_x_puid_attrs) {
-      foreach ($puid_x_puid_attrs as $puid_attr => $puids) {
-        foreach ($puids as $puid => $user_data) {
-
-          if ($account = $accounts[$user_data['uid']]) {
-            $user_edit['ldap_user_last_checked'][LANGUAGE_NONE][0]['value'] = $check_time;
-            $account = user_save($account, $user_edit, 'ldap_user');
-            if (!$user_data['exists']) {
-                /**
-              * $ldap_user_conf->orphanedDrupalAcctBehavior will either be
-               *  'ldap_user_orphan_email' or one of the user module options:
-               *     user_cancel_block, user_cancel_block_unpublish,
-               *     user_cancel_reassign, user_cancel_delete
-               */
-              if ($ldap_user_conf->orphanedDrupalAcctBehavior == 'ldap_user_orphan_email') {
-                 $email_list[] = $account->name . "," . $account->mail . "," . $base_url . "/user/" . $account->uid . "/edit";
-              }
-              else {
-                 _user_cancel(array(), $account, $ldap_user_conf->orphanedDrupalAcctBehavior);
-              }
+  }
+  //3. we now have $drupal_users[$sid][$puid_attr][$puid]['exists'] = FALSE | TRUE;
+  if ($ldap_user_conf->orphanedDrupalAcctBehavior == 'ldap_user_orphan_email') {
+    global $base_url;
+  }
+  foreach ($drupal_users as $sid => $puid_x_puid_attrs) {
+    foreach ($puid_x_puid_attrs as $puid_attr => $puids) {
+      foreach ($puids as $puid => $user_data) {
+
+        if ($account = $accounts[$user_data['uid']]) {
+          $user_edit = [];
+          $user_edit['ldap_user_last_checked'][LANGUAGE_NONE][0]['value'] = time();
+          $account = user_save($account, $user_edit, 'ldap_user');
+          if (!$user_data['exists']) {
+            /**
+             * $ldap_user_conf->orphanedDrupalAcctBehavior will either be
+             *  'ldap_user_orphan_email' or one of the user module options:
+             *     user_cancel_block, user_cancel_block_unpublish,
+             *     user_cancel_reassign, user_cancel_delete
+             */
+            if ($ldap_user_conf->orphanedDrupalAcctBehavior == 'ldap_user_orphan_email') {
+              $email_list[] = $account->name . "," . $account->mail . "," . $base_url . "/user/" . $account->uid . "/edit";
+            }
+            else {
+              _user_cancel([], $account, $ldap_user_conf->orphanedDrupalAcctBehavior);
             }
           }
         }
       }
     }
   }
-
-  if (count($email_list) > 0) {
-    $site_email =  variable_get('site_mail', FALSE);
-    $params = array('accounts' => $email_list);
-    if ($site_email) {
-      drupal_mail(
-        'ldap_user',
-        'orphaned_accounts',
-        $site_email,
-        language_default(),
-        $params
-      );
-    }
-  }
-
-  return TRUE;
+  return $email_list;
 }
diff --git a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.css b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.css
index 996e14cd..a86af74d 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.css
+++ b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.css
@@ -3,4 +3,4 @@
  */
 .field-name-ldap-user-prov-entries {
   display: none;
-}
\ No newline at end of file
+}
diff --git a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.info b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.info
index 0f7c5f33..a3d6ae1a 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.info
+++ b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.info
@@ -15,19 +15,17 @@ files[] = ldap_user.functions.inc
 files[] = ldap_user.admin.inc
 files[] = ldap_user.test_form.inc
 files[] = ldap_user.theme.inc
-;files[] = ldap_user.ws.inc
+
 files[] = LdapUserConf.class.php
 files[] = LdapUserConfAdmin.class.php
 files[] = tests/ldap_user.test
 
-stylesheets[all][] = ldap_user.css
 configure = admin/config/people/ldap/user
 
 test_dependencies[] = ldap_sso:ldap_sso
 
-; Information added by Drupal.org packaging script on 2017-08-27
-version = "7.x-2.3"
+; Information added by Drupal.org packaging script on 2018-08-13
+version = "7.x-2.4"
 core = "7.x"
 project = "ldap"
-datestamp = "1503841448"
-
+datestamp = "1534201086"
diff --git a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.install b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.install
index 0ebcd2ed..fe2cb66d 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.install
+++ b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.install
@@ -5,7 +5,6 @@
  * Install, update and uninstall functions for the LDAP User module.
  */
 
-
 /**
  * Implements hook_requirements().
  */
diff --git a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.module b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.module
index 5d9a4913..1142ba44 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.module
+++ b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.module
@@ -152,8 +152,8 @@ function ldap_user_cron() {
 function ldap_user_mail($key, &$message, $params) {
   switch ($key) {
     case 'orphaned_accounts':
-      $message['subject'] =  variable_get('site_name') . ' ' . t('Orphaned LDAP Users');
-      $message['body'][] =  t('The following !count Drupal users no longer have
+      $message['subject'] = variable_get('site_name') . ' ' . t('Orphaned LDAP Users');
+      $message['body'][] = t('The following !count Drupal users no longer have
         corresponding LDAP Entries.  Perhaps they have been removed from the LDAP
         and should be removed:', array('!count' => count($params['accounts'])))
         . "\n\n" . t('username,mail,edit url') . "\n" .
@@ -239,7 +239,7 @@ function ldap_user_ldap_attributes_needed_alter(&$attributes, $params) {
           $attributes[$ldap_server->unique_persistent_attr] = ldap_servers_set_attribute_map(@$attributes[$ldap_server->unique_persistent_attr]);
         }
         if ($ldap_server->mail_template) {
-          ldap_servers_token_extract_attributes($attributes,  $ldap_server->mail_template);
+          ldap_servers_token_extract_attributes($attributes, $ldap_server->mail_template);
         }
       break;
     }
@@ -263,7 +263,7 @@ function ldap_user_ldap_user_attrs_list_alter(&$available_user_attrs, &$params)
   $direction = isset($params['direction']) ? $params['direction'] : LDAP_USER_PROV_DIRECTION_NONE;
 
   if ($direction == LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY) {
-    $available_user_attrs['[property.name]'] =  array(
+    $available_user_attrs['[property.name]'] = array(
       'name' => 'Property: Username',
       'source' => '',
       'direction' => LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY,
@@ -274,7 +274,7 @@ function ldap_user_ldap_user_attrs_list_alter(&$available_user_attrs, &$params)
       'configurable_to_ldap' => TRUE,
       );
 
-    $available_user_attrs['[property.mail]'] =  array(
+    $available_user_attrs['[property.mail]'] = array(
       'name' => 'Property: Email',
       'source' => '',
       'direction' => LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY,
@@ -285,7 +285,7 @@ function ldap_user_ldap_user_attrs_list_alter(&$available_user_attrs, &$params)
       'configurable_to_ldap' => TRUE,
     );
 
-    $available_user_attrs['[property.picture]'] =  array(
+    $available_user_attrs['[property.picture]'] = array(
       'name' => 'Property: picture',
       'source' => '',
       'direction' => LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY,
@@ -296,7 +296,7 @@ function ldap_user_ldap_user_attrs_list_alter(&$available_user_attrs, &$params)
       'configurable_to_ldap' => TRUE,
     );
 
-    $available_user_attrs['[property.uid]'] =  array(
+    $available_user_attrs['[property.uid]'] = array(
       'name' => 'Property: Drupal User Id (uid)',
       'source' => '',
       'direction' => LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY,
@@ -372,7 +372,7 @@ function ldap_user_ldap_user_attrs_list_alter(&$available_user_attrs, &$params)
   }
 
   if ($direction == LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY) {
-    $available_user_attrs['[password.random]'] =  array(
+    $available_user_attrs['[password.random]'] = array(
       'name' => 'Pwd: Random',
       'source' => '',
       'direction' => LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY,
@@ -384,7 +384,7 @@ function ldap_user_ldap_user_attrs_list_alter(&$available_user_attrs, &$params)
     );
 
     // use user password when available fall back to random pwd
-    $available_user_attrs['[password.user-random]'] =  array(
+    $available_user_attrs['[password.user-random]'] = array(
       'name' => 'Pwd: User or Random',
       'source' => '',
       'direction' => LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY,
@@ -567,14 +567,14 @@ function ldap_user_form_user_register_form_alter(&$form, $form_state) {
 
   if ($ldap_user_conf->provisionEnabled(LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY, LDAP_USER_DRUPAL_USER_PROV_ON_USER_UPDATE_CREATE)) {
     $ldap_fieldset['ldap_user_association']['#disabled'] = TRUE;
-    $ldap_fieldset['ldap_user_association']['#description'] =  t('Since "Create
+    $ldap_fieldset['ldap_user_association']['#description'] = t('Since "Create
       or Synch to Drupal user anytime a Drupal user account is created or updated"
       is selected at admin/config/people/ldap/user, this option will have no
       effect so its disabled.');
   }
   elseif ($ldap_user_conf->manualAccountConflict != LDAP_USER_MANUAL_ACCT_CONFLICT_SHOW_OPTION_ON_FORM) {
     $ldap_fieldset['ldap_user_association']['#disabled'] = TRUE;
-    $ldap_fieldset['ldap_user_association']['#description'] =  t('To enable
+    $ldap_fieldset['ldap_user_association']['#description'] = t('To enable
       this an LDAP server must be selected for provisioning to Drupal in
       admin/config/people/ldap/user and "Show option on user create form..." must be selected.');
   }
@@ -594,9 +594,9 @@ function ldap_user_form_user_register_form_alter(&$form, $form_state) {
   if (count($ldap_fieldset) > 0) {
     $form['ldap_user_fields'] = $ldap_fieldset;
     $form['ldap_user_fields']['#type'] = 'fieldset';
-    $form['ldap_user_fields']['#title'] =  t('LDAP Options');
-    $form['ldap_user_fields']['#collapsible'] =  TRUE;
-    $form['ldap_user_fields']['#collapsed'] =  FALSE;
+    $form['ldap_user_fields']['#title'] = t('LDAP Options');
+    $form['ldap_user_fields']['#collapsible'] = TRUE;
+    $form['ldap_user_fields']['#collapsed'] = FALSE;
   }
 
   $form['#validate'][] = 'ldap_user_form_register_form_validate';
@@ -1038,8 +1038,10 @@ function ldap_user_user_presave(&$user_edit, $account, $category) {
       if ($ldap_user_conf->provisionEnabled(LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER, LDAP_USER_DRUPAL_USER_PROV_ON_USER_UPDATE_CREATE)) {
         if (ldap_user_is_ldap_associated($account, LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER)) {
           $ldap_user = ldap_servers_get_user_ldap_data($drupal_username, $ldap_user_conf->drupalAcctProvisionServer, 'ldap_user_prov_to_drupal');
-          $ldap_server = ldap_servers_get_servers($ldap_user_conf->drupalAcctProvisionServer, NULL, TRUE);
-          $ldap_user_conf->entryToUserEdit($ldap_user, $user_edit, $ldap_server, LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER, array(LDAP_USER_EVENT_SYNCH_TO_DRUPAL_USER));
+          if ($ldap_user) {
+            $ldap_server = ldap_servers_get_servers($ldap_user_conf->drupalAcctProvisionServer, NULL, TRUE);
+            $ldap_user_conf->entryToUserEdit($ldap_user, $user_edit, $ldap_server, LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER, array(LDAP_USER_EVENT_SYNCH_TO_DRUPAL_USER));
+          }
         }
       }
     }
@@ -1095,6 +1097,11 @@ function ldap_user_field_widget_form(&$form, &$form_state, $field, $instance, $l
       $element['value'] = $element + array(
         '#type' => 'value',
         '#value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : NULL,
+        '#attached' => array(
+          'css' => array(
+            drupal_get_path('module', 'ldap_user') . '/ldap_user.css',
+          ),
+        ),
       );
       break;
   }
diff --git a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.test_form.inc b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.test_form.inc
index 2a102677..32e573eb 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.test_form.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.test_form.inc
@@ -41,7 +41,7 @@ function ldap_user_test_form($form, &$form_state, $op = NULL) {
       '#type' => 'radios',
       '#title' => t('Testing Mode'),
       '#required' => 0,
-      '#default_value' => isset( $_SESSION['ldap_user_test_form']['test_mode']) ?  $_SESSION['ldap_user_test_form']['test_mode'] : 'query',
+      '#default_value' => isset( $_SESSION['ldap_user_test_form']['test_mode']) ? $_SESSION['ldap_user_test_form']['test_mode'] : 'query',
       '#options' => array(
         'query' => t('Test Query.  Will not alter anything in drupal or LDAP'),
         'execute' => t('Execute Action.  Will perform provisioning configured for events below.  If this is selected only one action should be selected below'),
@@ -124,7 +124,7 @@ function ldap_user_test_form_submit($form, &$form_state) {
     $results['ldap_user_conf'] = $ldap_user_conf;
 
     if (is_object($user_object)) {
-      $authmaps = db_query("SELECT aid, uid, module, authname FROM {authmap} WHERE uid = :uid", array(':uid' => $user_object->uid))->fetchAllAssoc('aid',  PDO::FETCH_ASSOC);
+      $authmaps = db_query("SELECT aid, uid, module, authname FROM {authmap} WHERE uid = :uid", array(':uid' => $user_object->uid))->fetchAllAssoc('aid', PDO::FETCH_ASSOC);
     }
     else {
       $authmaps = 'No authmaps available.  Authmaps only shown if user account exists beforehand';
@@ -199,6 +199,6 @@ function ldap_user_test_form_submit($form, &$form_state) {
   $_SESSION['ldap_user_test_form']['test_mode'] = $form_state['values']['test_mode'];
   $_SESSION['ldap_user_test_form']['testing_drupal_username'] = $username;
 
-  $form_state['redirect'] =  LDAP_USER_TEST_FORM_PATH;
+  $form_state['redirect'] = LDAP_USER_TEST_FORM_PATH;
 
 }
diff --git a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.theme.inc b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.theme.inc
index 2d43fda6..47bfd2a6 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.theme.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.theme.inc
@@ -5,7 +5,6 @@
  *   theme functions for ldap_user module
  */
 
-
 /**
  * turns array of variables to a form embedded in one table for each ldap server
  */
@@ -20,7 +19,7 @@ function theme_ldap_user_conf_form($variables) {
       list($direction, $discard, $column_name, $i) = $parts;
       $row = $element['#row'];
       $col = $element['#col'];
-      $tables[$direction]['rows'][$row][$col] = array('data' => drupal_render($form[$key]), 'class' => array('module'),  'colspan' => 1);
+      $tables[$direction]['rows'][$row][$col] = array('data' => drupal_render($form[$key]), 'class' => array('module'), 'colspan' => 1);
     }
   }
 
diff --git a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.ws.inc b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.ws.inc
index c4903085..e0e3e748 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.ws.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.ws.inc
@@ -61,12 +61,12 @@ function ldap_user_ws($action, $direction_tag, $drupal_user_name_or_dn, $key) {
   if ($direction_tag == 'todrupal') {
     $direction = LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER;
     $sid = $ldap_user_conf->drupalAcctProvisionServer;
-    $ldap_server =  ldap_servers_get_servers($sid, NULL, TRUE);
+    $ldap_server = ldap_servers_get_servers($sid, NULL, TRUE);
   }
   if ($direction_tag == 'toldap') {
     $direction = LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY;
     $sid = $ldap_user_conf->ldapEntryProvisionServer;
-    $ldap_server =  ldap_servers_get_servers($sid, NULL, TRUE);
+    $ldap_server = ldap_servers_get_servers($sid, NULL, TRUE);
   }
   else  {
     $direction = LDAP_USER_PROV_DIRECTION_NONE;
diff --git a/drupal7/sites/all/modules/ldap/ldap_user/tests/ldap_user.test b/drupal7/sites/all/modules/ldap/ldap_user/tests/ldap_user.test
index e6c49ae0..1be7a6e1 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/tests/ldap_user.test
+++ b/drupal7/sites/all/modules/ldap/ldap_user/tests/ldap_user.test
@@ -11,7 +11,6 @@
  *
  */
 
-
 module_load_include('php', 'ldap_test', 'LdapTestCase.class');
 
 class LdapUserUnitTests extends LdapTestCase {
@@ -91,7 +90,7 @@ class LdapUserUnitTests extends LdapTestCase {
     $mail = ldap_user_token_replace('[property.mail]', $account, $entity);
     $this->assertTrue($mail == $account->mail, t('[property.mail] token worked on ldap_user_token_replace().'), $this->testId('tokens.property'));
     $lname = ldap_user_token_replace('[field.lname]', $account, $entity);
-    $this->assertTrue($lname ==  $entity->lname[LANGUAGE_NONE][0]['value'], t('[field.lname] token worked on ldap_user_token_replace().'), $this->testId('tokens.property.field'));
+    $this->assertTrue($lname == $entity->lname[LANGUAGE_NONE][0]['value'], t('[field.lname] token worked on ldap_user_token_replace().'), $this->testId('tokens.property.field'));
     $house1 = ldap_user_token_replace('[field.house:1]', $account, $entity);
     $this->assertTrue($house1 == $entity->house[LANGUAGE_NONE][1]['value'], t('[field.house:1] token worked on ldap_user_token_replace().'), $this->testId('tokens.property.field.ordinal'));
     //@todo need tests for :last and a multivalued attribute.  see http://drupal.org/node/1245736
@@ -396,12 +395,12 @@ class LdapUserUnitTests extends LdapTestCase {
     $this->prepTestData('hogwarts', $sids, 'provisionToDrupal', 'default');
     $tests = array();
 
-    $tests[] =  array(
+    $tests[] = array(
       'disabled' => 0,
       'user' => 'hpotter',
       'field_name' => 'field_lname',
       'field_values' => array(array('sn' => 'Potter'), array('sn' => 'Pottery-Chard')),
-      'field_results' => array('Potter', 'Pottery-Chard'),  // first value is what is desired on synch, second if no sycn
+      'field_results' => array('Potter', 'Pottery-Chard'), // first value is what is desired on synch, second if no sycn
       'mapping' => array(
         'sid' => $sid,
         'name' => 'Field: Last Name',
@@ -418,12 +417,12 @@ class LdapUserUnitTests extends LdapTestCase {
     );
 
     // test for compound tokens
-    $tests[] =  array(
+    $tests[] = array(
       'disabled' => 0,
       'user' => 'hpotter',
       'field_name' => 'field_display_name',
-      'field_values' => array(array('givenname' => 'Harry', 'sn' => 'Potter'), array('givenname' => 'Sir Harry',  'sn' => 'Potter')),
-      'field_results' => array('Harry Potter', 'Sir Harry Potter'),  // desired results
+      'field_values' => array(array('givenname' => 'Harry', 'sn' => 'Potter'), array('givenname' => 'Sir Harry', 'sn' => 'Potter')),
+      'field_results' => array('Harry Potter', 'Sir Harry Potter'), // desired results
       'mapping' => array(
         'sid' => $sid,
         'ldap_attr' => '[givenName] [sn]',
@@ -441,7 +440,7 @@ class LdapUserUnitTests extends LdapTestCase {
 
 
     // test for constants in use (e.g. "Smith" and "0") instead of tokens e.g. "[sn]" and "[enabled]"
-    $tests[] =  array(
+    $tests[] = array(
       'disabled' => 0,
       'user' => 'hpotter',
       'field_name' => 'field_lname',
@@ -464,7 +463,7 @@ class LdapUserUnitTests extends LdapTestCase {
     );
 
     // test for compound tokens
-    $tests[] =  array(
+    $tests[] = array(
       'disabled' => 0,
       'user' => 'hpotter',
       'property_name' => 'signature',
@@ -485,7 +484,7 @@ class LdapUserUnitTests extends LdapTestCase {
       ),
     );
 
-    $tests[] =  array(
+    $tests[] = array(
       'disabled' => 0,
       'user' => 'hpotter',
       'property_name' => 'mail',
@@ -506,7 +505,7 @@ class LdapUserUnitTests extends LdapTestCase {
       ),
     );
 
-    $tests[] =  array(
+    $tests[] = array(
       'disabled' => 0,
       'user' => 'hpotter',
       'property_name' => 'status',
@@ -515,7 +514,7 @@ class LdapUserUnitTests extends LdapTestCase {
       'mapping' => array(
         'sid' => $sid,
         'ldap_attr' => '0',
-        'user_attr' => '[property.status]',  // testing of a constant mapped to property
+        'user_attr' => '[property.status]', // testing of a constant mapped to property
         'convert' => 0,
         'direction' => LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER,
         'prov_events' => array(LDAP_USER_EVENT_CREATE_DRUPAL_USER),
@@ -562,7 +561,7 @@ class LdapUserUnitTests extends LdapTestCase {
         $ldap_user_conf = ldap_user_conf('admin', TRUE);
         if ($property_name) {
           $token_attributes = array();
-          ldap_servers_token_extract_attributes($token_attributes,  $test['mapping']['ldap_attr']);
+          ldap_servers_token_extract_attributes($token_attributes, $test['mapping']['ldap_attr']);
           foreach ($token_attributes as $attr_name => $attr_parts) {
             $this->testFunctions->setFakeServerUserAttribute(
               'activedirectory1',
@@ -576,7 +575,7 @@ class LdapUserUnitTests extends LdapTestCase {
         }
         if ($field_name) {
           $token_attributes = array();
-          ldap_servers_token_extract_attributes($token_attributes,  $test['mapping']['ldap_attr']);
+          ldap_servers_token_extract_attributes($token_attributes, $test['mapping']['ldap_attr']);
           foreach ($token_attributes as $attr_name => $attr_parts ) {
             $this->testFunctions->setFakeServerUserAttribute(
               'activedirectory1',
@@ -621,7 +620,7 @@ class LdapUserUnitTests extends LdapTestCase {
           if (in_array($prov_event, $ldap_user_conf->ldapUserSynchMappings[$direction][$field_token]['prov_events'])) { // if intended to synch
             $field_success = isset($user_entity->{$field_name}[LANGUAGE_NONE][0]['value']) &&
               $user_entity->{$field_name}[LANGUAGE_NONE][0]['value'] == $test['field_results'][0];
-            $this->assertTrue($field_success, t("provisionDrupalAccount worked for field $field_name"),  $this->testId(":provisionDrupalAccount.i=$j.prov_event=$prov_event"));
+            $this->assertTrue($field_success, t("provisionDrupalAccount worked for field $field_name"), $this->testId(":provisionDrupalAccount.i=$j.prov_event=$prov_event"));
             if (!$field_success) {
               debug('field fail,' . $field_name); debug($user_entity->{$field_name}); debug($test['field_results'][0]); //debug($user_entity);
             }
@@ -1033,7 +1032,7 @@ class LdapUserIntegrationTests extends LdapTestCase {
         module_exists('ldap_servers') &&
         (variable_get('ldap_simpletest', 2) > 0)
       );
-    $this->assertTrue($setup_success, ' ldap_user setup successful',  $this->testId('orphaned entries tests'));
+    $this->assertTrue($setup_success, ' ldap_user setup successful', $this->testId('orphaned entries tests'));
 
     $sids = array('activedirectory1');
     $this->prepTestData('hogwarts', $sids, 'provisionToDrupal', 'default');
@@ -1055,7 +1054,7 @@ class LdapUserIntegrationTests extends LdapTestCase {
 
       // create 70 drupal accounts (clone0 to clone69) based on corresponding ldap entries
       $first_clone_username = 'clone0';
-      $last_clone_username= 'clone' . (LDAP_TEST_USER_ORPHAN_CLONE_COUNT - 1);
+      $last_clone_username = 'clone' . (LDAP_TEST_USER_ORPHAN_CLONE_COUNT - 1);
       for ($i = 0; $i < LDAP_TEST_USER_ORPHAN_CLONE_COUNT; $i++) { // 70
         $name = "clone" . $i;
         $account = $this->createLdapIdentifiedDrupalAccount(
@@ -1166,7 +1165,7 @@ class LdapUserIntegrationTests extends LdapTestCase {
         break;
       }
 
-      $this->assertTrue($success, $test_id,  $test_text);
+      $this->assertTrue($success, $test_id, $test_text);
 
       // remove all drupal users except 1 for next test
       foreach ($cn_to_account as $cn => $account) {
@@ -1232,7 +1231,7 @@ class LdapUserUITests extends LdapTestCase {
         module_exists('ldap_servers') &&
         (variable_get('ldap_simpletest', 2) > 0)
       );
-    $this->assertTrue($setup_success, ' ldap_user setup successful',  $this->testId('user interface tests'));
+    $this->assertTrue($setup_success, ' ldap_user setup successful', $this->testId('user interface tests'));
 
     $sids = array('activedirectory1');
     $this->prepTestData('hogwarts', $sids, 'provisionToDrupal', 'default');
diff --git a/drupal7/sites/all/modules/ldap/ldap_user/tests/ldap_user.test.manual.txt b/drupal7/sites/all/modules/ldap/ldap_user/tests/ldap_user.test.manual.txt
index 1fa9c282..f1a2fc4e 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/tests/ldap_user.test.manual.txt
+++ b/drupal7/sites/all/modules/ldap/ldap_user/tests/ldap_user.test.manual.txt
@@ -186,4 +186,3 @@ Test ldap entry provisioning workflow: User requests account -> email verificati
          in the database in the authmaps table, a record should exist with module=ldap_user and authname=<username tested>
   8.4 Test manual selection of "Create corresponding LDAP Entry" and Do not make this an LDAP Associated account in admin/people/create form
      -- is this even allowable?  What's the use case for this?
-    
\ No newline at end of file
diff --git a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_argument.inc b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_argument.inc
index 1554b970..0aba42c1 100644
--- a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_argument.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_argument.inc
@@ -4,6 +4,7 @@
  * @file
  * Basic textfield argument to handle known ldap attributes
  */
+
 class ldap_views_handler_argument extends views_handler_argument {
 
   /**
diff --git a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_argument_attribute.inc b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_argument_attribute.inc
index 10238bc1..d00e6685 100644
--- a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_argument_attribute.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_argument_attribute.inc
@@ -4,6 +4,7 @@
  * @file
  * Basic textfield argument to handle dynamic ldap attributes
  */
+
 class ldap_views_handler_argument_attribute extends views_handler_argument {
 
   function option_definition() {
diff --git a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_field.inc b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_field.inc
index a7e0624b..7c631ccc 100644
--- a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_field.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_field.inc
@@ -6,6 +6,7 @@
  *
  * Defines a new class field handler for a default ldap field
  */
+
 class ldap_views_handler_field extends views_handler_field {
 
   function render($values) {
@@ -34,7 +35,7 @@ class ldap_views_handler_field extends views_handler_field {
   function options_form(&$form, &$form_state) {
     parent::options_form($form, $form_state);
     $form['multivalue'] = array(
-      '#type' => 'select',     // it should be 'radios', but it makes #dependency not to work
+      '#type' => 'select', // it should be 'radios', but it makes #dependency not to work
       '#title' => t('Values to show'),
       '#description' => t('What to do whith  multivalue attributes'),
       '#options' => array(
diff --git a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_field_attribute.inc b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_field_attribute.inc
index 5ec64805..4afba50f 100644
--- a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_field_attribute.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_field_attribute.inc
@@ -6,6 +6,7 @@
  *
  * Defines a new class field handler for a default ldap field
  */
+
 class ldap_views_handler_field_attribute extends ldap_views_handler_field {
 
 
diff --git a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_filter.inc b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_filter.inc
index 4c474a29..df012d0f 100644
--- a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_filter.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_filter.inc
@@ -5,6 +5,7 @@
  * Basic textfield filter to handle string filtering commands
  * including equality, contains, not contains, etc.
  */
+
 class ldap_views_handler_filter extends views_handler_filter {
   // exposed filter options
   var $always_multiple = TRUE;
diff --git a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_filter_attribute.inc b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_filter_attribute.inc
index ad54cd23..dbd80bad 100644
--- a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_filter_attribute.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_filter_attribute.inc
@@ -5,6 +5,7 @@
  * Basic textfield filter to handle string filtering commands for a generic ldap attribute
  * Includes new criterias
  */
+
 class ldap_views_handler_filter_attribute extends ldap_views_handler_filter {
 
   /**
diff --git a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_sort.inc b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_sort.inc
index e0b38df0..e96a2c16 100644
--- a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_sort.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_sort.inc
@@ -4,5 +4,6 @@
  * @file
  * Base sort handler for a ldap attributes
  */
+
 class ldap_views_handler_sort extends views_handler_sort {
 }
diff --git a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_sort_attribute.inc b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_sort_attribute.inc
index b43f7a91..83d72a22 100644
--- a/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_sort_attribute.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_sort_attribute.inc
@@ -4,6 +4,7 @@
  * @file
  * Base sort handler for a ldap attributes
  */
+
 class ldap_views_handler_sort_attribute extends ldap_views_handler_sort {
   function option_definition() {
     $options = parent::option_definition();
diff --git a/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.info b/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.info
index 7af80730..63f3bb2c 100644
--- a/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.info
+++ b/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.info
@@ -21,9 +21,9 @@ files[] = handlers/ldap_views_handler_filter.inc
 files[] = handlers/ldap_views_handler_filter_attribute.inc
 files[] = handlers/ldap_views_handler_sort.inc
 files[] = handlers/ldap_views_handler_sort_attribute.inc
-; Information added by Drupal.org packaging script on 2017-08-27
-version = "7.x-2.3"
+
+; Information added by Drupal.org packaging script on 2018-08-13
+version = "7.x-2.4"
 core = "7.x"
 project = "ldap"
-datestamp = "1503841448"
-
+datestamp = "1534201086"
diff --git a/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.install b/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.install
index 6b148a41..6ea7e466 100644
--- a/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.install
+++ b/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.install
@@ -4,4 +4,3 @@
  * @file
  * Install functions for the ldap_views module.
  */
-
diff --git a/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.module b/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.module
index 57dd00ef..248b6a74 100644
--- a/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.module
+++ b/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.module
@@ -1,5 +1,9 @@
 <?php
 
+/**
+ * @file
+ */
+
 /**
  * Implements hook_views_api().
  */
diff --git a/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.views_default.inc b/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.views_default.inc
index 92dc76fd..7114c3d6 100644
--- a/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.views_default.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_views/ldap_views.views_default.inc
@@ -209,5 +209,3 @@ function ldap_views_views_default_views() {
 
   return $views;
 }
-
-
diff --git a/drupal7/sites/all/modules/ldap/ldap_views/plugins/ldap_views_plugin_query_ldap.inc b/drupal7/sites/all/modules/ldap/ldap_views/plugins/ldap_views_plugin_query_ldap.inc
index 50175ea5..c705aa65 100644
--- a/drupal7/sites/all/modules/ldap/ldap_views/plugins/ldap_views_plugin_query_ldap.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_views/plugins/ldap_views_plugin_query_ldap.inc
@@ -4,6 +4,7 @@
  * @file
  * Defines the default query object which builds and execute a ldap query
  */
+
 class ldap_views_plugin_query_ldap extends views_plugin_query {
 
   /**
@@ -168,7 +169,7 @@ class ldap_views_plugin_query_ldap extends views_plugin_query {
   function build_ldap_filter($filter) {
     $condition     = $this->build_condition();
     $contextual    = $this->build_contextual_filter();
-    $search_filter = !empty($contextual) && !empty($condition)? '(&' . $condition . $contextual . ')' : $condition . $contextual;
+    $search_filter = !empty($contextual) && !empty($condition) ? '(&' . $condition . $contextual . ')' : $condition . $contextual;
     return !empty($search_filter) ? $search_filter : $filter;
   }
 
@@ -245,7 +246,7 @@ class ldap_views_plugin_query_ldap extends views_plugin_query {
     if (property_exists($view->query, 'limit')) {
       $limit     = $view->query->limit;
     }
-    $offset = property_exists($view->query, 'offset')? $view->query->offset : 0;
+    $offset = property_exists($view->query, 'offset') ? $view->query->offset : 0;
     $result      = array();
     $sort_fields = array();
     if (!empty($this->orderby)) {
