This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, 6.1 has been updated
       via  7ad3fe97d8ef2db57d3cef77001fc45936a1491a (commit)
      from  c7f2b866f4b521fcedec8b9e3cdde28b02af9ef3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=7ad3fe97d8ef2db57d3cef77001fc45936a1491a

commit 7ad3fe97d8ef2db57d3cef77001fc45936a1491a
Author: Franck Villaume <[email protected]>
Date:   Fri Jan 12 17:38:17 2018 +0100

    globalactivity plugin: use standard Activity object to check for permission

diff --git a/src/plugins/globalactivity/common/globalactivity-init.php 
b/src/plugins/globalactivity/common/globalactivity-init.php
index 8429e92..9fd7c2c 100644
--- a/src/plugins/globalactivity/common/globalactivity-init.php
+++ b/src/plugins/globalactivity/common/globalactivity-init.php
@@ -1,8 +1,9 @@
 <?php
-
 /**
  *
  * This file is part of FusionForge.
+ * Copyright 2016, Roland Mas
+ * Copyright 2017, Franck Villaume - TrivialDev
  *
  * FusionForge is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -20,11 +21,12 @@
  */
 
 global $gfplugins;
-require_once 
$gfplugins.'globalactivity/include/globalactivityPlugin.class.php' ;
+require_once 
$gfplugins.'globalactivity/include/globalactivityPlugin.class.php';
+require_once $gfcommon.'include/Activity.class.php';
 
-$globalactivityPluginObject = new globalactivityPlugin ;
+$globalactivityPluginObject = new globalactivityPlugin;
 
-register_plugin ($globalactivityPluginObject) ;
+register_plugin($globalactivityPluginObject);
 
 // Local Variables:
 // mode: php
diff --git a/src/plugins/globalactivity/include/globalactivityPlugin.class.php 
b/src/plugins/globalactivity/include/globalactivityPlugin.class.php
index 2d9f345..cace0ea 100644
--- a/src/plugins/globalactivity/include/globalactivityPlugin.class.php
+++ b/src/plugins/globalactivity/include/globalactivityPlugin.class.php
@@ -81,7 +81,7 @@ class globalactivityPlugin extends Plugin {
                        
$uri.'#globalactivity_getActivityForProject','rpc','encoded');
        }
 
-       public function getData($begin,$end,&$show,&$ids,&$texts,$gid = NULL) {
+       public function getData($begin, $end, &$show, &$ids, &$texts, $gid = 
NULL) {
                if ($begin > $end) {
                        $tmp = $end;
                        $end = $begin;
@@ -137,73 +137,15 @@ class globalactivityPlugin extends Plugin {
                        $section = $show;
                }
 
-               function activity_date_compare($a, $b) {
-                       if ($a['activity_date'] == $b['activity_date']) {
-                               return 0;
-                       }
-                       return ($a['activity_date'] > $b['activity_date']) ? -1 
: 1;
-               }
-
-               global $cached_perms;
+               $ffactivity = new Activity();
                $cached_perms = array();
-               function check_perm_for_activity($arr) {
-                       global $cached_perms;
-                       $s = $arr['section'];
-                       $ref = $arr['ref_id'];
-                       $group_id = $arr['group_id'];
-
-                       if (!isset($cached_perms[$s][$ref])) {
-                               switch ($s) {
-                                       case 'scm': {
-                                               $cached_perms[$s][$ref] = 
forge_check_perm('scm', $group_id, 'read');
-                                               break;
-                                       }
-                                       case 'trackeropen':
-                                       case 'trackerclose': {
-                                               $cached_perms[$s][$ref] = 
forge_check_perm('tracker', $ref, 'read');
-                                               break;
-                                       }
-                                       case 'frsrelease': {
-                                               $cached_perms[$s][$ref] = 
forge_check_perm('frs', $ref, 'read');
-                                               break;
-                                       }
-                                       case 'forumpost':
-                                       case 'news': {
-                                               $cached_perms[$s][$ref] = 
forge_check_perm('forum', $ref, 'read');
-                                               break;
-                                       }
-                                       case 'taskopen':
-                                       case 'taskclose':
-                                       case 'taskdelete': {
-                                               $cached_perms[$s][$ref] = 
forge_check_perm('pm', $ref, 'read');
-                                               break;
-                                       }
-                                       case 'docmannew':
-                                       case 'docmanupdate':
-                                       case 'docgroupnew': {
-                                               $cached_perms[$s][$ref] = 
forge_check_perm('docman', $group_id, 'read');
-                                               break;
-                                       }
-                                       default: {
-                                               // Must be a bug somewhere, 
we're supposed to handle all types
-                                               $cached_perms[$s][$ref] = false;
-                                       }
-                               }
-                       }
-                       return $cached_perms[$s][$ref];
-               }
 
                if ($gid) {
                        $res = db_query_params('SELECT * FROM activity_vw WHERE 
activity_date BETWEEN $1 AND $2 AND section = ANY ($3) AND group_id = $4 ORDER 
BY activity_date DESC',
-                                                          array($begin,
-                                                                        $end,
-                                                                        
db_string_array_to_any_clause($section),
-                                                                        $gid));
+                                                          array($begin, $end, 
db_string_array_to_any_clause($section), $gid));
                } else {
                        $res = db_query_params('SELECT * FROM activity_vw WHERE 
activity_date BETWEEN $1 AND $2 AND section = ANY ($3) ORDER BY activity_date 
DESC',
-                                                          array($begin,
-                                                                        $end,
-                                                                        
db_string_array_to_any_clause($section)));
+                                                          array($begin, $end, 
db_string_array_to_any_clause($section)));
                }
 
                if (db_error()) {
@@ -216,7 +158,7 @@ class globalactivityPlugin extends Plugin {
                        if (!forge_check_perm('project_read', $group_id)) {
                                continue;
                        }
-                       if (!check_perm_for_activity($arr)) {
+                       if (!$ffactivity->check_perm_for_activity($arr, 
$cached_perms)) {
                                continue;
                        }
                        $results[] = $arr;
@@ -265,13 +207,13 @@ class globalactivityPlugin extends Plugin {
                        if (!forge_check_perm('project_read', $group_id)) {
                                continue;
                        }
-                       if (!check_perm_for_activity($arr)) {
+                       if (!$ffactivity->check_perm_for_activity($arr, 
$cached_perms)) {
                                continue;
                        }
                        $res2[] = $arr;
                }
 
-               usort($res2, 'activity_date_compare');
+               usort($res2, 'Activity::date_compare');
 
                return $res2;
        }

-----------------------------------------------------------------------

Summary of changes:
 .../globalactivity/common/globalactivity-init.php  | 10 +--
 .../include/globalactivityPlugin.class.php         | 72 +++-------------------
 2 files changed, 13 insertions(+), 69 deletions(-)


hooks/post-receive
-- 
FusionForge

_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits

Reply via email to