Galleries listing empty in og galleries admin
neurojavi - December 21, 2007 - 01:58
| Project: | OG Galleries |
| Version: | 5.x-1.7 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | neurojavi |
| Status: | needs review |
Description
Hi:
I had a the following problem:
A user with administer og galleries permissions goes to galleries (node/xx/galleries) and always gets an "No galleries available" message.
Only user 0 can see this list.
After some research, i've found that the problem is in og_galleries_db_rewrite_sql
We use $user->og_groups but it's possible that this was not initialized at that moment (for example in the admin page). So we need to do an user_load...
This is the change I propose to db_rewrite hook
function og_galleries_db_rewrite_sql($query, $table, $field) {
if (!user_access('administer site configuration') && ($field =='vid' || $field =='tid')) {
global $user;
// we have to perform a load in order to assure that the $user->og_groups bits are present.
if ($user->uid) {
$user = user_load(array('uid' => $user->uid));
}
else {
$user->og_groups = array();
}
$op = (arg(0) == 'node' && (arg(1) == 'add' || arg(2) == 'edit')) ? 'create' : 'list';This solved the problem for me.
I've attached a patch for your review.
| Attachment | Size |
|---|---|
| og_galleries.module.patch | 707 bytes |
