[Fusionforge-commits] FusionForge branch master updated. v6.1-88-g319e492

Franck Villaume nerville at libremir.placard.fr.eu.org
Thu Nov 1 20:01:42 CET 2018


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  319e492324eb41237c6ef50b4a17ce196a56a47f (commit)
      from  9c7adaf22e19411ca396fbc5dde2783726c24ed2 (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=319e492324eb41237c6ef50b4a17ce196a56a47f

commit 319e492324eb41237c6ef50b4a17ce196a56a47f
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Thu Nov 1 20:00:44 2018 +0100

    users page improvement: initial commit: basic support widget system

diff --git a/src/common/widget/Widget.class.php b/src/common/widget/Widget.class.php
index 8d30af1..109a20f 100644
--- a/src/common/widget/Widget.class.php
+++ b/src/common/widget/Widget.class.php
@@ -21,6 +21,7 @@
 
 require_once $gfcommon.'widget/WidgetLayoutManager.class.php';
 
+// User HomePage Widgets
 require_once $gfcommon.'widget/Widget_MySurveys.class.php';
 require_once $gfcommon.'widget/Widget_MyProjects.class.php';
 require_once $gfcommon.'widget/Widget_MyBookmarks.class.php';
@@ -34,6 +35,8 @@ require_once $gfcommon.'widget/Widget_MyTasks.class.php';
 require_once $gfcommon.'widget/Widget_MyRss.class.php';
 require_once $gfcommon.'widget/Widget_MyAdmin.class.php';
 require_once $gfcommon.'widget/Widget_MySystasks.class.php';
+
+// Project HomePage Widgets
 require_once $gfcommon.'widget/Widget_ProjectDescription.class.php';
 require_once $gfcommon.'widget/Widget_ProjectMembers.class.php';
 require_once $gfcommon.'widget/Widget_ProjectInfo.class.php';
@@ -46,6 +49,8 @@ require_once $gfcommon.'widget/Widget_ProjectRss.class.php';
 require_once $gfcommon.'widget/Widget_ProjectLatestCommits.class.php';
 require_once $gfcommon.'widget/Widget_ProjectLatestArtifacts.class.php';
 require_once $gfcommon.'widget/Widget_ProjectScmStats.class.php';
+
+// Forge HomePage Widgets
 require_once $gfcommon.'widget/Widget_HomeDetailActivityMostActiveProjectWeek.class.php';
 require_once $gfcommon.'widget/Widget_HomeLatestNews.class.php';
 require_once $gfcommon.'widget/Widget_HomeLatestFileReleases.class.php';
@@ -53,6 +58,8 @@ require_once $gfcommon.'widget/Widget_HomeStats.class.php';
 require_once $gfcommon.'widget/Widget_HomeTagCloud.class.php';
 require_once $gfcommon.'widget/Widget_HomeVersion.class.php';
 require_once $gfcommon.'widget/Widget_HomeRss.class.php';
+
+// Tracker Widgets
 require_once $gfcommon.'widget/Widget_TrackerComment.class.php';
 require_once $gfcommon.'widget/Widget_TrackerContent.class.php';
 require_once $gfcommon.'widget/Widget_TrackerDefaultActions.class.php';
@@ -60,6 +67,13 @@ require_once $gfcommon.'widget/Widget_TrackerGeneral.class.php';
 require_once $gfcommon.'widget/Widget_TrackerMain.class.php';
 require_once $gfcommon.'widget/Widget_TrackerSummary.class.php';
 
+// UserHome People Widgets
+require_once $gfcommon.'widget/Widget_UserhomePersonalInformation.class.php';
+require_once $gfcommon.'widget/Widget_UserhomeProjectInformation.class.php';
+require_once $gfcommon.'widget/Widget_UserhomePeerRatings.class.php';
+require_once $gfcommon.'widget/Widget_UserhomeActivity.class.php';
+
+
 /**
  * FusionForge Layout Widget
  */
@@ -171,7 +185,7 @@ require_once $gfcommon.'widget/Widget_TrackerSummary.class.php';
 	 * @param string $widget_name
 	 * @return Widget instance
 	 */
-	static function & getInstance($widget_name) {
+	static function & getInstance($widget_name, $owner_id) {
 		$o = null;
 		switch($widget_name) {
 			case 'homelatestnews':
@@ -292,6 +306,18 @@ require_once $gfcommon.'widget/Widget_TrackerSummary.class.php';
 			case 'trackersummary':
 				$o = new Widget_TrackerSummary();
 				break;
+			case 'uhpersonalinformation':
+				$o = new Widget_UserhomePersonalInformation($owner_id);
+				break;
+			case 'uhprojectinformation':
+				$o = new Widget_UserhomeProjectInformation($owner_id);
+				break;
+			case 'uhpeerratings':
+				$o = new Widget_UserhomePeerRatings($owner_id);
+				break;
+			case 'uhactivity':
+				$o = new Widget_UserhomeActivity($owner_id);
+				break;
 			default:
 				//$em = EventManager::instance();
 				//$em->processEvent('widget_instance', array('widget' => $widget_name, 'instance' => &$o));
@@ -331,6 +357,8 @@ require_once $gfcommon.'widget/Widget_TrackerSummary.class.php';
 			case WidgetLayoutManager::OWNER_TYPE_TRACKER:
 				$widgets = array('trackercontent', 'trackercomment', 'trackerdefaultactions', 'trackergeneral', 'trackermain', 'trackersummary');
 				break;
+			case WidgetLayoutManager::OWNER_TYPE_USERHOME:
+				$widgets = array('uhpersonalinformation', 'uhprojectinformation', 'uhpeerratings', 'uhactivity');
 			default:
 				$widgets = array();
 				break;
diff --git a/src/common/widget/WidgetLayoutManager.class.php b/src/common/widget/WidgetLayoutManager.class.php
index ef67516..a959ac7 100644
--- a/src/common/widget/WidgetLayoutManager.class.php
+++ b/src/common/widget/WidgetLayoutManager.class.php
@@ -35,10 +35,11 @@ class WidgetLayoutManager {
 	/**
 	 * define constants for type of widget page
 	 */
-	const OWNER_TYPE_USER    = 'u';
-	const OWNER_TYPE_GROUP   = 'g';
-	const OWNER_TYPE_HOME    = 'h';
-	const OWNER_TYPE_TRACKER = 't';
+	const OWNER_TYPE_USER     = 'u';
+	const OWNER_TYPE_GROUP    = 'g';
+	const OWNER_TYPE_HOME     = 'h';
+	const OWNER_TYPE_TRACKER  = 't';
+	const OWNER_TYPE_USERHOME = 'p';
 
 	/**
 	 * displayLayout
@@ -64,6 +65,9 @@ class WidgetLayoutManager {
 			} elseif ($owner_type == self::OWNER_TYPE_TRACKER) {
 				$this->createDefaultLayoutForTracker($owner_id);
 				$this->displayLayout($owner_id, $owner_type);
+			} elseif ($owner_type == self::OWNER_TYPE_USERHOME) {
+				$this->createDefaultLayoutForUserHome($owner_id);
+				$this->displayLayout($owner_id, $owner_type);
 			}
 		} else {
 			$sql = "SELECT l.*
@@ -77,17 +81,17 @@ class WidgetLayoutManager {
 				$readonly = !$this->_currentUserCanUpdateLayout($owner_id, $owner_type);
 				$layout = new WidgetLayout($data['id'], $data['name'], $data['description'], $data['scope']);
 				$sql = 'SELECT * FROM layouts_rows WHERE layout_id = $1 ORDER BY rank';
-				$req_rows = db_query_params($sql,array($layout->id));
+				$req_rows = db_query_params($sql, array($layout->id));
 				while ($data = db_fetch_array($req_rows)) {
 					$row = new WidgetLayout_Row($data['id'], $data['rank']);
 					$sql = 'SELECT * FROM layouts_rows_columns WHERE layout_row_id = $1';
-					$req_cols = db_query_params($sql,array($row->id));
+					$req_cols = db_query_params($sql, array($row->id));
 					while ($data = db_fetch_array($req_cols)) {
 						$col = new WidgetLayout_Row_Column($data['id'], $data['width']);
 						$sql = "SELECT * FROM layouts_contents WHERE owner_type = $1  AND owner_id = $2 AND column_id = $3 ORDER BY rank";
-						$req_content = db_query_params($sql,array($owner_type, $owner_id, $col->id));
+						$req_content = db_query_params($sql, array($owner_type, $owner_id, $col->id));
 						while ($data = db_fetch_array($req_content)) {
-							$c = Widget::getInstance($data['name']);
+							$c = Widget::getInstance($data['name'], $owner_id);
 							if ($c && $c->isAvailable()) {
 								$c->loadContent($data['content_id']);
 								$col->add($c, $data['is_minimized'], $data['display_preferences']);
@@ -117,6 +121,7 @@ class WidgetLayoutManager {
 		$request =& HTTPRequest::instance();
 		switch ($owner_type) {
 			case self::OWNER_TYPE_USER:
+			case self::OWNER_TYPE_USERHOME:
 				if (user_getid() == $owner_id) { //Current user can only update its own /my/ page
 					$modify = true;
 				}
@@ -141,6 +146,43 @@ class WidgetLayoutManager {
 		}
 		return $modify;
 	}
+
+	function createDefaultLayoutForUserHome($owner_id) {
+		db_begin();
+		$success = true;
+		$sql = "INSERT INTO owner_layouts(layout_id, is_default, owner_id, owner_type) VALUES (1, 1, $1, $2)";
+		if (db_query_params($sql, array($owner_id, self::OWNER_TYPE_USERHOME))) {
+
+			$sql = "INSERT INTO layouts_contents(owner_id, owner_type, layout_id, column_id, name, rank) VALUES ";
+
+			$args[] = "($1, $2, 1, 1, 'uhpersonalinformation', 0)";
+			$args[] = "($1, $2, 1, 1, 'uhprojectinformation', 1)";
+			$args[] = "($1, $2, 1, 1, 'uhpeerratings', 2)";
+			$args[] = "($1, $2, 1, 2, 'uhactivity', 0)";
+
+			foreach($args as $a) {
+				if (!db_query_params($sql.$a, array($owner_id, self::OWNER_TYPE_USERHOME))) {
+					$success = false;
+					break;
+				}
+			}
+
+			/*  $em =& EventManager::instance();
+			    $widgets = array();
+			    $em->processEvent('default_widgets_for_new_owner', array('widgets' => &$widgets, 'owner_type' => self::OWNER_TYPE_USER));
+			    foreach($widgets as $widget) {
+			    $sql .= ",($13, $14, 1, $15, $16, $17)";
+			    }*/
+		} else {
+			$success = false;
+		}
+		if (!$success) {
+			$success = db_error();
+			db_rollback();
+			exit_error(_('DB Error')._(': ').$success, 'widgets');
+		}
+		db_commit();
+	}
 	/**
 	 * createDefaultLayoutForUser
 	 *
@@ -171,7 +213,7 @@ class WidgetLayoutManager {
 			$args[] = "($1, $2, 1, 2, 'mymonitoredfp', 1)";
 
 			foreach($args as $a) {
-				if (!db_query_params($sql.$a,array($owner_id, self::OWNER_TYPE_USER))) {
+				if (!db_query_params($sql.$a, array($owner_id, self::OWNER_TYPE_USER))) {
 					$success = false;
 					break;
 				}
@@ -209,7 +251,7 @@ class WidgetLayoutManager {
 			$args[] = "($1, $2, 1, 1, 'homelatestnews', 1)";
 
 			foreach($args as $a) {
-				if (!db_query_params($sql.$a,array(0, self::OWNER_TYPE_HOME))) {
+				if (!db_query_params($sql.$a, array(0, self::OWNER_TYPE_HOME))) {
 					$success = false;
 					break;
 				}
@@ -866,7 +908,7 @@ class WidgetLayoutManager {
 			AND u.layout_id = $4
 			AND u.column_id <> 0
 			ORDER BY col.rank, col.id";
-		$res = db_query_params($sql,array($layout_id, $owner_type, $owner_id, $layout_id));
+		$res = db_query_params($sql, array($layout_id, $owner_type, $owner_id, $layout_id));
 		echo db_error();
 		$column_id = db_result($res, 0, 'id');
 		if (!$column_id) {
@@ -894,7 +936,7 @@ class WidgetLayoutManager {
 			AND owner_id = $2
 			AND layout_id = $3
 			AND name = $4";
-		$res = db_query_params($sql,array($owner_type, $owner_id, $layout_id, $name));
+		$res = db_query_params($sql, array($owner_type, $owner_id, $layout_id, $name));
 		echo db_error();
 		if (db_numrows($res) && !$widget->isUnique() && db_result($res, 0, 'column_id') == 0) {
 			//search for rank
diff --git a/src/common/widget/Widget_UserhomeActivity.class.php b/src/common/widget/Widget_UserhomeActivity.class.php
new file mode 100644
index 0000000..585c4f7
--- /dev/null
+++ b/src/common/widget/Widget_UserhomeActivity.class.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Userhome Activity Widget Class
+ *
+ * Copyright 2018, Franck Villaume - TrivialDev
+ * http://fusionforge.org
+ *
+ * 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';
+
+class Widget_UserhomeActivity extends Widget {
+
+	function __construct($owner_id) {
+		$this->owner_id = $owner_id;
+		parent::__construct('uhactivity', $owner_id, WidgetLayoutManager::OWNER_TYPE_USERHOME);
+		$this->title = _('Activity');
+	}
+
+	function getTitle() {
+		return $this->title;
+	}
+
+	function isAvailable() {
+		return isset($this->title);
+	}
+
+	function getContent() {
+		echo 'the content';
+	}
+}  
diff --git a/src/common/widget/Widget_UserhomePeerRatings.class.php b/src/common/widget/Widget_UserhomePeerRatings.class.php
new file mode 100644
index 0000000..669b629
--- /dev/null
+++ b/src/common/widget/Widget_UserhomePeerRatings.class.php
@@ -0,0 +1,92 @@
+<?php
+/**
+ * Userhome Peer Ratings Widget Class
+ *
+ * Copyright 2018, Franck Villaume - TrivialDev
+ * http://fusionforge.org
+ *
+ * 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 $gfwww.'include/vote_function.php';
+
+
+class Widget_UserhomePeerRatings extends Widget {
+
+	function __construct($owner_id) {
+		$me = session_get_user();
+		$user = user_get_object($owner_id);
+		if (forge_get_config('use_ratings')) {
+			if ($user->usesRatings() && (!$me || $me->usesRatings())) {
+				$this->owner_id = $owner_id;
+				parent::__construct('uhpeerratings', $owner_id, WidgetLayoutManager::OWNER_TYPE_USERHOME);
+				$this->title = _('Peer Ratings');
+			}
+		}
+	}
+
+	function getTitle() {
+		return $this->title;
+	}
+
+	function isAvailable() {
+		return isset($this->title);
+	}
+
+	function getContent() {
+		$me = session_get_user();
+		$user = user_get_object($this->owner_id);
+		print "<p>";
+		print _('If you are familiar with this user, please take a moment to rate him/her on the following criteria. Keep in mind, that your rating will be visible to the user and others.');
+		print "</p>";
+
+		print "<p>";
+		printf(_('The %s Peer Rating system is based on concepts from <a href="http://www.advogato.com/">Advogato.</a> The system has been re-implemented and expanded in a few ways.'), forge_get_config('forge_name'));
+		print "</p>";
+		?>
+
+		<div class="align-center">
+		<?php vote_show_user_rate_box ($user->getID(), $me? $me->getID() : 0); ?>
+		</div>
+
+		<?php
+		print "<p>";
+		print _('The Peer rating box shows all rating averages (and response levels) for each individual criteria. Due to the math and processing required to do otherwise, these numbers incorporate responses from both “trusted” and “non-trusted” users.');
+		print "</p>";
+
+		print "<ul>";
+		print "<li>";
+		printf(_('The “Sitewide Rank” field shows the user\'s rank compared to all ranked %s users.'), forge_get_config('forge_name'));
+		print "</li>";
+
+		print "<li>";
+		print _('The “Aggregate Score” shows an average, weighted overall score, based on trusted-responses only.');
+		print "</li>";
+
+		print "<li>";
+		print _('The “Personal Importance” field shows the weight that users ratings of other developers will be given (between 1 and 1.5) -- higher rated user\'s responses are given more weight.');
+		print "</li>";
+		print "</ul>";
+
+		print "<p>";
+		print "<em>";
+		printf(_('If you would like to opt-out from peer rating system (this will affect your ability to both rate and be rated), refer to <a href="%s">your account maintenance page</a>. If you choose not to participate, your ratings of other users will be permanently deleted and the “Peer Rating” box will disappear from your user page.'),
+				util_make_url("/account"));
+		print "</em>";
+		print "</p>";
+	}
+} 
diff --git a/src/common/widget/Widget_UserhomePersonalInformation.class.php b/src/common/widget/Widget_UserhomePersonalInformation.class.php
new file mode 100644
index 0000000..8ac6bf7
--- /dev/null
+++ b/src/common/widget/Widget_UserhomePersonalInformation.class.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Userhome Personal Information Widget Class
+ *
+ * Copyright 2018, Franck Villaume - TrivialDev
+ * http://fusionforge.org
+ *
+ * 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/user_profile.php';
+
+class Widget_UserhomePersonalInformation extends Widget {
+
+	function __construct($owner_id) {
+		$this->owner_id = $owner_id;
+		parent::__construct('uhpersonalinformation', $owner_id, WidgetLayoutManager::OWNER_TYPE_USERHOME);
+		$this->title = _('Personal Information');
+	}
+
+	function getTitle() {
+		return $this->title;
+	}
+
+	function isAvailable() {
+		return isset($this->title);
+	}
+
+	function getContent() {
+		$user = user_get_object($this->owner_id);
+		echo user_personal_information($user);
+	}
+}
diff --git a/src/common/widget/Widget_UserhomeProjectInformation.class.php b/src/common/widget/Widget_UserhomeProjectInformation.class.php
new file mode 100644
index 0000000..72cd344
--- /dev/null
+++ b/src/common/widget/Widget_UserhomeProjectInformation.class.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * Userhome Project Information Widget Class
+ *
+ * Copyright 2018, Franck Villaume - TrivialDev
+ * http://fusionforge.org
+ *
+ * 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';
+
+class Widget_UserhomeProjectInformation extends Widget {
+
+	function __construct($owner_id) {
+		$this->owner_id = $owner_id;
+		parent::__construct('uhprojectinformation', $owner_id, WidgetLayoutManager::OWNER_TYPE_USERHOME);
+		$this->title = _('Project Membership');
+	}
+
+	function getTitle() {
+		return $this->title;
+	}
+
+	function isAvailable() {
+		return isset($this->title);
+	}
+
+	function getContent() {
+		global $HTML;
+		$user = user_get_object($this->owner_id);
+		$projects = $user->getGroups();
+		sortProjectList ($projects) ;
+		$roles = RBACEngine::getInstance()->getAvailableRolesForUser($user);
+		sortRoleList($roles);
+		if (count ($projects) < 1) {
+			echo $HTML->information(_('This user is not a member of any project.'));
+		} else { // endif no groups
+			echo html_e('p', array(), _('This user is a member of the following projects')._(':'));
+
+			foreach ($projects as $p) {
+				if (!forge_check_perm('project_read', $p->getID())) {
+					continue;
+				}
+
+				$project_link = util_make_link_g ($p->getUnixName(),$p->getID(),$p->getPublicName());
+				$project_uri = util_make_url_g ($p->getUnixName(),$p->getID());
+				// sioc:UserGroups for all members of a project are named after /projects/A_PROJECT/members/
+				$usergroup_uri = $project_uri .'members/';
+
+				print '<div rel="sioc:member_of">'."\n"
+					.'<div about="'. $usergroup_uri .'" typeof="sioc:UserGroup">'."\n"
+					.'<div rel="sioc:usergroup_of">'."\n"
+					.'<div about="'. $project_uri .'" typeof="sioc:Space">';
+				$role_names = array () ;
+				$sioc_has_function_close = "";
+				foreach ($roles as $r) {
+					if ($r instanceof RoleExplicit
+					&& $r->getHomeProject() != NULL
+					&& $r->getHomeProject()->getID() == $p->getID()) {
+						$role_names[] = $r->getName() ;
+						print '<div property="sioc:has_function" content= "'.$r->getName().'">';
+						$sioc_has_function_close .= "</div>";
+					}
+				}
+
+				print ('<br />' . $project_link .' ('.htmlspecialchars (implode (', ', $role_names)).')');
+				print "\n";
+
+				if (forge_check_perm_for_user ($user, 'project_admin', $p->getID())) {
+					print '<span rev="doap:maintainer" resource="#me"></span>';
+				}
+				else {
+					print '<span rev="doap:developer" resource="#me"></span>';
+				}
+
+				echo $sioc_has_function_close."\n";  // sioc:has_function
+				echo "</div>\n";  // sioc:Space .../projects/A_PROJECT/
+				echo "</div>\n"; // sioc:usergroup_of
+				echo "</div>\n";  // sioc:UserGroup .../projects/A_PROJECT/members
+				echo "</div>\n"; // sioc:member_of
+			}
+		} // end if groups
+	}
+} 
diff --git a/src/etc/config.ini.d/defaults.ini b/src/etc/config.ini.d/defaults.ini
index fc44426..2ab5734 100644
--- a/src/etc/config.ini.d/defaults.ini
+++ b/src/etc/config.ini.d/defaults.ini
@@ -104,6 +104,7 @@ use_artefacts_dependencies = no
 ;tracker_parser_type = 'markdown'
 ;snippet_parser_type = 'markdown'
 use_user_theme = yes
+user_home_widget = no
 
 scm_single_host = yes
 system_user=fusionforge
diff --git a/src/www/include/user_home.php b/src/www/include/user_home.php
index 0d6c131..6d14203 100644
--- a/src/www/include/user_home.php
+++ b/src/www/include/user_home.php
@@ -32,9 +32,6 @@
 require_once $gfcommon.'include/user_profile.php';
 require_once $gfwww.'include/vote_function.php';
 
-$title = _('User Profile');
-$HTML->header(array('title'=>$title));
-
 echo $HTML->boxTop(_('Personal Information'), _('Personal Information'));
 echo html_ao('div', array('about' => '', 'typeof' => 'sioc:UserAccount'));
 echo user_personal_information($user);
@@ -43,7 +40,7 @@ if (forge_get_config('use_ratings')) {
 	echo $HTML->boxMiddle(_('Peer Rating'), _('Peer Rating'));
 	echo '<table class="my-layout-table" id="user-profile-rating">';
 	if ($user->usesRatings()) {
-		vote_show_user_rating($user_id);
+		vote_show_user_rating($user->getID());
 	} else {
 		echo '<tr><td colspan="2">';
 		echo _('User chose not to participate in peer rating');
@@ -55,36 +52,32 @@ if (forge_get_config('use_ratings')) {
 if (forge_get_config('use_diary')) {
 	echo $HTML->boxMiddle(_('Diary and Notes'), _('Diary and Notes'));
 
-	/*
-		Get their diary information
-	*/
+	/* Get their diary information */
 
 	$res = db_query_params('SELECT count(*) from user_diary WHERE user_id=$1 AND is_public=1',
-				array($user_id));
+				array($user->getID()));
 	echo _('Diary/Note entries')._(': ').db_result($res, 0, 0).'
 		<p>';
 		//.'<span rel="foaf:weblog">'
-		echo util_make_link('/developer/diary.php?diary_user='.$user_id,htmlentities(_('View Diary and Notes')));
-		//.'</span>'.
-		echo '</p>
-		<p>';
-		echo util_make_link('/developer/monitor.php?diary_user='.$user_id,
-						html_image("ic/check.png", 15, 13) ._('Monitor this Diary')
-			) ;
-		echo '</p>';
-		$hookparams['user_id'] = $user_id;
-		plugin_hook("user_personal_links", $hookparams);
-	}
-	?>
+	echo util_make_link('/developer/diary.php?diary_user='.$user->getID(), htmlentities(_('View Diary and Notes')));
+	//.'</span>'.
+	echo '</p>
+	<p>';
+	echo util_make_link('/developer/monitor.php?diary_user='.$user->getID(),
+					html_image("ic/check.png", 15, 13) ._('Monitor this Diary')
+		) ;
+	echo '</p>';
+	$hookparams['user_id'] = $user->getID();
+	plugin_hook("user_personal_links", $hookparams);
+}
 
