Flag module v3 patch applied to commons modules

Update Flag module to v3.9 as the 2.x branch is discontinued. The
patch 0004-accomodate-flag-v3.patch merged with local commons
modules under modules/commons directory.

SA-CONTRIB-2016-050
https://www.drupal.org/node/2793115

Change-Id: I335963fa16b66d8914071ee5c08b61849384ae6f
This commit is contained in:
Marton Kiss 2016-09-29 10:17:06 +02:00
parent b026be86bc
commit 2aad953dd8
30 changed files with 340 additions and 151 deletions

View File

@ -164,15 +164,7 @@ projects[file_entity][download][revision] = "b610413"
projects[flag][type] = "module"
projects[flag][subdir] = "contrib"
projects[flag][version] = "2.2"
; Issue #1965760: Manually set taxonomy term flag types because its different.
; http://drupal.org/node/1965760
projects[flag][patch][] = "https://drupal.org/files/issues/1965760.29.flag_.entity-tokens.patch"
; Provide a hook to allow default flag definitions to be altered.
; https://drupal.org/node/2027091#comment-8012263
projects[flag][patch][] = "https://drupal.org/files/flag-default-flags-alter-hook-2027091-03.patch"
projects[flag][version] = "3.9"
projects[flag_abuse][type] = "module"
projects[flag_abuse][subdir] = "contrib"

View File

