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  fe105b3fab0a5dea853dd2e68af601499580302e (commit)
       via  ae8fc66fff98692fbea8bb8659709141f8329a0a (commit)
      from  a7b38820aef23ca07974a8f08a2541ce8840acd5 (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=fe105b3fab0a5dea853dd2e68af601499580302e

commit fe105b3fab0a5dea853dd2e68af601499580302e
Author: Franck Villaume <[email protected]>
Date:   Sun Jan 3 19:23:05 2016 +0100

    full list softwaremap page: remove any limitation. use paging system

diff --git a/src/common/include/FusionForge.class.php 
b/src/common/include/FusionForge.class.php
index 021d67d..8cd12b4 100644
--- a/src/common/include/FusionForge.class.php
+++ b/src/common/include/FusionForge.class.php
@@ -61,11 +61,31 @@ class FusionForge extends Error {
 
        /**
         * List full number of hosted projects, public and private
+        *
+        * @param       array   $params         array of columns and values to 
filter query: $params['status'] = 'A' ...
+        * @param       string  $extended_qpa   string of SQL to be part of the 
QPA query
         */
-       function getNumberOfProjects($status) {
+       function getNumberOfProjects($params = array(), $extended_qpa = null) {
                $qpa = db_construct_qpa(false, 'SELECT count(*) as count FROM 
groups');
-               if ($status) {
-                       $qpa = db_construct_qpa($qpa, ' WHERE status = $1', 
array($status));
+               if (count($params) > 1) {
+                       $qpa = db_construct_qpa($qpa, ' WHERE ');
+                       $i = 0;
+                       foreach ($params as $key => $value) {
+                               $i++;
+                               $qpa = db_construct_qpa($qpa, $key.' = $1 ', 
array($value));
+                               if ($i < count($params)) {
+                                       $qpa = db_construct_qpa($qpa, ' AND ');
+                               }
+                       }
+               }
+               if (strlen($extended_qpa) > 1) {
+                       if (!strpos($qpa[0], 'WHERE')) {
+                               $qpa = db_construct_qpa($qpa, ' WHERE ');
+                       }
+                       if (strpos($qpa[0], 'AND')) {
+                               $qpa = db_construct_qpa($qpa, ' AND ');
+                       }
+                       $qpa = db_construct_qpa($qpa, $extended_qpa);
                }
                $res = db_query_qpa($qpa);
                if (!$res || db_numrows($res) < 1) {
@@ -75,15 +95,15 @@ class FusionForge extends Error {
                return $this->parseCount($res);
        }
        function getNumberOfActiveProjects() {
-               return $this->getNumberOfProjects('A');
+               return $this->getNumberOfProjects(array('status' => 'A'));
        }
 
        function getNumberOfDeletedProjects() {
-               return $this->getNumberOfProjects('D');
+               return $this->getNumberOfProjects(array('status' => 'D'));
        }
 
        function getNumberOfSuspendedProjects() {
-               return $this->getNumberOfProjects('S');
+               return $this->getNumberOfProjects(array('status' => 'S'));
        }
 
        function getNumberOfActiveUsers() {
diff --git a/src/common/include/Group.class.php 
b/src/common/include/Group.class.php
index cc0004e..93b17ba 100644
--- a/src/common/include/Group.class.php
+++ b/src/common/include/Group.class.php
@@ -161,24 +161,33 @@ function group_get_object_by_publicname($groupname) {
 /**
  * get_public_active_projects_asc() - Get a list of rows for public active 
projects (initially in trove/full_list)
  *
- * @param      int     $max_query_limit Optional Maximum number of rows to 
limit query length
+ * @param      int     $max_query_limit        Optional Maximum number of rows 
to limit query length
+ * @param      int     $offset                 start to retrieve rows from 
offset value
  * @return     array   List of public active projects
  */
-function group_get_public_active_projects_asc($max_query_limit = -1) {
+function group_get_public_active_projects_asc($max_query_limit = -1, $offset = 
0) {
+       $role_id = 1;
+       if (session_loggedin()) {
+               global $LUSER;
+               $userRoles = $LUSER->getRoles();
+               if (count($userRoles)) {
+                       foreach ($userRoles as $r) {
+                               $role_id .= ', '.$r->getID();
+                       }
+               }
+       }
 
        $res_grp = db_query_params ('
                        SELECT group_id, group_name, unix_group_name, 
short_description, register_time
                        FROM groups
                        WHERE status = $1 AND type_id=1 AND is_template=0 AND 
register_time > 0
+                       AND group_id in (select ref_id FROM pfo_role_setting 
WHERE section_name = $2 and perm_val = 1 and role_id IN ('.$role_id.'))
                        ORDER BY group_name ASC
                        ',
-                       array('A'),
-                       $max_query_limit);
+                       array('A', 'project_read'),
+                       $max_query_limit, $offset);
        $projects = array();
        while ($row_grp = db_fetch_array($res_grp)) {
-               if (!forge_check_perm ('project_read', $row_grp['group_id'])) {
-                       continue;
-               }
                $projects[] = $row_grp;
        }
        return $projects;
diff --git a/src/www/softwaremap/full_list.php 
b/src/www/softwaremap/full_list.php
index 9fd5ddd..21c8b03 100644
--- a/src/www/softwaremap/full_list.php
+++ b/src/www/softwaremap/full_list.php
@@ -2,7 +2,7 @@
 /**
  * Copyright (C) 2008-2009 Alcatel-Lucent
  * Copyright (C) 2010 Alain Peyrat - Alcatel-Lucent
- * Copyright 2012,2014 Franck Villaume - TrivialDev
+ * Copyright 2012,2014,2015, Franck Villaume - TrivialDev
  *
  * This file is part of FusionForge. FusionForge is free software;
  * you can redistribute it and/or modify it under the terms of the
@@ -51,88 +51,87 @@ if (!forge_get_config('use_project_full_list')) {
 }
 
 global $HTML;
+$role_id = 1;
+
+if (session_loggedin()) {
+       if (getStringFromRequest('setpaging')) {
+               /* store paging preferences */
+               $paging = getIntFromRequest('nres');
+               if (!$paging) {
+                       $paging = 25;
+               }
+               $LUSER->setPreference('paging', $paging);
+       }
+       /* logged in users get configurable paging */
+       $paging = $LUSER->getPreference('paging');
+       $userRoles = $LUSER->getRoles();
+       if (count($userRoles)) {
+               foreach ($userRoles as $r) {
+                       $role_id .= ', '.$r->getID();
+               }
+       }
+}
 
-$HTML->header(array('title'=>_('Project List'),'pagename'=>'softwaremap'));
-$HTML->printSoftwareMapLinks();
-
-$projects = group_get_public_active_projects_asc($TROVE_HARDQUERYLIMIT);
+if(!isset($paging) || !$paging)
+       $paging = 25;
 
-$querytotalcount = count($projects);
+$start = getIntFromRequest('start');
 
-// #################################################################
-// limit/offset display
+if ($start < 0) {
+       $start = 0;
+}
 
-$page = getIntFromRequest('page',1);
+$HTML->header(array('title'=>_('Project List'),'pagename'=>'softwaremap'));
+$HTML->printSoftwareMapLinks();
 
-// store this as a var so it can be printed later as well
-$html_limit = '';
-if ($querytotalcount == $TROVE_HARDQUERYLIMIT) {
-       $html_limit .= sprintf(_('More than <strong>%d</strong> projects in 
result set.'), $querytotalcount);
-}
-$html_limit .= sprintf(_('<strong>%d</strong> projects in result set.'), 
$querytotalcount);
+$nbProjects = FusionForge::getInstance()->getNumberOfProjects(array('status' 
=> 'A', 'type_id' => 1, 'is_template' => 0), 'register_time > 0 AND group_id in 
(select ref_id FROM pfo_role_setting WHERE section_name = \'project_read\' and 
perm_val = 1 and role_id IN ('.$role_id.'))');
 
-$html_limit .= ' ';
+$projects = group_get_public_active_projects_asc($paging, $start);
 
-// only display pages stuff if there is more to display
-if ($querytotalcount > $TROVE_BROWSELIMIT) {
-       $html_limit .= html_trove_limit_navigation_box($_SERVER['PHP_SELF'], 
$querytotalcount, $TROVE_BROWSELIMIT, $page);
-}
+$max = ($nbProjects > ($start + $paging)) ? ($start + $paging) : $nbProjects;
+echo $HTML->paging_top($start, $paging, $nbProjects, $max, 
'/softwaremap/full_list.php');
 
-echo $html_limit.html_e('hr');
+echo html_e('hr');
 
 // #################################################################
 // print actual project listings
-for ($i_proj=0;$i_proj<$querytotalcount;$i_proj++) {
+for ($i_proj = 0; $i_proj < count($projects); $i_proj++) {
        $row_grp = $projects[$i_proj];
 
-       // check to see if row is in page range
-       if (($i_proj >= (($page-1)*$TROVE_BROWSELIMIT)) && ($i_proj < 
($page*$TROVE_BROWSELIMIT))) {
-               $viewthisrow = 1;
-       } else {
-               $viewthisrow = 0;
+       // Embed RDFa description for /projects/PROJ_NAME
+       $proj_uri = 
util_make_url_g(strtolower($row_grp['unix_group_name']),$row_grp['group_id']);
+       echo html_ao('div', array('typeof' => 'doap:Project sioc:Space', 
'about' => $proj_uri));
+       echo html_e('span', array('rel' => 'planetforge:hosted_by', 'resource' 
=> util_make_url('/')), '', false);
+
+       echo $HTML->listTableTop();
+       $cells = array();
+       $content = 
util_make_link_g(strtolower($row_grp['unix_group_name']),$row_grp['group_id'],'<strong>'
+               .'<span property="doap:name">'
+               .$row_grp['group_name']
+               .'</span>'
+               .'</strong>').' ';
+       if ($row_grp['short_description']) {
+               $content .= '- '
+               . '<span property="doap:short_desc">'
+               . $row_grp['short_description']
+               . '</span>';
        }
-
-       if ($viewthisrow) {
-
-               // Embed RDFa description for /projects/PROJ_NAME
-               $proj_uri = 
util_make_url_g(strtolower($row_grp['unix_group_name']),$row_grp['group_id']);
-               echo html_ao('div', array('typeof' => 'doap:Project 
sioc:Space', 'about' => $proj_uri));
-               echo html_e('span', array('rel' => 'planetforge:hosted_by', 
'resource' => util_make_url('/')), '', false);
-
-               echo $HTML->listTableTop();
-               $cells = array();
-               $content = 
util_make_link_g(strtolower($row_grp['unix_group_name']),$row_grp['group_id'],'<strong>'
-                       .'<span property="doap:name">'
-                       .$row_grp['group_name']
-                       .'</span>'
-                       .'</strong>').' ';
-               if ($row_grp['short_description']) {
-                       $content .= '- '
-                       . '<span property="doap:short_desc">'
-                       . $row_grp['short_description']
-                       . '</span>';
-               }
-               $cells[] = array($content, 'colspan' => 2);
-               echo $HTML->multiTableRow(array('class' => 'top'), $cells);
-               $cells = array();
-               $content = '';
-               // list all trove categories
-               if (forge_get_config('use_trove')) {
-                       $content .= trove_getcatlisting($row_grp['group_id'], 
0, 1, 1);
-               }
-               $cells[] = array($content, 'class' => 'top');
-               $cells[] = array(html_e('br')._('Register Date')._(': 
').html_e('strong', array(), date(_('Y-m-d H:i'),$row_grp['register_time'])),
-                               'class' => 'bottom align-right');
-               echo $HTML->multiTableRow(array('class' => 'top'), $cells);
-               echo $HTML->listTableBottom();
-               echo html_ac(html_ap() -1);
-               echo html_e('hr');
-       } // end if for row and range chacking
-}
-
-// print bottom navigation if there are more projects to display
-if ($querytotalcount > $TROVE_BROWSELIMIT) {
-       echo $html_limit;
+       $cells[] = array($content, 'colspan' => 2);
+       echo $HTML->multiTableRow(array('class' => 'top'), $cells);
+       $cells = array();
+       $content = '';
+       // list all trove categories
+       if (forge_get_config('use_trove')) {
+               $content .= trove_getcatlisting($row_grp['group_id'], 0, 1, 1);
+       }
+       $cells[] = array($content, 'class' => 'top');
+       $cells[] = array(html_e('br')._('Register Date')._(': 
').html_e('strong', array(), date(_('Y-m-d H:i'),$row_grp['register_time'])),
+                       'class' => 'bottom align-right');
+       echo $HTML->multiTableRow(array('class' => 'top'), $cells);
+       echo $HTML->listTableBottom();
+       echo html_ac(html_ap() -1);
+       echo html_e('hr');
 }
 
+echo $HTML->paging_bottom($start, $paging, $nbProjects, 
'/softwaremap/full_list.php');
 $HTML->footer();

https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=ae8fc66fff98692fbea8bb8659709141f8329a0a

commit ae8fc66fff98692fbea8bb8659709141f8329a0a
Author: Franck Villaume <[email protected]>
Date:   Sun Jan 3 19:22:21 2016 +0100

    Layout: use proper html tag

diff --git a/src/www/include/Layout.class.php b/src/www/include/Layout.class.php
index c46a518..5bab928 100644
--- a/src/www/include/Layout.class.php
+++ b/src/www/include/Layout.class.php
@@ -1559,7 +1559,7 @@ if (isset($params['group']) && $params['group']) {
                        $sep = '&';
                }
                if ($start > 0) {
-                       $html_content .= 
util_make_link($actionUrl.$sep.'start='.($start-$paging),'<strong>← 
'._('previous').'</strong>');
+                       $html_content .= 
util_make_link($actionUrl.$sep.'start='.($start-$paging),'<strong>&larr; 
'._('previous').'</strong>');
                        $html_content .= '&nbsp;&nbsp;';
                }
                $pages = $totalElements / $paging;
@@ -1586,7 +1586,7 @@ if (isset($params['group']) && $params['group']) {
                        }
                }
                if ( $totalElements > $start + $paging) {
-                       $html_content .= 
util_make_link($actionUrl.$sep.'start='.($start+$paging),'<strong>'._('next').' 
→</strong>');
+                       $html_content .= 
util_make_link($actionUrl.$sep.'start='.($start+$paging),'<strong>'._('next').' 
&rarr;</strong>');
                }
                return $html_content;
        }

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

Summary of changes:
 src/common/include/FusionForge.class.php |  32 ++++++--
 src/common/include/Group.class.php       |  23 ++++--
 src/www/include/Layout.class.php         |   4 +-
 src/www/softwaremap/full_list.php        | 137 +++++++++++++++----------------
 4 files changed, 112 insertions(+), 84 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