3
* $Horde: horde/services/portal/edit.php,v 1.44.8.1 2005/01/03 12:25:46 jan Exp $
5
* Copyright 1999-2005 Chuck Hagenbuch <chuck@horde.org>
6
* Copyright 2003-2005 Mike Cochrane <mike@graftonhall.co.nz>
7
* Copyright 2003-2005 Jan Schneider <jan@horde.org>
9
* See the enclosed file COPYING for license information (LGPL). If you
10
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
13
@define('HORDE_BASE', dirname(__FILE__) . '/../..');
14
require_once HORDE_BASE . '/lib/base.php';
15
require_once 'Horde/Block.php';
16
require_once 'Horde/Block/Collection.php';
17
require_once 'Horde/Block/Layout.php';
18
require_once 'Horde/Identity.php';
19
require_once 'Horde/Help.php';
21
if (!Auth::isAuthenticated()) {
22
Horde::authenticationFailureRedirect();
26
$col = (int)Util::getFormData('col');
27
$row = (int)Util::getFormData('row');
28
$action = Util::getFormData('action');
32
// Get full name for title.
33
$identity = &Identity::singleton();
34
$fullname = $identity->getValue('fullname');
35
if (empty($fullname)) {
36
$fullname = Auth::getAuth();
39
// Instantiate the blocks objects.
40
$blocks = &Horde_Block_Collection::singleton('portal');
41
$layout = &Horde_Block_Layout::singleton();
43
// Handle requested actions.
58
$result = call_user_func(array(&$layout, $action), $row, $col);
59
if (is_a($result, 'PEAR_Error')) {
60
$notification->push($result);
66
// Save the changes made to a block.
68
// Save the changes made to a block and continue editing.
70
// Get requested block type.
71
list($newapp, $newtype) = explode(':', Util::getFormData('app'));
73
// Is this a new block?
75
if ($layout->isEmpty($row, $col) ||
76
!$layout->rowExists($row) ||
77
!$layout->colExists($col)) {
79
// Make sure there is somewhere to put it.
80
$layout->addBlock($row, $col);
83
// Or an existing one?
87
// Get target block info.
88
$info = $layout->getBlockInfo($row, $col);
89
$exists = $layout->isBlock($row, $col);
90
// Has a different block been selected?
92
($info['app'] != $newapp ||
93
$info['block'] != $newtype)) {
98
if ($new || $changed) {
99
// Change app or type.
101
$info['app'] = $newapp;
102
$info['block'] = $newtype;
103
$params = $blocks->getParams($newapp, $newtype);
104
foreach ($params as $newparam) {
105
$info['params'][$newparam] = $blocks->getDefaultValue($newapp, $newtype, $newparam);
107
$layout->setBlockInfo($row, $col, $info);
110
$layout->setBlockInfo($row, $col, array('params' => Util::getFormData('params', array())));
113
if ($action == 'save') {
117
// Make a block the current block for editing.
124
$title = _("My Portal Layout");
125
require HORDE_TEMPLATES . '/common-header.inc';
126
require HORDE_TEMPLATES . '/portal/menu.inc';
127
$notification->notify(array('listeners' => 'status'));
128
require HORDE_TEMPLATES . '/portal/edit.inc';
129
require HORDE_TEMPLATES . '/common-footer.inc';