#781792 by flobruit: Fix for user role condition when not using english as default...
authoryoung hahn
Wed, 28 Jul 2010 22:02:42 +0000 (22:02 +0000)
committeryoung hahn
Wed, 28 Jul 2010 22:02:42 +0000 (22:02 +0000)
plugins/context_condition_user.inc

index 0e3909e..fc2ebb0 100644 (file)
@@ -6,15 +6,24 @@
  */
 class context_condition_user extends context_condition {
   function condition_values() {
-    return drupal_map_assoc(user_roles());
+    $values = array();
+    foreach (user_roles() as $rid => $role_name) {
+      if ($rid == DRUPAL_ANONYMOUS_RID) {
+        $values['anonymous user'] = $role_name;
+      }
+      elseif ($rid == DRUPAL_AUTHENTICATED_RID) {
+        $values['authenticated user'] = $role_name;
+      }
+      else {
+        $values[$role_name] = $role_name;
+      }
+    }
+    return $values;
   }
 
   function execute($account) {
     $roles = $account->roles;
     foreach ($roles as $rid => $role) {
-      if ($rid == DRUPAL_ANONYMOUS_RID || $rid == DRUPAL_AUTHENTICATED_RID) {
-        $role = t($role);
-      }
       foreach ($this->get_contexts($role) as $context) {
         $this->condition_met($context, $role);
       }