commit 5136ce556c0af1daba59cd954e3645a5f1951ac3
Author: Assos Assos <assos+forge@centrale-marseille.fr>
Date:   Wed Aug 10 22:49:35 2016 +0200

    Weekly update of contrib modules

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 bc10e0b2..68b45c19 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.inc
@@ -121,7 +121,7 @@ function _ldap_authentication_form_user_profile_form_alter(&$form, $form_state)
 /**
  * Replaces the email address in $ldap_user with one from the template in
  * $auth_conf.
- * 
+ *
  * @param array $ldap_user
  *   LDAP user entry
  * @param LdapAuthenticationConf $auth_conf
@@ -156,17 +156,21 @@ function _ldap_authentication_user_login_authenticate_validate(&$form_state, $re
 
   // Default to name
   $entered_name = $form_state['values']['name'];
-  $authname_drupal_property = 'name';
+  $authname_drupal_property = $form_field_name = 'name';
 
   // Email registration module populates name even though user entered email
   if (!empty($form_state['values']['email'])) {
     $entered_name = $form_state['values']['email'];
     $authname_drupal_property = 'mail';
+    $form_field_name = 'email';
   }
 
   // $authname is the name the user is authenticated with from the logon form // patch 1599632
   $authname = $entered_name;
 
+  if (empty($form_state['values']['pass']) || empty ($form_state['values'][$form_field_name])) {
+    return FALSE;
+  }
   /*
    * If a fake form state was passed into this function from
    * _ldap_authentication_user_login_sso(), there will be a value outside of the
@@ -266,9 +270,9 @@ function _ldap_authentication_user_login_authenticate_validate(&$form_state, $re
   $email_template_tokens = array(
     '@username' => $drupal_accountname,
   );
-  
+
   $email_template_used = FALSE;
-  
+
   /**
    * Ensures that we respect the email template handling settings.
    */
@@ -288,7 +292,7 @@ function _ldap_authentication_user_login_authenticate_validate(&$form_state, $re
         break;
     }
   }
-  
+
   /**
    * VI. Find or create corresponding drupal account and set authmaps
    *
@@ -354,9 +358,9 @@ function _ldap_authentication_user_login_authenticate_validate(&$form_state, $re
    * VI.C: existing Drupal account with incorrect email.  fix email if appropriate
    *
    */