-<?php
 
 echo $HTML->boxMiddle(_('Project Information'), _('Project Information'));
 
 $projects = $user->getGroups();
 sortProjectList ($projects) ;
-$roles = RBACEngine::getInstance()->getAvailableRolesForUser ($user) ;
-sortRoleList ($roles) ;
+$roles = RBACEngine::getInstance()->getAvailableRolesForUser($user);
+sortRoleList($roles);
 
 // see if there were any groups
 echo '<div>'."\n";
@@ -153,13 +146,13 @@ if (forge_get_config('use_ratings')) {
 		print "<p>";
 		printf(_('The %s Peer Rating system is based on concepts from <a href="http://www.advogato.com/">Advogato.</a> The system has been re-implemented and expanded in a few ways.'), forge_get_config ('forge_name'));
 		print "</p>";
-?>
+	?>
 
-	<div class="align-center">
-        <?php vote_show_user_rate_box ($user_id, $me?$me->getID():0); ?>
-	</div>
+		<div class="align-center">
+		<?php vote_show_user_rate_box ($user->getID(), $me? $me->getID() : 0); ?>
+		</div>
 
-<?php
+	<?php
 		print "<p>";
 		print _('The Peer rating box shows all rating averages (and response levels) for each individual criteria. Due to the math and processing required to do otherwise, these numbers incorporate responses from both “trusted” and “non-trusted” users.');
 		print "</p>";
@@ -180,23 +173,22 @@ if (forge_get_config('use_ratings')) {
 
 		print "<p>";
 		print "<em>";
-		print _('If you would like to opt-out from peer rating system (this will affect your ability to both rate and be rated), refer to <a href="/account/">your account maintenance page</a>. If you choose not to participate, your ratings of other users will be permanently deleted and the “Peer Rating” box will disappear from your user page.');
+		printf(_('If you would like to opt-out from peer rating system (this will affect your ability to both rate and be rated), refer to <a href="%s">your account maintenance page</a>. If you choose not to participate, your ratings of other users will be permanently deleted and the “Peer Rating” box will disappear from your user page.'),
+				util_make_url("/account"));
 		print "</em>";
 		print "</p>";
 
-} elseif ($me && !$me->usesRatings()) {
+	} elseif ($me && !$me->usesRatings()) {
 		print "<p>";
 		print "<em>";
-		printf (_('You opted-out from peer rating system, otherwise you would have a chance to rate the user. Refer to <a href="%s">your account maintenance page</a> for more information.'),
-				  util_make_url ("/account"));
+		printf(_('You opted-out from peer rating system, otherwise you would have a chance to rate the user. Refer to <a href="%s">your account maintenance page</a> for more information.'),
+				util_make_url("/account"));
 		print "</em>";
 		print "</p>";
 	}
 }
 echo $HTML->boxBottom();
 
