Hi, I've come across an error when I have anonymous users unable to flag content and they are viewing a users profile.
I tracked it down to...
function flag_content_user($op, &$edit, &$account, $category = NULL) {
global $user;
switch($op) {
case 'view':
if ($user->uid == $account->uid) {
// User is viewing their own user page, don't show them anything
return array();
}
$links = flag_content_link(FLAG_CONTENT_TYPE_USER, $account);
foreach($links as $key => $value) {
$items[] = array(
'class' => $key,
'value' => l($value['title'], $value['href'], $value['attributes']),
);
}
return array(t('Flag user') => $items);
case 'delete':
db_query("DELETE FROM {flag_content} WHERE eid = %d AND type = '%s'", $account->uid, FLAG_CONTENT_TYPE_USER);
break;
}
}It looks like if flag_content_link() returns an empty array the foreach loop in flag_content_user() never loops which results in $items array not being created. This then messes up user.module when we... return array(t('Flag user') => $items);
I was able to bandaid the problem by adding...
$items = array();
Here is what the function looks like for me now.
function flag_content_user($op, &$edit, &$account, $category = NULL) {
global $user;
switch($op) {
case 'view':
if ($user->uid == $account->uid) {
// User is viewing their own user page, don't show them anything
return array();
}
$items = array();
$links = flag_content_link(FLAG_CONTENT_TYPE_USER, $account);
foreach($links as $key => $value) {
$items[] = array(
'class' => $key,
'value' => l($value['title'], $value['href'], $value['attributes']),
);
}
return array(t('Flag user') => $items);
case 'delete':
db_query("DELETE FROM {flag_content} WHERE eid = %d AND type = '%s'", $account->uid, FLAG_CONTENT_TYPE_USER);
break;
}
}
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | flag_content.module-186504.patch | 345 bytes | Greg Go |
Comments
Comment #1
mlncn commentedConfirming this bug (at least when using nodeprofile with an embedded profile).
And that rconstantine's proposal fixes it.
http://agaricdesign.com/project/wsf2008
Comment #2
Greg Go commentedThanks cois. Your fix works for me.
Attached is the same fix in patch form.
Comment #3
mlncn commentedChecked patch. In use. This works!
Fixes a multitude of issues with other modules.
Comment #4
kbahey commentedCommitted to 5.x
Thanks
Comment #5
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.