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  91c392032a090093c53ad9c6a30807e33273e35b (commit)
      from  46546d3239db91b4a3bfa10aded4bd4c11c37cff (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=91c392032a090093c53ad9c6a30807e33273e35b

commit 91c392032a090093c53ad9c6a30807e33273e35b
Author: Franck Villaume <[email protected]>
Date:   Wed Oct 11 15:50:21 2017 +0000

    forums: refactor getForumsAdmin for better permission check and error 
setting

diff --git a/src/common/forum/ForumFactory.class.php 
b/src/common/forum/ForumFactory.class.php
index 5ba1617..9fd9478 100644
--- a/src/common/forum/ForumFactory.class.php
+++ b/src/common/forum/ForumFactory.class.php
@@ -132,15 +132,14 @@ class ForumFactory extends FFError {
         * @return      array   The array of Forum objects.
         */
        function &getForumsAdmin() {
-               if ($this->forums) {
-                       return $this->forums;
-               }
-
                if (session_loggedin()) {
                        if (!forge_check_perm ('forum_admin', 
$this->Group->getID())) {
                                $this->setError(_('You are not allowed to 
access this page'));
                                $this->forums = false;
                        } else {
+                               if ($this->forums) {
+                                       return $this->forums;
+                               }
                                $result = db_query_params('SELECT * FROM 
forum_group_list_vw
                                                        WHERE group_id=$1
                                                        ORDER BY 
group_forum_id',
@@ -151,14 +150,20 @@ class ForumFactory extends FFError {
                        $this->forums = false;
                }
 
-               $rows = db_numrows($result);
-
-               if (!$result || ($rows < 1)) {
-                       $this->setError(_('Forum not found')._(': 
').db_error());
-                       $this->forums = false;
-               } else {
-                       while ($arr = db_fetch_array($result)) {
-                               $this->forums[] = new Forum($this->Group, 
$arr['group_forum_id'], $arr);
+               if (isset($result))
+                       if (!$result) {
+                               $this->setError(db_error());
+                               $this->forums = false;
+                       } else {
+                               $rows = db_numrows($result);
+                               if ($rows <= 0) {
+                                       $this->setError(_('No forums found.')); 
+                                       $this->forums = false;
+                               } else {
+                                       while ($arr = db_fetch_array($result)) {
+                                               $this->forums[] = new 
Forum($this->Group, $arr['group_forum_id'], $arr);
+                                       }
+                               }
                        }
                }
                return $this->forums;
diff --git a/src/www/forum/admin/index.php b/src/www/forum/admin/index.php
index 06047c1..4941f4d 100644
--- a/src/www/forum/admin/index.php
+++ b/src/www/forum/admin/index.php
@@ -365,8 +365,8 @@ if (getStringFromRequest('add_forum')) {
 
                $farr = $ff->getForums();
 
-               if ($ff->isError()) {
-                       echo $HTML->error_msg(sprintf(_('No Forums Found for 
%s'), $g->getPublicName()).' '.$ff->getErrorMessage());
+               if (is_array($farr) && count($farr) == 0) {
+                       echo $HTML->error_msg(_('No forums found.'));
                        forum_footer();
                        exit;
                }
@@ -439,8 +439,8 @@ if (getStringFromRequest('add_forum')) {
 
        $farr = $ff->getForumsAdmin();
 
-       if ($ff->isError()) {
-               echo $HTML->error_msg(sprintf(_('No Forums Found for %s'), 
$g->getPublicName()).' '.$ff->getErrorMessage());
+       if (!$farr) {
+               echo $HTML->error_msg($ff->getErrorMessage());
                forum_footer();
                exit;
        }

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

Summary of changes:
 src/common/forum/ForumFactory.class.php | 29 +++++++++++++++++------------
 src/www/forum/admin/index.php           |  8 ++++----
 2 files changed, 21 insertions(+), 16 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