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' => 'user_access', 'access arguments' => array('access content'), 'type' => MENU_NORMAL_ITEM, ); } if (module_exists('taxonomy')) { $items['taxonomy/term'] = array( 'title' => t('Taxonomy'), 'description' => t('Custom taxonomy term callback.'), 'page callback' => 'spaces_core_taxonomy', 'page arguments' => array(1), 'access callback' => 'user_access', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); } return $items; } /** * 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_id, &$form) { 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_nodeapi(). */ function spaces_core_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { switch ($op) { case "view": switch ($node->type) { case 'book': // Hide top book navigation if page is unusually short if (strlen(strip_tags($node->content['body']['#value'])) > 1000) { $node->content['spaces_book'] = array( '#value' => theme('book_navigation', $node, false), '#weight' => -100, ); } break; } break; } } /** * Implementation of hook_user(). */ function spaces_core_user($op, &$edit, &$account, $category = NULL) { switch ($op) { case 'view': global $user; context_set('spaces', 'user', $account->uid); if ($user->uid == $account->uid) { $links = array(); $links['user']['title'] = t('Edit my account'); $links['user']['href'] = 'user/'. $account->uid .'/edit'; $links['user']['custom'] = true; context_set('spaces', 'links', $links); } break; } } /** * Implementation of hook_default_views(). */ function spaces_core_views_default_views() { $default_views = array( '_spaces_core_views_blog', '_spaces_core_views_blog_comments', '_spaces_core_views_ref_blog2book', '_spaces_core_views_user_posts', '_spaces_core_views_changes', '_spaces_core_views_comments', '_spaces_core_views_taxonomy', '_spaces_core_views_tags', ); foreach ($default_views as $v) { $view = call_user_func($v); if (is_object($view) && $view->name) { $views[$view->name] = $view; } } return $views; } /** * Implementation of hook_context_define(). */ function spaces_core_context_define() { $items = array(); if (module_exists('blog')) { $items[] = array( 'namespace' => 'spaces', 'attribute' => 'feature', 'value' => 'blog', 'node' => array('blog'), 'views' => array('spaces_blog', 'spaces_blog_comments'), 'block' => array( array( 'module' => 'views', 'delta' => 'spaces_blog_comments', 'region' => 'right', 'weight' => -11, ), ), 'spaces' => array( 'label' => t('Blog'), 'description' => t('A member blog and team discussion space.'), 'menu' => array( 'blog' => array('title' => t('Blog'), 'weight' => -5), ), ), ); } if (module_exists('book')) { $items[] = array( 'namespace' => 'spaces', 'attribute' => 'feature', 'value' => 'book', '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( 'documents' => array('title' => t('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_ui_set('node', 'book'); $message = t('Please add your first book page to get started.'); $button = spaces_node_links(); $o = "$message
$button"; return $o; } } /** * @TODO: Abstract this into a hook -- we will not always be testing * against OG conditions! * * Page call back to handle taxonomy listing * * If a term is requested in a group context we use a group aware page * when then term's vocabulary is related to any group targeted node * types. If it is from a vocab that doesn't relate to any group aware * content or is request outsite of a group contexts we use a group * agnostic listing. * * @param $tid * The term id to generate a listing page for. * * @return * A themed taxonomy listing page. */ function spaces_core_taxonomy($tid) { if (is_numeric($tid) && $t = taxonomy_get_term($tid)) { $v = taxonomy_get_vocabulary($t->vid); } if ($v && $t) { $view = views_get_view('spaces_taxonomy'); $content = views_build_view('page', $view, array($tid), true, 25); if (is_object($t) && is_object($v)) { drupal_set_title($v->name .': '. $t->name); // set taxonomy context context_set('taxonomy', array('vid' => $t->vid, 'tid' => $t->tid)); if ($use_gid) { context_set('taxonomy', 'group_vocab', true); } } return $content; } return drupal_not_found(); exit; } /** * Implementation of hook_spaces_node_links_alter(); */ function spaces_core_spaces_node_links_alter(&$links) { if (isset($links['book'])) { if ($space = spaces_get_space()) { if ($space->feature_access('book') && arg(0) == 'node' && is_numeric(arg(1))) { $pid = arg(1); $links['book']['href'] = 'node/add/book/parent/'. $pid; } } } } /** * BLOCKS ============================================================= */ function _spaces_core_block_tags() { $space = spaces_get_space(); if (context_get('spaces', 'feature') == 'taxonomy') { $terms = taxonomy_terms_parse_string(arg(2)); $tid = $terms['tids'][0]; if ($term = taxonomy_get_term($tid)) { $vocab = taxonomy_get_vocabulary($term->vid); $view = views_get_view('spaces_tags'); $view->filter[1]['value'] = array($term->vid); $block['content'] = views_build_view('block', $view, array($space->sid)); $block['subject'] = $vocab->name; return $block; } } } /** * Spaces version of the book nav block -- shows all root books in a group */ function _spaces_core_block_book() { $space = spaces_get_space(); $block = array(); if ($space) { if ($node = menu_get_object()) { $current_bid = empty($node->book['bid']) ? 0 : $node->book['bid']; } // Only display this block when the user is browsing a book. $title = db_result(db_query(db_rewrite_sql('SELECT n.title FROM {node} n WHERE n.nid = %d'), $node->book['bid'])); // Only show the block if the user has view access for the top-level node. if ($title) { // Set customized title $features = spaces_features(); $feature_menu = space_customizer_menu::customize($space, 'book', $features['book']->spaces['menu']); $block['subject'] = isset($feature_menu['documents']['title']) ? $feature_menu['documents']['title'] : t('Documents'); // Generate book tree per book node in current space $output = ''; 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)) { foreach($view->result as $row) { $tree = menu_tree_all_data(book_menu_name($row->nid), $node->book); $output .= menu_tree_output($tree); } } } $block['content'] = $output; } } return $block; } /** * Group-aware book tree generation */ function _spaces_core_book_tree($parent = 0, $depth = 3, $unfold = array(), $sid = NULL) { if (!$sid && $space = spaces_get_space()) { $sid = $space->sid; } if ($sid) { $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid JOIN {og_ancestry} og ON og.nid = b.nid WHERE n.status = 1 AND og.group_nid = %d ORDER BY b.weight, n.title'), $sid); while ($node = db_fetch_object($result)) { $list = isset($children[$node->parent]) ? $children[$node->parent] : array(); $list[] = $node; $children[$node->parent] = $list; } if ($tree = book_tree_recurse($parent, $depth, $children, $unfold)) { return ' '; } } else { return ''; } } /* VIEWS */ function _spaces_core_views_blog() { $view = new stdClass(); $view->name = 'spaces_blog'; $view->description = t('Provides a default blog listing that is filterable by uid.'); $view->access = array(); $view->view_args_php = ''; $view->menu = TRUE; $view->menu_title = t('Blog'); $view->page = TRUE; $view->page_title = t('Blog'); $view->page_empty = ''; $view->page_empty_format = '2'; $view->page_type = 'teaser'; $view->url = 'blog'; $view->use_pager = TRUE; $view->nodes_per_page = '5'; $view->block = TRUE; $view->block_title = t('Recent blog posts'); $view->block_empty = "" . t('No blog entries found.') . "
"; $view->block_empty_format = '1'; $view->block_type = 'spaces_datetitle'; $view->nodes_per_block = '3'; $view->block_more = TRUE; $view->sort = array ( array ( 'tablename' => 'node', 'field' => 'created', 'sortorder' => 'DESC', 'options' => 'normal', ), ); $view->argument = array ( array ( 'type' => 'uid', 'argdefault' => '2', 'title' => '%1\'s Blog', 'options' => '', 'wildcard' => 'all', 'wildcard_substitution' => '', ), array ( 'type' => 'node_feed', 'argdefault' => '2', 'title' => 'Blog', 'options' => '', 'wildcard' => '', 'wildcard_substitution' => '', ), ); $view->field = array ( array ( 'tablename' => 'node', 'field' => 'created', 'label' => '', 'handler' => 'views_handler_field_date_small', ), array ( 'tablename' => 'node', 'field' => 'title', 'label' => '', 'handler' => 'views_handler_field_nodelink', 'options' => 'link', ), ); $view->filter = array ( array ( 'tablename' => 'node', 'field' => 'status', 'operator' => '=', 'options' => '', 'value' => '1', ), array ( 'tablename' => 'node', 'field' => 'type', 'operator' => 'OR', 'options' => '', 'value' => array ( 0 => 'blog', ), ), array ( 'tablename' => 'spaces', 'field' => 'type', 'operator' => 'all', 'options' => '', 'value' => 'all', ), ); $view->exposed_filter = array(); $view->requires = array(node); return $view; } function _spaces_core_views_blog_comments() { $view = new stdClass(); $view->name = 'spaces_blog_comments'; $view->description = t(''); $view->access = array(); $view->view_args_php = ''; $view->page = FALSE; $view->block = TRUE; $view->block_title = t('Recent Comments'); $view->block_empty = "" . t('No recent comments.') . "
"; $view->block_empty_format = '1'; $view->block_type = 'spaces_datetitle'; $view->nodes_per_block = '5'; $view->sort = array ( array ( 'tablename' => 'node_comment_statistics', 'field' => 'last_comment_timestamp', 'sortorder' => 'DESC', 'options' => 'normal', ), ); $view->argument = array(); $view->field = array ( array ( 'tablename' => 'comments', 'field' => 'subject', 'label' => t('Comment'), 'handler' => 'views_handler_field_commentlink', 'options' => 'link', ), array ( 'tablename' => 'comments', 'field' => 'name', 'label' => t('By'), ), array ( 'tablename' => 'node', 'field' => 'title', 'label' => t('On Post'), 'handler' => 'views_handler_field_nodelink', 'options' => 'nolink', ), array ( 'tablename' => 'node_comment_statistics', 'field' => 'last_comment_timestamp', 'label' => t('Date'), 'handler' => 'views_handler_field_date_small', ), ); $view->filter = array ( array ( 'tablename' => 'node', 'field' => 'status', 'operator' => '=', 'options' => '', 'value' => '1', ), array ( 'tablename' => 'node_comment_statistics', 'field' => 'comment_count', 'operator' => '>', 'options' => '', 'value' => '0', ), array ( 'tablename' => 'node', 'field' => 'type', 'operator' => 'OR', 'options' => '', 'value' => array ( 0 => 'blog', ), ), array ( 'tablename' => 'spaces', 'field' => 'type', 'operator' => 'all', 'options' => '', 'value' => 'all', ), array ( 'tablename' => 'node_comment_statistics', 'field' => 'last_comment_timestamp', 'operator' => '>', 'options' => -1*SPACES_ARCHIVE_TIMESTAMP, 'value' => 'now', ), ); $view->exposed_filter = array(); $view->requires = array(node_comment_statistics, comments, node); return $view; } function _spaces_core_views_ref_blog2book() { $view = new stdClass(); $view->name = 'ref_blog2book'; $view->description = 'Provides a list of blog entries that refer to the given book page.'; $view->access = array(); $view->view_args_php = ''; $view->page = FALSE; $view->block = TRUE; $view->block_title = t('Discussions'); $view->block_type = 'table'; $view->nodes_per_block = '50'; $view->sort = array ( array ( 'tablename' => 'node', 'field' => 'created', 'sortorder' => 'DESC', 'options' => 'normal', ), ); $view->argument = array( array( 'type' => 'content: field_referenced_book_page', 'argdefault' => '1', ), ); $view->field = array ( array ( 'tablename' => 'node', 'field' => 'title', 'label' => t('Title'), 'handler' => 'views_handler_field_nodelink', 'options' => 'link', ), array ( 'tablename' => 'users', 'field' => 'name', 'label' => t('Author'), ), array ( 'tablename' => 'node', 'field' => 'created', 'label' => t('Posted'), 'handler' => 'views_handler_field_date_small', ), ); $view->filter = array ( array ( 'tablename' => 'node', 'field' => 'type', 'operator' => 'OR', 'options' => '', 'value' => array ( 0 => 'blog', ), ), array ( 'tablename' => 'spaces', 'field' => 'type', 'operator' => 'all', 'options' => '', 'value' => 'all', ), ); $view->requires = array(node, node_comment_statistics, users); return $view; } function _spaces_core_views_user_posts() { $view = new stdClass(); $view->name = 'spaces_user_posts'; $view->description = t('Shows updated posts.'); $view->access = array(); $view->view_args_php = ''; $view->page = TRUE; $view->page_title = t('Recent Posts'); $view->page_empty = ''.t('No recent posts found').'
'; $view->page_empty_format = '2'; $view->page_type = 'table'; $view->url = 'userposts'; $view->use_pager = TRUE; $view->nodes_per_page = '25'; $view->block = TRUE; $view->block_title = t('Recent Posts'); $view->block_empty = ''.t('No recent posts found').'
'; $view->block_empty_format = '1'; $view->block_type = 'table'; $view->nodes_per_block = '10'; $view->block_more = TRUE; $view->sort = array ( array ( 'tablename' => 'node_comment_statistics', 'field' => 'last_comment_timestamp', 'sortorder' => 'DESC', 'options' => 'normal', ), ); $view->argument = array( array ( 'type' => 'uidtouch', 'argdefault' => '7', 'title' => "%1's Posts", ), ); $view->field = array ( array ( 'tablename' => 'node', 'field' => 'title', 'label' => 'Title', 'handler' => 'views_handler_field_nodelink_with_mark', 'options' => 'link', ), array ( 'tablename' => 'node', 'field' => 'type', 'label' => 'Type', ), array ( 'tablename' => 'node_comment_statistics', 'field' => 'comment_count', 'label' => 'Replies', 'handler' => 'views_handler_comments', ), array ( 'tablename' => 'node_comment_statistics', 'field' => 'last_comment_timestamp', 'label' => 'Last Post', 'handler' => 'views_handler_field_since', 'options' => 1, ), ); $view->filter = array ( array ( 'tablename' => 'node', 'field' => 'status', 'operator' => '=', 'options' => '', 'value' => '1', ), array ( 'tablename' => 'node', 'field' => 'type', 'operator' => 'NOR', 'options' => '', 'value' => array_merge(og_get_types('group'), array('shout')), ), array ( 'tablename' => 'spaces', 'field' => 'type', 'operator' => 'all', 'options' => '', 'value' => 'all', ), ); $view->requires = array(node_comment_statistics, node); return $view; } function _spaces_core_views_changes() { $view = new stdClass(); $view->name = 'spaces_changes'; $view->description = t('Displays a list of recently modified nodes.'); $view->access = array(); $view->view_args_php = ''; $view->page = TRUE; $view->page_title = t('Recent Changes'); $view->page_type = 'table'; $view->url = 'changes'; $view->use_pager = TRUE; $view->nodes_per_page = '25'; $view->block = TRUE; $view->block_title = t('Recent Changes'); $view->block_empty = "" . t('No recent changes.') . "
"; $view->block_empty_format = '1'; $view->block_type = 'spaces_datetitle'; $view->nodes_per_block = '5'; $view->argument = array(); $view->sort = array ( array ( 'tablename' => 'node', 'field' => 'changed', 'sortorder' => 'DESC', 'options' => 'normal', ), ); $view->field = array ( array ( 'tablename' => 'og_node_data', 'field' => 'title', 'label' => 'Group', 'handler' => 'spaces_views_handler_crayon_name', 'options' => 'og', ), array ( 'tablename' => 'node', 'field' => 'title', 'label' => t('Title'), 'handler' => 'views_handler_field_nodelink', 'options' => 'link', ), array ( 'tablename' => 'node', 'field' => 'changed', 'label' => t('Changed'), 'handler' => 'views_handler_field_since', 'options' => 1, ), array ( 'tablename' => 'node', 'field' => 'type', 'label' => t('Type'), ), array ( 'tablename' => 'users', 'field' => 'name', 'label' => t('Author'), ), ); if (variable_get('spaces_calendar_feed_itemtype', '')) { $excluded = array('shout', variable_get('spaces_calendar_feed_itemtype', '')); } else { $excluded = array('shout'); } $view->filter = array ( array ( 'tablename' => 'node', 'field' => 'type', 'operator' => 'NOR', 'options' => '', 'value' => array_merge(og_get_types('group'), $excluded), ), array ( 'tablename' => 'og_uid_node', 'field' => 'currentuid', 'operator' => '=', 'options' => '', 'value' => '***CURRENT_USER***', ), array ( 'tablename' => 'spaces', 'field' => 'type', 'operator' => 'active', 'options' => '', 'value' => 'all', ), array ( 'tablename' => 'node', 'field' => 'changed', 'operator' => '>', 'options' => -1*SPACES_ARCHIVE_TIMESTAMP, 'value' => 'now', ), ); $view->exposed_filter = array(); $view->requires = array('node', 'users', 'og_node_data', 'og_uid_node'); return $view; } function _spaces_core_views_comments() { $view = new stdClass(); $view->name = 'spaces_comments'; $view->description = t('Displays a listing of recent comments'); $view->access = array(); $view->view_args_php = ''; $view->page = TRUE; $view->page_title = t('Recent Comments'); $view->page_empty = ''. t('No recent comments found.') .'
'; $view->page_empty_format = '2'; $view->page_type = 'table'; $view->url = 'comments'; $view->use_pager = TRUE; $view->nodes_per_page = '25'; $view->block = TRUE; $view->block_title = t('Recent Comments'); $view->block_empty = "". t('No recent comments.') ."
"; $view->block_empty_format = '1'; $view->block_type = 'spaces_datetitle'; $view->nodes_per_block = '5'; $view->sort = array ( array ( 'tablename' => 'node_comment_statistics', 'field' => 'last_comment_timestamp', 'sortorder' => 'DESC', 'options' => 'normal', ), ); $view->argument = array(); $view->field = array ( array ( 'tablename' => 'og_node_data', 'field' => 'title', 'label' => 'Group', 'handler' => 'spaces_views_handler_crayon_name', 'options' => 'og', ), array ( 'tablename' => 'comments', 'field' => 'subject', 'label' => t('Comment'), 'handler' => 'views_handler_field_commentlink', 'options' => 'link', ), array ( 'tablename' => 'comments', 'field' => 'name', 'label' => t('By'), ), array ( 'tablename' => 'node', 'field' => 'title', 'label' => t('On Post'), 'handler' => 'views_handler_field_nodelink', 'options' => 'nolink', ), array ( 'tablename' => 'node', 'field' => 'type', 'label' => t('Type'), ), array ( 'tablename' => 'node_comment_statistics', 'field' => 'last_comment_timestamp', 'label' => t('Date'), 'handler' => 'views_handler_field_date_small', ), ); $view->filter = array ( array ( 'tablename' => 'node', 'field' => 'status', 'operator' => '=', 'options' => '', 'value' => '1', ), array ( 'tablename' => 'node_comment_statistics', 'field' => 'comment_count', 'operator' => '>', 'options' => '', 'value' => '0', ), array ( 'tablename' => 'og_uid_node', 'field' => 'currentuid', 'operator' => '=', 'options' => '', 'value' => '***CURRENT_USER***', ), array ( 'tablename' => 'spaces', 'field' => 'type', 'operator' => 'active', 'options' => '', 'value' => 'all', ), array ( 'tablename' => 'node_comment_statistics', 'field' => 'last_comment_timestamp', 'operator' => '>', 'options' => -1*SPACES_ARCHIVE_TIMESTAMP, 'value' => 'now', ), ); $view->exposed_filter = array(); $view->requires = array(node_comment_statistics, comments, node, og_node_data, og_uid_node); return $view; } function _spaces_core_views_taxonomy() { $view = new stdClass(); $view->name = 'spaces_taxonomy'; $view->description = t('Spaces taxonomy override.'); $view->access = $view->field = $view->exposed_filter = array (); $view->page = TRUE; $view->page_empty = ''. t('No entries found.') . '
'; $view->page_empty_format = '2'; $view->page_type = 'table'; $view->use_pager = TRUE; $view->nodes_per_page = '20'; $view->field = array( array ( 'tablename' => 'node', 'field' => 'title', 'label' => 'Title', 'handler' => 'views_handler_field_nodelink', 'sortable' => '1', 'options' => 'link', ), array ( 'tablename' => 'node', 'field' => 'created', 'label' => 'Date', 'handler' => 'views_handler_field_date_small', 'sortable' => '1', 'defaultsort' => 'DESC', ), array ( 'tablename' => 'node', 'field' => 'type', 'label' => 'Type', 'sortable' => '1', ), ); $view->sort = array (); $view->argument = array ( array ( 'type' => 'taxid', 'argdefault' => '1', 'options' => '0', 'wildcard' => '', 'wildcard_substitution' => '', ), ); $view->filter = array ( array ( 'tablename' => 'node', 'field' => 'status', 'operator' => '=', 'options' => '', 'value' => '1', ), array ( 'tablename' => 'spaces', 'field' => 'type', 'operator' => 'active', 'options' => '', 'value' => 'all', ), ); $view->requires = array(node); return $view; } function _spaces_core_views_tags() { $view = new stdClass(); $view->name = 'spaces_tags'; $view->description = ''; $view->access = array(); $view->page = FALSE; $view->block = TRUE; $view->block_title = t('Tags'); $view->block_empty = ''. t('No tags found.') .'
'; $view->block_empty_format = '1'; $view->block_type = 'tagadelic'; $view->nodes_per_block = '20'; $view->sort = array (); $view->filter = array ( array ( 'tablename' => 'node', 'field' => 'status', 'operator' => '=', 'options' => '', 'value' => '1', ), array ( 'tablename' => 'term_data', 'field' => 'vid', 'operator' => 'AND', 'options' => '', 'value' => array ( 0 => '11', ), ), array ( 'tablename' => 'spaces', 'field' => 'type', 'operator' => 'active', 'options' => '', 'value' => 'all', ), ); $view->argument = array (); $view->field = array ( array ( 'tablename' => 'term_node', 'field' => 'name', 'label' => '', 'options' => 'link', ), ); $view->exposed_filter = array(); $view->requires = array(term_node, node, term_data); return $view; }