'Commit messages', 'page callback' => 'commitlog_operations_page', 'access arguments' => array($view_access), 'type' => MENU_SUGGESTED_ITEM, ); $items['commitlog/repository/%'] = array( 'title' => 'Commit messages', 'page callback' => 'commitlog_operations_page', 'page arguments' => array('repository', 2), 'access arguments' => array($view_access), 'type' => MENU_SUGGESTED_ITEM, ); $items['commitlog/author/%'] = array( 'title' => 'Commit messages', 'page callback' => 'commitlog_operations_page', 'page arguments' => array('author', 2), 'access arguments' => array($view_access), 'type' => MENU_SUGGESTED_ITEM, ); $items['commitlog/commit/%/%'] = array( 'title' => 'Commit', 'page callback' => 'commitlog_operations_page', 'page arguments' => array('commit', 2, 3), 'access arguments' => array($view_access), 'type' => MENU_SUGGESTED_ITEM, ); $items['user/%user/track/code'] = array( 'title' => 'Commits', 'page callback' => 'commitlog_operations_page', 'page arguments' => array('user', 1), 'access arguments' => array($view_access), 'type' => MENU_LOCAL_TASK, 'weight' => 2, ); return $items; } /** * Implementation of hook_perm(). */ function commitlog_perm() { return array('access commit messages'); } /** * Implementation of hook_theme(). */ function commitlog_theme() { return array( 'commitlog_operations_page' => array( 'arguments' => array('constraints' => NULL), ), ); } /** * Implementation of hook_views_api(). * * @return array */ function commitlog_views_api() { return array( 'api' => 2, 'path' => drupal_get_path('module', 'commitlog'). '/includes/views', ); } /** * Implementation of ctools hook_ctools_plugin_directory(). */ function commitlog_ctools_plugin_directory($module, $plugin) { if ($module == 'versioncontrol') { return "includes/plugins/$plugin"; } } /** * Page callback for the 'commitlog' family of menu paths. * * @param $type * What type of commit log listing we're creating. Supported types are 'author' and 'repository'. * @param $argument * The argument with which to filter the view. This is used as the first argument in the view in question. * @param $argument2 * Another argument to filter the view. This is used as the second argument in the view in question. */ function commitlog_operations_page($type = NULL, $argument = NULL, $argument2 = NULL) { drupal_add_css(drupal_get_path('module', 'commitlog') . '/commitlog.css', 'module'); $view = ''; if ($type == 'author' && !is_null($argument)) { $set = versioncontrol_get_views_set('user_commit_view'); $view = $set->getViewName(); } else if ($type == 'user' && !is_null($argument)) { drupal_set_title($argument->name); $argument = $argument->uid; $set = versioncontrol_get_views_set('user_commit_view'); $view = $set->getViewName(); } else if ($type == 'repository' && !is_null($argument)) { $set = versioncontrol_get_views_set('repository_commit_view'); $view = $set->getViewNameByEntity(versioncontrol_repository_load($argument)); } else if ($type == 'commit' && !is_null($argument) && !is_null($argument2)) { $set = versioncontrol_get_views_set('individual_commit_view'); $view_name = $set->getViewName(); $view = views_get_view($view_name); // Basic logic here borrowed from views_embed_view(). if (!$view || !$view->access('default')) { return drupal_not_found(); } $output = $view->preview('default', array($argument, $argument2)); $title = $view->get_title(); if (!empty($title)) { drupal_set_title($title); } return $output; } else { $set = versioncontrol_get_views_set('global_commit_view'); $view = $set->getViewName(); } return views_embed_view($view, 'default', $argument); }