3 * http://fusionforge.org
5 * This file is part of FusionForge.
7 * FusionForge is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * FusionForge is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with FusionForge; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 require_once('../env.inc.php');
23 require_once $gfcommon.'include/pre.php';
24 require_once $gfcommon.'include/preplugins.php';
25 require_once $gfcommon.'include/plugins_utils.php';
26 require_once $gfcommon.'widget/WidgetLayoutManager.class.php';
27 require_once $gfcommon.'widget/Widget.class.php';
29 $request =& HTTPRequest::instance();
31 $lm = new WidgetLayoutManager();
34 $owner = $request->get('owner');
37 $owner_id = (int)substr($owner, 1);
38 $owner_type = substr($owner, 0, 1);
40 case WidgetLayoutManager::OWNER_TYPE_USER:
41 $owner_id = user_getid();
42 $layout_id =(int)$request->get('layout_id');
46 case WidgetLayoutManager::OWNER_TYPE_GROUP:
47 $pm = ProjectManager::instance();
48 if ($project = $pm->getProject($owner_id)) {
49 $group_id = $owner_id;
50 $_REQUEST['group_id'] = $_GET['group_id'] = $group_id;
51 $request->params['group_id'] = $group_id; //bad!
52 $redirect = '/projects/'. $project->getUnixName().'/';
53 if (!user_ismember($group_id, 'A') && !user_is_super_user()) {
54 $GLOBALS['Response']->redirect($redirect);
63 if (($layout_id = (int)$request->get('layout_id')) || $request->get('action') == 'preferences') {
65 if ($request->exist('name')) {
66 $param = $request->get('name');
67 $name = array_pop(array_keys($param));
68 $instance_id = (int)$param[$name];
70 switch($request->get('action')) {
72 if ($name && $request->exist('layout_id')) {
73 if ($widget = Widget::getInstance($name)) {
74 if ($widget->isAvailable()) {
75 $action = array_pop(array_keys($param[$name]));
78 $instance_id = (int)$param[$name][$action];
79 $lm->removeWidget($owner_id, $owner_type, $layout_id, $name, $instance_id, $widget);
83 $redirect ='/widgets/widgets.php?owner='. $owner_type.$owner_id.'&layout_id='. $layout_id.'#filter-widget-categ-'.$widget->getCategory();
84 $lm->addWidget($owner_id, $owner_type, $layout_id, $name, $widget, $request);
93 $lm->mimizeWidget($owner_id, $owner_type, $layout_id, $name, $instance_id);
98 $lm->maximizeWidget($owner_id, $owner_type, $layout_id, $name, $instance_id);
103 $lm->displayWidgetPreferences($owner_id, $owner_type, $layout_id, $name, $instance_id);
107 $lm->updateLayout($owner_id, $owner_type, $request->get('layout_id'), $request->get('new_layout'));
110 $lm->reorderLayout($owner_id, $owner_type, $layout_id, $request);
116 if (!$request->isAjax()) {
117 htmlRedirect($redirect);