In the 'edit' screen for homebox pages, the translated names are (displayed and) stored in the settings['roles'] property.

This means _homebox_user_access_view_homebox() (which compares against the untranslated names) will always return false.

Patch attached. Please test the update function (I did, but not fully).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mguillermin’s picture

I had the same issue on a French website.

Your patch worked fine for me (though I didn't test the "database update" part as I didn't need it).

flocondetoile’s picture

I had the same issue on a french site.
I have to apply the patch manually on the section about the file homebox.module. Problems with the section that no matches the lines of the module (i checked it and seems to be OK, but i don't know the syntax of the batch git).

Otherwise, your patch works fine. All is now OK and users can access to their homebox tab in their profil.
This works without update the database.
I execute the script to update the database, and the update works fine too.

Thanks.

chrbak’s picture

I tried to commit the patch but after running the update my current homebox pages were having problems.
At the administrator page of Homebox the names of my homebox pages converted to the letter 'a'... and when i went to the edit page of one of them the data weren't loaded at all.
Therefore i tried the below change of code and worked fine for me. Instead of (at line 1572) :

  if (array_search($role, $user->roles)) {

The code :

  $rl = user_role_load_by_name($role);
  if (array_key_exists($rl->rid, $user->roles)) {
mgifford’s picture

This is instead of this fragment?

diff --git a/homebox.module b/homebox.module
index 74dfb85..7cf18f0 100644
--- a/homebox.module
+++ b/homebox.module
@@ -1564,15 +1564,9 @@ function _homebox_user_access_view_homebox($page, $require_login = FALSE) {
   }
   // Check page object for role restrictions
   elseif ($page->settings['roles']) {
-    // Iterate each role to look for a match
-    foreach ($page->settings['roles'] as $role) {
-      if (array_search($role, $user->roles)) {
-        return TRUE;
-      }
-    }
-
-    // No matches on restricted role
-    return FALSE;
+    // See which Role IDs are also in the user object
+    $matching_roles = array_intersect($page->settings['roles'], array_keys($user->roles));
+    return !empty($matching_roles);
   }
   else {
     // If here, no access
roderik’s picture

Looks like it, yes. The full change in that fragment is not really necessary, it was just some optimization.

I have a hunch that you can also just replace array_search($role, $user->roles) by array_search($role, $user->roles, TRUE) .

mgifford’s picture

Ok, so what then needs to be done before this patch (which is nearly 2 years old) marked RTBC? From #3 it seems like a new patch is in order.

Tomefa’s picture

Issue summary: View changes

See next comment

Tomefa’s picture

Here is the working patch file made with the #3 comment information.
It's working for me now.

Needs review on this patch and add it to the next release of Homebox.
It's really important for all the multi-language website.

ThanksHere is the working patch file made with the #3 comment information.
It's working for me now.

Needs review on this patch and add it to the next release of Homebox.
It's really important for all the multi-language website.

Thanks

Tomefa’s picture

Priority: Major » Critical
Tomefa’s picture

Version: 7.x-2.x-dev » 7.x-2.0-beta7
Tomefa’s picture

Version: 7.x-2.0-beta7 » 7.x-2.x-dev
Issue tags: +Needs Review
mgifford’s picture

I just tested it here in a bilingual environment http://sc0b30340f99fad8.s3.simplytest.me/fr/testbox

Seemed to work.

jsacksick’s picture

Issue tags: -
FileSize
536 bytes

Patch rerolled against dev.

drumm’s picture

Status: Needs review » Fixed

Thanks, committed!

  • drumm committed 4a1db9b on 7.x-2.x authored by jsacksick
    Issue #1467140 by Tomefa, roderik, jsacksick: Per-role access...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.