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  29c6d1f6a0db8531215258ea06567a25bcbcd3d8 (commit)
      from  da4a8c45f8571ae366f913ae134a3995fac69f18 (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=29c6d1f6a0db8531215258ea06567a25bcbcd3d8

commit 29c6d1f6a0db8531215258ea06567a25bcbcd3d8
Author: Franck Villaume <[email protected]>
Date:   Sun Jan 12 19:44:09 2020 +0100

    new widget: Hall Of Fame: display most voted project, diary & artifact

diff --git a/src/CHANGES b/src/CHANGES
index 6c21777..57aa312 100644
--- a/src/CHANGES
+++ b/src/CHANGES
@@ -7,6 +7,7 @@ FusionForge X.y:
 * Utils: crossref, support diary [Nxxx] and Project [Pxxx] (TrivialDev)
 * Widget HomeLatestDiaryNotes: new widget for Forge home page to display 5 
latest public Diary Notes across the forge (TrivialDev)
 * Widget_RSS: upgrade SimplePie integration to 1.3.1 version (align source 
install & debian install) [#913] (TrivialDev)
+* Widget_HomeHallOfFame: new widget to display to most voted artifact, 
project, diary across the forge (TrivialDev)
 
 FusionForge 6.1.1:
 * Plugin Scmhook: fix scmhook commitEmail for scmhg broken [#903] (TrivialDev)
diff --git a/src/common/diary/DiaryNote.class.php 
b/src/common/diary/DiaryNote.class.php
index 0440fdb..9b9fb06 100644
--- a/src/common/diary/DiaryNote.class.php
+++ b/src/common/diary/DiaryNote.class.php
@@ -199,7 +199,8 @@ class DiaryNote extends FFObject {
                        default:
                                $abstract = nl2br($abstract);
                }
-               $content = html_e('div', array('class' => 
'widget-sticker-header box'), html_e('div', 
array(),util_make_link($this->getLink(), 
$this->getSummary()).'&nbsp;'._('by').'&nbsp;').util_display_user($this->getUser()->getUnixname(),
 $this->getUser()->getID(), $this->getUser()->GetRealname()));
+               $arr_v = $this->getVotes();
+               $content = html_e('div', array('class' => 
'widget-sticker-header box'), html_e('div', array(), 
util_make_link($this->getLink(), $this->getSummary()).' - '.$arr_v[0].' 
'._('Vote(s)').'&nbsp;'._('by').'&nbsp;').util_display_user($this->getUser()->getUnixname(),
 $this->getUser()->getID(), $this->getUser()->GetRealname()));
                $content .= html_e('div', array('class' => 
'widget-sticker-body'), 
$abstract.html_e('br').util_make_link($this->getLink(),_('... Read more')));
                $content .= html_e('div', array('class' => 
'widget-sticker-footer'), _('Posted')._(': ').$this->getDatePostedOn());
                return html_e('div', array('class' => 
'widget-sticker-container'), $content);
diff --git a/src/common/include/FusionForge.class.php 
b/src/common/include/FusionForge.class.php
index 88cd8a3..559c3e7 100644
--- a/src/common/include/FusionForge.class.php
+++ b/src/common/include/FusionForge.class.php
@@ -4,7 +4,7 @@
  *
  * Copyright 2002, GForge, LLC
  * Copyright 2009-2011, Roland Mas
- * Copyright 2015, Franck Villaume - TrivialDev
+ * Copyright 2015,2020, 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
@@ -212,6 +212,58 @@ class FusionForge extends FFError {
                $row_count = db_fetch_array($res);
                return (int)$row_count['count'];
        }
+
+       function getHallOfFameObjects($filter, $limit = 10) {
+               $objArr = array();
+               switch($filter) {
+                       case 'P':
+                               $query = 'select group_id as id, 
count(group_id) as ref, \'group\' from group_votes group by group_id order by 
ref desc';
+                               break;
+                       case 'D':
+                               $query = 'select diary_id as id, 
count(diary_id) as ref, \'diary\' from diary_votes group by diary_id order by 
ref desc';
+                               break;
+                       case 'A':
+                               $query = 'select artifact_id as id, 
count(artifact_id) as ref, \'artifact\' from artifact_votes group by 
artifact_id order by ref desc';
+                               break;
+                       case 'PA':
+                               $query = 'select group_id as id, 
count(group_id) as ref, \'group\' as object from group_votes group by group_id 
+                                       union select artifact_id as id, 
count(artifact_id) as ref, \'artifact\' as object from artifact_votes group by 
artifact_id
+                                       order by ref desc';
+                               break;
+                       case 'PD':
+                               $query = 'select group_id as id, 
count(group_id) as ref, \'group\' as object from group_votes group by group_id 
+                                       union select diary_id as id, 
count(diary_id) as ref, \'diary\' as object from diary_votes group by diary_id
+                                       order by ref desc';
+                               break;
+                       case 'DA':
+                               $query = 'select artifact_id as id, 
count(artifact_id) as ref, \'artifact\' as object from artifact_votes group by 
artifact_id
+                                       union select diary_id as id, 
count(diary_id) as ref, \'diary\' as object from diary_votes group by diary_id
+                                       order by ref desc';
+                               break;
+                       case 'PDA':
+                       default:
+                               $query = 'select group_id as id, 
count(group_id) as ref, \'group\' as object from group_votes group by group_id 
+                                       union select artifact_id as id, 
count(artifact_id) as ref, \'artifact\' as object from artifact_votes group by 
artifact_id
+                                       union select diary_id as id, 
count(diary_id) as ref, \'diary\' as object from diary_votes group by diary_id
+                                       order by ref desc';
+                               break;
+               }
+               $res = db_query_params($query, array(), $limit);
+               while ($arr = db_fetch_array($res)) {
+                       switch($arr[2]) {
+                               case 'group':
+                                       $objArr[] = group_get_object($arr[0]);
+                                       break;
+                               case 'diary':
+                                       $objArr[] = 
diarynote_get_object($arr[0]);
+                                       break;
+                               case 'artifact':
+                                       $objArr[] = 
artifact_get_object($arr[0]);
+                                       break;
+                       }
+               }
+               return $objArr;
+       }
 }
 
 // Local Variables:
diff --git a/src/common/widget/Widget.class.php 
b/src/common/widget/Widget.class.php
index 2417250..122aff3 100644
--- a/src/common/widget/Widget.class.php
+++ b/src/common/widget/Widget.class.php
@@ -61,6 +61,7 @@ require_once $gfcommon.'widget/Widget_HomeVersion.class.php';
 require_once $gfcommon.'widget/Widget_HomeRss.class.php';
 require_once $gfcommon.'widget/Widget_HomeLatestDiaryNotes.class.php';
 require_once $gfcommon.'widget/Widget_HomeSponsoredHeadLines.class.php';
+require_once $gfcommon.'widget/Widget_HomeHallOfFame.class.php';
 
 // Tracker Widgets
 require_once $gfcommon.'widget/Widget_TrackerComment.class.php';
@@ -218,6 +219,9 @@ require_once 
$gfcommon.'widget/Widget_UserhomeRss.class.php';
                        case 'homesponsoredheadlines';
                                $o = new Widget_HomeSponsoredHeadLines();
                                break;
+                       case 'homehalloffame';
+                               $o = new Widget_HomeHallOfFame();
+                               break;
                        case 'mysurveys':
                                $o = new Widget_MySurveys();
                                break;
@@ -367,7 +371,7 @@ require_once 
$gfcommon.'widget/Widget_UserhomeRss.class.php';
                                break;
                        case WidgetLayoutManager::OWNER_TYPE_HOME:
                                $widgets = array('hometagcloud', 'homeversion', 
'homelatestnews', 'homestats', 'homedetailactivitymostactiveprojectweek',
-                                               'homelatestfilereleases', 
'homerss', 'homelatestdiarynotes', 'homesponsoredheadlines');
+                                               'homelatestfilereleases', 
'homerss', 'homelatestdiarynotes', 'homesponsoredheadlines', 'homehalloffame');
                                break;
                        case WidgetLayoutManager::OWNER_TYPE_TRACKER:
                                $widgets = array('trackercontent', 
'trackercomment', 'trackerdefaultactions', 'trackergeneral', 'trackermain', 
'trackersummary');
diff --git a/src/common/widget/Widget_HomeHallOfFame.class.php 
b/src/common/widget/Widget_HomeHallOfFame.class.php
new file mode 100644
index 0000000..83d791f
--- /dev/null
+++ b/src/common/widget/Widget_HomeHallOfFame.class.php
@@ -0,0 +1,134 @@
+<?php
+/**
+ * Copyright 2020, Franck Villaume - TrivialDev
+ * This file is a part of Fusionforge.
+ *
+ * Fusionforge is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Fusionforge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Fusionforge. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+require_once 'Widget.class.php';
+require_once $gfcommon.'include/FusionForge.class.php';
+
+class Widget_HomeHallOfFame extends Widget {
+       var $_hall_show = 'PDA';
+       function __construct() {
+               parent::__construct('homehalloffame');
+               if (session_loggedin()) {
+                       $userPrefValue = 
UserManager::instance()->getCurrentUser()->getPreference('my_home_hall_of_fame');
+                       if ($userPrefValue) {
+                               $this->_hall_show = $userPrefValue;
+                       }
+               }
+       }
+
+       function getTitle() {
+               return _('Hall Of Fame');
+       }
+
+       function getContent() {
+               $ff = new FusionForge();
+               $objects = $ff->getHallOfFameObjects($this->_hall_show);
+               $content = '';
+               foreach($objects as $object) {
+                       if (method_exists($object, 'getAbstract')) {
+                               $content .= $object->getAbstract();
+                       } else {
+                               switch (get_class($object)) {
+                                       case 'Group':
+                                               if 
(strstr($object->getDescription(),'<br/>')) {
+                                                       // the news is html, 
fckeditor made for example
+                                                       $arr = explode('<br/>', 
$object->getDescription());
+                                               } else {
+                                                       $arr = explode("\n", 
$object->getDescription());
+                                               }
+                                               $summ_txt = 
util_make_links($arr[0]);
+                                               $arr_v = $object->getVotes();
+                                               $news = html_e('div', 
array('class' => 'widget-sticker-header box'), html_e('div', array(), 
util_make_link($object->getHomePage(), $object->getPublicName(), false, true).' 
- '.$arr_v[0].' '._('Vote(s)')));
+                                               $news .= html_e('div', 
array('class' => 'widget-sticker-body'), 
$summ_txt.html_e('br').util_make_link($object->getHomePage(), _('... Read 
more'), false, true));
+                                               $news .= html_e('div', 
array('class' => 'widget-sticker-footer'), _('Registered')._(': 
').date(_('Y-m-d H:i'), $object->getStartDate()));
+                                               $content .= html_e('div', 
array('class' => 'widget-sticker-container'), $news);
+                                               break;
+                                       default:
+                                               $content .= 'BUILT The 
Abstract';
+                                               break;
+                               }
+                       }
+               }
+
+               if (strlen($content)) {
+                       return $content.html_e('div', array('style' => 
'clear:both'), '&nbsp;');
+               }
+       }
+
+       function getDescription() {
+               return _('Display most voted projets, diaries, artifacts.');
+       }
+
+       function hasPreferences() {
+               if (session_loggedin()) {
+                       return true;
+               }
+               return false;
+       }
+
+       function updatePreferences(&$request) {
+               $request->valid(new Valid_String('cancel'));
+               $vShow = new Valid_WhiteList('show', array('P', 'D', 'A', 'PA', 
'PD', 'DA', 'PDA'));
+               $vShow->required();
+               if (!$request->exist('cancel')) {
+                       if ($request->valid($vShow)) {
+                               switch($request->get('show')) {
+                                       case 'P':
+                                               $this->_hall_show = 'P';
+                                               break;
+                                       case 'D':
+                                               $this->_hall_show = 'D';
+                                               break;
+                                       case 'A':
+                                               $this->_hall_show = 'A';
+                                               break;
+                                       case 'PA':
+                                               $this->_hall_show = 'PA';
+                                               break;
+                                       case 'PD':
+                                               $this->_hall_show = 'PD';
+                                               break;
+                                       case 'DA':
+                                               $this->_hall_show = 'DA';
+                                               break;
+                                       case 'PDA':
+                                       default:
+                                               $this->_hall_show = 'PDA';
+                               }
+                               
UserManager::instance()->getCurrentUser()->setPreference('my_home_hall_of_fame',
 $this->_hall_show);
+                       }
+               }
+               return true;
+       }
+
+       function getPreferences() {
+               $optionsArray = array('P', 'D', 'A', 'PA', 'PD', 'DA', 'PDA');
+               $textsArray = array();
+               $textsArray[] = _('Projets'.' [P]');
+               $textsArray[] = _('Diaries'.' [D]');
+               $textsArray[] = _('Artifacts'.' [A]');
+               $textsArray[] = _('Projects & Artifacts'.' [PA]');
+               $textsArray[] = _('Projects & Diaries'.' [PD]');
+               $textsArray[] = _('Diaries & Artifacts'.' [DA]');
+               $textsArray[] = _('Projects, Diaries & Artifacts'.' [PDA]');
+               $prefs = _('Select objects')._(': 
').html_build_select_box_from_arrays($optionsArray, $textsArray, 'show', 
$this->_hall_show, false);
+               return $prefs;
+       }
+}
+ 

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

Summary of changes:
 src/CHANGES                                       |   1 +
 src/common/diary/DiaryNote.class.php              |   3 +-
 src/common/include/FusionForge.class.php          |  54 ++++++++-
 src/common/widget/Widget.class.php                |   6 +-
 src/common/widget/Widget_HomeHallOfFame.class.php | 134 ++++++++++++++++++++++
 5 files changed, 195 insertions(+), 3 deletions(-)
 create mode 100644 src/common/widget/Widget_HomeHallOfFame.class.php


hooks/post-receive
-- 
FusionForge

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

Reply via email to