Browse Source

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
tags/0.40^0
Marton Kiss 2 years ago
parent
commit
2aad953dd8
30 changed files with 340 additions and 151 deletions
  1. 1
    9
      drupal-org.make
  2. 10
    21
      modules/commons/commons_content_moderation/commons_content_moderation.features.inc
  3. 68
    0
      modules/commons/commons_content_moderation/commons_content_moderation.features.user_permission.inc
  4. 7
    0
      modules/commons/commons_content_moderation/commons_content_moderation.info
  5. 1
    1
      modules/commons/commons_content_moderation/commons_content_moderation.views_default.inc
  6. 3
    3
      modules/commons/commons_follow/commons_follow.module
  7. 8
    24
      modules/commons/commons_follow/commons_follow_group/commons_follow_group.features.inc
  8. 50
    0
      modules/commons/commons_follow/commons_follow_group/commons_follow_group.features.user_permission.inc
  9. 4
    0
      modules/commons/commons_follow/commons_follow_group/commons_follow_group.info
  10. 6
    6
      modules/commons/commons_follow/commons_follow_group/commons_follow_group.module
  11. 6
    12
      modules/commons/commons_follow/commons_follow_node/commons_follow_node.features.inc
  12. 32
    0
      modules/commons/commons_follow/commons_follow_node/commons_follow_node.features.user_permission.inc
  13. 2
    0
      modules/commons/commons_follow/commons_follow_node/commons_follow_node.info
  14. 4
    4
      modules/commons/commons_follow/commons_follow_node/commons_follow_node.module
  15. 4
    4
      modules/commons/commons_follow/commons_follow_node/commons_follow_node.views_default.inc
  16. 7
    11
      modules/commons/commons_follow/commons_follow_term/commons_follow_term.features.inc
  17. 32
    0
      modules/commons/commons_follow/commons_follow_term/commons_follow_term.features.user_permission.inc
  18. 2
    0
      modules/commons/commons_follow/commons_follow_term/commons_follow_term.info
  19. 4
    4
      modules/commons/commons_follow/commons_follow_term/commons_follow_term.module
  20. 3
    3
      modules/commons/commons_follow/commons_follow_term/commons_follow_term.views_default.inc
  21. 2
    10
      modules/commons/commons_follow/commons_follow_user/commons_follow_user.features.inc
  22. 32
    0
      modules/commons/commons_follow/commons_follow_user/commons_follow_user.features.user_permission.inc
  23. 2
    0
      modules/commons/commons_follow/commons_follow_user/commons_follow_user.info
  24. 8
    8
      modules/commons/commons_follow/commons_follow_user/commons_follow_user.module
  25. 9
    9
      modules/commons/commons_follow/commons_follow_user/commons_follow_user.views_default.inc
  26. 2
    2
      modules/commons/commons_like/commons-like.tpl.php
  27. 1
    1
      modules/commons/commons_like/commons_like.module
  28. 1
    1
      modules/commons/commons_q_a/commons_q_a.module
  29. 25
    14
      modules/commons/commons_radioactivity/includes/incidents/commons_radioactivity.incidents_flag.inc
  30. 4
    4
      modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.module

+ 1
- 9
drupal-org.make View File

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

+ 10
- 21
modules/commons/commons_content_moderation/commons_content_moderation.features.inc View File