-$HTML->footer();
-
 // Local Variables:
 // mode: php
 // c-file-style: "bsd"
diff --git a/src/www/users b/src/www/users
index 2c6be57..ddbcb30 100644
--- a/src/www/users
+++ b/src/www/users
@@ -83,10 +83,17 @@ if (!$user || !is_object($user) || $user->isError() || !$user->isActive()) {
 				exit(0);
 		}
 	} else { // default HTML view
-		$user_id = $user->getID();
-
 		//now show the user page
-		include $gfwww.'include/user_home.php';
+		$title = _('User Profile');
+		$HTML->header(array('title'=>$title));
+
+		if (!forge_get_config('user_home_widget')) {
+			include $gfwww.'include/user_home.php';
+		} else {
+			$lm = new WidgetLayoutManager();
+			$lm->displayLayout($user->getID(), WidgetLayoutManager::OWNER_TYPE_USERHOME);
+		}
+		$HTML->footer();
 	}
 }
 

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

Summary of changes:
 src/common/widget/Widget.class.php                 | 30 ++++++-
 src/common/widget/WidgetLayoutManager.class.php    | 66 ++++++++++++---
 ...class.php => Widget_UserhomeActivity.class.php} | 28 ++++---
 .../widget/Widget_UserhomePeerRatings.class.php    | 92 ++++++++++++++++++++
 ...> Widget_UserhomePersonalInformation.class.php} | 33 ++++----
 .../Widget_UserhomeProjectInformation.class.php    | 98 ++++++++++++++++++++++
 src/etc/config.ini.d/defaults.ini                  |  1 +
 src/www/include/user_home.php                      | 60 ++++++-------
 src/www/users                                      | 13 ++-
 9 files changed, 344 insertions(+), 77 deletions(-)
 copy src/common/widget/{Widget_HomeVersion.class.php => Widget_UserhomeActivity.class.php} (63%)
 create mode 100644 src/common/widget/Widget_UserhomePeerRatings.class.php
 copy src/common/widget/{Widget_HomeTagCloud.class.php => Widget_UserhomePersonalInformation.class.php} (58%)
 create mode 100644 src/common/widget/Widget_UserhomeProjectInformation.class.php


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list