diff --git a/modules/flag_bookmark/config/views.view.flag_bookmarks.json b/modules/flag_bookmark/config/views.view.flag_bookmarks.json new file mode 100644 index 0000000..ab77645 --- /dev/null +++ b/modules/flag_bookmark/config/views.view.flag_bookmarks.json @@ -0,0 +1,162 @@ +{ + "_config_name": "views.view.flag_bookmarks", + "name": "flag_bookmarks", + "description": "A page listing the current user's bookmarks at /bookmarks.", + "tag": "flag", + "disabled": false, + "base_table": "node", + "human_name": "Flag bookmarks", + "core": 0, + "display": { + "default": { + "display_title": "Defaults", + "display_plugin": "default", + "display_options": { + "query": { + "type": "views_query", + "options": [] + }, + "title": "My bookmarks", + "use_more_always": false, + "access": { + "type": "perm", + "perm": "flag bookmarks" + }, + "cache": { + "type": "none" + }, + "exposed_form": { + "type": "basic" + }, + "pager": { + "type": "full", + "options": { + "items_per_page": "25" + } + }, + "style_plugin": "table", + "style_options": { + "grouping": "", + "columns": { + "type": "type", + "title": "title", + "name": "name", + "comment_count": "comment_count", + "last_comment_timestamp": "last_comment_timestamp", + "ops": "ops" + }, + "default": "last_comment_timestamp", + "info": { + "type": { + "sortable": true + }, + "title": { + "sortable": true + }, + "name": { + "sortable": true + }, + "comment_count": { + "sortable": true + }, + "last_comment_timestamp": { + "sortable": true + } + }, + "override": false, + "sticky": true, + "order": "desc" + }, + "empty": { + "text": { + "id": "area", + "table": "views", + "field": "area", + "content": "You have not yet bookmarked any content. Click the \"Bookmark this\" link when viewing a piece of content to add it to this list.", + "format": "plain_text" + } + }, + "relationships": { + "flag_content_rel": { + "id": "flag_content_rel", + "table": "node", + "field": "flag_content_rel", + "label": "bookmarks", + "flag": "bookmarks" + }, + "uid_1": { + "id": "uid_1", + "table": "node", + "field": "uid" + } + }, + "fields": { + "type": { + "id": "type", + "table": "node", + "field": "type" + }, + "title": { + "id": "title", + "table": "node", + "field": "title" + }, + "name": { + "id": "name", + "table": "users", + "field": "name", + "relationship": "uid_1", + "label": "Author" + }, + "comment_count": { + "id": "comment_count", + "table": "node_comment_statistics", + "field": "comment_count", + "label": "Replies" + }, + "last_comment_timestamp": { + "id": "last_comment_timestamp", + "table": "node_comment_statistics", + "field": "last_comment_timestamp", + "label": "Last Post" + }, + "ops": { + "id": "ops", + "table": "flagging", + "field": "ops", + "relationship": "flag_content_rel", + "label": "Ops" + } + }, + "filters": { + "status": { + "id": "status", + "table": "node", + "field": "status", + "value": 1, + "group": "0", + "expose": { + "operator": false + } + } + } + } + }, + "page": { + "display_title": "Page", + "display_plugin": "page", + "display_options": { + "query": { + "type": "views_query", + "options": [] + }, + "path": "bookmarks", + "menu": { + "type": "normal", + "title": "My bookmarks", + "weight": "0" + } + } + } + } +} diff --git a/modules/flag_bookmark/config/views.view.flag_bookmarks_tab.json b/modules/flag_bookmark/config/views.view.flag_bookmarks_tab.json new file mode 100644 index 0000000..bb555e6 --- /dev/null +++ b/modules/flag_bookmark/config/views.view.flag_bookmarks_tab.json @@ -0,0 +1,185 @@ +{ + "_config_name": "views.view.flag_bookmarks_tab", + "name": "flag_bookmarks_tab", + "description": "Provides a tab on all users' profile pages containing bookmarks for that user.", + "tag": "flag", + "disabled": false, + "base_table": "node", + "human_name": "Flag bookmarks tab", + "core": 0, + "display": { + "default": { + "display_title": "Defaults", + "display_plugin": "default", + "display_options": { + "query": { + "type": "views_query", + "options": [] + }, + "title": "User bookmarks", + "use_more_always": false, + "access": { + "type": "perm", + "perm": "flag bookmarks" + }, + "cache": { + "type": "none" + }, + "exposed_form": { + "type": "basic" + }, + "pager": { + "type": "full", + "options": { + "items_per_page": "25" + } + }, + "style_plugin": "table", + "style_options": { + "grouping": "", + "columns": { + "type": "type", + "title": "title", + "name": "name", + "comment_count": "comment_count", + "last_comment_timestamp": "last_comment_timestamp" + }, + "default": "last_comment_timestamp", + "info": { + "type": { + "sortable": true + }, + "title": { + "sortable": true + }, + "name": { + "sortable": true + }, + "comment_count": { + "sortable": true + }, + "last_comment_timestamp": { + "sortable": true + } + }, + "override": false, + "sticky": true, + "order": "desc" + }, + "empty": { + "text": { + "id": "area", + "table": "views", + "field": "area", + "content": "This user has not yet bookmarked any content.", + "format": "plain_text" + } + }, + "relationships": { + "flag_content_rel": { + "id": "flag_content_rel", + "table": "node", + "field": "flag_content_rel", + "label": "bookmarks", + "flag": "bookmarks", + "user_scope": "any" + }, + "uid_1": { + "id": "uid_1", + "table": "node", + "field": "uid" + }, + "uid": { + "id": "uid", + "table": "flagging", + "field": "uid", + "relationship": "flag_content_rel", + "label": "bookmarks_user", + "required": true + } + }, + "fields": { + "type": { + "id": "type", + "table": "node", + "field": "type" + }, + "title": { + "id": "title", + "table": "node", + "field": "title" + }, + "name": { + "id": "name", + "table": "users", + "field": "name", + "relationship": "uid_1", + "label": "Author" + }, + "comment_count": { + "id": "comment_count", + "table": "node_comment_statistics", + "field": "comment_count", + "label": "Replies" + }, + "last_comment_timestamp": { + "id": "last_comment_timestamp", + "table": "node_comment_statistics", + "field": "last_comment_timestamp", + "label": "Last Post" + } + }, + "arguments": { + "uid": { + "id": "uid", + "table": "users", + "field": "uid", + "relationship": "uid", + "default_action": "empty", + "exception": { + "value": "" + }, + "title_enable": true, + "title": "%1's bookmarks", + "default_argument_type": "fixed", + "summary": { + "format": "default_summary" + }, + "specify_validation": true, + "validate": { + "type": "flag_bookmark_plugin_owner_perm" + } + } + }, + "filters": { + "status": { + "id": "status", + "table": "node", + "field": "status", + "value": 1, + "group": "0", + "expose": { + "operator": false + } + } + } + } + }, + "page": { + "display_title": "Page", + "display_plugin": "page", + "display_options": { + "query": { + "type": "views_query", + "options": [] + }, + "path": "user/%/bookmarks", + "menu": { + "type": "tab", + "title": "Bookmarks", + "weight": "0" + } + } + } + } +} diff --git a/modules/flag_bookmark/flag_bookmark.install b/modules/flag_bookmark/flag_bookmark.install index eb010a3..da415bf 100644 --- a/modules/flag_bookmark/flag_bookmark.install +++ b/modules/flag_bookmark/flag_bookmark.install @@ -65,3 +65,371 @@ function _flag_bookmark_install_get_suggested_node_types() { } return $existing; } + +/** + * Install two default views. + */ +function flag_bookmark_update_1000() { + $config = config('views.view.flag_bookmarks_tab'); + if ($config->isNew()) { + $config->setData( + array ( + 'name' => 'flag_bookmarks_tab', + 'description' => 'Provides a tab on all users\' profile pages containing bookmarks for that user.', + 'tag' => 'flag', + 'disabled' => false, + 'base_table' => 'node', + 'human_name' => 'Flag bookmarks tab', + 'core' => 0, + 'display' => array( + 'default' => array( + 'display_title' => 'Defaults', + 'display_plugin' => 'default', + 'display_options' => array( + 'query' => array( + 'type' => 'views_query', + 'options' => array( + ), + ), + 'title' => 'User bookmarks', + 'use_more_always' => false, + 'access' => array( + 'type' => 'perm', + 'perm' => 'flag bookmarks', + ), + 'cache' => array( + 'type' => 'none', + ), + 'exposed_form' => array( + 'type' => 'basic', + ), + 'pager' => array( + 'type' => 'full', + 'options' => array( + 'items_per_page' => '25', + ), + ), + 'style_plugin' => 'table', + 'style_options' => array( + 'grouping' => '', + 'columns' => array( + 'type' => 'type', + 'title' => 'title', + 'name' => 'name', + 'comment_count' => 'comment_count', + 'last_comment_timestamp' => 'last_comment_timestamp', + ), + 'default' => 'last_comment_timestamp', + 'info' => array( + 'type' => array( + 'sortable' => true, + ), + 'title' => array( + 'sortable' => true, + ), + 'name' => array( + 'sortable' => true, + ), + 'comment_count' => array( + 'sortable' => true, + ), + 'last_comment_timestamp' => array( + 'sortable' => true, + ), + ), + 'override' => false, + 'sticky' => true, + 'order' => 'desc', + ), + 'empty' => array( + 'text' => array( + 'id' => 'area', + 'table' => 'views', + 'field' => 'area', + 'content' => 'This user has not yet bookmarked any content.', + 'format' => 'plain_text', + ), + ), + 'relationships' => array( + 'flag_content_rel' => array( + 'id' => 'flag_content_rel', + 'table' => 'node', + 'field' => 'flag_content_rel', + 'label' => 'bookmarks', + 'flag' => 'bookmarks', + 'user_scope' => 'any', + ), + 'uid_1' => array( + 'id' => 'uid_1', + 'table' => 'node', + 'field' => 'uid', + ), + 'uid' => array( + 'id' => 'uid', + 'table' => 'flagging', + 'field' => 'uid', + 'relationship' => 'flag_content_rel', + 'label' => 'bookmarks_user', + 'required' => true, + ), + ), + 'fields' => array( + 'type' => array( + 'id' => 'type', + 'table' => 'node', + 'field' => 'type', + ), + 'title' => array( + 'id' => 'title', + 'table' => 'node', + 'field' => 'title', + ), + 'name' => array( + 'id' => 'name', + 'table' => 'users', + 'field' => 'name', + 'relationship' => 'uid_1', + 'label' => 'Author', + ), + 'comment_count' => array( + 'id' => 'comment_count', + 'table' => 'node_comment_statistics', + 'field' => 'comment_count', + 'label' => 'Replies', + ), + 'last_comment_timestamp' => array( + 'id' => 'last_comment_timestamp', + 'table' => 'node_comment_statistics', + 'field' => 'last_comment_timestamp', + 'label' => 'Last Post', + ), + ), + 'arguments' => array( + 'uid' => array( + 'id' => 'uid', + 'table' => 'users', + 'field' => 'uid', + 'relationship' => 'uid', + 'default_action' => 'empty', + 'exception' => array( + 'value' => '', + ), + 'title_enable' => true, + 'title' => '%1\'s bookmarks', + 'default_argument_type' => 'fixed', + 'summary' => array( + 'format' => 'default_summary', + ), + 'specify_validation' => true, + 'validate' => array( + 'type' => 'flag_bookmark_plugin_owner_perm', + ), + ), + ), + 'filters' => array( + 'status' => array( + 'id' => 'status', + 'table' => 'node', + 'field' => 'status', + 'value' => 1, + 'group' => '0', + 'expose' => array( + 'operator' => false, + ), + ), + ), + ), + ), + 'page' => array( + 'display_title' => 'Page', + 'display_plugin' => 'page', + 'display_options' => array( + 'query' => array( + 'type' => 'views_query', + 'options' => array( + ), + ), + 'path' => 'user/%/bookmarks', + 'menu' => array( + 'type' => 'tab', + 'title' => 'Bookmarks', + 'weight' => '0', + ), + ), + ), + ), + ) + ); + $config->save(); + } + + $config = config('views.view.flag_bookmarks'); + if ($config->isNew()) { + $config->setData( + array( + 'name' => 'flag_bookmarks', + 'description' => 'A page listing the current user\'s bookmarks at /bookmarks.', + 'tag' => 'flag', + 'disabled' => false, + 'base_table' => 'node', + 'human_name' => 'Flag bookmarks', + 'core' => 0, + 'display' => array( + 'default' => array( + 'display_title' => 'Defaults', + 'display_plugin' => 'default', + 'display_options' => array( + 'query' => array( + 'type' => 'views_query', + 'options' => array( + ), + ), + 'title' => 'My bookmarks', + 'use_more_always' => false, + 'access' => array( + 'type' => 'perm', + 'perm' => 'flag bookmarks', + ), + 'cache' => array( + 'type' => 'none', + ), + 'exposed_form' => array( + 'type' => 'basic', + ), + 'pager' => array( + 'type' => 'full', + 'options' => array( + 'items_per_page' => '25', + ), + ), + 'style_plugin' => 'table', + 'style_options' => array( + 'grouping' => '', + 'columns' => array( + 'type' => 'type', + 'title' => 'title', + 'name' => 'name', + 'comment_count' => 'comment_count', + 'last_comment_timestamp' => 'last_comment_timestamp', + 'ops' => 'ops', + ), + 'default' => 'last_comment_timestamp', + 'info' => array( + 'type' => array( + 'sortable' => true, + ), + 'title' => array( + 'sortable' => true, + ), + 'name' => array( + 'sortable' => true, + ), + 'comment_count' => array( + 'sortable' => true, + ), + 'last_comment_timestamp' => array( + 'sortable' => true, + ), + ), + 'override' => false, + 'sticky' => true, + 'order' => 'desc', + ), + 'empty' => array( + 'text' => array( + 'id' => 'area', + 'table' => 'views', + 'field' => 'area', + 'content' => 'You have not yet bookmarked any content. Click the "Bookmark this" link when viewing a piece of content to add it to this list.', + 'format' => 'plain_text', + ), + ), + 'relationships' => array( + 'flag_content_rel' => array( + 'id' => 'flag_content_rel', + 'table' => 'node', + 'field' => 'flag_content_rel', + 'label' => 'bookmarks', + 'flag' => 'bookmarks', + ), + 'uid_1' => array( + 'id' => 'uid_1', + 'table' => 'node', + 'field' => 'uid', + ), + ), + 'fields' => array( + 'type' => array( + 'id' => 'type', + 'table' => 'node', + 'field' => 'type', + ), + 'title' => array( + 'id' => 'title', + 'table' => 'node', + 'field' => 'title', + ), + 'name' => array( + 'id' => 'name', + 'table' => 'users', + 'field' => 'name', + 'relationship' => 'uid_1', + 'label' => 'Author', + ), + 'comment_count' => array( + 'id' => 'comment_count', + 'table' => 'node_comment_statistics', + 'field' => 'comment_count', + 'label' => 'Replies', + ), + 'last_comment_timestamp' => array( + 'id' => 'last_comment_timestamp', + 'table' => 'node_comment_statistics', + 'field' => 'last_comment_timestamp', + 'label' => 'Last Post', + ), + 'ops' => array( + 'id' => 'ops', + 'table' => 'flagging', + 'field' => 'ops', + 'relationship' => 'flag_content_rel', + 'label' => 'Ops', + ), + ), + 'filters' => array( + 'status' => array( + 'id' => 'status', + 'table' => 'node', + 'field' => 'status', + 'value' => 1, + 'group' => '0', + 'expose' => array( + 'operator' => false, + ), + ), + ), + ), + ), + 'page' => array( + 'display_title' => 'Page', + 'display_plugin' => 'page', + 'display_options' => array( + 'query' => array( + 'type' => 'views_query', + 'options' => array( + ), + ), + 'path' => 'bookmarks', + 'menu' => array( + 'type' => 'normal', + 'title' => 'My bookmarks', + 'weight' => '0', + ), + ), + ), + ), + ) + ); + $config->save(); + } +} \ No newline at end of file diff --git a/modules/flag_bookmark/includes/flag_bookmark.views_default.inc b/modules/flag_bookmark/includes/flag_bookmark.views_default.inc deleted file mode 100644 index e656ca3..0000000 --- a/modules/flag_bookmark/includes/flag_bookmark.views_default.inc +++ /dev/null @@ -1,284 +0,0 @@ - array( - 'id' => 'type', - 'table' => 'node', - 'field' => 'type', - 'label' => 'Type', - ), - 'title' => array( - 'id' => 'title', - 'table' => 'node', - 'field' => 'title', - 'label' => 'Title', - 'link_to_node' => 1, - ), - 'name' => array( - 'label' => 'Author', - 'link_to_user' => 1, - 'id' => 'name', - 'table' => 'users', - 'field' => 'name', - 'relationship' => 'uid_1', - ), - ); - - $style_options = array( - 'grouping' => '', - 'override' => 0, - 'sticky' => 1, - 'columns' => array(), - 'default' => 'title', - 'order' => 'asc', - 'columns' => array( - 'type' => 'type', - 'title' => 'title', - 'name' => 'name', - ), - 'info' => array( - 'type' => array( - 'sortable' => TRUE, - ), - 'title' => array( - 'sortable' => TRUE, - ), - 'name' => array( - 'sortable' => TRUE, - ), - ), - 'override' => FALSE, - 'order' => 'asc', - ); - - $filters = array( - 'status' => array( - 'operator' => '=', - 'value' => 1, - 'group' => '0', - 'exposed' => FALSE, - 'expose' => array( - 'operator' => FALSE, - 'label' => '', - ), - 'id' => 'status', - 'table' => 'node', - 'field' => 'status', - 'relationship' => 'none', - ), - ); - - $relationships = array( - 'flag_content_rel' => array( - 'label' => 'bookmarks', - 'required' => 1, - 'flag' => 'bookmarks', - 'user_scope' => 'current', - 'id' => 'flag_content_rel', - 'table' => 'node', - 'field' => 'flag_content_rel', - 'relationship' => 'none', - 'override' => array( - 'button' => 'Override', - ), - ), - 'uid_1' => array( - 'label' => 'author', - 'required' => 0, - 'id' => 'uid_1', - 'table' => 'node', - 'field' => 'uid', - ), - ); - - $access = array( - 'type' => 'perm', - 'perm' => 'flag bookmarks', - ); - - // Additional fields and style options if comment exists. - if (module_exists('comment')) { - $fields += array( - 'comment_count' => array( - 'id' => 'comment_count', - 'table' => 'node_comment_statistics', - 'field' => 'comment_count', - 'label' => 'Replies', - ), - 'last_comment_timestamp' => array( - 'id' => 'last_comment_timestamp', - 'table' => 'node_comment_statistics', - 'field' => 'last_comment_timestamp', - 'label' => 'Last Post', - ), - ); - - $style_options['default'] = 'last_comment_timestamp'; - $style_options['order'] = 'desc'; - $style_options['info'] += array( - 'comment_count' => array( - 'sortable' => TRUE, - ), - 'last_comment_timestamp' => array( - 'sortable' => TRUE, - ), - ); - $style_options['columns'] += array( - 'comment_count' => 'comment_count', - 'last_comment_timestamp' => 'last_comment_timestamp', - ); - } - - /* Individual users user/%/bookmarks tab. */ - - // Additional relationship for this view. - $relationships_tab = $relationships; - $relationships_tab['flag_content_rel']['user_scope'] = 'any'; - $relationships_tab += array( - 'uid' => array( - 'label' => 'bookmarks_user', - 'required' => 1, - 'id' => 'uid', - 'table' => 'flagging', - 'field' => 'uid', - 'relationship' => 'flag_content_rel', - ), - ); - - // Additional argument for this view. - $arguments_tab = array( - 'uid' => array( - 'default_action' => 'empty', - 'style_plugin' => 'default_summary', - 'style_options' => array(), - 'wildcard' => 'all', - 'wildcard_substitution' => 'All', - 'title' => '%1\'s bookmarks', - 'default_argument_type' => 'fixed', - 'default_argument' => '', - 'validate_type' => 'none', - 'validate_fail' => 'not found', - 'break_phrase' => 0, - 'not' => 0, - 'id' => 'uid', - 'table' => 'users', - 'field' => 'uid', - 'override' => array( - 'button' => 'Override', - ), - 'relationship' => 'uid', - 'default_options_div_prefix' => '', - 'default_argument_user' => 0, - 'default_argument_fixed' => '', - 'default_argument_php' => '', - ), - ); - - $view = new view; - $view->name = 'flag_bookmarks_tab'; - $view->description = "Provides a tab on all users' profile pages containing bookmarks for that user."; - $view->tag = 'flag'; - $view->view_php = ''; - $view->base_table = 'node'; - $view->is_cacheable = FALSE; - $view->api_version = 2; - $view->disabled = FALSE; - $handler = $view->new_display('default', 'Defaults', 'default'); - $handler->override_option('relationships', $relationships_tab); - $handler->override_option('fields', $fields); - $handler->override_option('arguments', $arguments_tab); - $handler->override_option('filters', $filters); - $handler->override_option('access', $access); - $handler->override_option('title', 'User bookmarks'); - $handler->override_option('empty', 'This user has not yet bookmarked any content.'); - $handler->override_option('empty_format', filter_fallback_format()); - $handler->override_option('items_per_page', '25'); - $handler->override_option('use_pager', TRUE); - $handler->override_option('style_plugin', 'table'); - $handler->override_option('style_options', $style_options); - - $handler = $view->new_display('page', 'Page', 'page'); - $handler->override_option('path', 'user/%/bookmarks'); - $handler->override_option('menu', array( - 'type' => 'tab', - 'title' => 'Bookmarks', - 'weight' => '0', - 'name' => 'navigation', - )); - $handler->override_option('tab_options', array( - 'type' => 'none', - 'title' => NULL, - 'weight' => NULL, - )); - - $views[$view->name] = $view; - - /* User bookmarks page with Ops. */ - - // Add some unique options for this view. - $style_options['columns'] += array('ops' => 'ops'); - $fields += array( - 'ops' => array( - 'label' => 'Ops', - 'id' => 'ops', - 'table' => 'flagging', - 'field' => 'ops', - 'relationship' => 'flag_content_rel', - ), - ); - - $view = new view; - $view->name = 'flag_' . $flag->name; - $view->description = "A page listing the current user's bookmarks at /bookmarks."; - $view->tag = 'flag'; - $view->view_php = ''; - $view->base_table = 'node'; - $view->is_cacheable = '0'; - $view->api_version = 2; - $view->disabled = FALSE; - $handler = $view->new_display('default', 'Defaults', 'default'); - $handler->override_option('relationships', $relationships); - $handler->override_option('fields', $fields); - $handler->override_option('filters', $filters); - $handler->override_option('access', $access); - $handler->override_option('title', t('My bookmarks')); - $handler->override_option('items_per_page', '25'); - $handler->override_option('use_pager', TRUE); - $handler->override_option('empty', 'You have not yet bookmarked any content. Click the "' . $flag->flag_short . '" link when viewing a piece of content to add it to this list.'); - $handler->override_option('empty_format', filter_fallback_format()); - $handler->override_option('style_plugin', 'table'); - $handler->override_option('style_options', $style_options); - $handler = $view->new_display('page', 'Page', 'page'); - $handler->override_option('path', 'bookmarks'); - $handler->override_option('menu', array( - 'type' => 'normal', - 'title' => t('My bookmarks'), - 'weight' => '0', - )); - $handler->override_option('tab_options', array( - 'type' => 'none', - 'title' => NULL, - 'weight' => NULL, - )); - - $views[$view->name] = $view; - - return $views; -}