From e8ac3ba58962c48e5e007de8544ad49a12e77de1 Mon Sep 17 00:00:00 2001 From: Marton Kiss Date: Mon, 23 Feb 2015 10:19:54 +0100 Subject: [PATCH] Enable group registration workflow New registration link and new group review queue link added to user profile page of users with ambassador or community manager roles. The registration workflow had been enabled so a new group must be approved by an ambassador or community mgr. Change-Id: I8b633f122da7c6a442f109211214fe7ecec250dc --- ...groups_groups.features.user_permission.inc | 41 +++++++++++++++++++ .../groups/groups_groups/groups_groups.info | 7 +++- .../groups/groups_groups/groups_groups.module | 5 ++- themes/openstack_bootstrap/template.php | 25 +++++++++++ .../templates/user-profile.tpl.php | 2 + 5 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 modules/groups/groups_groups/groups_groups.features.user_permission.inc diff --git a/modules/groups/groups_groups/groups_groups.features.user_permission.inc b/modules/groups/groups_groups/groups_groups.features.user_permission.inc new file mode 100644 index 0000000..c91959a --- /dev/null +++ b/modules/groups/groups_groups/groups_groups.features.user_permission.inc @@ -0,0 +1,41 @@ + 'access administration pages', + 'roles' => array(), + 'module' => 'system', + ); + + // Exported permission: 'access content overview'. + $permissions['access content overview'] = array( + 'name' => 'access content overview', + 'roles' => array( + 'ambassador' => 'ambassador', + 'community_manager' => 'community_manager', + ), + 'module' => 'node', + ); + + // Exported permission: 'edit any group content'. + $permissions['edit any group content'] = array( + 'name' => 'edit any group content', + 'roles' => array( + 'ambassador' => 'ambassador', + 'community_manager' => 'community_manager', + ), + 'module' => 'node', + ); + + return $permissions; +} diff --git a/modules/groups/groups_groups/groups_groups.info b/modules/groups/groups_groups/groups_groups.info index 8b030d3..88ef623 100644 --- a/modules/groups/groups_groups/groups_groups.info +++ b/modules/groups/groups_groups/groups_groups.info @@ -13,8 +13,10 @@ dependencies[] = geocoder dependencies[] = geofield dependencies[] = groups_common dependencies[] = list +dependencies[] = node dependencies[] = number dependencies[] = options +dependencies[] = system dependencies[] = views features[ctools][] = views:views_default:3.0 features[features_api][] = api:2 @@ -30,8 +32,11 @@ features[field_instance][] = node-group-field_group_location features[field_instance][] = node-group-field_group_status features[field_instance][] = node-group-field_meetup_members features[field_instance][] = node-group-field_resource_links +features[user_permission][] = access administration pages +features[user_permission][] = access content overview +features[user_permission][] = edit any group content features[user_role][] = ambassador features[user_role][] = community_manager features[views_view][] = groups_ambassadors features_exclude[dependencies][ctools] = ctools -mtime = 1423845401 +mtime = 1424680610 diff --git a/modules/groups/groups_groups/groups_groups.module b/modules/groups/groups_groups/groups_groups.module index cc417ce..24e58ab 100644 --- a/modules/groups/groups_groups/groups_groups.module +++ b/modules/groups/groups_groups/groups_groups.module @@ -49,11 +49,12 @@ function groups_groups_field_default_field_instances_alter(&$fields) { /** * Implement hook_node_prepare * - * Add a default published status to group content type. + * Add a default not published status to group content type, + * so group will be placed at review queue. */ function groups_groups_node_prepare($node) { if (($node->type == 'group') && (empty($node->nid))) { - $node->status = NODE_PUBLISHED; + $node->status = NODE_NOT_PUBLISHED; } } diff --git a/themes/openstack_bootstrap/template.php b/themes/openstack_bootstrap/template.php index 6eecc1e..efbf876 100755 --- a/themes/openstack_bootstrap/template.php +++ b/themes/openstack_bootstrap/template.php @@ -249,4 +249,29 @@ function openstack_bootstrap_preprocess_user_profile(&$variables) { '#suffix' => '', ); } + if ((in_array('community_manager', $account->roles)) || + (in_array('ambassador', $account->roles))) { + $pending_groups = db_select('node', 'n') + ->fields('n') + ->condition('n.status', 0, '=') + ->countQuery() + ->execute() + ->fetchField(); + if ($pending_groups > 0) { + $content = l(t('@pending group(s) waiting in the review queue', array('@pending' => $pending_groups)), + 'admin/content/groups'); + } else { + $content = t('No new groups waiting in the review queue.'); + } + $variables['user_profile']['pending_groups'] = array( + '#prefix' => '

'.t('Groups waiting for approval').'

', + '#markup' => $content, + ); + } + if (user_is_logged_in()) { + $variables['user_profile']['register_new_group'] = array( + '#prefix' => '

'.t('Groups registration').'

', + '#markup' => l('Register a new user group', 'node/add/group'), + ); + } } \ No newline at end of file diff --git a/themes/openstack_bootstrap/templates/user-profile.tpl.php b/themes/openstack_bootstrap/templates/user-profile.tpl.php index becb047..02bf8d4 100644 --- a/themes/openstack_bootstrap/templates/user-profile.tpl.php +++ b/themes/openstack_bootstrap/templates/user-profile.tpl.php @@ -46,4 +46,6 @@ + + \ No newline at end of file