-  if ((!($auth_conf->templateUsageNeverUpdate && $email_template_used)) && 
-      $drupal_account_exists && 
-      $drupal_account->mail != $ldap_user['mail'] && 
+  if ((!($auth_conf->templateUsageNeverUpdate && $email_template_used)) &&
+      $drupal_account_exists &&
+      $drupal_account->mail != $ldap_user['mail'] &&
       (
         $auth_conf->emailUpdate == LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_ENABLE_NOTIFY ||
         $auth_conf->emailUpdate == LDAP_AUTHENTICATION_EMAIL_UPDATE_ON_LDAP_CHANGE_ENABLE
@@ -448,7 +452,7 @@ function _ldap_authentication_user_login_authenticate_validate(&$form_state, $re
     else {
       $user_edit = array('name' => $drupal_accountname, 'status' => 1);
     }
-    
+
     // If the email template was used, we want to pass in the email that was
     // generated so that its not overridden by the provisioner.
     if ($email_template_used) {
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 7391d857..7e3073a7 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.info
+++ b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.info
@@ -14,9 +14,9 @@ files[] = ldap_authentication.theme.inc
 files[] = ldap_authentication.admin.inc
 files[] = tests/ldap_authentication.test
 
-; Information added by Drupal.org packaging script on 2014-01-08
-version = "7.x-2.0-beta8"
+; Information added by Drupal.org packaging script on 2016-08-07
+version = "7.x-2.0-beta11"
 core = "7.x"
 project = "ldap"
-datestamp = "1389150511"
+datestamp = "1470608343"
 
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 965a4d95..b586b73b 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.module
+++ b/drupal7/sites/all/modules/ldap/ldap_authentication/ldap_authentication.module
@@ -220,7 +220,7 @@ function _ldap_authentication_verify_user_profile() {
  */
 function ldap_authentication_init() {
   $auth_conf = ldap_authentication_get_valid_conf();
-  if ($auth_conf->templateUsagePromptUser) {
+  if ($auth_conf && $auth_conf->templateUsagePromptUser) {
     ldap_authentication_check_for_email_template();
   }
 }
@@ -342,7 +342,7 @@ function ldap_authentication_show_reset_pwd($user = NULL) {
 
   if ($user->uid == 0) {
     // hide reset password for anonymous users if ldap only authentication and password updates are disabled, otherwise show
-    if ($auth_conf->authenticationMode != LDAP_AUTHENTICATION_EXCLUSIVE) {
+    if ($auth_conf->authenticationMode == LDAP_AUTHENTICATION_EXCLUSIVE) {
       if ($auth_conf->passwordOption == LDAP_AUTHENTICATION_PASSWORD_FIELD_ALLOW) {
         return TRUE;
       }
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 d982c472..7e8c14ec 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.info
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/ldap_authorization.info
@@ -18,9 +18,9 @@ files[] = tests/Og1Tests.test
 files[] = tests/Og2Tests.test
 configure = admin/config/people/ldap/authorization
 
-; Information added by Drupal.org packaging script on 2014-01-08
-version = "7.x-2.0-beta8"
+; Information added by Drupal.org packaging script on 2016-08-07
+version = "7.x-2.0-beta11"
 core = "7.x"
 project = "ldap"
-datestamp = "1389150511"
+datestamp = "1470608343"
 
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 42ef7246..a0caeb21 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,9 @@ files[] = LdapAuthorizationConsumerRole.class.php
 files[] = ldap_authorization_drupal_role.module
 files[] = ldap_authorization_drupal_role.inc
 
-; Information added by Drupal.org packaging script on 2014-01-08
-version = "7.x-2.0-beta8"
+; Information added by Drupal.org packaging script on 2016-08-07
+version = "7.x-2.0-beta11"
 core = "7.x"
 project = "ldap"
-datestamp = "1389150511"
+datestamp = "1470608343"
 
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 31a6d32c..8855b1d1 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
@@ -583,6 +583,7 @@ class LdapAuthorizationConsumerOG extends LdapAuthorizationConsumerAbstract {
       $this->og2Revokes($og_actions, $user, $user_auth_data); 
     }
 
+    $user_edit = array('data' => $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];  // reset this variable because user save hooks can impact it.
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 3e1187fa..48640585 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,9 @@ files[] = ldap_authorization_og.inc
 
 core = "7.x"
 
-; Information added by Drupal.org packaging script on 2014-01-08
-version = "7.x-2.0-beta8"
+; Information added by Drupal.org packaging script on 2016-08-07
+version = "7.x-2.0-beta11"
 core = "7.x"
 project = "ldap"
-datestamp = "1389150511"
+datestamp = "1470608343"
 
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 b0ca0af8..2f336490 100644
--- a/drupal7/sites/all/modules/ldap/ldap_authorization/tests/Og2Tests.test
+++ b/drupal7/sites/all/modules/ldap/ldap_authorization/tests/Og2Tests.test
@@ -10,6 +10,7 @@
  *  - 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');
 
diff --git a/drupal7/sites/all/modules/ldap/ldap_feeds/FeedsLdapEntryParser.inc b/drupal7/sites/all/modules/ldap/ldap_feeds/FeedsLdapEntryParser.inc
index 54848263..d72a17ed 100644
--- a/drupal7/sites/all/modules/ldap/ldap_feeds/FeedsLdapEntryParser.inc
+++ b/drupal7/sites/all/modules/ldap/ldap_feeds/FeedsLdapEntryParser.inc
@@ -34,6 +34,10 @@ class FeedsLdapEntryParser extends FeedsParser {
           if ($ldap_attributes[$source_lcase]['count'] == 1 && is_scalar($ldap_attributes[$source_lcase][0])) {
             $parsed_item[$source] = (string)$ldap_attributes[$source_lcase][0];
           }
+          else {
+            unset($ldap_attributes[$source_lcase]['count']);
+            $parsed_item[$source] = $ldap_attributes[$source_lcase];
+          }
         }
         else {
           $parsed_item[$source] = '';
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 a3a12530..ae1db126 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,9 @@ configure = admin/structure/feeds
 core = 7.x
 php = 5.2
 
-; Information added by Drupal.org packaging script on 2014-01-08
-version = "7.x-2.0-beta8"
+; Information added by Drupal.org packaging script on 2016-08-07
+version = "7.x-2.0-beta11"
 core = "7.x"
 project = "ldap"
-datestamp = "1389150511"
+datestamp = "1470608343"
 
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 71306aa4..dd1331a7 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 2014-01-08
-version = "7.x-2.0-beta8"
+; Information added by Drupal.org packaging script on 2016-08-07
+version = "7.x-2.0-beta11"
 core = "7.x"
 project = "ldap"
-datestamp = "1389150511"
+datestamp = "1470608343"
 
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 06a92872..83b31db3 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,9 @@ files[] = tests/ldap_query.test
 
 configure = admin/config/people/ldap/query
 
-; Information added by Drupal.org packaging script on 2014-01-08
-version = "7.x-2.0-beta8"
+; Information added by Drupal.org packaging script on 2016-08-07
+version = "7.x-2.0-beta11"
 core = "7.x"
 project = "ldap"
-datestamp = "1389150511"
+datestamp = "1470608343"
 
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 514a7b62..9d98c2d4 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/LdapServer.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/LdapServer.class.php
@@ -234,7 +234,7 @@ class LdapServer {
     }
 
     if ($bindpw) {
-      $this->bindpw = ldap_servers_decrypt($bindpw);
+      $this->bindpw = ($bindpw == '') ? '' : ldap_servers_decrypt($bindpw);
     }
 
     $this->paginationEnabled = (boolean)(ldap_servers_php_supports_pagination() && $this->searchPagination);
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 2a0bb7f8..928d3e63 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
@@ -379,14 +379,20 @@ function ldap_server_massage_text($value, $value_type, $context) {
     */
 
     function ldap_pear_hex2asc($string) {
+
+      if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
         $string = preg_replace_callback(
           "/\\\([0-9A-Fa-f]{2})/",
           function ($m){
             return chr(hexdec($m[1]));
           },
           $string);
+      }
+      else {
+        $string = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''", $string);
+      }
 
-        return $string;
+      return $string;
     }
 
     /**
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 b78735eb..a1881b4c 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.info
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.info
@@ -9,7 +9,6 @@ files[] = LdapServerAdmin.class.php
 files[] = ldap_servers.admin.inc
 files[] = ldap_servers.encryption.inc
 files[] = ldap_servers.functions.inc
-files[] = ldap_servers.inc
 files[] = ldap_servers.install
 files[] = ldap_servers.module
 files[] = ldap_servers.settings.inc
@@ -18,9 +17,9 @@ files[] = ldap_servers.theme.inc
 files[] = tests/ldap_servers.test
 configure = admin/config/people/ldap/servers
 
-; Information added by Drupal.org packaging script on 2014-01-08
-version = "7.x-2.0-beta8"
+; Information added by Drupal.org packaging script on 2016-08-07
+version = "7.x-2.0-beta11"
 core = "7.x"
 project = "ldap"
-datestamp = "1389150511"
+datestamp = "1470608343"
 
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 2a9ca579..84ac23f5 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.install
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.install
@@ -28,6 +28,7 @@ function ldap_servers_uninstall() {
  */
 function ldap_servers_requirements($phase) {
   $requirements = array();
+  $t = get_t();
 
   if ($phase == 'install') {
     $requirements['ldap_extension_loaded']['title'] = t('LDAP Extension Loaded');
@@ -55,6 +56,48 @@ function ldap_servers_requirements($phase) {
       See http://drupal.org/node/1023016. This message will go away when the ldapauth database table is removed.');
   }
   // check that ldapauth not installed.
+
+  // Check enabled LDAP servers are configured and Drupal can connect to them.
+  if ($phase == 'runtime') {
+    $requirements['ldap_servers_enabled'] = array(
+      'title' => $t('LDAP Server status'),
+      'value' =>  $t('Disabled'),
+      'severity' => REQUIREMENT_WARNING,
+    );
+
+    $servers = ldap_servers_get_servers(NULL, 'enabled');
+    if (!empty($servers)) {
+      unset($requirements['ldap_servers_enabled']);
+
+      foreach ($servers as $server) {
+        $server_req_key = 'ldap_servers_sid_' . $server->sid;
+        $server_tokens = array(
+          '@host' => $server->address,
+          '@sid' => $server->sid,
+        );
+        $requirements[$server_req_key] = array(
+          'title' => $t('LDAP Server status: @sid (@host)', $server_tokens),
+          'value' =>  $t('Connection: Failed, check logs for details.', $server_tokens),
+          'severity' => REQUIREMENT_ERROR,
+        );
+
+        try {
+          $connect_result = $server->connect();
+          if ($connect_result == LDAP_SUCCESS) {
+            $bind_result = $server->bind();
+            if ($bind_result == LDAP_SUCCESS) {
+              $requirements[$server_req_key]['value'] = $t('Connection: Success, Bind: Success', $server_tokens);
+              $requirements[$server_req_key]['severity'] = REQUIREMENT_OK;
+            }
+          }
+          $server->disconnect();
+        }
+        catch (Exception $e) {
+        }
+      }
+    }
+  }
+
   return $requirements;
 }
 
@@ -287,7 +330,7 @@ function ldap_servers_update_7107() {
 
 
 function ldap_servers_db_field_exists($table, $field_name) {
-  if (!ldap_servers_db_field_exists($table, $field_name) && !ldap_servers_db_field_exists($table, drupal_strtolower($field_name)) ) {
+  if (!db_field_exists($table, $field_name) && !db_field_exists($table, drupal_strtolower($field_name)) ) {
     return false;
   }
   else {
@@ -300,7 +343,7 @@ function ldap_servers_db_field_exists($table, $field_name) {
 function ldap_servers_update_7108() {
 
   foreach (array('groupFunctionalityUnused', 'groupNested', 'groupSearchAll', 'groupUserMembershipsAttrExists', 'groupDeriveFromDn', 'groupUserMembershipsAttrExists') as $tinyint_field_name) {
-    if (!ldap_servers_ldap_servers_db_field_exists('ldap_servers', $tinyint_field_name))  {
+    if (!ldap_servers_db_field_exists('ldap_servers', $tinyint_field_name))  {
       db_add_field('ldap_servers', $tinyint_field_name, array(
         'type' => 'int',
         'size' => 'tiny',
@@ -796,21 +839,22 @@ function ldap_servers_update_7205() {
 }
 
 
-
 /**
  * Add LDAP Referrals fields in schema
  */
 function ldap_servers_update_7206() {
-  db_add_field(
-    'ldap_servers',
-    'followrefs',
-    array(
-      'type' => 'int',
-      'size' => 'tiny',
-      'not null' => FALSE,
-      'default' => 0,
-    )
-  );
+  if (!ldap_servers_db_field_exists('ldap_servers', 'followrefs')) {
+    db_add_field(
+      'ldap_servers',
+      'followrefs',
+      array(
+        'type' => 'int',
+        'size' => 'tiny',
+        'not null' => FALSE,
+        'default' => 0,
+      )
+    );
+  }
 }
 
 function ldap_servers_install_update_schema($schema, &$change_log) {
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 44dd65fd..844c9149 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.module
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_servers.module
@@ -32,7 +32,7 @@ define('LDAP_SERVERS_ENC_TYPE_SHA', 8);
 define('LDAP_SERVERS_ENC_TYPE_SALTED_SHA', 9);
 define('LDAP_SERVERS_ENC_TYPE_CLEARTEXT', 10);
 
-define('LDAP_SERVERS_CYPHER_MODE', 'cfb', 12);
+define('LDAP_SERVERS_CYPHER_MODE', 'cfb');
 
 define('LDAP_SERVERS_BIND_METHOD_SERVICE_ACCT', 1);
 define('LDAP_SERVERS_BIND_METHOD_USER', 2);
@@ -93,6 +93,8 @@ define('LDAP_INVALID_DN_SYNTAX', 0x22);
 
 define('LDAP_IS_LEAF', 0x23);
 define('LDAP_ALIAS_DEREF_PROBLEM', 0x24);
+if ( ! defined('LDAP_DEREF_NEVER') )
+  define('LDAP_DEREF_NEVER', 0x25);
 
 define('LDAP_INAPPROPRIATE_AUTH', 0x30);
 define('LDAP_INVALID_CREDENTIALS', 0x31);
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 ed765068..c0487de9 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
@@ -71,8 +71,13 @@ function ldap_servers_settings_submit($form, &$form_state) {
     if ($new_encyption != $old_encyption) {
       $servers = db_query("SELECT sid, bindpw FROM {ldap_servers} WHERE bindpw is not NULL AND bindpw <> ''")->fetchAllAssoc('sid');
       foreach ($servers as $sid => $server) {
-        $decrypted_bind_pwd = ldap_servers_decrypt($server->bindpw, $old_encyption);
-        $rencrypted = ldap_servers_encrypt($decrypted_bind_pwd, $new_encyption);
+        if ($server->bindpw != '') {
+          $decrypted_bind_pwd = ldap_servers_decrypt($server->bindpw, $old_encyption);
+          $rencrypted = ldap_servers_encrypt($decrypted_bind_pwd, $new_encyption);
+        }
+        else {
+          $rencrypted = '';
+        }
         db_query("UPDATE {ldap_servers} SET bindpw = :bindpw WHERE sid = :sid", array(':bindpw' => $rencrypted, ':sid' => $sid));
       }
     }
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 3a9e9492..e0f9640a 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
@@ -330,21 +330,27 @@ function ldap_servers_test_form_submit($form, &$form_state) {
       $results_tables['groupfromDN'][] = array("Groups from DN", theme('item_list', array('items' => $groups_from_dn, 'type' => 'ul')));
     }
 
-    list($has_errors, $more_results, $ldap_user) = ldap_servers_test_user_mapping($values['testing_drupal_username'], $ldap_server);
+  }
 
-    $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);
-    }
-    $form_state['ldap_server_test_data'] = array(
-      'username' => $values['testing_drupal_username'],
-      'group_entry' => $group_entry,
-      'results_tables' => $results_tables,
-    );
-    if (isset($ldap_user)) {
-      $form_state['ldap_server_test_data']['ldap_user'] = $ldap_user;
-    }
+  list($has_errors, $more_results, $ldap_user) = ldap_servers_test_user_mapping($values['testing_drupal_username'], $ldap_server);
+
+  $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);
+  }
+  $form_state['ldap_server_test_data'] = array(
+    'username' => $values['testing_drupal_username'],
+    'results_tables' => $results_tables,
+  );
+
+  if (isset($ldap_user)) {
+    $form_state['ldap_server_test_data']['ldap_user'] = $ldap_user;
+  }
+
+  if ( isset($group_entry) ) {
+    $form_state['ldap_server_test_data']['group_entry'] = $group_entry;
   }
+  
 }
 
 /**
diff --git a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_types/LdapTypeOpenLdap.class.php b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_types/LdapTypeOpenLdap.class.php
index 5585fd35..a940e3dd 100644
--- a/drupal7/sites/all/modules/ldap/ldap_servers/ldap_types/LdapTypeOpenLdap.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_servers/ldap_types/LdapTypeOpenLdap.class.php
@@ -1,4 +1,4 @@
-  <?php
+<?php
 
 /**
  * @file
diff --git a/drupal7/sites/all/modules/ldap/ldap_sso/ldap_sso.info b/drupal7/sites/all/modules/ldap/ldap_sso/ldap_sso.info
index 8f3913d5..bfc2236e 100644
--- a/drupal7/sites/all/modules/ldap/ldap_sso/ldap_sso.info
+++ b/drupal7/sites/all/modules/ldap/ldap_sso/ldap_sso.info
@@ -6,9 +6,9 @@ dependencies[] = ldap_authentication
 core = 7.x
 configure = admin/config/people/ldap/authentication
 
-; Information added by Drupal.org packaging script on 2014-01-08
-version = "7.x-2.0-beta8"
+; Information added by Drupal.org packaging script on 2016-08-07
+version = "7.x-2.0-beta11"
 core = "7.x"
 project = "ldap"
-datestamp = "1389150511"
+datestamp = "1470608343"
 
diff --git a/drupal7/sites/all/modules/ldap/ldap_sso/ldap_sso.module b/drupal7/sites/all/modules/ldap/ldap_sso/ldap_sso.module
index 91d28c4d..715fcea1 100644
--- a/drupal7/sites/all/modules/ldap/ldap_sso/ldap_sso.module
+++ b/drupal7/sites/all/modules/ldap/ldap_sso/ldap_sso.module
@@ -66,7 +66,7 @@ function ldap_sso_boot() {
         }
 
         require_once DRUPAL_ROOT . '/includes/common.inc';
-        require_once DRUPAL_ROOT . '/includes/path.inc';
+        require_once DRUPAL_ROOT . '/' . variable_get('path_inc', 'includes/path.inc');
         $ldap_authentication_conf = variable_get('ldap_authentication_conf', array());
 
         if (isset($ldap_authentication_conf['seamlessLogin']) && $ldap_authentication_conf['seamlessLogin'] == 1 && ($login_attempted != 'true')) {
@@ -286,8 +286,6 @@ function ldap_sso_user_login_sso() {
     global $user;
     $user = ldap_authentication_user_login_authenticate_validate(array(), $fake_form_state, TRUE);
 
-    // Reload the account to ensure we have a fully populated user object.
-    $user = user_load($user->uid);
 
     if ($detailed_watchdog_log) {
       $watchdog_tokens['!uid'] = is_object($user) ? $user->uid : NULL;
@@ -295,6 +293,9 @@ function ldap_sso_user_login_sso() {
     }
 
     if ($user && $user->uid > 0) {
+      // Reload the account to ensure we have a fully populated user object.
+      $user = user_load($user->uid);
+
       if ($auth_conf->seamlessLogin == 1) {
         if ($detailed_watchdog_log) {
           watchdog('ldap_authentication', 'ldap_sso_user_login_sso.remote_user.user_success.seamlessLogin', $watchdog_tokens, WATCHDOG_DEBUG);
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 16a00070..75fed6d2 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,9 @@ files[] = LdapServerTest.class.php
 files[] = LdapTestFunctions.class.php
 files[] = LdapUserTestCase.class.php
 
-; Information added by Drupal.org packaging script on 2014-01-08
-version = "7.x-2.0-beta8"
+; Information added by Drupal.org packaging script on 2016-08-07
+version = "7.x-2.0-beta11"
 core = "7.x"
 project = "ldap"
-datestamp = "1389150511"
+datestamp = "1470608343"
 
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 8a14b28f..d59ea7dc 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/LdapUserConf.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_user/LdapUserConf.class.php
@@ -606,14 +606,11 @@ class LdapUserConf {
         if (!$ldap_user_prov_entry_exists) {
           $user_entity->ldap_user_prov_entries['und'][] = array(
             'value' =>  $ldap_user_prov_entry,
-            'format' => NULL,
-            'save_value' => $ldap_user_prov_entry,
           );
-          $edit = array(
-            'ldap_user_prov_entries' => $user_entity->ldap_user_prov_entries,
-          );
-          $account = user_load($account->uid);
-          $account = user_save($account, $edit);
+
+          // Save the field without calling user_save()
+          field_attach_presave('user', $user_entity);
+          field_attach_update('user', $user_entity);
         }
 
       }
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 9eccc522..6b7c8f0e 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/LdapUserConfAdmin.class.php
+++ b/drupal7/sites/all/modules/ldap/ldap_user/LdapUserConfAdmin.class.php
@@ -288,7 +288,7 @@ class LdapUserConfAdmin extends LdapUserConf {
     );
 */
 
-    $form['server_mapping_preamble'] = array(
+    $form['basic_to_drupal']['server_mapping_preamble'] = array(
       '#type' => 'markup',
       '#markup' => t('
 The relationship between a Drupal user and an LDAP entry is defined within the LDAP server configurations.
@@ -300,7 +300,6 @@ When more than one ldap server is enabled for provisioning data (or simply more
 mappings need to be setup for each server.  If no tables are listed below, you have not enabled any provisioning servers at
 the top of this form.
 '),
-
     );
 
     foreach (array(LDAP_USER_PROV_DIRECTION_TO_DRUPAL_USER, LDAP_USER_PROV_DIRECTION_TO_LDAP_ENTRY) as $direction) {
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 4a5e603c..c5ed0778 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
@@ -134,7 +134,7 @@ function _ldap_user_orphans($ldap_user_conf) {
             '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' => $query),
+            array('%sid' => $sid, '%query' => serialize($query)),
             WATCHDOG_ERROR);
           continue;
         }
@@ -156,21 +156,22 @@ function _ldap_user_orphans($ldap_user_conf) {
       foreach ($puid_x_puid_attrs as $puid_attr => $puids) {
         foreach ($puids as $puid => $user_data) {
 
-          $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/$uid/edit";
-            }
-            else {
-               _user_cancel(array(), $account, $ldap_user_conf->orphanedDrupalAcctBehavior);
+          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/$uid/edit";
+              }
+              else {
+                 _user_cancel(array(), $account, $ldap_user_conf->orphanedDrupalAcctBehavior);
+              }
             }
           }
         }
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 2c510a5a..af5e56c6 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.info
+++ b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.info
@@ -23,9 +23,9 @@ files[] = tests/ldap_user.test
 stylesheets[all][] = ldap_user.css
 configure = admin/config/people/ldap/user
 
-; Information added by Drupal.org packaging script on 2014-01-08
-version = "7.x-2.0-beta8"
+; Information added by Drupal.org packaging script on 2016-08-07
+version = "7.x-2.0-beta11"
 core = "7.x"
 project = "ldap"
-datestamp = "1389150511"
+datestamp = "1470608343"
 
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 9ca42b2a..c1ac6346 100644
--- a/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.module
+++ b/drupal7/sites/all/modules/ldap/ldap_user/ldap_user.module
@@ -225,6 +225,7 @@ function ldap_user_ldap_attributes_needed_alter(&$attributes, $params) {
       case 'ldap_user_insert_drupal_user':
       case 'ldap_user_update_drupal_user':
       case 'ldap_user_ldap_associate':
+      case 'all':
         $attributes[$ldap_server->user_attr] = ldap_servers_set_attribute_map(@$attributes[$ldap_server->user_attr]); // array($ldap_server->user_attr, 0, NULL);
         $attributes[$ldap_server->mail_attr] = ldap_servers_set_attribute_map(@$attributes[$ldap_server->mail_attr]);
         $attributes[$ldap_server->picture_attr] = ldap_servers_set_attribute_map(@$attributes[$ldap_server->picture_attr]);
@@ -528,10 +529,11 @@ function ldap_user_form_user_register_form_alter(&$form, $form_state) {
   }
   $ldap_user_conf = ldap_user_conf();
   if ($ldap_user_conf->disableAdminPasswordField == TRUE) {
-    $form['account']['pass']['#required'] = FALSE;
-    $form['account']['pass']['#disabled'] = TRUE;
+    $form['account']['pass']['#type'] = 'value';
     $form['account']['pass']['#value'] = user_password(20);
-    $form['account']['pass']['#description'] = t('An LDAP setting at /admin/config/people/ldap/user has disabled the password fields. Drupal will store a 20 character random password in the Drupal "users" table, and the user will login with their LDAP password.');
+    $form['account']['pass_disabled']['#type'] = 'fieldset';
+    $form['account']['pass_disabled']['#title'] = t('Password');
+    $form['account']['pass_disabled'][]['#markup'] = t('An LDAP setting at /admin/config/people/ldap/user has disabled the password fields. Drupal will store a 20 character random password in the Drupal "users" table, and the user will login with their LDAP password.');
   }
 
   $ldap_fieldset = array();
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 2e1e3bbc..16461a2c 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 2014-01-08
-version = "7.x-2.0-beta8"
+; Information added by Drupal.org packaging script on 2016-08-07
+version = "7.x-2.0-beta11"
 core = "7.x"
 project = "ldap"
-datestamp = "1389150511"
+datestamp = "1470608343"
 
diff --git a/drupal7/sites/all/modules/piwik/piwik.admin.inc b/drupal7/sites/all/modules/piwik/piwik.admin.inc
index 644b967e..312d4c8f 100644
--- a/drupal7/sites/all/modules/piwik/piwik.admin.inc
+++ b/drupal7/sites/all/modules/piwik/piwik.admin.inc
@@ -235,7 +235,7 @@ function piwik_admin_settings_form($form_state) {
     '#type' => 'checkboxes',
     '#title' => t('Track messages of type'),
     '#default_value' => variable_get('piwik_trackmessages', array()),
-    '#description' => t('This will track the selected message types shown to users. Tracking of form validation errors may help you identifying usability issues in your site. Every message is tracked as one individual event. Messages from excluded pages cannot tracked.'),
+    '#description' => t('This will track the selected message types shown to users. Tracking of form validation errors may help you identifying usability issues in your site. Every message is tracked as one individual event. Messages from excluded pages cannot be tracked.'),
     '#options' => array(
       'status' => t('Status message'),
       'warning' => t('Warning message'),
@@ -387,6 +387,8 @@ function piwik_admin_settings_form($form_state) {
   }
 
   // Code snippet settings.
+  $user_access_add_js_snippets = !user_access('add JS snippets for piwik');
+  $user_access_add_js_snippets_permission_warning = $user_access_add_js_snippets ? ' <em>' . t('This field has been disabled because you do not have sufficient permissions to edit it.') . '</em>' : '';
   $form['advanced']['codesnippet'] = array(
     '#type' => 'fieldset',
     '#title' => t('Custom JavaScript code'),
@@ -398,6 +400,7 @@ function piwik_admin_settings_form($form_state) {
     '#type' => 'textarea',
     '#title' => t('Code snippet (before)'),
     '#default_value' => variable_get('piwik_codesnippet_before', ''),
+    '#disabled' => $user_access_add_js_snippets,
     '#rows' => 5,
     '#description' => t('Code in this textarea will be added <strong>before</strong> _paq.push(["trackPageView"]).')
   );
@@ -405,6 +408,7 @@ function piwik_admin_settings_form($form_state) {
     '#type' => 'textarea',
     '#title' => t('Code snippet (after)'),
     '#default_value' => variable_get('piwik_codesnippet_after', ''),
+    '#disabled' => $user_access_add_js_snippets,
     '#rows' => 5,
     '#description' => t('Code in this textarea will be added <strong>after</strong> _paq.push(["trackPageView"]). This is useful if you\'d like to track a site in two accounts.')
   );
diff --git a/drupal7/sites/all/modules/piwik/piwik.info b/drupal7/sites/all/modules/piwik/piwik.info
index 3334d13f..9a1f7506 100644
--- a/drupal7/sites/all/modules/piwik/piwik.info
+++ b/drupal7/sites/all/modules/piwik/piwik.info
@@ -5,9 +5,9 @@ package = Statistics
 configure = admin/config/system/piwik
 files[] = piwik.test
 test_dependencies[] = token
-; Information added by Drupal.org packaging script on 2016-04-23
-version = "7.x-2.8"
+; Information added by Drupal.org packaging script on 2016-08-09
+version = "7.x-2.9"
 core = "7.x"
 project = "piwik"
-datestamp = "1461442443"
+datestamp = "1470779970"
 
diff --git a/drupal7/sites/all/modules/piwik/piwik.module b/drupal7/sites/all/modules/piwik/piwik.module
index 600e2dda..db682aba 100644
--- a/drupal7/sites/all/modules/piwik/piwik.module
+++ b/drupal7/sites/all/modules/piwik/piwik.module
@@ -60,6 +60,11 @@ function piwik_permission() {
       'description' => t('Enter PHP code in the field for tracking visibility settings.'),
       'restrict access' => TRUE,
     ),
+    'add JS snippets for piwik' => array(
+      'title' => t('Add JavaScript snippets'),
+      'description' => 'Enter JavaScript code snippets for advanced Piwik functionality.',
+      'restrict access' => TRUE,
+    ),
   );
 }
 
@@ -112,7 +117,7 @@ function piwik_page_alter(&$page) {
     $link_settings = array();
     $link_settings['trackMailto'] = variable_get('piwik_trackmailto', 1);
 
-    if (module_exists('colorbox') && ($track_colorbox = variable_get('googleanalytics_trackcolorbox', 1))) {
+    if (module_exists('colorbox') && ($track_colorbox = variable_get('piwik_trackcolorbox', 1))) {
       $link_settings['trackColorbox'] = $track_colorbox;
     }
 
diff --git a/drupal7/sites/all/modules/piwik/piwik.test b/drupal7/sites/all/modules/piwik/piwik.test
index cddd2850..64fb9543 100644
--- a/drupal7/sites/all/modules/piwik/piwik.test
+++ b/drupal7/sites/all/modules/piwik/piwik.test
@@ -6,6 +6,13 @@
  */
 class PiwikBasicTest extends DrupalWebTestCase {
 
+  /**
+   * User without permissions to edit snippets.
+   *
+   * @var \StdClass
+   */
+  protected $noSnippetUser;
+
   public static function getInfo() {
     return array(
       'name' => t('Piwik basic tests'),
@@ -23,6 +30,8 @@ class PiwikBasicTest extends DrupalWebTestCase {
     );
 
     // User to set up piwik.
+    $this->noSnippetUser = $this->drupalCreateUser($permissions);
+    $permissions[] = 'add JS snippets for piwik';
     $this->admin_user = $this->drupalCreateUser($permissions);
     $this->drupalLogin($this->admin_user);
   }
@@ -36,6 +45,22 @@ class PiwikBasicTest extends DrupalWebTestCase {
     $edit['piwik_site_id'] = $this->randomName(2);
     $this->drupalPost('admin/config/system/piwik', $edit, 'Save configuration');
     $this->assertRaw(t('A valid Piwik site ID is an integer only.'), '[testPiwikConfiguration]: Invalid Piwik site ID number validated.');
+
+    // User should have access to code snippets.
+    $this->assertFieldByName('piwik_codesnippet_before');
+    $this->assertFieldByName('piwik_codesnippet_after');
+    $this->assertNoFieldByXPath("//textarea[@name='piwik_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is enabled.');
+    $this->assertNoFieldByXPath("//textarea[@name='piwik_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is enabled.');
+
+    // Login as user without JS permissions.
+    $this->drupalLogin($this->noSnippetUser);
+    $this->drupalGet('admin/config/system/piwik');
+
+    // User should *not* have access to snippets, but create fields.
+    $this->assertFieldByName('piwik_codesnippet_before');
+    $this->assertFieldByName('piwik_codesnippet_after');
+    $this->assertFieldByXPath("//textarea[@name='piwik_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is disabled.');
+    $this->assertFieldByXPath("//textarea[@name='piwik_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is disabled.');
   }
 
   function testPiwikPageVisibility() {
