'aid', 'title' => t('Activity'), 'help' => t('Activity table stuff help'), ); $data['activity']['aid'] = array( 'title' => t('Activity id'), 'help' => t('The id of the activity item'), 'field' => array( 'handler' => 'views_handler_field', 'click sortable' => TRUE, ), ); $data['activity']['uid'] = array( 'title' => t('User id'), 'help' => t('The user id of the user who triggered the activity.'), 'filter' => array( 'handler' => 'views_handler_filter_user_current' ), 'relationship' => array( 'handler' => 'views_handler_relationship', 'base' => 'users', 'relationship field' => 'uid', 'label' => t('Activity: Users'), ) ); $data['activity']['module'] = array( 'title' => t('Module'), 'help' => t('The module that triggered the activity'), 'field' => array( 'handler' => 'views_handler_field', 'click sortable' => TRUE, ), 'filter' => array( 'handler' => 'activity_views_handler_filter_module', ), 'sort' => array( 'handler' => 'views_handler_sort', ), ); $data['activity']['type'] = array( 'title' => t('Type'), 'help' => t('The type of activity'), 'field' => array( 'handler' => 'views_handler_field', 'click sortable' => TRUE, ), 'filter' => array( 'handler' => 'activity_views_handler_filter_type', ), 'sort' => array( 'handler' => 'views_handler_sort', ), ); $data['activity']['operation'] = array( 'title' => t('Operation'), 'help' => t('The operation done'), 'field' => array( 'handler' => 'views_handler_field', 'click sortable' => TRUE, ), 'filter' => array( 'handler' => 'activity_views_handler_filter_operation', ), 'sort' => array( 'handler' => 'views_handler_sort', ), ); $data['activity']['created'] = array( 'title' => t('Created'), 'help' => t('The date of the activity'), 'field' => array( 'handler' => 'views_handler_field_date', 'click sortable' => TRUE, ), 'filter' => array( 'handler' => 'views_handler_filter_date', ), 'sort' => array( 'handler' => 'views_handler_sort_date', ), ); $data['activity']['data'] = array( 'title' => t('Data'), 'help' => t('The serialized data of the activity, user id, node id, etc...'), 'field' => array( 'handler' => 'activity_views_handler_field_serial', 'click sortable' => FALSE, ), ); $data['activity_targets']['table']['group'] = t('Activity'); $data['activity_targets']['table']['join'] = array( 'activity' => array( 'left_field' => 'aid', 'field' => 'aid', ), ); $data['activity_targets']['target_uid'] = array( 'title' => t('Target User'), 'help' => t('The user id to target'), 'field' => array( 'handler' => 'views_handler_field', 'click sortable' => TRUE, ), 'relationship' => array( 'handler' => 'views_handler_relationship', 'base' => 'users', 'relationship field' => 'uid', 'label' => t('Activity Target: Users'), ), ); $data['activity_targets']['target_role'] = array( 'title' => t('Target Role'), 'help' => t('The target role'), 'field' => array( 'handler' => 'views_handler_field', 'click sortable' => TRUE, ), 'filter' => array( 'handler' => 'activity_views_handler_filter_role', ), 'sort' => array( 'handler' => 'activity_views_sort', ), ); return $data; } /** * Implementation of hook_views_handler */ function activity_views_handlers() { $handlers = array( 'info' => array( 'path' => drupal_get_path('module','activity') . '/views', ), 'handlers' => array( 'activity_views_handler_field_serial' => array( 'parent' => 'views_handler_field', ), 'activity_views_handler_filter_module' => array( 'parent' => 'views_handler_filter_in_operator', ), 'activity_views_handler_filter_role' => array( 'parent' => 'views_handler_filter_in_operator', ), 'activity_views_handler_filter_operation' => array( 'parent' => 'views_handler_filter_in_operator', ), 'activity_views_handler_filter_type' => array( 'parent' => 'views_handler_filter_in_operator', ), ), ); return $handlers; } /** * Implementation of hook_views_default_views(). */ function activity_views_default_views() { $views = array(); $view = new view; $view->name = 'all_activity'; $view->description = 'View all activity'; $view->tag = 'activity'; $view->view_php = ''; $view->base_table = 'activity'; $view->is_cacheable = FALSE; $view->api_version = 2; $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ $handler = $view->new_display('default', 'Defaults', 'default'); $handler->override_option('relationships', array( 'uid' => array( 'label' => 'Users', 'required' => 1, 'id' => 'uid', 'table' => 'activity', 'field' => 'uid', 'relationship' => 'none', ), )); $handler->override_option('fields', array( 'name' => array( 'label' => 'Name', 'link_to_user' => 1, 'exclude' => 0, 'id' => 'name', 'table' => 'users', 'field' => 'name', 'relationship' => 'uid', ), 'created' => array( 'label' => 'Date', 'date_format' => 'small', 'custom_date_format' => '', 'exclude' => 0, 'id' => 'created', 'table' => 'activity', 'field' => 'created', 'relationship' => 'none', 'override' => array( 'button' => 'Override', ), ), 'data' => array( 'label' => 'Data', 'alter' => array( 'alter_text' => FALSE, 'text' => '', 'make_link' => FALSE, 'path' => '', 'alt' => '', 'prefix' => '', 'suffix' => '', 'trim' => FALSE, 'max_length' => '', 'word_boundary' => TRUE, 'ellipsis' => TRUE, 'strip_tags' => FALSE, 'html' => FALSE, ), 'exclude' => 0, 'id' => 'data', 'table' => 'activity', 'field' => 'data', 'relationship' => 'none', 'link_object' => '1', 'override' => array( 'button' => 'Override', ), 'target_role' => 'all', ), 'module' => array( 'label' => 'Module', 'exclude' => 0, 'id' => 'module', 'table' => 'activity', 'field' => 'module', 'relationship' => 'none', ), 'operation' => array( 'label' => 'Operation', 'exclude' => 0, 'id' => 'operation', 'table' => 'activity', 'field' => 'operation', 'relationship' => 'none', ), 'type' => array( 'label' => 'Type', 'exclude' => 0, 'id' => 'type', 'table' => 'activity', 'field' => 'type', 'relationship' => 'none', ), )); $handler->override_option('access', array( 'type' => 'perm', 'perm' => 'view public activity', )); $handler->override_option('title', 'All Activity'); $handler->override_option('items_per_page', 25); $handler->override_option('style_plugin', 'table'); $handler->override_option('style_options', array( 'grouping' => '', 'override' => 1, 'sticky' => 0, 'order' => 'asc', 'columns' => array( 'name' => 'name', 'created' => 'created', 'data' => 'data', 'module' => 'module', 'operation' => 'operation', 'type' => 'type', ), 'info' => array( 'name' => array( 'sortable' => 0, 'separator' => '', ), 'created' => array( 'sortable' => 0, 'separator' => '', ), 'data' => array( 'separator' => '', ), 'module' => array( 'sortable' => 0, 'separator' => '', ), 'operation' => array( 'sortable' => 0, 'separator' => '', ), 'type' => array( 'sortable' => 0, 'separator' => '', ), ), 'default' => '-1', )); $handler->override_option('row_plugin', 'activity'); $handler->override_option('row_options', array( 'messages' => 1, )); $handler = $view->new_display('page', 'Page', 'page_1'); $handler->override_option('use_pager', '1'); $handler->override_option('style_plugin', 'default'); $handler->override_option('style_options', NULL); $handler->override_option('path', 'activity/view'); $handler->override_option('menu', array( 'type' => 'none', 'title' => '', 'description' => '', 'weight' => 0, 'name' => 'navigation', )); $handler->override_option('tab_options', array( 'type' => 'none', 'title' => '', 'description' => '', 'weight' => 0, )); $views[$view->name] = $view; return $views; } /** * Implementation of hook_views_plugins(). */ function activity_views_plugins() { return array( 'module' => 'activity', 'row' => array( 'activity' => array( 'title' => t('Activity'), 'help' => t('Display the activity with the standard activity view.'), 'handler' => 'activity_views_plugin_row_activity_view', 'path' => drupal_get_path('module', 'activity') . '/views', 'base' => array('activity'), 'theme' => 'views_view_row_activity', 'uses options' => TRUE, 'type' => 'normal', 'help topic' => 'style-activity', ), ), ); } /** * Template handler for theme_views_view_row_activity(). */ function template_preprocess_views_view_row_activity(&$vars) { $options = $vars['options']; $vars['activity'] = ''; // Make sure var is defined. $aid = $vars['row']->aid; if (!is_numeric($aid)) { return; } $activity = activity_load($aid); if (empty($activity)) { return; } $vars['row']->activity_message = activity_token_replace($activity); }