6 include_once('julio_core.features.inc');
8 define('JULIO_CORE_OG_USER_REF', 'julio_og_user_group_ref');
9 define('JULIO_CORE_OG_GROUP_REF', 'julio_og_group_ref');
12 * Implements hook_menu().
14 function julio_core_menu() {
15 $items['admin/config/system/homepage-layout'] = array(
16 'title' => 'Homepage Layout',
17 'description' => 'Choose the homepage layout.',
18 'page callback' => 'drupal_get_form',
19 'page arguments' => array('julio_core_homepage_layout_select_form'),
20 'access callback' => TRUE
,
27 * Implements hook_menu_breadcrumb_alter().
29 function julio_core_menu_breadcrumb_alter(&$active_trail, $item) {
32 // hide all crumbs referencing /admin except for uid = 1
33 if ($user->uid
!= 1) {
35 foreach ($active_trail as
$index => $item) {
36 if (isset($item['link_path'])) {
37 if (strpos($item['link_path'], 'admin') === 0) {
38 unset($active_trail[$index]);
48 * Implements hook_modules_installed().
50 * TODO: This should be removed after #73 gets a better solution
52 function julio_core_modules_installed($modules) {
53 if (in_array(array('julio_homepage_slideshow_node', 'julio_homepage_slideshow'), $modules)) {
54 // we need to re-assess our homepage layout contexts because they have variable
55 // data dependent on julio_homepage_slideshow
56 context_invalidate_cache();
61 * Implements hook_modules_uninstalled().
63 * TODO: This should be removed after #73 gets a better solution
65 function julio_core_modules_uninstalled($modules) {
66 if (in_array(array('julio_homepage_slideshow_node', 'julio_homepage_slideshow'), $modules)) {
67 // we need to re-assess our homepage layout contexts because they have variable
68 // data dependent on julio_homepage_slideshow
69 context_invalidate_cache();
76 function julio_core_block_info() {
79 'info' => t('Julio: Footer Block'),
80 'cache' => DRUPAL_CACHE_GLOBAL
,
83 'group-content-links' => array(
84 'info' => t('Julio: Group Content Links'),
85 'cache' => DRUPAL_CACHE_PER_USER
,
94 function julio_core_block_view($delta = '') {
101 '#markup' => check_markup(variable_get('julio_core_footer_block_content', '<div>Click the contextual link on the right and choose "Configure Block" to change the footer text.</div>'), 'filtered_html', '', TRUE
),
105 case
'group-content-links':
107 $object = menu_get_object();
108 if (!user_is_anonymous()) {
109 if (!empty($object) && !og_is_group_type('node', $object->type
)) {
110 // try to load the parent group
111 if (og_is_group_content_type('node', $object->type
)) {
112 if (!empty($object->julio_og_group_ref
[$object->language
][0]['target_id'])) {
113 $object = node_load($object->julio_og_group_ref
[$object->language
][0]['target_id']);
118 if (!empty($object) && og_is_group_type('node', $object->type
)) {
119 $og_membership = og_get_membership('node', $object->nid
, 'user', $user->uid
);
120 if (!empty($og_membership) && $og_membership->state
== OG_STATE_ACTIVE
) {
121 // they are a member of the group load the content links
122 $links = julio_core_build_content_links($object);
123 $content = '<div class="current-group">
124 <span class="current-group-title">' .
t('Currently in: !group', array('!group' => l($object->title
, 'node/' .
$object->nid
))) .
'</span>' .
125 '<div class="group-content-links"><span class="group-content-links-leadin">' .
t('Create new') .
'</span>' .
render($links) .
'</div></div>';
127 elseif (empty($og_membership)) {
128 // they are not a member of the group load the join link
132 '#title' => t('Join @group', array('@group' => check_plain($object->title
))),
133 '#href' => 'group/node/' .
$object->nid .
'/subscribe',
136 $content = '<div class="join-group">' .
render($links) .
'</div>';
139 // they have requested membership but it is not active
140 $content = '<div class="group-pending"><span class="current-group-title">' .
t('Your membership for !group is pending', array('!group' => l($object->title
, 'node/' .
$object->nid
))) .
'</span></div>';
144 'content' => $content,
150 'content' => t('Not currently in any group'),
164 function julio_core_block_configure($delta = '') {
168 $form['julio_core_footer_block_content'] = array(
169 '#type' => 'text_format',
170 '#format' => 'filtered_html',
171 '#default_value' => variable_get('julio_core_footer_block_content', '<div>Click the contextual link on the right and choose "Configure Block" to change the footer text.</div>'),
178 function julio_core_block_save($delta = '', $edit = array()) {
181 variable_set('julio_core_footer_block_content', $edit['julio_core_footer_block_content']['value']);
186 function julio_core_build_content_links($object) {
187 $group_entities = og_get_all_group_content_bundle();
188 $groups = og_get_all_group_bundle();
191 // if we are in a top-level section add the appropriate group_type node creation links
192 if (isset($object->nid
)) {
193 switch ($object->nid
) {
194 case
variable_get('julio_clubs_nid', -1):
197 '#title' => check_plain($groups['node']['julio_club']),
198 '#href' => 'node/add/julio-club',
201 case
variable_get('julio_departments_nid', -1):
204 '#title' => check_plain($groups['node']['julio_department']),
205 '#href' => 'node/add/julio-department',
208 case
variable_get('julio_admissions_node_nid', -1):
209 // no additional links here
211 case
variable_get('julio_teams_nid', -1):
214 '#title' => check_plain($groups['node']['julio_team']),
215 '#href' => 'node/add/julio-team',
221 if (!empty($group_entities['node'])) {
222 // now add group content links
223 foreach ($group_entities['node'] as
$bundle_type => $label) {
224 if (node_access('create', $bundle_type)) {
227 '#title' => check_plain($label),
228 '#href' => 'node/add/' .
str_replace('_', '-', $bundle_type),
231 JULIO_CORE_OG_GROUP_REF
=> $object->nid
,
242 * Implements hook_block_view_alter().
244 * Can't use hook_block_view_MODULE_DELTA_alter because delta has '-'
245 * http://drupal.org/node/1076132
247 function julio_core_block_view_alter(&$data, $block) {
248 if ($block->module
== 'menu' && $block->delta
== 'menu-julio-contact-menu') {
249 $data['subject'] = '';
254 * Implements hook_form_alter().
256 function julio_core_form_node_form_alter(&$form, &$form_state, $form_id) {
257 // hide extraneous option from user
258 if (isset($form['media_nivo_slider_block'])) {
259 $form['media_nivo_slider_block'][$form['media_nivo_slider_block']['#language']]['#type'] = 'value';
260 $form['media_nivo_slider_block'][$form['media_nivo_slider_block']['#language']]['#value'] = $form['media_nivo_slider_block'][$form['media_nivo_slider_block']['#language']]['#default_value'];
265 * Implements hook_form_FORM_ID_alter
267 function julio_core_form_block_admin_configure_alter(&$form, &$form_state, $form_id) {
273 foreach ($sections as
$section) {
274 $form[$section]['#access'] = FALSE
;
279 * Implements hook_form_FORM_ID_alter
281 function julio_core_form_quicktabs_form_alter(&$form, &$form_state, $form_id) {
282 if (variable_get('julio_core_cleanup_quicktab_ui', 1)) {
283 $sections = variable_get('julio_core_cleanup_quicktab_sections', array('ajax', 'renderer', 'options'));
285 foreach ($sections as
$section) {
286 $form[$section]['#access'] = FALSE
;
289 foreach (element_children($form['qt_wrapper']['tabs']) as
$index) {
290 $form['qt_wrapper']['tabs'][$index]['type']['#options'] = array(
302 function julio_core_homepage_layout_select_form($form, &$form_state) {
303 $layouts = julio_core_get_homepage_layouts();
305 $header = array('layout' => t('Layout Preview'), 'description' => t('Description'));
309 $enabled = 0; // counter for how many enabled
310 if (!empty($layouts)) {
311 foreach ($layouts as
$layout => $details) {
312 if ($layout != 'default') {
313 if (!empty($details['icon'])) {
315 'path' => $details['icon'],
316 'alt' => t('@layout icon', array('@layout' => $layout)),
317 'attributes' => array(),
319 $icon = '<div class="homepage-layout-icon">' .
theme_image($variables) .
'</div>';
324 $options[$layout] = array(
326 'description' => check_plain($details['description']),
329 if (!$details['disabled']) {
337 if (!empty($layouts['default'])) {
338 if (!$layouts[$layouts['default']]['disabled'] && (empty($selected) || $enabled > 1)) {
339 $selected = $layouts['default'];
343 $form['layouts'] = array(
344 '#type' => 'tableselect',
345 '#header' => $header,
346 '#options' => $options,
347 '#multiple' => FALSE
,
349 '#default_value' => $selected,
350 '#empty' => t('No homepage layouts available.'),
353 $form['submit'] = array('#type' => 'submit', '#value' => t('Choose homepage layout'));
360 function julio_core_homepage_layout_select_form_submit($form, &$form_state) {
361 ctools_include('export');
362 $layouts = julio_core_get_homepage_layouts();
363 if (!empty($form_state['values']['layouts'])) {
364 // disable all non-selected homepage layouts
365 foreach ($layouts as
$layout => $details) {
366 if ($layout != $form_state['values']['layouts']) {
367 $context = context_load($layout);
368 if (!empty($context)) {
369 ctools_export_crud_disable($context->table
, $context);
374 // enable selected homepage layout
375 $context = context_load($form_state['values']['layouts']);
376 if (!empty($context)) {
377 ctools_export_crud_enable($context->table
, $context);
380 context_invalidate_cache();
385 * Helper function to manage parsing the .info file for layouts to be exposed
388 function julio_core_get_homepage_layouts() {
389 $layouts = &drupal_static(__FUNCTION__
);
391 if (!isset($layouts)) {
392 $path = drupal_get_path('module', 'julio_core');
393 $infofile = $path .
'/julio_core.info';
394 $info = drupal_parse_info_file($infofile);
395 if (!empty($info['homepage_layout'])) {
396 foreach ($info['homepage_layout'] as
$layout => $details) {
397 if (!empty($details['icon'])) {
398 $details['icon'] = $path .
'/' .
$details['icon'];
399 $context = context_load($layout);
400 if (!empty($context)) {
401 $details['disabled'] = $context->disabled
;
402 $layouts[$layout] = $details;
405 watchdog('julio_core', 'Invalid context listed in julio_core homepage layout', array(), WATCHDOG_NOTICE
);
411 if (isset($info['homepage_layout']['default'])) {
412 $layouts['default'] = $info['homepage_layout']['default'];