@ -27,7 +27,7 @@ function commons_content_moderation_flag_default_flags() {
$flags = array();
// Exported flag: "Comment inappropriate".
$flags['inappropriate_comment'] = array(
'content_type' => 'comment',
'entity_type' => 'comment',
'title' => 'Comment inappropriate',
'global' => 0,
'types' => array(
@ -47,29 +47,25 @@ function commons_content_moderation_flag_default_flags() {
'unflag_message' => '',
'unflag_denied_text' => '',
'link_type' => 'confirm',
'roles' => array(
'flag' => array(
0 => 2,
),
'unflag' => array(
0 => 2,
),
'show_in_links' => array(
'diff_standard' => TRUE,
'full' => TRUE,
'token' => TRUE,
),
'weight' => 0,
'show_on_form' => 0,
'access_author' => 'comment_others',
'show_on_comment' => 1,
'flag_confirmation' => 'Are you sure you want to report this comment as inappropriate?',
'unflag_confirmation' => 'Are you sure you want to cancel reporting this comment as inappropriate?',
'module' => 'commons_content_moderation',
'locked' => array(
0 => 'name',
),
'api_version' => 2,
'api_version' => 3,
);
// Exported flag: "Node inappropriate".
$flags['inappropriate_node'] = array(
'content_type' => 'node',
'entity_type' => 'node',
'title' => 'Node inappropriate',
'global' => 0,
'types' => array(
@ -87,19 +83,12 @@ function commons_content_moderation_flag_default_flags() {
'unflag_message' => '',
'unflag_denied_text' => '',
'link_type' => 'confirm',
'roles' => array(
'flag' => array(
0 => 2,
),
'unflag' => array(
0 => 2,
),
'show_in_links' => array(
'full' => TRUE,
),
'weight' => 0,
'show_on_form' => 0,
'access_author' => '',
'show_on_page' => 1,
'show_on_teaser' => 0,
'show_contextual_link' => FALSE,
'i18n' => 0,
'flag_confirmation' => 'Are you sure you want to report this content as inappropriate?',
@ -108,7 +97,7 @@ function commons_content_moderation_flag_default_flags() {
'locked' => array(
0 => 'name',
),
'api_version' => 2,
'api_version' => 3,
);
return $flags;

View File

@ -0,0 +1,68 @@
<?php
/**
* @file
* commons_content_moderation.features.user_permission.inc
*/
/**
* Implements hook_user_default_permissions().
*/
function commons_content_moderation_user_default_permissions() {
$permissions = array();
// Exported permission: 'flag abuse_user'.
$permissions['flag abuse_user'] = array(
'name' => 'flag abuse_user',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
// Exported permission: 'flag inappropriate_comment'.
$permissions['flag inappropriate_comment'] = array(
'name' => 'flag inappropriate_comment',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
// Exported permission: 'flag inappropriate_node'.
$permissions['flag inappropriate_node'] = array(
'name' => 'flag inappropriate_node',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
// Exported permission: 'unflag abuse_user'.
$permissions['unflag abuse_user'] = array(
'name' => 'unflag abuse_user',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
// Exported permission: 'unflag inappropriate_comment'.
$permissions['unflag inappropriate_comment'] = array(
'name' => 'unflag inappropriate_comment',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
// Exported permission: 'unflag inappropriate_node'.
$permissions['unflag inappropriate_node'] = array(
'name' => 'unflag inappropriate_node',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
return $permissions;
}

View File

@ -3,6 +3,7 @@ description = Provides a content moderator role which allows privileged users to
package = Commons - Building blocks
core = 7.x
dependencies[] = comment
dependencies[] = ctools
dependencies[] = flag
dependencies[] = flag_abuse
@ -14,6 +15,12 @@ features[ctools][] = views:views_default:3.0
features[features_api][] = api:2
features[flag][] = inappropriate_comment
features[flag][] = inappropriate_node
features[user_permission][] = flag abuse_user
features[user_permission][] = flag inappropriate_comment
features[user_permission][] = flag inappropriate_node
features[user_permission][] = unflag abuse_user
features[user_permission][] = unflag inappropriate_comment
features[user_permission][] = unflag inappropriate_node
features[user_role][] = content moderator
features[variable][] = flag_abuse_flags
features[views_view][] = commons_content_moderation_reported_comments

View File

@ -245,7 +245,7 @@ function commons_content_moderation_views_default_views() {
$handler->display->display_options['fields']['entity_id']['field'] = 'comment_body';
/* Sort criterion: Flags: Flagged time */
$handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp';
$handler->display->display_options['sorts']['timestamp']['table'] = 'flag_content';
$handler->display->display_options['sorts']['timestamp']['table'] = 'flagging';
$handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp';
$handler->display->display_options['sorts']['timestamp']['relationship'] = 'flag_content_rel';
/* Filter criterion: Comment: Approved */

View File

@ -111,7 +111,7 @@ function commons_follow_views_default_views_alter(&$views) {
// Exposed "Following" filter.
$handler->display->display_options['filters']['flagged']['id'] = 'flagged';
$handler->display->display_options['filters']['flagged']['table'] = 'flag_content';
$handler->display->display_options['filters']['flagged']['table'] = 'flagging';
$handler->display->display_options['filters']['flagged']['field'] = 'flagged';
$handler->display->display_options['filters']['flagged']['relationship'] = 'flag_content_rel';
$handler->display->display_options['filters']['flagged']['ui_name'] = 'Following';
@ -309,9 +309,9 @@ function commons_follow_get_followed_content($account = array()) {
$results = array();
$flag_ids = commons_follow_get_flag_ids();
// Get a list of everything that the user is following.
$result = db_query("SELECT fid, content_id FROM {flag_content} WHERE fid IN (:fids) AND uid = :uid", array(':fids' => array_keys($flag_ids), ':uid' => $account->uid));
$result = db_query("SELECT fid, entity_id FROM {flagging} WHERE fid IN (:fids) AND uid = :uid", array(':fids' => array_keys($flag_ids), ':uid' => $account->uid));
foreach ($result as $this_result) {
$results[$flag_ids[$this_result->fid]][] = $this_result->content_id;
$results[$flag_ids[$this_result->fid]][] = $this_result->entity_id;
}
return $results;

View File

@ -21,7 +21,7 @@ function commons_follow_group_flag_default_flags() {
// Exported flag: "Groups".
$flags['commons_follow_group'] = array(
'content_type' => 'node',
'entity_type' => 'node',
'title' => 'Groups',
'global' => 0,
'types' => array(
@ -35,31 +35,25 @@ function commons_follow_group_flag_default_flags() {
'unflag_message' => 'Not following',
'unflag_denied_text' => '',
'link_type' => 'toggle',
'roles' => array(
'flag' => array(
0 => 2,
),
'unflag' => array(
0 => 2,
),
),
'weight' => 0,
'show_on_form' => 0,
'access_author' => '',
'show_on_page' => 1,
'show_on_teaser' => 1,
'show_in_links' => array(
'full' => TRUE,
'teaser' => TRUE,
),
'show_contextual_link' => FALSE,
'i18n' => 0,
'module' => 'commons_follow_group',
'locked' => array(
0 => 'name',
),
'api_version' => 2,
'api_version' => 3,
);
// Exported flag: "Commons Follow (Groups - Email)".
$flags['email_group'] = array(
'content_type' => 'node',
'entity_type' => 'node',
'title' => 'Commons Follow (Groups - Email)',
'global' => 0,
'types' => array(
@ -73,26 +67,16 @@ function commons_follow_group_flag_default_flags() {
'unflag_message' => '',
'unflag_denied_text' => '',
'link_type' => 'toggle',
'roles' => array(
'flag' => array(
0 => 2,
),
'unflag' => array(
0 => 2,
),
),
'weight' => -11,
'show_on_form' => 0,
'access_author' => '',
'show_on_page' => 0,
'show_on_teaser' => 0,
'show_contextual_link' => FALSE,
'i18n' => 0,
'module' => 'commons_follow_group',
'locked' => array(
0 => 'name',
),
'api_version' => 2,
'api_version' => 3,
);
return $flags;

View File

@ -0,0 +1,50 @@
<?php
/**
* @file
* commons_follow_group.features.user_permission.inc
*/
/**
* Implements hook_user_default_permissions().
*/
function commons_follow_group_user_default_permissions() {
$permissions = array();
// Exported permission: 'flag commons_follow_group'.
$permissions['flag commons_follow_group'] = array(
'name' => 'flag commons_follow_group',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
// Exported permission: 'flag email_group'.
$permissions['flag email_group'] = array(
'name' => 'flag email_group',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
// Exported permission: 'unflag commons_follow_group'.
$permissions['unflag commons_follow_group'] = array(
'name' => 'unflag commons_follow_group',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
// Exported permission: 'unflag email_group'.
$permissions['unflag email_group'] = array(
'name' => 'unflag email_group',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
return $permissions;
}

View File

@ -12,6 +12,10 @@ features[ctools][] = strongarm:strongarm:1
features[features_api][] = api:2
features[flag][] = commons_follow_group
features[flag][] = email_group
features[user_permission][] = flag commons_follow_group
features[user_permission][] = flag email_group
features[user_permission][] = unflag commons_follow_group
features[user_permission][] = unflag email_group
features[variable][] = message_subscribe_og
; Information added by Drupal.org packaging script on 2015-03-18

View File

@ -19,7 +19,7 @@ function commons_follow_group_commons_follow_get_nids($account, $options) {
// Get subscribe flag IDs.
$flag_ids = commons_follow_get_subscription_flags_ids('node');
$query = db_select('flag_content', 'f');
$query = db_select('flagging', 'f');
if (!empty($options['range'])) {
$query->range(0, $options['range']);
}
@ -27,9 +27,9 @@ function commons_follow_group_commons_follow_get_nids($account, $options) {
$result = $query
->condition('fid', $flag_ids, 'IN')
->condition('uid', $account->uid, '=')
->condition('content_type', 'node', '=')
->condition('content_id', $gids['node'], 'IN')
->fields('f',array('content_id'))
->condition('entity_type', 'node', '=')
->condition('entity_id', $gids['node'], 'IN')
->fields('f',array('entity_id'))
->execute()
->fetchAll();
@ -39,7 +39,7 @@ function commons_follow_group_commons_follow_get_nids($account, $options) {
$nids = array();
foreach($result as $row) {
$nids[] = $row->content_id;
$nids[] = $row->entity_id;
}
// Get the groups' content IDs.
@ -135,7 +135,7 @@ function commons_follow_group_og_membership_delete(OgMembership $og_membership)
}
}
// function flag($action, $flag_name, $content_id, $account = NULL) {
// function flag($action, $flag_name, $entity_id, $account = NULL) {
function commons_follow_group_sync_flag_to_group_membership($og_membership) {
if ($og_membership->entity_type == 'user' && $og_membership->field_name == 'og_user_node') {

View File

@ -19,7 +19,7 @@ function commons_follow_node_flag_default_flags() {
// Exported flag: "Other content you follow".
$flags['commons_follow_node'] = array(
'content_type' => 'node',
'entity_type' => 'node',
'title' => 'Other content',
'global' => 0,
'types' => array(),
@ -31,26 +31,20 @@ function commons_follow_node_flag_default_flags() {
'unflag_message' => 'Not following',
'unflag_denied_text' => '',
'link_type' => 'toggle',
'roles' => array(
'flag' => array(
0 => 2,
),
'unflag' => array(
0 => 2,
),
),
'weight' => -10,
'show_on_form' => 0,
'access_author' => '',
'show_on_page' => 1,
'show_on_teaser' => 1,
'show_in_links' => array(
'full' => TRUE,
'teaser' => TRUE,
),
'show_contextual_link' => FALSE,
'i18n' => 0,
'module' => 'commons_follow_node',
'locked' => array(
0 => 'name',
),
'api_version' => 2,
'api_version' => 3,
);
return $flags;

View File

@ -0,0 +1,32 @@
<?php
/**
* @file
* commons_follow_node.features.user_permission.inc
*/
/**
* Implements hook_user_default_permissions().
*/
function commons_follow_node_user_default_permissions() {
$permissions = array();
// Exported permission: 'flag commons_follow_node'.
$permissions['flag commons_follow_node'] = array(
'name' => 'flag commons_follow_node',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
// Exported permission: 'unflag commons_follow_node'.
$permissions['unflag commons_follow_node'] = array(
'name' => 'unflag commons_follow_node',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
return $permissions;
}

View File

@ -10,6 +10,8 @@ dependencies[] = views_litepager
features[ctools][] = views:views_default:3.0
features[features_api][] = api:2
features[flag][] = commons_follow_node
features[user_permission][] = flag commons_follow_node
features[user_permission][] = unflag commons_follow_node
features[views_view][] = commons_follow_node
features_exclude[dependencies][views] = views

View File

@ -19,7 +19,7 @@ function commons_follow_node_commons_follow_get_nids($account, $options) {
return array();
}
$query = db_select('flag_content', 'f');
$query = db_select('flagging', 'f');
if (!empty($options['range'])) {
$query->range(0, $options['range']);
@ -28,13 +28,13 @@ function commons_follow_node_commons_follow_get_nids($account, $options) {
$result = $query
->condition('fid', $flag_ids, 'IN')
->condition('uid', $account->uid, '=')
->condition('content_type', 'node', '=')
->fields('f',array('content_id'))
->condition('entity_type', 'node', '=')
->fields('f',array('entity_id'))
->execute()
->fetchAll();
$nids = array();
foreach($result as $row) {
$nids[] = (integer) $row->content_id;
$nids[] = (integer) $row->entity_id;
}
return $nids;

View File

@ -84,7 +84,7 @@ function commons_follow_node_views_default_views() {
$handler->display->display_options['relationships']['flag_content_rel_1']['user_scope'] = 'any';
/* Relationship: Flags: User */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'flag_content';
$handler->display->display_options['relationships']['uid']['table'] = 'flagging';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
$handler->display->display_options['relationships']['uid']['relationship'] = 'flag_content_rel';
/* Field: Content: Title */
@ -94,14 +94,14 @@ function commons_follow_node_views_default_views() {
$handler->display->display_options['fields']['title_field']['link_to_entity'] = 1;
/* Field: Flags: Flag link */
$handler->display->display_options['fields']['ops_1']['id'] = 'ops_1';
$handler->display->display_options['fields']['ops_1']['table'] = 'flag_content';
$handler->display->display_options['fields']['ops_1']['table'] = 'flagging';
$handler->display->display_options['fields']['ops_1']['field'] = 'ops';
$handler->display->display_options['fields']['ops_1']['relationship'] = 'flag_content_rel_1';
$handler->display->display_options['fields']['ops_1']['label'] = 'Send email?';
$handler->display->display_options['fields']['ops_1']['element_label_colon'] = FALSE;
/* Field: Flags: Flag link */
$handler->display->display_options['fields']['ops']['id'] = 'ops';
$handler->display->display_options['fields']['ops']['table'] = 'flag_content';
$handler->display->display_options['fields']['ops']['table'] = 'flagging';
$handler->display->display_options['fields']['ops']['field'] = 'ops';
$handler->display->display_options['fields']['ops']['relationship'] = 'flag_content_rel';
$handler->display->display_options['fields']['ops']['label'] = '';
@ -109,7 +109,7 @@ function commons_follow_node_views_default_views() {
$handler->display->display_options['fields']['ops']['link_type'] = 'toggle';
/* Sort criterion: Flags: Flagged time */
$handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp';
$handler->display->display_options['sorts']['timestamp']['table'] = 'flag_content';
$handler->display->display_options['sorts']['timestamp']['table'] = 'flagging';
$handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp';
$handler->display->display_options['sorts']['timestamp']['relationship'] = 'flag_content_rel';
$handler->display->display_options['sorts']['timestamp']['order'] = 'DESC';

View File

@ -19,7 +19,7 @@ function commons_follow_term_flag_default_flags() {
// Exported flag: "Topics you follow".
$flags['commons_follow_term'] = array(
'content_type' => 'taxonomy_term',
'entity_type' => 'taxonomy_term',
'title' => 'Topics',
'global' => 0,
'types' => array(
@ -33,23 +33,19 @@ function commons_follow_term_flag_default_flags() {
'unflag_message' => 'Not following',
'unflag_denied_text' => '',
'link_type' => 'toggle',
'roles' => array(
'flag' => array(
0 => 2,
),
'unflag' => array(
0 => 2,
),
),
'weight' => -8,
'show_on_entity' => 1,
'show_in_links' => array(
'diff_standard' => TRUE,
'full' => TRUE,
'token' => TRUE,
),
'show_on_form' => 0,
'access_author' => '',
'module' => 'commons_follow_term',
'locked' => array(
0 => 'name',
),
'api_version' => 2,
'api_version' => 3,
);
return $flags;

View File

@ -0,0 +1,32 @@
<?php
/**
* @file
* commons_follow_term.features.user_permission.inc
*/
/**
* Implements hook_user_default_permissions().
*/
function commons_follow_term_user_default_permissions() {
$permissions = array();
// Exported permission: 'flag commons_follow_term'.
$permissions['flag commons_follow_term'] = array(
'name' => 'flag commons_follow_term',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
// Exported permission: 'unflag commons_follow_term'.
$permissions['unflag commons_follow_term'] = array(
'name' => 'unflag commons_follow_term',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
return $permissions;
}

View File

@ -10,6 +10,8 @@ dependencies[] = views_litepager
features[ctools][] = views:views_default:3.0
features[features_api][] = api:2
features[flag][] = commons_follow_term
features[user_permission][] = flag commons_follow_term
features[user_permission][] = unflag commons_follow_term
features[views_view][] = commons_follow_taxonomy_term
features_exclude[dependencies][ctools] = ctools

View File

@ -19,12 +19,12 @@ function commons_follow_term_commons_follow_get_nids($account, $options) {
}
// Get user's flagged terms.
$query = db_select('flag_content', 'f');
$query = db_select('flagging', 'f');
$result = $query
->condition('fid', $flag_ids, 'IN')
->condition('uid', $account->uid, '=')
->condition('content_type', 'taxonomy_term', '=')
->fields('f',array('content_id'))
->condition('entity_type', 'taxonomy_term', '=')
->fields('f',array('entity_id'))
->execute()
->fetchAll();
@ -35,7 +35,7 @@ function commons_follow_term_commons_follow_get_nids($account, $options) {
$tids = array();
foreach($result as $row) {
$tids[] = (integer) $row->content_id;
$tids[] = (integer) $row->entity_id;
}
// Get IDs of nodes tagged by the specified terms.

View File

@ -84,7 +84,7 @@ function commons_follow_term_views_default_views() {
$handler->display->display_options['relationships']['flag_content_rel_1']['user_scope'] = 'any';
/* Relationship: Flags: User */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'flag_content';
$handler->display->display_options['relationships']['uid']['table'] = 'flagging';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
$handler->display->display_options['relationships']['uid']['relationship'] = 'flag_content_rel';
/* Field: Taxonomy term: Name */
@ -97,13 +97,13 @@ function commons_follow_term_views_default_views() {
$handler->display->display_options['fields']['name']['link_to_taxonomy'] = TRUE;
/* Field: Flags: Flag link */
$handler->display->display_options['fields']['ops_1']['id'] = 'ops_1';
$handler->display->display_options['fields']['ops_1']['table'] = 'flag_content';
$handler->display->display_options['fields']['ops_1']['table'] = 'flagging';
$handler->display->display_options['fields']['ops_1']['field'] = 'ops';
$handler->display->display_options['fields']['ops_1']['relationship'] = 'flag_content_rel_1';
$handler->display->display_options['fields']['ops_1']['label'] = 'Send email?';
/* Field: Flags: Flag link */
$handler->display->display_options['fields']['ops']['id'] = 'ops';
$handler->display->display_options['fields']['ops']['table'] = 'flag_content';
$handler->display->display_options['fields']['ops']['table'] = 'flagging';
$handler->display->display_options['fields']['ops']['field'] = 'ops';
$handler->display->display_options['fields']['ops']['relationship'] = 'flag_content_rel';
$handler->display->display_options['fields']['ops']['label'] = '';

View File

@ -28,7 +28,7 @@ function commons_follow_user_flag_default_flags() {
// Exported flag: "People".
$flags['commons_follow_user'] = array(
'content_type' => 'user',
'entity_type' => 'user',
'title' => 'People',
'global' => 0,
'types' => array(),
@ -40,14 +40,6 @@ function commons_follow_user_flag_default_flags() {
'unflag_message' => 'Not following',
'unflag_denied_text' => '',
'link_type' => 'toggle',
'roles' => array(
'flag' => array(
0 => 2,
),
'unflag' => array(
0 => 2,
),
),
'weight' => -13,
'show_on_form' => 0,
'access_author' => '',
@ -57,7 +49,7 @@ function commons_follow_user_flag_default_flags() {
'locked' => array(
0 => 'name',
),
'api_version' => 2,
'api_version' => 3,
);
return $flags;

View File

@ -0,0 +1,32 @@
<?php
/**
* @file
* commons_follow_user.features.user_permission.inc
*/
/**
* Implements hook_user_default_permissions().
*/
function commons_follow_user_user_default_permissions() {
$permissions = array();
// Exported permission: 'flag commons_follow_user'.
$permissions['flag commons_follow_user'] = array(
'name' => 'flag commons_follow_user',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
// Exported permission: 'unflag commons_follow_user'.
$permissions['unflag commons_follow_user'] = array(
'name' => 'unflag commons_follow_user',
'roles' => array(
'authenticated user' => 'authenticated user',
),
'module' => 'flag',
);
return $permissions;
}

View File

@ -22,6 +22,8 @@ features[features_api][] = api:2
features[field_instance][] = message-commons_follow_user_user_followed-field_target_users
features[flag][] = commons_follow_user
features[message_type][] = commons_follow_user_user_followed
features[user_permission][] = flag commons_follow_user
features[user_permission][] = unflag commons_follow_user
features[variable][] = field_bundle_settings_message__commons_follow_user_user_followed
features[views_view][] = commons_follow_user
features[views_view][] = commons_follow_user_followers

View File

@ -21,12 +21,12 @@ function commons_follow_user_commons_follow_get_nids($account, $options) {
}
// Get flagged user IDs.
$query = db_select('flag_content', 'f');
$query = db_select('flagging', 'f');
$result = $query
->condition('fid', $flag_ids, 'IN')
->condition('uid', $account->uid, '=')
->condition('content_type', 'user', '=')
->fields('f',array('content_id'))
->condition('entity_type', 'user', '=')
->fields('f',array('entity_id'))
->execute()
->fetchAll();
@ -37,7 +37,7 @@ function commons_follow_user_commons_follow_get_nids($account, $options) {
$uids = array();
foreach($result as $row) {
$uids[] = (integer) $row->content_id;
$uids[] = (integer) $row->entity_id;
}
// Get the user's node IDs.
@ -63,12 +63,12 @@ function commons_follow_user_commons_follow_get_nids($account, $options) {
}
/**
* Implements hook_flag().
* Implements hook_flag_flag().
*/
function commons_follow_user_flag($op, $flag, $content_id, $account, $fcid) {
function commons_follow_user_flag_flag($flag, $entity_id, $account, $fcid) {
// Display an activity stream message when a user follows another user.
if (module_exists('commons_activity_streams') && $flag->name == 'commons_follow_user' && $op == 'flag') {
$followed_user = user_load($content_id);
if (module_exists('commons_activity_streams') && $flag->name == 'commons_follow_user') {
$followed_user = user_load($entity_id);
// Don't generate a message for flagging blocked users.
if (!$followed_user->status) {
return;

View File

@ -84,7 +84,7 @@ function commons_follow_user_views_default_views() {
$handler->display->display_options['relationships']['flag_content_rel_1']['user_scope'] = 'any';
/* Relationship: Flags: User */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'flag_content';
$handler->display->display_options['relationships']['uid']['table'] = 'flagging';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
$handler->display->display_options['relationships']['uid']['relationship'] = 'flag_content_rel';
/* Field: User: Name */
@ -96,20 +96,20 @@ function commons_follow_user_views_default_views() {
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = FALSE;
/* Field: Flags: Flag link */
$handler->display->display_options['fields']['ops_1']['id'] = 'ops_1';
$handler->display->display_options['fields']['ops_1']['table'] = 'flag_content';
$handler->display->display_options['fields']['ops_1']['table'] = 'flagging';
$handler->display->display_options['fields']['ops_1']['field'] = 'ops';
$handler->display->display_options['fields']['ops_1']['relationship'] = 'flag_content_rel_1';
$handler->display->display_options['fields']['ops_1']['label'] = 'Send email?';
/* Field: Flags: Flag link */
$handler->display->display_options['fields']['ops']['id'] = 'ops';
$handler->display->display_options['fields']['ops']['table'] = 'flag_content';
$handler->display->display_options['fields']['ops']['table'] = 'flagging';
$handler->display->display_options['fields']['ops']['field'] = 'ops';
$handler->display->display_options['fields']['ops']['relationship'] = 'flag_content_rel';
$handler->display->display_options['fields']['ops']['label'] = '';
$handler->display->display_options['fields']['ops']['element_label_colon'] = FALSE;
/* Sort criterion: Flags: Flagged time */
$handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp';
$handler->display->display_options['sorts']['timestamp']['table'] = 'flag_content';
$handler->display->display_options['sorts']['timestamp']['table'] = 'flagging';
$handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp';
$handler->display->display_options['sorts']['timestamp']['relationship'] = 'flag_content_rel';
$handler->display->display_options['sorts']['timestamp']['order'] = 'DESC';
@ -206,7 +206,7 @@ function commons_follow_user_views_default_views() {
$handler->display->display_options['relationships']['flag_content_rel']['user_scope'] = 'any';
/* Relationship: Flags: User */
$handler->display->display_options['relationships']['uid']['id'] = 'uid';
$handler->display->display_options['relationships']['uid']['table'] = 'flag_content';
$handler->display->display_options['relationships']['uid']['table'] = 'flagging';
$handler->display->display_options['relationships']['uid']['field'] = 'uid';
$handler->display->display_options['relationships']['uid']['relationship'] = 'flag_content_rel';
$handler->display->display_options['relationships']['uid']['required'] = TRUE;
@ -233,13 +233,13 @@ function commons_follow_user_views_default_views() {
$handler->display->display_options['fields']['name']['element_default_classes'] = FALSE;
/* Sort criterion: Flags: Flagged time */
$handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp';
$handler->display->display_options['sorts']['timestamp']['table'] = 'flag_content';
$handler->display->display_options['sorts']['timestamp']['table'] = 'flagging';
$handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp';
$handler->display->display_options['sorts']['timestamp']['relationship'] = 'flag_content_rel';
$handler->display->display_options['sorts']['timestamp']['order'] = 'DESC';
/* Contextual filter: Flags: Content ID */
$handler->display->display_options['arguments']['content_id']['id'] = 'content_id';
$handler->display->display_options['arguments']['content_id']['table'] = 'flag_content';
$handler->display->display_options['arguments']['content_id']['table'] = 'flagging';
$handler->display->display_options['arguments']['content_id']['field'] = 'content_id';
$handler->display->display_options['arguments']['content_id']['relationship'] = 'flag_content_rel';
$handler->display->display_options['arguments']['content_id']['default_action'] = 'default';
@ -381,13 +381,13 @@ function commons_follow_user_views_default_views() {
$handler->display->display_options['fields']['name']['element_default_classes'] = FALSE;
/* Sort criterion: Flags: Flagged time */
$handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp';
$handler->display->display_options['sorts']['timestamp']['table'] = 'flag_content';
$handler->display->display_options['sorts']['timestamp']['table'] = 'flagging';
$handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp';
$handler->display->display_options['sorts']['timestamp']['relationship'] = 'flag_content_rel';
$handler->display->display_options['sorts']['timestamp']['order'] = 'DESC';
/* Contextual filter: Flags: User uid */
$handler->display->display_options['arguments']['uid']['id'] = 'uid';
$handler->display->display_options['arguments']['uid']['table'] = 'flag_content';
$handler->display->display_options['arguments']['uid']['table'] = 'flagging';
$handler->display->display_options['arguments']['uid']['field'] = 'uid';
$handler->display->display_options['arguments']['uid']['relationship'] = 'flag_content_rel';
$handler->display->display_options['arguments']['uid']['default_action'] = 'default';

View File

@ -32,8 +32,8 @@
* )
* - $mode: Display mode.
* - $just_voted: Indicator whether the user has just voted (boolean).
* - $content_type: "node" or "comment".
* - $content_id: Node or comment id.
* - $entity_type: "node" or "comment".
* - $entity_id: Node or comment id.
* - $buttons: Array with themed buttons (built in preprocess function).
* - $info: String with user readable information (built in preprocess function).
*/

View File

@ -89,7 +89,7 @@ function commons_like_existing_node_like_messages($acting_uid, $target_nids) {
function commons_like_theme() {
return array(
'rate_template_commons_like' => array(
'variables' => array('links' => NULL, 'results' => NULL, 'mode' => NULL, 'just_voted' => FALSE, 'content_type' => NULL, 'content_id' => NULL, 'display_options' => NULL),
'variables' => array('links' => NULL, 'results' => NULL, 'mode' => NULL, 'just_voted' => FALSE, 'entity_type' => NULL, 'entity_id' => NULL, 'display_options' => NULL),
'template' => 'commons-like',
),
);

View File

@ -12,7 +12,7 @@ include_once 'commons_q_a.features.inc';
function commons_q_a_theme() {
return array(
'rate_template_commons_thumbs_up_down' => array(
'variables' => array('links' => NULL, 'results' => NULL, 'mode' => NULL, 'just_voted' => FALSE, 'content_type' => NULL, 'content_id' => NULL, 'display_options' => NULL),
'variables' => array('links' => NULL, 'results' => NULL, 'mode' => NULL, 'just_voted' => FALSE, 'entity_type' => NULL, 'entity_id' => NULL, 'display_options' => NULL),
'template' => 'commons-thumbs-up-down',
),
);

View File

@ -6,26 +6,37 @@
*/
/**
* Implements hook_flag().
* Implements hook_flag_flag().
*
* Trigger radioactivity incidents when a user follows a node or group.
*/
function commons_radioactivity_flag($op, $flag, $content_id, $account, $fcid) {
function commons_radioactivity_flag_flag($flag, $entity_id, $account, $fcid) {
if (in_array($flag->name, array('commons_follow_node', 'commons_follow_group'))) {
$node = node_load($content_id);
$node = node_load($entity_id);
if ($op == 'flag') {
// A user following their own node should not increase radioactivity.
if ($node->uid != $account->uid) {
commons_radioactivity_incident_node($node, COMMONS_RADIOACTIVITY_FLAG_NODE);
}
// A user following their own node shouldn't add to its radioactivity.
if ($node->uid == $account->uid) {
return;
}
if ($op == 'unflag') {
// A user unfollowing their own node should not decrease radioactivity.
if ($node->uid != $account->uid) {
commons_radioactivity_incident_node($node, -1 * COMMONS_RADIOACTIVITY_FLAG_NODE);
}
}
commons_radioactivity_incident_node($node, COMMONS_RADIOACTIVITY_FLAG_NODE);
}
}
/**
* Implements hook_flag_unflag().
*
* Trigger radioactivity incidents when a user follows a node or group.
*/
function commons_radioactivity_flag_unflag($flag, $entity_id, $account, $flagging) {
if (in_array($flag->name, array('commons_follow_node', 'commons_follow_group'))) {
$node = node_load($entity_id);
// A user unfollowing their own node shouldn't add to its radioactivity.
if ($node->uid == $account->uid) {
return;
}
commons_radioactivity_incident_node($node, -1 * COMMONS_RADIOACTIVITY_FLAG_NODE);
}
}

View File

@ -86,9 +86,9 @@ function commons_search_solr_user_apachesolr_search_page_alter(&$build, $search_
$out_results = array();
if ($flagged && $flag = flag_get_flag('commons_follow_user')) {
// Get the count of flagged users for a particular account.
$fl_results = db_select('flag_content', 'f')
->fields('f', array('content_id', 'uid'))
->condition('f.content_type', 'user', '=')
$fl_results = db_select('flagging', 'f')
->fields('f', array('entity_id', 'uid'))
->condition('f.entity_type','user','=')
->condition('f.uid', $user->uid, '=')
->condition('f.fid', $flag->fid, '=')
->extend('PagerDefault')->limit($limit)
@ -96,7 +96,7 @@ function commons_search_solr_user_apachesolr_search_page_alter(&$build, $search_
->addMetaData('flagged', $flagged)
->execute();
while ($record = $fl_results->fetchAssoc()) {
$out_results[] = user_view(user_load($record['content_id']), 'search_results');
$out_results[] = user_view(user_load($record['entity_id']), 'search_results');
}
$build['pager'] = array('#theme' => 'pager');
}