[dev] [patches] Displaying invalid objects
Francois Marier
francois at nit.ca
Thu Jul 29 11:25:04 PDT 2004
Here are three patches to fix the same problem in Ingo, Mnemo and
Nag (Kronolith and Turba don't have that problem):
- open the same filter/memo/task in two different windows
- in the first one, delete the filter/memo/task
- reload the second window
In all three cases weird errors (especially in the case of Ingo) or
empty pages are displayed. These patches make these applications
handle invalid objects the same way as Kronolith and Turba:
- return to the main application page (list of filters/memos/tasks)
- display a notice saying that the filter/memo/task could not be found
Francois
-------------- next part --------------
diff -rpuN -X ../ignorelist ../build/ingo/rule.php ingo/rule.php
--- ../build/ingo/rule.php Sat Jan 17 17:57:16 2004
+++ ingo/rule.php Wed Jul 14 16:58:47 2004
@@ -133,6 +133,12 @@ if ($registry->hasMethod('mail/createFol
Horde::addScriptFile('new_folder.js');
}
+if (!$rule) {
+ $notification->push(_("Filter not found."), 'horde.error');
+ header('Location: ' . Horde::applicationUrl('filters.php', true));
+ exit;
+}
+
$title = _("New Rule");
require INGO_TEMPLATES . '/common-header.inc';
Ingo::menu();
-------------- next part --------------
diff -rpuN -X ../ignorelist ../build/mnemo/memo.php mnemo/memo.php
--- ../build/mnemo/memo.php Mon Jun 28 10:56:12 2004
+++ mnemo/memo.php Thu Jul 29 14:05:03 2004
@@ -42,7 +42,7 @@ case 'modify_memo':
/* Get the current note. */
$memo = Mnemo::getMemo($memolist_id, $memo_id);
- if (!$memo) {
+ if (!isset($memo) || !isset($memo['memo_id'])) {
$notification->push(_("Note not found."), 'horde.error');
header('Location: ' . Horde::applicationUrl('list.php', true));
exit;
diff -rpuN -X ../ignorelist ../build/mnemo/templates/view/no-memo.inc mnemo/templates/view/no-memo.inc
--- ../build/mnemo/templates/view/no-memo.inc Sat Sep 21 12:37:23 2002
+++ mnemo/templates/view/no-memo.inc Wed Dec 31 19:00:00 1969
@@ -1,6 +0,0 @@
-<table border="0" cellpadding="2" cellspacing="0" width="100%">
-<tr align="center">
- <td class="menu"><?php echo _("The requested note does not exist.") ?></td>
-</tr>
-</table>
-<br />
diff -rpuN -X ../ignorelist ../build/mnemo/view.php mnemo/view.php
--- ../build/mnemo/view.php Fri May 21 13:38:35 2004
+++ mnemo/view.php Thu Jul 29 14:05:03 2004
@@ -69,8 +69,10 @@ if ($print_view) {
}
/* If the requested note doesn't exist, display an error message. */
-if (!$memo) {
- include MNEMO_TEMPLATES . '/view/no-memo.inc';
+if (!isset($memo) || !isset($memo['memo_id'])) {
+ $notification->push(_("Note not found."), 'horde.error');
+ header('Location: ' . Horde::applicationUrl('list.php', true));
+ exit;
} else {
include MNEMO_TEMPLATES . '/view/memo.inc';
}
-------------- next part --------------
diff -rpuN -X ../ignorelist ../build/nag/task.php nag/task.php
--- ../build/nag/task.php Wed Mar 31 13:20:29 2004
+++ nag/task.php Wed Jul 14 16:20:59 2004
@@ -66,7 +66,7 @@ case 'modify_task':
$alarm_unit = 'min';
$alarm_set = false;
- if ($task) {
+ if (isset($task) && isset($task['task_id'])) {
/* Set up the task attributes. */
$task_name = $task['name'];
$task_due = $task['due'];
@@ -114,7 +114,9 @@ case 'modify_task':
$title = _("Modifying:") . ' ' . $task_name;
} else {
- $title = _("Unknown task");
+ $notification->push(_("Task not found."), 'horde.error');
+ header('Location: ' . Horde::applicationUrl('list.php', true));
+ exit;
}
break;
diff -rpuN -X ../ignorelist ../build/nag/templates/view/no-task.inc nag/templates/view/no-task.inc
--- ../build/nag/templates/view/no-task.inc Sat Jun 15 01:04:43 2002
+++ nag/templates/view/no-task.inc Wed Dec 31 19:00:00 1969
@@ -1,6 +0,0 @@
-<table border="0" cellpadding="2" cellspacing="0" width="100%">
-<tr align="center">
- <td class="menu"><?php echo _("The requested task does not exist.") ?></td>
-</tr>
-</table>
-<br />
diff -rpuN -X ../ignorelist ../build/nag/view.php nag/view.php
--- ../build/nag/view.php Wed Jul 14 16:22:27 2004
+++ nag/view.php Wed Jul 14 16:21:32 2004
@@ -82,8 +82,10 @@ if ($print_view) {
}
/* If the requested task doesn't exist, display an error message. */
-if (!$task) {
- require NAG_TEMPLATES . '/view/no-task.inc';
+if (!isset($task) || !isset($task['task_id'])) {
+ $notification->push(_("Task not found."), 'horde.error');
+ header('Location: ' . Horde::applicationUrl('list.php', true));
+ exit;
} else {
/* Set up alarm units and value. */
$task_alarm = $task['alarm'];
More information about the dev
mailing list