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 d6d296411e6ce4709b8b4854a8b736e3e06938f9 (commit)
from 2cfe8459a576c0ba6aa687ff3fbf68d39af8bc25 (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=d6d296411e6ce4709b8b4854a8b736e3e06938f9
commit d6d296411e6ce4709b8b4854a8b736e3e06938f9
Author: Franck Villaume <[email protected]>
Date: Mon Nov 5 21:23:59 2018 +0100
/users/<nickname> improvement: be able to add/remove widgets to build the
public page of the user
diff --git a/src/common/widget/Widget.class.php
b/src/common/widget/Widget.class.php
index 6c910ff..e8c1808 100644
--- a/src/common/widget/Widget.class.php
+++ b/src/common/widget/Widget.class.php
@@ -339,7 +339,7 @@ require_once
$gfcommon.'widget/Widget_UserhomeActivity.class.php';
* @param unknown_type $owner_type
* @return mixed
*/
- static function getCodendiWidgets($owner_type) {
+ static function getCodendiWidgets($owner_type, $owner_id = null) {
switch ($owner_type) {
case WidgetLayoutManager::OWNER_TYPE_USER:
$widgets = array('myadmin', 'mysurveys',
'myprojects', 'mybookmarks',
diff --git a/src/common/widget/WidgetLayoutManager.class.php
b/src/common/widget/WidgetLayoutManager.class.php
index a959ac7..e201e96 100644
--- a/src/common/widget/WidgetLayoutManager.class.php
+++ b/src/common/widget/WidgetLayoutManager.class.php
@@ -2,7 +2,7 @@
/**
* Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights
reserved
* Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
- * Copyright 2013-2017, Franck Villaume - TrivialDev
+ * Copyright 2013-2018, Franck Villaume - TrivialDev
*
* This file is a part of Fusionforge.
*
@@ -560,7 +560,7 @@ class WidgetLayoutManager {
AND owner_id = $2
AND layout_id = $3
AND content_id = 0 AND column_id <> 0";
- $res = db_query_params($sql,array($owner_type, $owner_id,
$layout_id));
+ $res = db_query_params($sql, array($owner_type, $owner_id,
$layout_id));
while($data = db_fetch_array($res)) {
$used_widgets[] = $data['name'];
}
@@ -616,7 +616,7 @@ class WidgetLayoutManager {
//]]></script>
<?php
$sql = "SELECT * FROM layouts WHERE scope='S' ORDER BY
id ";
- $req_layouts = db_query_params($sql,array());
+ $req_layouts = db_query_params($sql, array());
echo $HTML->listTableTop();
$is_custom = true;
while ($data = db_fetch_array($req_layouts)) {
@@ -676,7 +676,7 @@ class WidgetLayoutManager {
<tbody>
<tr class="top">
<td>';
- $after .=
$this->_displayWidgetsSelectionForm(sprintf(_("%s Widgets"),
forge_get_config('forge_name')), Widget::getCodendiWidgets($owner_type),
$used_widgets);
+ $after .=
$this->_displayWidgetsSelectionForm(Widget::getCodendiWidgets($owner_type),
$used_widgets, $owner_id);
echo '</td>
<td id="widget-content-categ">'. $after .'</td>
</tr>
@@ -806,16 +806,16 @@ class WidgetLayoutManager {
/**
* _displayWidgetsSelectionForm - displays a widget selection form
*
- * @param string $title title
- * @param array $widgets widgets
+ * @param array $widgets widgets
* @param array $used_widgets used widgets
+ * @param int $owner_id
* @return string
*/
- function _displayWidgetsSelectionForm($title, $widgets, $used_widgets) {
+ function _displayWidgetsSelectionForm($widgets, $used_widgets,
$owner_id = null) {
$hp = Codendi_HTMLPurifier::instance();
$additionnal_html = '';
if (count($widgets)) {
- $categs = $this->getCategories($widgets);
+ $categs = $this->getCategories($widgets, $owner_id);
$widget_rows = array();
if (count($categs)) {
// display the categories selector in left panel
@@ -861,12 +861,13 @@ class WidgetLayoutManager {
* getCategories - sort the widgets in their different categories
*
* @param array $widgets
+ * @param int $owner_id
* @return array (category => widgets)
*/
- function getCategories($widgets) {
+ function getCategories($widgets, $owner_id = null) {
$categ = array();
foreach($widgets as $widget_name) {
- if ($widget = Widget::getInstance($widget_name)) {
+ if ($widget = Widget::getInstance($widget_name,
$owner_id)) {
if ($widget->isAvailable()) {
$category = str_replace(' ', '_',
$widget->getCategory());
$cs = explode(',', $category);
diff --git a/src/www/users b/src/www/users
index ddbcb30..4f1590a 100644
--- a/src/www/users
+++ b/src/www/users
@@ -5,6 +5,7 @@
* Copyright 1999-2001 (c) VA Linux Systems
* Copyright 2002-2004 (c) GForge Team
* Copyright 2010-2011, Franck Villaume - Capgemini
+ * Copyright 2018, Franck Villaume - TrivialDev
* http://fusionforge.org/
*
* This file is part of FusionForge. FusionForge is free software;
@@ -90,6 +91,26 @@ if (!$user || !is_object($user) || $user->isError() ||
!$user->isActive()) {
if (!forge_get_config('user_home_widget')) {
include $gfwww.'include/user_home.php';
} else {
+ $sql = "SELECT l.*
+ FROM layouts AS l INNER JOIN
owner_layouts AS o ON(l.id = o.layout_id)
+ WHERE o.owner_type = $1
+ AND o.owner_id = $2
+ AND o.is_default = 1
+ ";
+ $res =
db_query_params($sql,array(WidgetLayoutManager::OWNER_TYPE_USERHOME,
$user->getID()));
+ $layout_id = db_result($res, 0 , 'id');
+ if (!$layout_id) {
+ $layout_id = 1;
+ }
+ $ap = html_ap();
+ echo html_ao('ul', array('class' => 'widget_toolbar'));
+ $url =
'/widgets/widgets.php?owner='.WidgetLayoutManager::OWNER_TYPE_USERHOME.$user->getID().'&layout_id='.$layout_id;
+ $labels = array(_('Add widgets'), _('Customize
Layout'));
+ $urls = array($url, $url.'&update=layout');
+ for ($i = 0; $i < count($urls); $i++) {
+ echo html_e('li', array(),
util_make_link($urls[$i], $labels[$i]));
+ }
+ echo html_ac($ap);
$lm = new WidgetLayoutManager();
$lm->displayLayout($user->getID(),
WidgetLayoutManager::OWNER_TYPE_USERHOME);
}
diff --git a/src/www/widgets/updatelayout.php b/src/www/widgets/updatelayout.php
index 7b0ab12..f3ce031 100644
--- a/src/www/widgets/updatelayout.php
+++ b/src/www/widgets/updatelayout.php
@@ -1,7 +1,7 @@
<?php
/**
* Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights
reserved
- * Copyright 2016, Franck Villaume - TrivialDev
+ * Copyright 2016,2018, Franck Villaume - TrivialDev
* http://fusionforge.org
*
* This file is part of FusionForge. FusionForge is free software;
@@ -39,10 +39,11 @@ if ($owner) {
$owner_type = substr($owner, 0, 1);
switch($owner_type) {
case WidgetLayoutManager::OWNER_TYPE_USER:
- $owner_id = user_getid();
- $layout_id =(int)$request->get('layout_id');
- $redirect = '/my/';
- $good = true;
+ if ($owner_id == user_getid()) {
+ $layout_id =(int)$request->get('layout_id');
+ $redirect = '/my/';
+ $good = true;
+ }
break;
case WidgetLayoutManager::OWNER_TYPE_GROUP:
$pm = ProjectManager::instance();
@@ -82,6 +83,14 @@ if ($owner) {
$good = true;
}
break;
+ case WidgetLayoutManager::OWNER_TYPE_USERHOME:
+ if ($owner_id == user_getid()) {
+ $user = user_get_object(user_getid());
+ $layout_id =(int)$request->get('layout_id');
+ $redirect = '/users/'.$user->getUnixName();
+ $good = true;
+ }
+ break;
default:
break;
}
diff --git a/src/www/widgets/widget.php b/src/www/widgets/widget.php
index fb03bf6..eed6a2d 100644
--- a/src/www/widgets/widget.php
+++ b/src/www/widgets/widget.php
@@ -1,7 +1,7 @@
<?php
/**
* http://fusionforge.org
- * Copyright 2016, Franck Villaume - TrivialDev
+ * Copyright 2016,2018, 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
@@ -40,9 +40,10 @@ if ($request->valid($vOwner)) {
$owner_type = substr($owner, 0, 1);
switch($owner_type) {
case WidgetLayoutManager::OWNER_TYPE_USER:
- $owner_id = user_getid();
- $redirect = '/my/';
- $good = true;
+ if ($owner_id == user_getid()) {
+ $redirect = '/my/';
+ $good = true;
+ }
break;
case WidgetLayoutManager::OWNER_TYPE_GROUP:
$pm = ProjectManager::instance();
@@ -74,6 +75,12 @@ if ($request->valid($vOwner)) {
$good = true;
}
break;
+ case WidgetLayoutManager::OWNER_TYPE_USERHOME:
+ if ($owner_id == user_getid()) {
+ $user = user_get_object(user_getid());
+ $redirect = '/users/'.$user->getUnixName();
+ $good = true;
+ }
default:
break;
}
diff --git a/src/www/widgets/widgets.php b/src/www/widgets/widgets.php
index 7d49ff8..9206a4f 100644
--- a/src/www/widgets/widgets.php
+++ b/src/www/widgets/widgets.php
@@ -107,6 +107,15 @@ if (session_loggedin()) {
}
}
break;
+ case WidgetLayoutManager::OWNER_TYPE_USERHOME:
+ if ($owner_id == user_getid()) {;
+ $userm =
UserManager::instance();
+ $current =
$userm->getCurrentUser();
+
site_header(array('title'=>sprintf(_('Profile Page for %s'), user_getname())));
+
$lm->displayAvailableWidgets(user_getid(),
WidgetLayoutManager::OWNER_TYPE_USERHOME, $layout_id);
+ site_footer();
+ }
+ break;
default:
break;
}
-----------------------------------------------------------------------
Summary of changes:
src/common/widget/Widget.class.php | 2 +-
src/common/widget/WidgetLayoutManager.class.php | 21 +++++++++++----------
src/www/users | 21 +++++++++++++++++++++
src/www/widgets/updatelayout.php | 19 ++++++++++++++-----
src/www/widgets/widget.php | 15 +++++++++++----
src/www/widgets/widgets.php | 9 +++++++++
6 files changed, 67 insertions(+), 20 deletions(-)
hooks/post-receive
--
FusionForge
_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits