summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role')
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/LdapAuthorizationConsumerRole.class.php72
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.info6
2 files changed, 40 insertions, 38 deletions
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/LdapAuthorizationConsumerRole.class.php b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/LdapAuthorizationConsumerRole.class.php
index 102f749..f6fd40b 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/LdapAuthorizationConsumerRole.class.php
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/LdapAuthorizationConsumerRole.class.php
@@ -25,7 +25,7 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
public $revokeLdapProvisionedDefault = TRUE;
public $regrantLdapProvisionedDefault = TRUE;
public $createContainersDefault = TRUE;
- public $drupalRolesByName = array();
+ private $drupalRolesByName = array();
/**
* Constructor Method
@@ -112,15 +112,15 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
public function revokeSingleAuthorization(&$user, $role_name, &$user_auth_data) {
- $user_edit = array('roles' => array_diff($user->roles, array($this->drupalRolesByName[$role_name] => $role_name)));
+ $user_edit = array('roles' => array_diff($user->roles, array($this->getDrupalRoleByName($role_name) => $role_name)));
$account = user_load($user->uid);
$user = user_save($account, $user_edit);
- $result = ($user && !isset($user->roles[$this->drupalRolesByName[$role_name]]));
+ $result = ($user && !isset($user->roles[$this->getDrupalRoleByName($role_name)]));
if ($this->detailedWatchdogLog) {
watchdog('ldap_authorization', 'LdapAuthorizationConsumerDrupalRole.revokeSingleAuthorization()
revoked: rid=%rid, role_name=%role_name for username=%username, result=%result',
- array('%rid' => $this->drupalRolesByName[$role_name], '%role_name' => $role_name, '%username' => $user->name,
+ array('%rid' => $this->getDrupalRoleByName($role_name), '%role_name' => $role_name, '%username' => $user->name,
'%result' => $result), WATCHDOG_DEBUG);
}
@@ -133,19 +133,16 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
*/
public function grantSingleAuthorization(&$user, $role_name, &$user_auth_data) {
- if (! isset($this->drupalRolesByName[$role_name])) {
+ if (is_null($this->getDrupalRoleByName($role_name))) {
watchdog('ldap_authorization', 'LdapAuthorizationConsumerDrupalRole.grantSingleAuthorization()
failed to grant %username the role %role_name because role does not exist',
array('%role_name' => $role_name, '%username' => $user->name),
WATCHDOG_ERROR);
return FALSE;
}
- debug($user->roles);
- $new_roles = $user->roles + array($this->drupalRolesByName[$role_name] => $role_name);
+ $new_roles = $user->roles + array($this->getDrupalRoleByName($role_name) => $role_name);
$user_edit = array('roles' => $new_roles);
- debug($new_roles);
- debug($user_edit);
if ($this->detailedWatchdogLog) {
watchdog('ldap_authorization', 'grantSingleAuthorization in drupal rold' . print_r($user, TRUE), array(), WATCHDOG_DEBUG);
}
@@ -157,7 +154,7 @@ 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' => $this->drupalRolesByName[$role_name], '%role_name' => $role_name, '%username' => $user->name,
+ array('%rid' => $this->getDrupalRoleByName($role_name), '%role_name' => $role_name, '%username' => $user->name,
'%result' => $result), WATCHDOG_DEBUG);
}
@@ -171,40 +168,45 @@ class LdapAuthorizationConsumerDrupalRole extends LdapAuthorizationConsumerAbstr
public function validateAuthorizationMappingTarget($map_to, $form_values = NULL, $clear_cache = FALSE) {
$has_form_values = is_array($form_values);
- $message_type = NULL;
- $message_text = NULL;
- $normalized = $this->normalizeMappings(array($map_to));
- $tokens = array('!map_to' => $map_to);
- $pass = FALSE;
- if (is_array($normalized) && isset($normalized[0][1]) && $normalized[0][1] !== FALSE ) {
- $available_authorization_ids = $this->availableConsumerIDs($clear_cache);
+ $message_type = NULL;
+ $message_text = NULL;
+ $normalized = $this->normalizeMappings(array($map_to));
+ $tokens = array('!map_to' => $map_to);
+ $pass = FALSE;
+
+ if (is_array($normalized) && isset($normalized[0][1]) && $normalized[0][1] !== FALSE ) {
+ $available_authorization_ids = $this->availableConsumerIDs($clear_cache);
$available_authorization_ids = array_map('drupal_strtolower', $available_authorization_ids);
- // debug($available_authorization_ids); debug($normalized[0]);
- $pass = (in_array(drupal_strtolower($normalized[0]), $available_authorization_ids));
- }
+ $pass = (in_array(drupal_strtolower($normalized[0]), $available_authorization_ids));
+ }
- if (!$pass) {
- $message_text = '<code>"' . t('!map_to', $tokens) . '</code>" ' . t('does not map to any existing Drupal roles. ');
+ if (!$pass) {
+ $message_text = '<code>"' . t('!map_to', $tokens) . '</code>" ' . t('does not map to any existing Drupal roles. ');
if ($has_form_values) {
$create_consumers = (isset($form_values['synchronization_actions']['create_consumers']) && $form_values['synchronization_actions']['create_consumers']);
}
else {
$create_consumers = $this->consumerConf->create_consumers;
}
- if ($create_consumers && $this->allowConsumerObjectCreation) {
- $message_type = 'warning';
+ if ($create_consumers && $this->allowConsumerObjectCreation) {
+ $message_type = 'warning';
$message_text .= t('It will be created when needed. If "!map_to" is not intentional, please fix it', $tokens);
- }
- elseif (!$this->allowConsumerObjectCreation) {
- $message_type = 'error';
- $message_text .= t('Since automatic Drupal role creation is not possible with this module, an existing role must be mapped to.');
- }
- elseif (!$create_consumers) {
- $message_type = 'error';
- $message_text .= t('Since automatic Drupal role creation is disabled, an existing role must be mapped to. Either enable role creation or map to an existing role.');
- }
-
- }
+ }
+ elseif (!$this->allowConsumerObjectCreation) {
+ $message_type = 'error';
+ $message_text .= t('Since automatic Drupal role creation is not possible with this module, an existing role must be mapped to.');
+ }
+ elseif (!$create_consumers) {
+ $message_type = 'error';
+ $message_text .= t('Since automatic Drupal role creation is disabled, an existing role must be mapped to. Either enable role creation or map to an existing role.');
+ }
+ }
return array($message_type, $message_text);
}
+
+ private function getDrupalRoleByName($role_name) {
+ $role_name_lowercase = drupal_strtolower($role_name);
+
+ return (isset($this->drupalRolesByName[$role_name_lowercase]) ? $this->drupalRolesByName[$role_name_lowercase] : NULL);
+ }
}
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.info b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.info
index 39c1848..29163f2 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.info
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/ldap/ldap_authorization/ldap_authorization_drupal_role/ldap_authorization_drupal_role.info
@@ -10,9 +10,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 2012-06-14
-version = "7.x-1.0-beta11"
+; Information added by drupal.org packaging script on 2012-08-20
+version = "7.x-1.0-beta12"
core = "7.x"
project = "ldap"
-datestamp = "1339643179"
+datestamp = "1345503423"