Skip to content
Snippets Groups Projects
Commit 169b406e authored by Tim Steiner's avatar Tim Steiner
Browse files

[gh-233] Merging from testing into staging

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@1077 20a16fea-79d4-4915-8869-1ea9d5ebf173
parent 83b08a72
No related branches found
No related tags found
No related merge requests found
......@@ -1144,5 +1144,48 @@ function _unl_limit_menu_depth($menu_links, $depth) {
/**
* Implements hook_block_info()
*/
function unl_block_info() {
$blocks = array();
$blocks['my_sites'] = array(
'info' => 'My Sites',
);
return $blocks;
}
/**
* Implements hook_block_view()
*/
function unl_block_view($delta = '') {
switch ($delta) {
case 'my_sites':
return unl_block_view_my_sites();
break;
default:
return array();
}
}
/**
* Implements hook_block_view('my_sites').
* Displays the list of sites/roles for the current user.
*/
function unl_block_view_my_sites()
{
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'unl_site_creation.php';
$block = array();
$block['content'] = _unl_get_user_audit_content($GLOBALS['user']->name);
return $block;
}
......@@ -695,34 +695,54 @@ function unl_user_audit($form, &$form_state) {
// Otherwise, since we have a username, we can query the sub-sites and return a list of roles for each.
$username = $form_state['values']['username'];
$form['results'] = array(
'#type' => 'fieldset',
'#title' => 'Results',
);
$form['results']['roles'] = _unl_get_user_audit_content($username);
return $form;
}
/**
* Returns an array that can be passed to drupal_render() of the given user's sites/roles.
* @param string $username
*/
function _unl_get_user_audit_content($username) {
$audit_map = array();
foreach (unl_get_site_user_map('username', $username) as $site_id => $site) {
$audit_map[] = array(
'data' => l($site['uri'], $site['uri']),
'children' => $site['roles'],
);
}
$form['results'] = array(
'#type' => 'fieldset',
'#title' => 'Results',
);
if (count($audit_map) > 0) {
$form['results']['roles'] = array(
$content = array(
'#theme' => 'item_list',
'#title' => 'The user "' . $username . '" belongs to the following sites as a member of the listed roles.',
'#type' => 'ul',
'#items' => $audit_map,
);
if ($username == $GLOBALS['user']->name) {
$content['#title'] = 'You belong to the following sites as a member of the listed roles.';
} else {
$content['#title'] = 'The user "' . $username . '" belongs to the following sites as a member of the listed roles.';
}
} else {
$form['results']['roles'] = array(
$content = array(
'#type' => 'item',
'#title' => 'The user "' . $username . '" does not belong to any roles on any sites.',
);
if ($username == $GLOBALS['user']->name) {
$content['#title'] = 'You do not belong to any roles on any sites.';
} else {
$content['#title'] = 'The user "' . $username . '" does not belong to any roles on any sites.';
}
}
return $form;
return $content;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment