Skip to content

Instantly share code, notes, and snippets.

@kevee
Created October 19, 2011 04:37
Show Gist options
  • Save kevee/1297480 to your computer and use it in GitHub Desktop.
Save kevee/1297480 to your computer and use it in GitHub Desktop.
BadCamp 2011 Open Atrium as a Campus Intranet presentation
<?php
/**
* Implementation of hook_atrium_account_links_alter()
* Here we can add new items to the account list
*/
function mymodule_atrium_account_links_alter(&$links, $space = null) {
array_splice($links, 3, 0, 'placeholder');
$links[3] = array('title' => 'Change theme', 'href' => 'user/'. $user->uid .'/edit/theme_select');
}
/**
* Implementation of hook_spaces_dashboard_block_access_alter
* This is where we turn off blocks that a user doesn't have access to
*/
function mymodule_spaces_dashboard_block_access_alter(&$access) {
$block_access = variable_get('mycsumb_dashboard_blocks_access', array());
global $user;
foreach ($access as $block_delta => $allowed) {
if($block_access[$block_delta]) {
$this_access = false;
foreach($block_access[$block_delta] as $rid) {
if($user->roles[$rid]) {
$this_access = true;
}
}
$access[$block_delta] = $this_access;
}
}
}
/**
* Implementation of hook_spaces_presets_alter
* Alter the default dashboard settings in code.
*/
function mymodule_spaces_presets_alter(&$items) {
$blocks = &$items['atrium_groups_private']->value['context']['spaces_dashboard-custom-1:reaction:block']['blocks'];
// Remove "Welcome" block.
unset($blocks['atrium-welcome_member']);
// Add "Latest discussions" block.
$blocks['views-blog_listing-block_1'] = array(
'module' => 'views',
'delta' => 'blog_listing-block_2',
'region' => 'content',
'weight' => 1,
);
}
/**
* Defining a custom space tab that can be edited easily
* using context + features
*/
function mymodule_menu() {
$items['students'] = array(
'title' => 'Students',
'menu_name' => 'features',
'page callback' => 'mymodule_pages_simple',
'page arguments' => array('students'),
'access arguments' => array('access students space'),
'type' => MENU_NORMAL_ITEM,
);
}
/**
* Implementation of hook_perm
*/
function mymodule_perm() {
return array('access students space');
}
/**
* Useful menu callback to make an empty space page with a context that can be edited
*/
function mymodule_pages_simple($space) {
$context = context_load("mymodule_space_". $space);
if (!$context) {
$context = ctools_export_new_object('context');
$context->name = "mymodule_space_". $space;
$context->description = 'MyCSUMB Space for '. ucfirst($space);
$context->tag = 'MyCSUMB Spaces';
context_save($context);
}
context_set('spaces', $space, "mymodule_space_". $space);
context_set('context', "mymodule_space_". $space, $context);
return '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment