View source
<?php
function express_dashboard_user_user_login(&$edit, $account) {
$redirection = 'admin/dashboard/user';
if (empty($_GET['destination']) && !is_null($redirection) && (!isset($_POST['form_id']) || $_POST['form_id'] != 'user_pass_reset')) {
$edit['redirect'] = $redirection;
}
}
function express_dashboard_user_express_dashboard($variables) {
$variables['user'] = array(
'title' => 'User',
'callback' => 'express_dashboard_user_content',
'weight' => -99,
'access arguments' => array(
'use user dashboard',
),
);
return $variables;
}
function express_dashboard_user_permission() {
return array(
'use user dashboard' => array(
'title' => 'Use the User Dashboard',
'description' => 'Access the user dashboard',
),
);
}
function express_dashboard_user_content() {
global $user;
$vars['user'] = (array) $user;
$excluded_roles = array(
'authenticated user',
);
foreach ($vars['user']['roles'] as $rid => $role) {
if (in_array($role, $excluded_roles)) {
unset($vars['user']['roles'][$rid]);
}
}
$output['user_profile']['widgets']['user']['title'] = $user->name;
$output['user_profile']['widgets']['user']['content']['#markup'] = theme('express_dashboard_user_profile', (array) $vars);
return $output;
}
function express_dashboard_user_theme(&$existing, $type, $theme, $path) {
$registry = array();
$template_dir = drupal_get_path('module', 'express_dashboard_user') . '/templates';
$registry['express_dashboard_user_profile'] = array(
'template' => 'express-dashboard-user-profile',
'path' => $template_dir,
'render element' => 'elements',
);
return $registry;
}
function express_dashboard_user_secure_permissions($role) {
$permissions = array(
'authenticated user' => array(
'use user dashboard',
),
'administrator' => array(
'use user dashboard',
),
'content_editor' => array(
'use user dashboard',
),
'developer' => array(
'use user dashboard',
),
'edit_my_content' => array(
'use user dashboard',
),
'site_owner' => array(
'use user dashboard',
),
);
if (isset($permissions[$role])) {
return $permissions[$role];
}
}