[development] hook_user('categories')
William Roboly
wilco at nurf.com
Wed Apr 29 02:14:35 UTC 2009
Hi David, I hope this helps you out:
You'll now note this function _user_categories($account) which invokes
the hook_categories(), so you can in fact simply build your categories
that way.
Here is an example of some code from a project I was working on (it
will give you an idea of what you can do with it):
======
function custom_categories($uid, $type, $type_name) {
$content = array();
if (user_access('edit own extended permissions')) {
$content['content_profile_'. $type] = array(
'#theme' => 'content_profile_display_view',
'#edit_link' => content_profile_get_settings($type, 'edit_link'),
'#uid' => $uid,
'#style' => $style,
'#content_type' => $type,
'#weight' => content_profile_get_settings($type, 'weight'),
'#suffix' => '<br />',
);
// Working around the bug described at http://drupal.org/node/302873
module_load_include('inc', 'content_profile', 'content_profile.theme');
}
$content['#prefix'] = '<p id="content-profile-view">';
$content['#suffix'] = '</p>';
return $content;
}
======
I'm also using the content_profile module as an API for added
functions. But those can be replaced with whatever functions you want.
I hope that is of use to you.
-wilco
Quoting "David Cohen" <drupal at dave-cohen.com>:
> Sometime in the 5.x-6.x timeframe, the API for hook_user($op ==
> 'categories') changed in a major way. No longer is the $account
> parameter passed in, and I think the data structure to be returned
> gained a lot of options. But I can't find the documentation for this.
> Its not in the 5.x to 6.x page on d.o (http://drupal.org/node/114774),
> nor is it reflected on http://api.drupal.org/api/function/hook_user/6.
>
> Can someone point me to general doc, or an example of how to emulate the
> following logic in D6. The logic is basically to show the user an edit
> category only if they have permission to change their own settings.
>
> if ($op == 'categories') {
> if (user_access('edit own extended permissions') &&
> $user->uid == $account->uid) {
> // build the data structure
> }
> }
>
> The above logic wont apply in D6 because $account is not passed in, and
> the return value is expected to have new menu data structure elements
> which take the place of that logic. But I'm struggle to figure out, in
> part because I can't find the doc.
>
> thanks.
>
>
More information about the development
mailing list