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, master has been updated
       via  fb49e468234a3e2ce6be16ec01d3af2db6d56530 (commit)
      from  46d37b0782b12006ba483316956c079afe84fb97 (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 -----------------------------------------------------------------
commit fb49e468234a3e2ce6be16ec01d3af2db6d56530
Author: Franck Villaume <[email protected]>
Date:   Thu Jun 26 13:40:20 2014 +0200

    Implement [#697]: FRS "My monitored packages" widget

diff --git a/src/CHANGES b/src/CHANGES
index fb48c37..ae88ff5 100644
--- a/src/CHANGES
+++ b/src/CHANGES
@@ -2,6 +2,7 @@ Fusionforge-X.X:
 * [#658] Docman: Basic Webdav write mkcol, delete, put, move support 
(TrivialDev)
 * [#657] Docman: Add move mass actions (TrivialDev)
 * [#692] FRS: Reorganise code (TrivialDev)
+* [#697] FRS: Enable widget "My monitored packages" (TrivialDev)
 * [#656] General: drop tipsy plugin, use standard jQuery UI tooltip already 
provided (TrivialDev)
 * [#663] General: FusionForge Theme & jQuery UI theme sync (TrivialDev)
 * [#664] General: Update the jQuery & jQuery UI frameworks (TrivialDev)
diff --git a/src/common/frs/actions/monitor.php 
b/src/common/frs/actions/monitor.php
index abf33af..a6c815a 100644
--- a/src/common/frs/actions/monitor.php
+++ b/src/common/frs/actions/monitor.php
@@ -29,50 +29,81 @@ global $HTML;
 
 $sysdebug_enable = false;
 
+$ajax = getIntFromRequest('ajax', 1);
+
 $result = array();
 if (!forge_check_perm('frs', $group_id, 'read_public')) {
-       $result['html'] = $HTML->warning_msg(_('FRS Action Denied.'));
-       echo json_encode($result);
-       exit;
+       $warning_msg = _('FRS Action Denied.');
+       if ($ajax) {
+               $result['html'] = $HTML->warning_msg($warning_msg);
+               echo json_encode($result);
+               exit;
+       } else {
+               session_redirect('/frs/?group_id='.$group_id);
+       }
 }
 
 $package_id = getIntFromRequest('package_id');
+$redirect_url = getStringFromRequest('redirect_url', '/my/');
 
 if ($package_id) {
        $frsp = new FRSPackage($g, $package_id);
        if (!$frsp || !is_object($frsp)) {
-               $result['html'] = $HTML->error_msg(_('Error Getting 
FRSPackage'));
-               echo json_encode($result);
-               exit;
+               $error_msg = _('Error Getting FRSPackage');
+               if ($ajax) {
+                       $result['html'] = $HTML->error_msg($error_msg);
+                       echo json_encode($result);
+                       exit;
+               } else {
+                       session_redirect('/frs/?group_id='.$group_id);
+               }
        } elseif ($frsp->isError()) {
-               $result['html'] = $HTML->error_msg($frsp->getErrorMessage());
-               echo json_encode($result);
-               exit;
+               $error_msg = $frsp->getErrorMessage();
+               if ($ajax) {
+                       $result['html'] = $HTML->error_msg($error_msg);
+                       echo json_encode($result);
+                       exit;
+               } else {
+                       session_redirect('/frs/?group_id='.$group_id);
+               }
        }
        $monitorStatus = getIntFromRequest('status');
        $url = 
'/frs/?group_id='.$frsp->Group->getID().'&package_id='.$package_id.'&action=monitor';
        if ($monitorStatus) {
                if ($frsp->setMonitor()) {
-                       $url .= '&status=0';
-                       $result['html'] = $HTML->feedback(_('Monitoring started 
successfuly'));
-                       $result['action'] = 
'javascript:controllerFRS.doAction({action:\''.$url.'\', 
id:\'pkgid'.$package_id.'\'})';
-                       $result['property'] = 'onclick';
-                       $result['img'] = 
$HTML->getStopMonitoringPic($frsp->getName().' - '._('Stop monitoring this 
package'));
-                       echo json_encode($result);
-                       exit;
+                       if ($ajax) {
+                               $url .= '&status=0';
+                               $result['html'] = $HTML->feedback(_('Monitoring 
started successfuly'));
+                               $result['action'] = 
'javascript:controllerFRS.doAction({action:\''.$url.'\', 
id:\'pkgid'.$package_id.'\'})';
+                               $result['property'] = 'onclick';
+                               $result['img'] = 
$HTML->getStopMonitoringPic($frsp->getName().' - '._('Stop monitoring this 
package'));
+                               echo json_encode($result);
+                               exit;
+                       } else {
+                               session_redirect($redirect_url);
+                       }
                }
        } else {
                if ($frsp->stopMonitor()) {
-                       $url .= '&status=1';
-                       $result['html'] = $HTML->feedback(_('Monitoring stopped 
successfuly'));
-                       $result['action'] = 
'javascript:controllerFRS.doAction({action:\''.$url.'\', 
id:\'pkgid'.$package_id.'\'})';
-                       $result['property'] = 'onclick';
-                       $result['img'] = 
$HTML->getStartMonitoringPic($frsp->getName().' - '._('Start monitoring this 
package'));
-                       echo json_encode($result);
-                       exit;
+                       if ($ajax) {
+                               $url .= '&status=1';
+                               $result['html'] = $HTML->feedback(_('Monitoring 
stopped successfuly'));
+                               $result['action'] = 
'javascript:controllerFRS.doAction({action:\''.$url.'\', 
id:\'pkgid'.$package_id.'\'})';
+                               $result['property'] = 'onclick';
+                               $result['img'] = 
$HTML->getStartMonitoringPic($frsp->getName().' - '._('Start monitoring this 
package'));
+                               echo json_encode($result);
+                               exit;
+                       } else {
+                               session_redirect($redirect_url);
+                       }
                }
        }
 }
-$result['html'] = $HTML->error_msg(_('Missing package_id'));
-echo json_encode($result);
-exit;
+$error_msg = _('Missing package_id');
+if ($ajax) {
+       $result['html'] = $HTML->error_msg($error_msg);
+       echo json_encode($result);
+       exit;
+} else {
+       session_redirect('/frs/?group_id='.$group_id);
+}
diff --git a/src/common/widget/Widget.class.php 
b/src/common/widget/Widget.class.php
index e9a4067..29f1811 100644
--- a/src/common/widget/Widget.class.php
+++ b/src/common/widget/Widget.class.php
@@ -25,7 +25,7 @@ require_once 'common/widget/Widget_MySurveys.class.php';
 require_once 'common/widget/Widget_MyProjects.class.php';
 require_once 'common/widget/Widget_MyBookmarks.class.php';
 require_once 'common/widget/Widget_MyMonitoredForums.class.php';
-//require_once('common/widget/Widget_MyMonitoredFp.class.php');
+require_once('common/widget/Widget_MyMonitoredFp.class.php');
 require_once 'common/widget/Widget_MyLatestSvnCommits.class.php';
 require_once 'common/widget/Widget_MyProjectsLastDocuments.class.php';
 require_once 'common/widget/Widget_MyArtifacts.class.php';
@@ -213,10 +213,10 @@ require_once 
'common/widget/Widget_MyMonitoredDocuments.class.php';
                                break;/*
                        case 'mysrs':
                                $o = new Widget_MySrs();
-                               break;
+                               break;*/
                        case 'mymonitoredfp':
                                $o = new Widget_MyMonitoredFp();
-                               break;
+                               break;/*
                        case 'mylatestsvncommits':
                                $o = new Widget_MyLatestSvnCommits();
                                break;
diff --git a/src/common/widget/Widget_MyMonitoredFp.class.php 
b/src/common/widget/Widget_MyMonitoredFp.class.php
index 9ef7875..b780fbb 100644
--- a/src/common/widget/Widget_MyMonitoredFp.class.php
+++ b/src/common/widget/Widget_MyMonitoredFp.class.php
@@ -1,6 +1,7 @@
 <?php
 /**
  * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights 
reserved
+ * Copyright 2014, Franck Villaume - TrivialDev
  *
  * This file is a part of Fusionforge.
  *
@@ -19,111 +20,116 @@
  */
 
 require_once 'Widget.class.php';
-require_once 'common/frs/FRSPackageFactory.class.php';
 /**
 * Widget_MyMonitoredFp
 *
-* Filemodules that are actively monitored
+* FRS packages that are actively monitored
 */
 class Widget_MyMonitoredFp extends Widget {
-    function Widget_MyMonitoredFp() {
-        $this->Widget('mymonitoredfp');
-    }
-    function getTitle() {
-        return _("Monitored File Packages");
-    }
-    function getContent() {
-        $frsrf = new FRSReleaseFactory();
-        $html_my_monitored_fp = '';
-        $sql="SELECT groups.group_name,groups.group_id ".
-            "FROM groups,filemodule_monitor,frs_package ".
-            "WHERE groups.group_id=frs_package.group_id ".
-            "AND frs_package.status_id !=$1".
-            "AND frs_package.package_id=filemodule_monitor.filemodule_id ".
-            "AND filemodule_monitor.user_id=$2";
-        $um =& UserManager::instance();
-        $current_user =& $um->getCurrentUser();
-        if ($current_user->isRestricted()) {
-            $projects = $current_user->getProjects();
-            $sql .= "AND groups.group_id IN (". implode(',', $projects) .") ";
-        }
-        $sql .= "GROUP BY group_id ORDER BY group_id ASC LIMIT 100";
+       function Widget_MyMonitoredFp() {
+               $this->Widget('mymonitoredfp');
+       }
+       function getTitle() {
+               return _('Monitored File Packages');
+       }
+       function getContent() {
+               global $HTML;
+               $html_my_monitored_fp = '';
+               $sql = "SELECT groups.group_name,groups.group_id ".
+                       "FROM groups,filemodule_monitor,frs_package ".
+                       "WHERE groups.group_id=frs_package.group_id ".
+                       "AND groups.status = 'A'".
+                       "AND 
frs_package.package_id=filemodule_monitor.filemodule_id ".
+                       "AND filemodule_monitor.user_id=$1";
+               $um = UserManager::instance();
+               $current_user = $um->getCurrentUser();
+               if ($current_user->getStatus()=='S') {
+                       $projects = $current_user->getProjects();
+                       $sql .= 'AND groups.group_id IN ('. implode(',', 
$projects) .') ';
+               }
+               $sql .= 'GROUP BY groups.group_id ORDER BY groups.group_id ASC 
LIMIT 100';
 
-        
$result=db_query_params($sql,array($frsrf->STATUS_DELETED,user_getid()));
-        $rows=db_numrows($result);
-        if (!$result || $rows < 1) {
-            $html_my_monitored_fp .= '<p><b>' . _("You are not monitoring any 
files.") . '</b></p><p>' . _("If you monitor files, you will be sent new 
release notices via email, with a link to the new file on our download 
server.") . '</p><p>' . _("You can monitor files by visiting a project's 
“Summary Page” and clicking on the appropriate icon in the files section.") . 
'</p>';
-        } else {
-            $html_my_monitored_fp .= '<table style="width:100%">';
-            $request =& HTTPRequest::instance();
-            for ($j=0; $j<$rows; $j++) {
-                $group_id = db_result($result,$j,'group_id');
+               $result = db_query_params($sql,array(user_getid()));
+               $rows = db_numrows($result);
+               if (!$result || $rows < 1) {
+                       $html_my_monitored_fp .= $HTML->warning_msg(_('You are 
not monitoring any files.')).html_e('p', array(), _('If you monitor files, you 
will be sent new release notices via email, with a link to the new file on our 
download server.')).html_e('p', array(), _("You can monitor files by visiting a 
project's “Summary Page” and clicking on the appropriate icon in the files 
section."));
+               } else {
+                       $html_my_monitored_fp .= $HTML->listTableTop();
+                       $request =& HTTPRequest::instance();
+                       for ($j = 0; $j < $rows; $j++) {
+                               $group_id = db_result($result, $j, 'group_id');
 
-                $sql2="SELECT 
frs_package.name,filemodule_monitor.filemodule_id ".
-                    "FROM groups,filemodule_monitor,frs_package ".
-                    "WHERE groups.group_id=frs_package.group_id ".
-                    "AND groups.group_id=$1 ".
-                    "AND frs_package.status_id !=$2".
-                    "AND 
frs_package.package_id=filemodule_monitor.filemodule_id ".
-                    "AND filemodule_monitor.user_id=$3  LIMIT 100";
-                $result2 = 
db_query_params($sql2,array($group_id,$frsrf->STATUS_DELETED,user_getid()));
-                $rows2 = db_numrows($result2);
+                               $sql2="SELECT 
frs_package.name,filemodule_monitor.filemodule_id ".
+                                       "FROM 
groups,filemodule_monitor,frs_package ".
+                                       "WHERE 
groups.group_id=frs_package.group_id ".
+                                       "AND groups.group_id=$1 ".
+                                       "AND 
frs_package.package_id=filemodule_monitor.filemodule_id ".
+                                       "AND filemodule_monitor.user_id=$2  
LIMIT 100";
+                               $result2 = db_query_params($sql2, 
array($group_id, user_getid()));
+                               $rows2 = db_numrows($result2);
 
-                $vItemId = new Valid_UInt('hide_item_id');
-                $vItemId->required();
-                if($request->valid($vItemId)) {
-                    $hide_item_id = $request->get('hide_item_id');
-                } else {
-                    $hide_item_id = null;
-                }
+                               $vItemId = new Valid_UInt('hide_item_id');
+                               $vItemId->required();
+                               if($request->valid($vItemId)) {
+                                       $hide_item_id = 
$request->get('hide_item_id');
+                               } else {
+                                       $hide_item_id = null;
+                               }
 
-                $vFrs = new Valid_WhiteList('hide_frs', array(0, 1));
-                $vFrs->required();
-                if($request->valid($vFrs)) {
-                    $hide_frs = $request->get('hide_frs');
-                } else {
-                    $hide_frs = null;
-                }
+                               $vFrs = new Valid_WhiteList('hide_frs', 
array(0, 1));
+                               $vFrs->required();
+                               if($request->valid($vFrs)) {
+                                       $hide_frs = $request->get('hide_frs');
+                               } else {
+                                       $hide_frs = null;
+                               }
 
-                list($hide_now,$count_diff,$hide_url) = 
my_hide_url('frs',$group_id,$hide_item_id,$rows2,$hide_frs);
+                               list($hide_now, $count_diff, $hide_url) = 
my_hide_url('frs', $group_id, $hide_item_id, $rows2, $hide_frs);
 
-                $html_hdr = '<tr class="boxitem"><td colspan="2">'.
-                    $hide_url.'<a href="/project/?group_id='.$group_id.'">'.
-                    db_result($result,$j,'group_name').'</a> ';
+                               $count_new = max(0, $count_diff);
+                               $cells = array();
+                               $cells[] = 
array($hide_url.util_make_link('/frs/?group_id='.$group_id, 
db_result($result,$j,'group_name')).my_item_count($rows2,$count_new), 'colspan' 
=> 2);
+                               $html_hdr = $HTML->multiTableRow(array('class' 
=> 'boxitem'), $cells);
+                               $html = '';
+                               for ($i = 0; $i < $rows2; $i++) {
+                                       if (!$hide_now) {
+                                               $cells = array();
+                                               $url = 
'/frs/?group_id='.$group_id.'&package_id='.db_result($result2,$i,'filemodule_id').'&action=monitor&status=0&ajax=0';
+                                               $title = 
db_result($result2,$i,'name').' - '._('Stop monitoring this package');
+                                               $package_monitor = 
util_make_link($url, $HTML->getDeletePic($title));
+                                               $cells[] = array('    - 
'.util_make_link('/frs/?group_id='.$group_id, db_result($result2,$i,'name')), 
'width' => '99%');
+                                               $cells[][] = $package_monitor;
+                                               $html .= 
$HTML->multiTableRow(array('class' => $HTML->boxGetAltRowStyle($i, true)), 
$cells);
+                                       }
+                               }
+                               $html_my_monitored_fp .= $html_hdr .$html;
+                       }
+                       $html_my_monitored_fp .= $HTML->listTableBottom();
+               }
+               return $html_my_monitored_fp;
+       }
 
-                $html = '';
-                $count_new = max(0, $count_diff);
-                for ($i=0; $i<$rows2; $i++) {
-                    if (!$hide_now) {
-                        $html .='
-                        <tr class="'. util_get_alt_row_color($i) .'">'.
-                            '<td style="width:99%">    - <a 
href="/file/showfiles.php?group_id='.$group_id.'">'.
-                            db_result($result2,$i,'name').'</a></td>'.
-                            '<td><a 
href="/file/filemodule_monitor.php?filemodule_id='.
-                            db_result($result2,$i,'filemodule_id').
-                            '" onClick="return confirm(\''._("Stop Monitoring 
this Package?").'\')">'.
-                            '<img 
src="'.util_get_image_theme("ic/trash.png").'" height="16" width="16" '.
-                            'alt="'._("Stop Monitoring").'" /></a></td></tr>';
-                    }
-                }
+       function getCategory() {
+               return _('File Release System');
+       }
+       function getDescription() {
+               return _('List packages that you are currently monitoring, by 
project.')
+               . '<br />'
+               . _('To cancel any of the monitored items just click on the 
trash icon next to the item label.');
+       }
+       function isAjax() {
+               return true;
+       }
 
-                $html_hdr .= my_item_count($rows2,$count_new).'</td></tr>';
-                $html_my_monitored_fp .= $html_hdr .$html;
-            }
-            $html_my_monitored_fp .= '</table>';
-        }
-        return $html_my_monitored_fp;
-    }
-
-    function getCategory() {
-        return _('File Release System');
-    }
-    function getDescription() {
-        return _("List packages that you are currently monitoring, by 
project.")
-             . '<br />'
-             . _("To cancel any of the monitored items just click on the trash 
icon next to the item label.");
-    }
-    function isAjax() {
-        return true;
-    }
+       function isAvailable() {
+               if (!forge_get_config('use_frs')) {
+                       return false;
+               }
+               foreach 
(UserManager::instance()->getCurrentUser()->getGroups(false) as $p) {
+                       if ($p->usesFRS()) {
+                               return true;
+                       }
+               }
+               return false;
+       }
 }

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

Summary of changes:
 src/CHANGES                                      |    1 +
 src/common/frs/actions/monitor.php               |   83 ++++++---
 src/common/widget/Widget.class.php               |    6 +-
 src/common/widget/Widget_MyMonitoredFp.class.php |  194 +++++++++++-----------
 4 files changed, 161 insertions(+), 123 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