View source
<?php
function panels_user_profile_panels_content_types() {
$items['user_profile'] = array(
'title' => t('User profile'),
'content_types' => 'panels_admin_content_types_user_profile',
'single' => TRUE,
'render callback' => 'panels_content_user_profile',
'title callback' => 'panels_admin_title_user_profile',
);
return $items;
}
function panels_content_user_profile($subtype, $conf, $panel_args, $context) {
$account = isset($context->data) ? drupal_clone($context->data) : NULL;
$block = new stdClass();
$block->module = 'term-list';
if ($account === FALSE || $account->access == 0 && !user_access('administer users')) {
return drupal_not_found();
}
$fields = array();
foreach (module_list() as $module) {
if ($data = module_invoke($module, 'user', 'view', '', $account)) {
foreach ($data as $category => $items) {
foreach ($items as $key => $item) {
$item['class'] = "{$module}-" . $item['class'];
$fields[$category][$key] = $item;
}
}
}
}
foreach (module_implements('profile_alter') as $module) {
$function = $module . '_profile_alter';
$function($account, $fields);
}
$block->title = check_plain($account->name);
$block->content = theme('user_profile', $account, $fields);
return $block;
}
function panels_admin_content_types_user_profile() {
return array(
'description' => array(
'title' => t('User profile'),
'icon' => 'icon_user.png',
'path' => panels_get_path('content_types/user'),
'description' => t('The profile of a user.'),
'required context' => new panels_required_context(t('User'), 'user'),
'category' => array(
t('User context'),
-9,
),
),
);
}
function panels_admin_title_user_profile($subtype, $conf, $context) {
return t('"@s" user profile', array(
'@s' => $context->identifier,
));
}