t('Documents'), 'description' => t('Displays the parent book node for a given spaces group.'), 'page callback' => 'spaces_core_documents', 'page arguments' => array(1), 'access callback' => 'spaces_feature_access', 'access arguments' => array('book'), 'type' => MENU_NORMAL_ITEM, ); } return $items; } /** * Implementation of hook_menu_alter(). * * Purge router items provided by the blog module so that views-based * replacements will work. */ function spaces_core_menu_alter(&$callbacks) { if (module_exists('blog')) { $unset = array('blog', 'blog/%user/feed', 'blog/%user_uid_optional'); foreach ($unset as $path) { if (!empty($callbacks[$path]) && $callbacks[$path]['module'] == 'blog') { unset($callbacks[$path]); } } } } /** * Implementation of hook_help(). */ function spaces_core_help($page) { switch (context_get('spaces', 'feature')) { case 'blog': return "
". t('The blog is a team discussion place where you can post and discuss information relevant to your team.') ."
"; case 'book': return "". t('The book provides a place for you to post documents and other reference material.') ."
"; } } /** * Implementation of hook_block(). */ function spaces_core_block($op = 'list', $delta = 0) { if ($op == 'list') { $blocks['tags']['info'] = t('Spaces Core: Tag chart'); $blocks['book']['info'] = t('Spaces Core: Book navigation'); return $blocks; } else if ($op == 'view') { switch ($delta) { case 'tags': return _spaces_core_block_tags(); case 'book': return _spaces_core_block_book(); } } } /** * Implementation of hook_form_alter(). */ function spaces_core_form_alter(&$form, $form_state, $form_id) { // Book mods if ($form['#id'] == 'node-form' && book_type_is_allowed($form['#node']->type)) { $node = $form['#node']; if (!empty($form['book'])) { // Fieldset mods $form['book']['#weight'] = !empty($form['body_field']['#weight']) ? $form['body_field']['#weight'] : 0; $form['book']['#collapsible'] = $form['book']['#collapsed'] = FALSE; if (!empty($form['book']['bid']['#options'])) { // Remove "none" option -- do not allow book pages to be orphaned unset($form['book']['bid']['#options'][0]); // Filter book options by current space if ($view = views_get_view('spaces_book_current')) { $view->set_display(); $view->set_items_per_page(0); $view->execute(); // Collect books in this space into an array $books = array(); $books[$node->nid] = 1; if (is_array($view->result) && count($view->result)) { foreach($view->result as $row) { $books[$row->nid] = 1; } } // Use collected array to filter options foreach ($form['book']['bid']['#options'] as $k => $v) { if (is_numeric($k) && !isset($books[$k])) { unset($form['book']['bid']['#options'][$k]); } } } } } } switch ($form_id) { case 'user_edit': unset($form['og_settings']); // Remove the og email settings. break; case 'comment_form': if (!drupal_get_title()) drupal_set_title(t('Reply')); break; } } /** * Implementation of hook_default_views(). */ function spaces_core_views_default_views() { $views = array(); if (module_load_include('inc', 'spaces_core', 'spaces_core_views') !== FALSE) { $default_views = _spaces_core_views_list_views(); foreach ($default_views as $v) { $function = '_spaces_core_views_'. $v; if (function_exists($function)) { $view = call_user_func($function); if (is_object($view) && $view->name) { $views[$view->name] = $view; } } else { watchdog(WATCHDOG_ERROR, 'An exported view could not be loaded because the function !function was not found.', array('!function' => $function)); } } } return $views; } /** * Implementation of hook_context_default_contexts(). */ function spaces_core_context_default_contexts() { $items = array(); $items[] = array ( 'namespace' => 'spaces', 'attribute' => 'feature', 'value' => 'blog', 'menu' => 'blog', 'node' => array ('blog'), 'views' => array ('spaces_blog'), 'block' => array ( array ( 'module' => 'views', 'delta' => 'spaces_blog-block_1', 'region' => 'right', 'weight' => '11', ), array ( 'module' => 'views', 'delta' => 'spaces_blog_comments-block_1', 'region' => 'right', 'weight' => '10', ), ), 'spaces' => array( 'label' => t('Blog'), 'description' => t('A blog for team communications.'), 'menu' => array( array('title' => t('Blog'), 'href' => 'blog'), ), 'types' => array(), ), ); if (module_exists('book')) { $items[] = array( 'namespace' => 'spaces', 'attribute' => 'feature', 'value' => 'book', 'menu' => 'documents', 'node' => array('book'), 'block' => array( array( 'module' => 'spaces_core', 'delta' => 'book', 'region' => 'right', 'weight' => -11, ), ), 'spaces' => array( 'label' => t('Documents'), 'description' => t('A document section for maintaining a knowledge base.'), 'menu' => array( array('title' => t('Documents'), 'href' => 'documents'), ), 'types' => array('og'), ), ); } if (module_exists('taxonomy')) { $items[] = array( 'namespace' => 'spaces', 'attribute' => 'feature', 'value' => 'taxonomy', 'views' => array('spaces_taxonomy'), 'block' => array( array( 'module' => 'spaces_core', 'delta' => 'tags', 'region' => 'right', 'weight' => -11, ), ), ); } return $items; } /* * This function acts as a fallback in case users delete or re-path the root book page at 'documents' */ function spaces_core_documents() { // og version of the book root lookup if ($space = spaces_get_space()) { if ($view = views_get_view('spaces_book_current')) { $view->set_display(); $view->set_items_per_page(0); $view->execute(); if (is_array($view->result) && count($view->result)) { $row = array_shift($view->result); drupal_goto('node/'. $row->nid); } } context_set_by_condition('node', 'book'); $message = t('Please add your first book page to get started.'); $button = theme('context_links', context_links()); $o = "