@@ -27,7 +27,7 @@ function commons_content_moderation_flag_default_flags() {
27 27
   $flags = array();
28 28
   // Exported flag: "Comment inappropriate".
29 29
   $flags['inappropriate_comment'] = array(
30
-    'content_type' => 'comment',
30
+    'entity_type' => 'comment',
31 31
     'title' => 'Comment inappropriate',
32 32
     'global' => 0,
33 33
     'types' => array(
@@ -47,29 +47,25 @@ function commons_content_moderation_flag_default_flags() {
47 47
     'unflag_message' => '',
48 48
     'unflag_denied_text' => '',
49 49
     'link_type' => 'confirm',
50
-    'roles' => array(
51
-      'flag' => array(
52
-        0 => 2,
53
-      ),
54
-      'unflag' => array(
55
-        0 => 2,
56
-      ),
50
+    'show_in_links' => array(
51
+      'diff_standard' => TRUE,
52
+      'full' => TRUE,
53
+      'token' => TRUE,
57 54
     ),
58 55
     'weight' => 0,
59 56
     'show_on_form' => 0,
60 57
     'access_author' => 'comment_others',
61
-    'show_on_comment' => 1,
62 58
     'flag_confirmation' => 'Are you sure you want to report this comment as inappropriate?',
63 59
     'unflag_confirmation' => 'Are you sure you want to cancel reporting this comment as inappropriate?',
64 60
     'module' => 'commons_content_moderation',
65 61
     'locked' => array(
66 62
       0 => 'name',
67 63
     ),
68
-    'api_version' => 2,
64
+    'api_version' => 3,
69 65
   );
70 66
   // Exported flag: "Node inappropriate".
71 67
   $flags['inappropriate_node'] = array(
72
-    'content_type' => 'node',
68
+    'entity_type' => 'node',
73 69
     'title' => 'Node inappropriate',
74 70
     'global' => 0,
75 71
     'types' => array(
@@ -87,19 +83,12 @@ function commons_content_moderation_flag_default_flags() {
87 83
     'unflag_message' => '',
88 84
     'unflag_denied_text' => '',
89 85
     'link_type' => 'confirm',
90
-    'roles' => array(
91
-      'flag' => array(
92
-        0 => 2,
93
-      ),
94
-      'unflag' => array(
95
-        0 => 2,
96
-      ),
86
+    'show_in_links' => array(
87
+      'full' => TRUE,
97 88
     ),
98 89
     'weight' => 0,
99 90
     'show_on_form' => 0,
100 91
     'access_author' => '',
101
-    'show_on_page' => 1,
102
-    'show_on_teaser' => 0,
103 92
     'show_contextual_link' => FALSE,
104 93
     'i18n' => 0,
105 94
     'flag_confirmation' => 'Are you sure you want to report this content as inappropriate?',
@@ -108,7 +97,7 @@ function commons_content_moderation_flag_default_flags() {
108 97
     'locked' => array(
109 98
       0 => 'name',
110 99
     ),
111
-    'api_version' => 2,
100
+    'api_version' => 3,
112 101
   );
113 102
   return $flags;
114 103
 

+ 68
- 0
modules/commons/commons_content_moderation/commons_content_moderation.features.user_permission.inc View File

@@ -0,0 +1,68 @@
1
+<?php
2
+/**
3
+ * @file
4
+ * commons_content_moderation.features.user_permission.inc
5
+ */
6
+
7
+/**
8
+ * Implements hook_user_default_permissions().
9
+ */
10
+function commons_content_moderation_user_default_permissions() {
11
+  $permissions = array();
12
+
13
+  // Exported permission: 'flag abuse_user'.
14
+  $permissions['flag abuse_user'] = array(
15
+    'name' => 'flag abuse_user',
16
+    'roles' => array(
17
+      'authenticated user' => 'authenticated user',
18
+    ),
19
+    'module' => 'flag',
20
+  );
21
+
22
+  // Exported permission: 'flag inappropriate_comment'.
23
+  $permissions['flag inappropriate_comment'] = array(
24
+    'name' => 'flag inappropriate_comment',
25
+    'roles' => array(
26
+      'authenticated user' => 'authenticated user',
27
+    ),
28
+    'module' => 'flag',
29
+  );
30
+
31
+  // Exported permission: 'flag inappropriate_node'.
32
+  $permissions['flag inappropriate_node'] = array(
33
+    'name' => 'flag inappropriate_node',
34
+    'roles' => array(
35
+      'authenticated user' => 'authenticated user',
36
+    ),
37
+    'module' => 'flag',
38
+  );
39
+
40
+  // Exported permission: 'unflag abuse_user'.
41
+  $permissions['unflag abuse_user'] = array(
42
+    'name' => 'unflag abuse_user',
43
+    'roles' => array(
44
+      'authenticated user' => 'authenticated user',
45
+    ),
46
+    'module' => 'flag',
47
+  );
48
+
49
+  // Exported permission: 'unflag inappropriate_comment'.
50
+  $permissions['unflag inappropriate_comment'] = array(
51
+    'name' => 'unflag inappropriate_comment',
52
+    'roles' => array(
53
+      'authenticated user' => 'authenticated user',
54
+    ),
55
+    'module' => 'flag',
56
+  );
57
+
58
+  // Exported permission: 'unflag inappropriate_node'.
59
+  $permissions['unflag inappropriate_node'] = array(
60
+    'name' => 'unflag inappropriate_node',
61
+    'roles' => array(
62
+      'authenticated user' => 'authenticated user',
63
+    ),
64
+    'module' => 'flag',
65
+  );
66
+
67
+  return $permissions;
68
+}

+ 7
- 0
modules/commons/commons_content_moderation/commons_content_moderation.info View File

@@ -3,6 +3,7 @@ description = Provides a content moderator role which allows privileged users to
3 3
 package = Commons - Building blocks
4 4
 core = 7.x
5 5
 
6
+dependencies[] = comment
6 7
 dependencies[] = ctools
7 8
 dependencies[] = flag
8 9
 dependencies[] = flag_abuse
@@ -14,6 +15,12 @@ features[ctools][] = views:views_default:3.0
14 15
 features[features_api][] = api:2
15 16
 features[flag][] = inappropriate_comment
16 17
 features[flag][] = inappropriate_node
18
+features[user_permission][] = flag abuse_user
19
+features[user_permission][] = flag inappropriate_comment
20
+features[user_permission][] = flag inappropriate_node
21
+features[user_permission][] = unflag abuse_user
22
+features[user_permission][] = unflag inappropriate_comment
23
+features[user_permission][] = unflag inappropriate_node
17 24
 features[user_role][] = content moderator
18 25
 features[variable][] = flag_abuse_flags
19 26
 features[views_view][] = commons_content_moderation_reported_comments

+ 1
- 1
modules/commons/commons_content_moderation/commons_content_moderation.views_default.inc View File

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

+ 3
- 3
modules/commons/commons_follow/commons_follow.module View File

@@ -111,7 +111,7 @@ function commons_follow_views_default_views_alter(&$views) {
111 111
 
112 112
     // Exposed "Following" filter.
113 113
     $handler->display->display_options['filters']['flagged']['id'] = 'flagged';
114
-    $handler->display->display_options['filters']['flagged']['table'] = 'flag_content';
114
+    $handler->display->display_options['filters']['flagged']['table'] = 'flagging';
115 115
     $handler->display->display_options['filters']['flagged']['field'] = 'flagged';
116 116
     $handler->display->display_options['filters']['flagged']['relationship'] = 'flag_content_rel';
117 117
     $handler->display->display_options['filters']['flagged']['ui_name'] = 'Following';
@@ -309,9 +309,9 @@ function commons_follow_get_followed_content($account = array()) {
309 309
   $results = array();
310 310
   $flag_ids = commons_follow_get_flag_ids();
311 311
   // Get a list of everything that the user is following.
312
-  $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));
312
+  $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));
313 313
   foreach ($result as $this_result) {
314
-    $results[$flag_ids[$this_result->fid]][] = $this_result->content_id;
314
+    $results[$flag_ids[$this_result->fid]][] = $this_result->entity_id;
315 315
   }
316 316
 
317 317
   return $results;

+ 8
- 24
modules/commons/commons_follow/commons_follow_group/commons_follow_group.features.inc View File

@@ -21,7 +21,7 @@ function commons_follow_group_flag_default_flags() {
21 21
 
22 22
   // Exported flag: "Groups".
23 23
   $flags['commons_follow_group'] = array(
24
-    'content_type' => 'node',
24
+    'entity_type' => 'node',
25 25
     'title' => 'Groups',
26 26
     'global' => 0,
27 27
     'types' => array(
@@ -35,31 +35,25 @@ function commons_follow_group_flag_default_flags() {
35 35
     'unflag_message' => 'Not following',
36 36
     'unflag_denied_text' => '',
37 37
     'link_type' => 'toggle',
38
-    'roles' => array(
39
-      'flag' => array(
40
-        0 => 2,
41
-      ),
42
-      'unflag' => array(
43
-        0 => 2,
44
-      ),
45
-    ),
46 38
     'weight' => 0,
47 39
     'show_on_form' => 0,
48 40
     'access_author' => '',
49
-    'show_on_page' => 1,
50
-    'show_on_teaser' => 1,
41
+    'show_in_links' => array(
42
+      'full' => TRUE,
43
+      'teaser' => TRUE,
44
+    ),
51 45
     'show_contextual_link' => FALSE,
52 46
     'i18n' => 0,
53 47
     'module' => 'commons_follow_group',
54 48
     'locked' => array(
55 49
       0 => 'name',
56 50
     ),
57
-    'api_version' => 2,
51
+    'api_version' => 3,
58 52
   );
59 53
 
60 54
   // Exported flag: "Commons Follow (Groups - Email)".
61 55
   $flags['email_group'] = array(
62
-    'content_type' => 'node',
56
+    'entity_type' => 'node',
63 57
     'title' => 'Commons Follow (Groups - Email)',
64 58
     'global' => 0,
65 59
     'types' => array(
@@ -73,26 +67,16 @@ function commons_follow_group_flag_default_flags() {
73 67
     'unflag_message' => '',
74 68
     'unflag_denied_text' => '',
75 69
     'link_type' => 'toggle',
76
-    'roles' => array(
77
-      'flag' => array(
78
-        0 => 2,
79
-      ),
80
-      'unflag' => array(
81
-        0 => 2,
82
-      ),
83
-    ),
84 70
     'weight' => -11,
85 71
     'show_on_form' => 0,
86 72
     'access_author' => '',
87
-    'show_on_page' => 0,
88
-    'show_on_teaser' => 0,
89 73
     'show_contextual_link' => FALSE,
90 74
     'i18n' => 0,
91 75
     'module' => 'commons_follow_group',
92 76
     'locked' => array(
93 77
       0 => 'name',
94 78
     ),
95
-    'api_version' => 2,
79
+    'api_version' => 3,
96 80
   );
97 81
 
98 82
   return $flags;

+ 50
- 0
modules/commons/commons_follow/commons_follow_group/commons_follow_group.features.user_permission.inc View File

@@ -0,0 +1,50 @@
1
+<?php
2
+/**
3
+ * @file
4
+ * commons_follow_group.features.user_permission.inc
5
+ */
6
+
7
+/**
8
+ * Implements hook_user_default_permissions().
9
+ */
10
+function commons_follow_group_user_default_permissions() {
11
+  $permissions = array();
12
+
13
+  // Exported permission: 'flag commons_follow_group'.
14
+  $permissions['flag commons_follow_group'] = array(
15
+    'name' => 'flag commons_follow_group',
16
+    'roles' => array(
17
+      'authenticated user' => 'authenticated user',
18
+    ),
19
+    'module' => 'flag',
20
+  );
21
+
22
+  // Exported permission: 'flag email_group'.
23
+  $permissions['flag email_group'] = array(
24
+    'name' => 'flag email_group',
25
+    'roles' => array(
26
+      'authenticated user' => 'authenticated user',
27
+    ),
28
+    'module' => 'flag',
29
+  );
30
+
31
+  // Exported permission: 'unflag commons_follow_group'.
32
+  $permissions['unflag commons_follow_group'] = array(
33
+    'name' => 'unflag commons_follow_group',
34
+    'roles' => array(
35
+      'authenticated user' => 'authenticated user',
36
+    ),
37
+    'module' => 'flag',
38
+  );
39
+
40
+  // Exported permission: 'unflag email_group'.
41
+  $permissions['unflag email_group'] = array(
42
+    'name' => 'unflag email_group',
43
+    'roles' => array(
44
+      'authenticated user' => 'authenticated user',
45
+    ),
46
+    'module' => 'flag',
47
+  );
48
+
49
+  return $permissions;
50
+}

+ 4
- 0
modules/commons/commons_follow/commons_follow_group/commons_follow_group.info View File

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

+ 6
- 6
modules/commons/commons_follow/commons_follow_group/commons_follow_group.module View File

@@ -19,7 +19,7 @@ function commons_follow_group_commons_follow_get_nids($account, $options) {
19 19
   // Get subscribe flag IDs.
20 20
   $flag_ids = commons_follow_get_subscription_flags_ids('node');
21 21
 
22
-  $query = db_select('flag_content', 'f');
22
+  $query = db_select('flagging', 'f');
23 23
   if (!empty($options['range'])) {
24 24
     $query->range(0, $options['range']);
25 25
   }
@@ -27,9 +27,9 @@ function commons_follow_group_commons_follow_get_nids($account, $options) {
27 27
   $result = $query
28 28
     ->condition('fid', $flag_ids, 'IN')
29 29
     ->condition('uid', $account->uid, '=')
30
-    ->condition('content_type', 'node', '=')
31
-    ->condition('content_id', $gids['node'], 'IN')
32
-    ->fields('f',array('content_id'))
30
+    ->condition('entity_type', 'node', '=')
31
+    ->condition('entity_id', $gids['node'], 'IN')
32
+    ->fields('f',array('entity_id'))
33 33
     ->execute()
34 34
     ->fetchAll();
35 35
 
@@ -39,7 +39,7 @@ function commons_follow_group_commons_follow_get_nids($account, $options) {
39 39
 
40 40
   $nids = array();
41 41
   foreach($result as $row) {
42
-    $nids[] = $row->content_id;
42
+    $nids[] = $row->entity_id;
43 43
   }
44 44
 
45 45
   // Get the groups' content IDs.
@@ -135,7 +135,7 @@ function commons_follow_group_og_membership_delete(OgMembership $og_membership)
135 135
   }
136 136
 }
137 137
 
138
-// function flag($action, $flag_name, $content_id, $account = NULL) {
138
+// function flag($action, $flag_name, $entity_id, $account = NULL) {
139 139
 
140 140
 function commons_follow_group_sync_flag_to_group_membership($og_membership) {
141 141
   if ($og_membership->entity_type == 'user' && $og_membership->field_name == 'og_user_node') {

+ 6
- 12
modules/commons/commons_follow/commons_follow_node/commons_follow_node.features.inc View File

@@ -19,7 +19,7 @@ function commons_follow_node_flag_default_flags() {
19 19
 
20 20
   // Exported flag: "Other content you follow".
21 21
   $flags['commons_follow_node'] = array(
22
-    'content_type' => 'node',
22
+    'entity_type' => 'node',
23 23
     'title' => 'Other content',
24 24
     'global' => 0,
25 25
     'types' => array(),
@@ -31,26 +31,20 @@ function commons_follow_node_flag_default_flags() {
31 31
     'unflag_message' => 'Not following',
32 32
     'unflag_denied_text' => '',
33 33
     'link_type' => 'toggle',
34
-    'roles' => array(
35
-      'flag' => array(
36
-        0 => 2,
37
-      ),
38
-      'unflag' => array(
39
-        0 => 2,
40
-      ),
41
-    ),
42 34
     'weight' => -10,
43 35
     'show_on_form' => 0,
44 36
     'access_author' => '',
45
-    'show_on_page' => 1,
46
-    'show_on_teaser' => 1,
37
+    'show_in_links' => array(
38
+      'full' => TRUE,
39
+      'teaser' => TRUE,
40
+    ),
47 41
     'show_contextual_link' => FALSE,
48 42
     'i18n' => 0,
49 43
     'module' => 'commons_follow_node',
50 44
     'locked' => array(
51 45
       0 => 'name',
52 46
     ),
53
-    'api_version' => 2,
47
+    'api_version' => 3,
54 48
   );
55 49
 
56 50
   return $flags;

+ 32
- 0
modules/commons/commons_follow/commons_follow_node/commons_follow_node.features.user_permission.inc View File

@@ -0,0 +1,32 @@
1
+<?php
2
+/**
3
+ * @file
4
+ * commons_follow_node.features.user_permission.inc
5
+ */
6
+
7
+/**
8
+ * Implements hook_user_default_permissions().
9
+ */
10
+function commons_follow_node_user_default_permissions() {
11
+  $permissions = array();
12
+
13
+  // Exported permission: 'flag commons_follow_node'.
14
+  $permissions['flag commons_follow_node'] = array(
15
+    'name' => 'flag commons_follow_node',
16
+    'roles' => array(
17
+      'authenticated user' => 'authenticated user',
18
+    ),
19
+    'module' => 'flag',
20
+  );
21
+
22
+  // Exported permission: 'unflag commons_follow_node'.
23
+  $permissions['unflag commons_follow_node'] = array(
24
+    'name' => 'unflag commons_follow_node',
25
+    'roles' => array(
26
+      'authenticated user' => 'authenticated user',
27
+    ),
28
+    'module' => 'flag',
29
+  );
30
+
31
+  return $permissions;
32
+}

+ 2
- 0
modules/commons/commons_follow/commons_follow_node/commons_follow_node.info View File

@@ -10,6 +10,8 @@ dependencies[] = views_litepager
10 10
 features[ctools][] = views:views_default:3.0
11 11
 features[features_api][] = api:2
12 12
 features[flag][] = commons_follow_node
13
+features[user_permission][] = flag commons_follow_node
14
+features[user_permission][] = unflag commons_follow_node
13 15
 features[views_view][] = commons_follow_node
14 16
 
15 17
 features_exclude[dependencies][views] = views

+ 4
- 4
modules/commons/commons_follow/commons_follow_node/commons_follow_node.module View File

@@ -19,7 +19,7 @@ function commons_follow_node_commons_follow_get_nids($account, $options) {
19 19
     return array();
20 20
   }
21 21
 
22
-  $query = db_select('flag_content', 'f');
22
+  $query = db_select('flagging', 'f');
23 23
 
24 24
   if (!empty($options['range'])) {
25 25
     $query->range(0, $options['range']);
@@ -28,13 +28,13 @@ function commons_follow_node_commons_follow_get_nids($account, $options) {
28 28
   $result = $query
29 29
     ->condition('fid', $flag_ids, 'IN')
30 30
     ->condition('uid', $account->uid, '=')
31
-    ->condition('content_type', 'node', '=')
32
-    ->fields('f',array('content_id'))
31
+    ->condition('entity_type', 'node', '=')
32
+    ->fields('f',array('entity_id'))
33 33
     ->execute()
34 34
     ->fetchAll();
35 35
   $nids = array();
36 36
   foreach($result as $row) {
37
-    $nids[] = (integer) $row->content_id;
37
+    $nids[] = (integer) $row->entity_id;
38 38
   }
39 39
 
40 40
   return $nids;

+ 4
- 4
modules/commons/commons_follow/commons_follow_node/commons_follow_node.views_default.inc View File

@@ -84,7 +84,7 @@ function commons_follow_node_views_default_views() {
84 84
   $handler->display->display_options['relationships']['flag_content_rel_1']['user_scope'] = 'any';
85 85
   /* Relationship: Flags: User */
86 86
   $handler->display->display_options['relationships']['uid']['id'] = 'uid';
87
-  $handler->display->display_options['relationships']['uid']['table'] = 'flag_content';
87
+  $handler->display->display_options['relationships']['uid']['table'] = 'flagging';
88 88
   $handler->display->display_options['relationships']['uid']['field'] = 'uid';
89 89
   $handler->display->display_options['relationships']['uid']['relationship'] = 'flag_content_rel';
90 90
   /* Field: Content: Title */
@@ -94,14 +94,14 @@ function commons_follow_node_views_default_views() {
94 94
   $handler->display->display_options['fields']['title_field']['link_to_entity'] = 1;
95 95
   /* Field: Flags: Flag link */
96 96
   $handler->display->display_options['fields']['ops_1']['id'] = 'ops_1';
97
-  $handler->display->display_options['fields']['ops_1']['table'] = 'flag_content';
97
+  $handler->display->display_options['fields']['ops_1']['table'] = 'flagging';
98 98
   $handler->display->display_options['fields']['ops_1']['field'] = 'ops';
99 99
   $handler->display->display_options['fields']['ops_1']['relationship'] = 'flag_content_rel_1';
100 100
   $handler->display->display_options['fields']['ops_1']['label'] = 'Send email?';
101 101
   $handler->display->display_options['fields']['ops_1']['element_label_colon'] = FALSE;
102 102
   /* Field: Flags: Flag link */
103 103
   $handler->display->display_options['fields']['ops']['id'] = 'ops';
104
-  $handler->display->display_options['fields']['ops']['table'] = 'flag_content';
104
+  $handler->display->display_options['fields']['ops']['table'] = 'flagging';
105 105
   $handler->display->display_options['fields']['ops']['field'] = 'ops';
106 106
   $handler->display->display_options['fields']['ops']['relationship'] = 'flag_content_rel';
107 107
   $handler->display->display_options['fields']['ops']['label'] = '';
@@ -109,7 +109,7 @@ function commons_follow_node_views_default_views() {
109 109
   $handler->display->display_options['fields']['ops']['link_type'] = 'toggle';
110 110
   /* Sort criterion: Flags: Flagged time */
111 111
   $handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp';
112
-  $handler->display->display_options['sorts']['timestamp']['table'] = 'flag_content';
112
+  $handler->display->display_options['sorts']['timestamp']['table'] = 'flagging';
113 113
   $handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp';
114 114
   $handler->display->display_options['sorts']['timestamp']['relationship'] = 'flag_content_rel';
115 115
   $handler->display->display_options['sorts']['timestamp']['order'] = 'DESC';

+ 7
- 11
modules/commons/commons_follow/commons_follow_term/commons_follow_term.features.inc View File

@@ -19,7 +19,7 @@ function commons_follow_term_flag_default_flags() {
19 19
 
20 20
   // Exported flag: "Topics you follow".
21 21
   $flags['commons_follow_term'] = array(
22
-    'content_type' => 'taxonomy_term',
22
+    'entity_type' => 'taxonomy_term',
23 23
     'title' => 'Topics',
24 24
     'global' => 0,
25 25
     'types' => array(
@@ -33,23 +33,19 @@ function commons_follow_term_flag_default_flags() {
33 33
     'unflag_message' => 'Not following',
34 34
     'unflag_denied_text' => '',
35 35
     'link_type' => 'toggle',
36
-    'roles' => array(
37
-      'flag' => array(
38
-        0 => 2,
39
-      ),
40
-      'unflag' => array(
41
-        0 => 2,
42
-      ),
43
-    ),
44 36
     'weight' => -8,
45
-    'show_on_entity' => 1,
37
+    'show_in_links' => array(
38
+      'diff_standard' => TRUE,
39
+      'full' => TRUE,
40
+      'token' => TRUE,
41
+    ),
46 42
     'show_on_form' => 0,
47 43
     'access_author' => '',
48 44
     'module' => 'commons_follow_term',
49 45
     'locked' => array(
50 46
       0 => 'name',
51 47
     ),
52
-    'api_version' => 2,
48
+    'api_version' => 3,
53 49
   );
54 50
 
55 51
   return $flags;

+ 32
- 0
modules/commons/commons_follow/commons_follow_term/commons_follow_term.features.user_permission.inc View File

@@ -0,0 +1,32 @@
1
+<?php
2
+/**
3
+ * @file
4
+ * commons_follow_term.features.user_permission.inc
5
+ */
6
+
7
+/**
8
+ * Implements hook_user_default_permissions().
9
+ */
10
+function commons_follow_term_user_default_permissions() {
11
+  $permissions = array();
12
+
13
+  // Exported permission: 'flag commons_follow_term'.
14
+  $permissions['flag commons_follow_term'] = array(
15
+    'name' => 'flag commons_follow_term',
16
+    'roles' => array(
17
+      'authenticated user' => 'authenticated user',
18
+    ),
19
+    'module' => 'flag',
20
+  );
21
+
22
+  // Exported permission: 'unflag commons_follow_term'.
23
+  $permissions['unflag commons_follow_term'] = array(
24
+    'name' => 'unflag commons_follow_term',
25
+    'roles' => array(
26
+      'authenticated user' => 'authenticated user',
27
+    ),
28
+    'module' => 'flag',
29
+  );
30
+
31
+  return $permissions;
32
+}

+ 2
- 0
modules/commons/commons_follow/commons_follow_term/commons_follow_term.info View File

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

+ 4
- 4
modules/commons/commons_follow/commons_follow_term/commons_follow_term.module View File

@@ -19,12 +19,12 @@ function commons_follow_term_commons_follow_get_nids($account, $options) {
19 19
   }
20 20
 
21 21
   // Get user's flagged terms.
22
-  $query = db_select('flag_content', 'f');
22
+  $query = db_select('flagging', 'f');
23 23
   $result = $query
24 24
     ->condition('fid', $flag_ids, 'IN')
25 25
     ->condition('uid', $account->uid, '=')
26
-    ->condition('content_type', 'taxonomy_term', '=')
27
-    ->fields('f',array('content_id'))
26
+    ->condition('entity_type', 'taxonomy_term', '=')
27
+    ->fields('f',array('entity_id'))
28 28
     ->execute()
29 29
     ->fetchAll();
30 30
 
@@ -35,7 +35,7 @@ function commons_follow_term_commons_follow_get_nids($account, $options) {
35 35
 
36 36
   $tids = array();
37 37
   foreach($result as $row) {
38
-    $tids[] = (integer) $row->content_id;
38
+    $tids[] = (integer) $row->entity_id;
39 39
   }
40 40
 
41 41
   // Get IDs of nodes tagged by the specified terms.

+ 3
- 3
modules/commons/commons_follow/commons_follow_term/commons_follow_term.views_default.inc View File

@@ -84,7 +84,7 @@ function commons_follow_term_views_default_views() {
84 84
   $handler->display->display_options['relationships']['flag_content_rel_1']['user_scope'] = 'any';
85 85
   /* Relationship: Flags: User */
86 86
   $handler->display->display_options['relationships']['uid']['id'] = 'uid';
87
-  $handler->display->display_options['relationships']['uid']['table'] = 'flag_content';
87
+  $handler->display->display_options['relationships']['uid']['table'] = 'flagging';
88 88
   $handler->display->display_options['relationships']['uid']['field'] = 'uid';
89 89
   $handler->display->display_options['relationships']['uid']['relationship'] = 'flag_content_rel';
90 90
   /* Field: Taxonomy term: Name */
@@ -97,13 +97,13 @@ function commons_follow_term_views_default_views() {
97 97
   $handler->display->display_options['fields']['name']['link_to_taxonomy'] = TRUE;
98 98
   /* Field: Flags: Flag link */
99 99
   $handler->display->display_options['fields']['ops_1']['id'] = 'ops_1';
100
-  $handler->display->display_options['fields']['ops_1']['table'] = 'flag_content';
100
+  $handler->display->display_options['fields']['ops_1']['table'] = 'flagging';
101 101
   $handler->display->display_options['fields']['ops_1']['field'] = 'ops';
102 102
   $handler->display->display_options['fields']['ops_1']['relationship'] = 'flag_content_rel_1';
103 103
   $handler->display->display_options['fields']['ops_1']['label'] = 'Send email?';
104 104
   /* Field: Flags: Flag link */
105 105
   $handler->display->display_options['fields']['ops']['id'] = 'ops';
106
-  $handler->display->display_options['fields']['ops']['table'] = 'flag_content';
106
+  $handler->display->display_options['fields']['ops']['table'] = 'flagging';
107 107
   $handler->display->display_options['fields']['ops']['field'] = 'ops';
108 108
   $handler->display->display_options['fields']['ops']['relationship'] = 'flag_content_rel';
109 109
   $handler->display->display_options['fields']['ops']['label'] = '';

+ 2
- 10
modules/commons/commons_follow/commons_follow_user/commons_follow_user.features.inc View File

@@ -28,7 +28,7 @@ function commons_follow_user_flag_default_flags() {
28 28
 
29 29
   // Exported flag: "People".
30 30
   $flags['commons_follow_user'] = array(
31
-    'content_type' => 'user',
31
+    'entity_type' => 'user',
32 32
     'title' => 'People',
33 33
     'global' => 0,
34 34
     'types' => array(),
@@ -40,14 +40,6 @@ function commons_follow_user_flag_default_flags() {
40 40
     'unflag_message' => 'Not following',
41 41
     'unflag_denied_text' => '',
42 42
     'link_type' => 'toggle',
43
-    'roles' => array(
44
-      'flag' => array(
45
-        0 => 2,
46
-      ),
47
-      'unflag' => array(
48
-        0 => 2,
49
-      ),
50
-    ),
51 43
     'weight' => -13,
52 44
     'show_on_form' => 0,
53 45
     'access_author' => '',
@@ -57,7 +49,7 @@ function commons_follow_user_flag_default_flags() {
57 49
     'locked' => array(
58 50
       0 => 'name',
59 51
     ),
60
-    'api_version' => 2,
52
+    'api_version' => 3,
61 53
   );
62 54
 
63 55
   return $flags;

+ 32
- 0
modules/commons/commons_follow/commons_follow_user/commons_follow_user.features.user_permission.inc View File

@@ -0,0 +1,32 @@
1
+<?php
2
+/**
3
+ * @file
4
+ * commons_follow_user.features.user_permission.inc
5
+ */
6
+
7
+/**
8
+ * Implements hook_user_default_permissions().
9
+ */
10
+function commons_follow_user_user_default_permissions() {
11
+  $permissions = array();
12
+
13
+  // Exported permission: 'flag commons_follow_user'.
14
+  $permissions['flag commons_follow_user'] = array(
15
+    'name' => 'flag commons_follow_user',
16
+    'roles' => array(
17
+      'authenticated user' => 'authenticated user',
18
+    ),
19
+    'module' => 'flag',
20
+  );
21
+
22
+  // Exported permission: 'unflag commons_follow_user'.
23
+  $permissions['unflag commons_follow_user'] = array(
24
+    'name' => 'unflag commons_follow_user',
25
+    'roles' => array(
26
+      'authenticated user' => 'authenticated user',
27
+    ),
28
+    'module' => 'flag',
29
+  );
30
+
31
+  return $permissions;
32
+}

+ 2
- 0
modules/commons/commons_follow/commons_follow_user/commons_follow_user.info View File

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

+ 8
- 8
modules/commons/commons_follow/commons_follow_user/commons_follow_user.module View File

@@ -21,12 +21,12 @@ function commons_follow_user_commons_follow_get_nids($account, $options) {
21 21
   }
22 22
 
23 23
   // Get flagged user IDs.
24
-  $query = db_select('flag_content', 'f');
24
+  $query = db_select('flagging', 'f');
25 25
   $result = $query
26 26
     ->condition('fid', $flag_ids, 'IN')
27 27
     ->condition('uid', $account->uid, '=')
28
-    ->condition('content_type', 'user', '=')
29
-    ->fields('f',array('content_id'))
28
+    ->condition('entity_type', 'user', '=')
29
+    ->fields('f',array('entity_id'))
30 30
     ->execute()
31 31
     ->fetchAll();
32 32
 
@@ -37,7 +37,7 @@ function commons_follow_user_commons_follow_get_nids($account, $options) {
37 37
 
38 38
   $uids = array();
39 39
   foreach($result as $row) {
40
-    $uids[] = (integer) $row->content_id;
40
+    $uids[] = (integer) $row->entity_id;
41 41
   }
42 42
 
43 43
   // Get the user's node IDs.
@@ -63,12 +63,12 @@ function commons_follow_user_commons_follow_get_nids($account, $options) {
63 63
 }
64 64
 
65 65
 /**
66
- * Implements hook_flag().
66
+ * Implements hook_flag_flag().
67 67
  */
68
-function commons_follow_user_flag($op, $flag, $content_id, $account, $fcid) {
68
+function commons_follow_user_flag_flag($flag, $entity_id, $account, $fcid) {
69 69
   // Display an activity stream message when a user follows another user.
70
-  if (module_exists('commons_activity_streams') && $flag->name == 'commons_follow_user' && $op == 'flag') {
71
-    $followed_user = user_load($content_id);
70
+  if (module_exists('commons_activity_streams') && $flag->name == 'commons_follow_user') {
71
+    $followed_user = user_load($entity_id);
72 72
     // Don't generate a message for flagging blocked users.
73 73
     if (!$followed_user->status) {
74 74
       return;

+ 9
- 9
modules/commons/commons_follow/commons_follow_user/commons_follow_user.views_default.inc View File

@@ -84,7 +84,7 @@ function commons_follow_user_views_default_views() {
84 84
   $handler->display->display_options['relationships']['flag_content_rel_1']['user_scope'] = 'any';
85 85
   /* Relationship: Flags: User */
86 86
   $handler->display->display_options['relationships']['uid']['id'] = 'uid';
87
-  $handler->display->display_options['relationships']['uid']['table'] = 'flag_content';
87
+  $handler->display->display_options['relationships']['uid']['table'] = 'flagging';
88 88
   $handler->display->display_options['relationships']['uid']['field'] = 'uid';
89 89
   $handler->display->display_options['relationships']['uid']['relationship'] = 'flag_content_rel';
90 90
   /* Field: User: Name */
@@ -96,20 +96,20 @@ function commons_follow_user_views_default_views() {
96 96
   $handler->display->display_options['fields']['name']['alter']['ellipsis'] = FALSE;
97 97
   /* Field: Flags: Flag link */
98 98
   $handler->display->display_options['fields']['ops_1']['id'] = 'ops_1';
99
-  $handler->display->display_options['fields']['ops_1']['table'] = 'flag_content';
99
+  $handler->display->display_options['fields']['ops_1']['table'] = 'flagging';
100 100
   $handler->display->display_options['fields']['ops_1']['field'] = 'ops';
101 101
   $handler->display->display_options['fields']['ops_1']['relationship'] = 'flag_content_rel_1';
102 102
   $handler->display->display_options['fields']['ops_1']['label'] = 'Send email?';
103 103
   /* Field: Flags: Flag link */
104 104
   $handler->display->display_options['fields']['ops']['id'] = 'ops';
105
-  $handler->display->display_options['fields']['ops']['table'] = 'flag_content';
105
+  $handler->display->display_options['fields']['ops']['table'] = 'flagging';
106 106
   $handler->display->display_options['fields']['ops']['field'] = 'ops';
107 107
   $handler->display->display_options['fields']['ops']['relationship'] = 'flag_content_rel';
108 108
   $handler->display->display_options['fields']['ops']['label'] = '';
109 109
   $handler->display->display_options['fields']['ops']['element_label_colon'] = FALSE;
110 110
   /* Sort criterion: Flags: Flagged time */
111 111
   $handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp';
112
-  $handler->display->display_options['sorts']['timestamp']['table'] = 'flag_content';
112
+  $handler->display->display_options['sorts']['timestamp']['table'] = 'flagging';
113 113
   $handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp';
114 114
   $handler->display->display_options['sorts']['timestamp']['relationship'] = 'flag_content_rel';
115 115
   $handler->display->display_options['sorts']['timestamp']['order'] = 'DESC';
@@ -206,7 +206,7 @@ function commons_follow_user_views_default_views() {
206 206
   $handler->display->display_options['relationships']['flag_content_rel']['user_scope'] = 'any';
207 207
   /* Relationship: Flags: User */
208 208
   $handler->display->display_options['relationships']['uid']['id'] = 'uid';
209
-  $handler->display->display_options['relationships']['uid']['table'] = 'flag_content';
209
+  $handler->display->display_options['relationships']['uid']['table'] = 'flagging';
210 210
   $handler->display->display_options['relationships']['uid']['field'] = 'uid';
211 211
   $handler->display->display_options['relationships']['uid']['relationship'] = 'flag_content_rel';
212 212
   $handler->display->display_options['relationships']['uid']['required'] = TRUE;
@@ -233,13 +233,13 @@ function commons_follow_user_views_default_views() {
233 233
   $handler->display->display_options['fields']['name']['element_default_classes'] = FALSE;
234 234
   /* Sort criterion: Flags: Flagged time */
235 235
   $handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp';
236
-  $handler->display->display_options['sorts']['timestamp']['table'] = 'flag_content';
236
+  $handler->display->display_options['sorts']['timestamp']['table'] = 'flagging';
237 237
   $handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp';
238 238
   $handler->display->display_options['sorts']['timestamp']['relationship'] = 'flag_content_rel';
239 239
   $handler->display->display_options['sorts']['timestamp']['order'] = 'DESC';
240 240
   /* Contextual filter: Flags: Content ID */
241 241
   $handler->display->display_options['arguments']['content_id']['id'] = 'content_id';
242
-  $handler->display->display_options['arguments']['content_id']['table'] = 'flag_content';
242
+  $handler->display->display_options['arguments']['content_id']['table'] = 'flagging';
243 243
   $handler->display->display_options['arguments']['content_id']['field'] = 'content_id';
244 244
   $handler->display->display_options['arguments']['content_id']['relationship'] = 'flag_content_rel';
245 245
   $handler->display->display_options['arguments']['content_id']['default_action'] = 'default';
@@ -381,13 +381,13 @@ function commons_follow_user_views_default_views() {
381 381
   $handler->display->display_options['fields']['name']['element_default_classes'] = FALSE;
382 382
   /* Sort criterion: Flags: Flagged time */
383 383
   $handler->display->display_options['sorts']['timestamp']['id'] = 'timestamp';
384
-  $handler->display->display_options['sorts']['timestamp']['table'] = 'flag_content';
384
+  $handler->display->display_options['sorts']['timestamp']['table'] = 'flagging';
385 385
   $handler->display->display_options['sorts']['timestamp']['field'] = 'timestamp';
386 386
   $handler->display->display_options['sorts']['timestamp']['relationship'] = 'flag_content_rel';
387 387
   $handler->display->display_options['sorts']['timestamp']['order'] = 'DESC';
388 388
   /* Contextual filter: Flags: User uid */
389 389
   $handler->display->display_options['arguments']['uid']['id'] = 'uid';
390
-  $handler->display->display_options['arguments']['uid']['table'] = 'flag_content';
390
+  $handler->display->display_options['arguments']['uid']['table'] = 'flagging';
391 391
   $handler->display->display_options['arguments']['uid']['field'] = 'uid';
392 392
   $handler->display->display_options['arguments']['uid']['relationship'] = 'flag_content_rel';
393 393
   $handler->display->display_options['arguments']['uid']['default_action'] = 'default';

+ 2
- 2
modules/commons/commons_like/commons-like.tpl.php View File

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

+ 1
- 1
modules/commons/commons_like/commons_like.module View File

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

+ 1
- 1
modules/commons/commons_q_a/commons_q_a.module View File

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

+ 25
- 14
modules/commons/commons_radioactivity/includes/incidents/commons_radioactivity.incidents_flag.inc View File

@@ -6,26 +6,37 @@
6 6
  */
7 7
 
8 8
 /**
9
- * Implements hook_flag().
9
+ * Implements hook_flag_flag().
10 10
  *
11 11
  * Trigger radioactivity incidents when a user follows a node or group.
12 12
  */
13
-function commons_radioactivity_flag($op, $flag, $content_id, $account, $fcid) {
13
+function commons_radioactivity_flag_flag($flag, $entity_id, $account, $fcid) {
14 14
   if (in_array($flag->name, array('commons_follow_node', 'commons_follow_group'))) {
15
-    $node = node_load($content_id);
15
+    $node = node_load($entity_id);
16 16
 
17
-    if ($op == 'flag') {
18
-      // A user following their own node should not increase radioactivity.
19
-      if ($node->uid != $account->uid) {
20
-        commons_radioactivity_incident_node($node,  COMMONS_RADIOACTIVITY_FLAG_NODE);
21
-      }
17
+    // A user following their own node shouldn't add to its radioactivity.
18
+    if ($node->uid == $account->uid) {
19
+      return;
22 20
     }
23 21
 
24
-    if ($op == 'unflag') {
25
-      // A user unfollowing their own node should not decrease radioactivity.
26
-      if ($node->uid != $account->uid) {
27
-        commons_radioactivity_incident_node($node,  -1 * COMMONS_RADIOACTIVITY_FLAG_NODE);
28
-      }
29
-    }
22
+    commons_radioactivity_incident_node($node,  COMMONS_RADIOACTIVITY_FLAG_NODE);
30 23
   }
31 24
 }
25
+
26
+/**
27
+ * Implements hook_flag_unflag().
28
+ *
29
+ * Trigger radioactivity incidents when a user follows a node or group.
30
+ */
31
+function commons_radioactivity_flag_unflag($flag, $entity_id, $account, $flagging) {
32
+  if (in_array($flag->name, array('commons_follow_node', 'commons_follow_group'))) {
33
+    $node = node_load($entity_id);
34
+
35
+    // A user unfollowing their own node shouldn't add to its radioactivity.
36
+    if ($node->uid == $account->uid) {
37
+      return;
38
+    }
39
+
40
+    commons_radioactivity_incident_node($node,  -1 * COMMONS_RADIOACTIVITY_FLAG_NODE);
41
+  }
42
+}

+ 4
- 4
modules/commons/commons_search/modules/commons_search_solr_user/commons_search_solr_user.module View File

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

Loading…
Cancel
Save