summaryrefslogtreecommitdiff
path: root/patches/horde-webmail/1.2.0/tg/t_kronolith_HK_SB_SaveEventAttendees.diff
blob: 2a674a83e5fb3d154b9bb1d0b2862bc25b048e40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
From: Gunnar Wrobel <p@rdus.de>
Subject: [PATCH] t/kronolith/HK/SB/SaveEventAttendees

Allow to save attendees when adding them to kronolith events.

FIXME: It would be better to save these as distribution lists now.

Signed-off-by: Gunnar Wrobel <p@rdus.de>

---
 horde-webmail/kronolith/attendees.php              |   18 +++++
 horde-webmail/kronolith/config/prefs.php.dist      |    8 ++
 horde-webmail/kronolith/po/de_DE.po                |    6 ++
 horde-webmail/kronolith/savedattlist.php           |   77 ++++++++++++++++++++
 .../kronolith/templates/attendees/attendees.inc    |    2 +
 .../templates/javascript/open_savedattlist_win.js  |   36 +++++++++
 .../templates/savedattlist/savedattlist.inc        |   68 +++++++++++++++++
 7 files changed, 215 insertions(+), 0 deletions(-)

diff --git a/horde-webmail/kronolith/attendees.php b/horde-webmail/kronolith/attendees.php
index a2d8b3e..e1b15c0 100644
--- a/horde-webmail/kronolith/attendees.php
+++ b/horde-webmail/kronolith/attendees.php
@@ -178,6 +178,16 @@ case 'clear':
     $attendees = array();
     $_SESSION['kronolith']['attendees'] = $attendees;
     break;
+
+case 'save':
+    if (empty($attendees)) {
+        break;
+    }
+    $savedattlist = unserialize($prefs->getValue('saved_attendee_list'));
+    $savedattlist[] = array_keys($attendees);
+    $prefs->setValue('saved_attendee_list', serialize($savedattlist));
+    $notification->push(_('Successfully saved attendee list'), 'horde.success');
+    break;
 }
 
 // Get the current Free/Busy view; default to the 'day' view if none specified.
@@ -264,6 +274,14 @@ Imple::factory('ContactAutoCompleter', array('triggerId' => 'newAttendees'));
 
 $title = _("Edit attendees");
 require KRONOLITH_TEMPLATES . '/common-header.inc';
+
+if ($browser->hasFeature('javascript')) {
+    Horde::addScriptFile('open_savedattlist_win.js');
+    $savedattlist_url = 'javascript:open_savedattlist_win();';
+} else {
+    $savedattlist_url = Horde::applicationUrl('savedattlist.php');
+}
+
 $notification->notify(array('status'));
 require KRONOLITH_TEMPLATES . '/attendees/attendees.inc';
 require $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/horde-webmail/kronolith/config/prefs.php.dist b/horde-webmail/kronolith/config/prefs.php.dist
index 22c08c3..b1c49d8 100644
--- a/horde-webmail/kronolith/config/prefs.php.dist
+++ b/horde-webmail/kronolith/config/prefs.php.dist
@@ -497,3 +497,11 @@ $_prefs['last_kronolith_maintenance'] = array(
     'shared' => false,
     'type' => 'implicit'
 );
+
+$_prefs['saved_attendee_list'] = array(
+    'value' => 'a:0:{}',
+    'locked' => false,
+    'shared' => false,
+    'type' => 'implicit',
+    'desc' => _("A saved list of attendees")
+);
diff --git a/horde-webmail/kronolith/po/de_DE.po b/horde-webmail/kronolith/po/de_DE.po
index 2b555a2..68ed35c 100644
--- a/horde-webmail/kronolith/po/de_DE.po
+++ b/horde-webmail/kronolith/po/de_DE.po
@@ -2674,3 +2674,9 @@ msgstr "Jahr(e) am gleichen Jahrestag"
 #: templates/view/view.inc:116 templates/edit/edit.inc:271
 msgid "year(s) on the same weekday and month of the year"
 msgstr "Jahr(e) am gleichen Wochentag und Monat des Jahres"
+
+msgid "Load Attendee List"
+msgstr "Teilnehmerliste laden"
+
+msgid "Save Attendee List"
+msgstr "Teilnehmerliste speichern"
diff --git a/horde-webmail/kronolith/savedattlist.php b/horde-webmail/kronolith/savedattlist.php
new file mode 100644
index 0000000..631b994
--- /dev/null
+++ b/horde-webmail/kronolith/savedattlist.php
@@ -0,0 +1,77 @@
+<?php
+/**
+ * $Horde: kronolith/attendeeshandler.php,v 1.1 2004/05/25 08:34:21 stuart Exp $
+ *
+ * Copyright 2004 Code Fusion  <http://www.codefusion.co.za/>
+ *                Stuart Binge <s.binge@codefusion.co.za>
+ *
+ * See the enclosed file COPYING for license information (GPL).  If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ */
+
+@define('KRONOLITH_BASE', dirname(__FILE__));
+require_once KRONOLITH_BASE . '/lib/base.php';
+require_once KRONOLITH_BASE . '/lib/FBView.php';
+
+$title = _('Load Attendee List');
+
+Horde::addScriptFile('tooltip.js', 'horde');
+require KRONOLITH_TEMPLATES . '/common-header.inc';
+
+// Get our list of saved attendees
+$savedattlist = unserialize($prefs->getValue('saved_attendee_list'));
+
+// Preformat our image urls
+$delimg = Horde::img('delete.png', _("Remove List"), null, $GLOBALS['registry']->getImageDir('horde'));
+$loadimg = Horde::img('tree/folder.png', _("Load List"), null, $GLOBALS['registry']->getImageDir('horde'));
+
+// Get our Action ID & Value. This specifies what action the user initiated.
+$actionID = Util::getFormData('actionID', false);
+$actionValue = Util::getFormData('actionValue', false);
+if (!$actionID) {
+    $actionID = (Util::getFormData('addNew', false) ? 'add' : false);
+    $actionValue = Util::getFormData('newAttendees', '');
+}
+
+// Perform the specified action, if there is one.
+switch ($actionID) {
+case 'remove':
+    // Remove the specified attendee
+    if (array_key_exists($actionValue, $savedattlist)) {
+        unset($savedattlist[$actionValue]);
+	$prefs->setValue('saved_attendee_list', serialize($savedattlist));
+    }
+    
+    break;
+
+case 'dismiss':
+    // Make sure we're actually allowed to dismiss
+    if (!$allow_dismiss) break;
+
+    // Close the attendee window
+    global $browser;
+
+    if ($browser->hasFeature('javascript')) {
+        Util::closeWindowJS();
+    } else {
+        $url = Util::getFormData('url');
+
+        if (!empty($url)) {
+            $location = Horde::applicationUrl($url, true);
+        } else {
+            $url = Util::addParameter($prefs->getValue('defaultview') . '.php', 'month', Util::getFormData('month'));
+            $url = Util::addParameter($url, 'year', Util::getFormData('year'));
+            $location = Horde::applicationUrl($url, true);
+        }
+
+        // Make sure URL is unique.
+        $location = Util::addParameter($location, 'unique', md5(microtime()));
+
+        header('Location: ' . $location);
+    }
+    break;
+}
+
+$form_handler = Horde::applicationUrl('savedattlist.php');
+require KRONOLITH_TEMPLATES . '/savedattlist/savedattlist.inc';
+require $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc';
diff --git a/horde-webmail/kronolith/templates/attendees/attendees.inc b/horde-webmail/kronolith/templates/attendees/attendees.inc
index b057ea0..88f77eb 100644
--- a/horde-webmail/kronolith/templates/attendees/attendees.inc
+++ b/horde-webmail/kronolith/templates/attendees/attendees.inc
@@ -92,6 +92,8 @@ function switchDateView(view, timestamp)
 <div>
  <input type="submit" class="button" name="addNew" value="<?php echo htmlspecialchars(_("Save Attendees")) ?>" />
  <input type="submit" class="button" name="addNewClose" value="<?php echo htmlspecialchars(_("Save and Finish")) ?>" />
+ <input type="button" class="button" name="loadAttList" value="<?php echo htmlspecialchars(_("Load Attendee List")) ?>" onclick="<?php echo $savedattlist_url ?>" />
+ <?php if (!empty($attendees)): ?><input type="button" class="button" name="saveAttList" value="<?php echo htmlspecialchars(_("Save Attendee List")) ?>" onclick="performAction('save', '');" /><?php endif; ?>
  <?php if (!empty($attendees)): ?><input type="submit" class="button" name="clearAll" value="<?php echo htmlspecialchars(_("Clear all attendees")) ?>" /><?php endif; ?>
 </div>
 
diff --git a/horde-webmail/kronolith/templates/javascript/open_savedattlist_win.js b/horde-webmail/kronolith/templates/javascript/open_savedattlist_win.js
new file mode 100644
index 0000000..388a4b7
--- /dev/null
+++ b/horde-webmail/kronolith/templates/javascript/open_savedattlist_win.js
@@ -0,0 +1,36 @@
+<?php if (!strstr($_SERVER['PHP_SELF'], 'javascript.php')): ?><script language="JavaScript" type="text/javascript">
+<!--
+<?php endif; ?>
+function open_savedattlist_win(args)
+{
+    var url = "<?php echo Horde::url($GLOBALS['registry']->applicationWebPath('%application%/savedattlist.php', 'kronolith')) ?>";
+    if (url.indexOf('?') == -1) glue = '?';
+    else glue = '<?php echo ini_get('arg_separator.output') ?>';
+    var now = new Date();
+    var name = "savedattlist_window_" + now.getTime();
+    if (args != "") {
+        url = url + glue + args + '<?php echo ini_get('arg_separator.output') ?>' + "uniq=" + now.getTime();
+    } else {
+        url = url + glue + "uniq=" + now.getTime();
+    }
+    var Width = screen.width;
+    if (Width > 775) {
+        Width = 700;
+    } else {
+        Width -= 75;
+    }
+    var Height = screen.height;
+    if (Height > 725) {
+        Height = 650;
+    } else {
+        Height -= 75;
+    }
+    param = "toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=" + Width + ",height=" + Height + ",left=0,top=0";
+    name = window.open(url, name, param);
+    if (!eval("name.opener")) {
+        name.opener = self;
+    }
+}
+<?php if (!strstr($_SERVER['PHP_SELF'], 'javascript.php')): ?>// -->
+</script>
+<?php endif; ?>
diff --git a/horde-webmail/kronolith/templates/savedattlist/savedattlist.inc b/horde-webmail/kronolith/templates/savedattlist/savedattlist.inc
new file mode 100644
index 0000000..2489f25
--- /dev/null
+++ b/horde-webmail/kronolith/templates/savedattlist/savedattlist.inc
@@ -0,0 +1,68 @@
+<!-- javascript action handling -->
+<script language="JavaScript" type="text/javascript">
+<!--
+function performAction(id, value)
+{
+    document.savedattlistForm.actionID.value = id;
+    document.savedattlistForm.actionValue.value = value;
+    document.savedattlistForm.submit();
+    return false;
+}
+
+function updateMessage(list)
+{
+    if (parent.opener.closed) {
+        alert('<?php echo addslashes(_("The Edit Attendees screen is no longer present. Exiting.")) ?>');
+        this.close();
+        return;
+    }
+
+    if (!parent.opener.document.attendeesForm) {
+        alert('<?php echo addslashes(_("You can only use this form from the Edit Attendees screen.")) ?>');
+        this.close();
+        return;
+    }
+
+    parent.opener.document.attendeesForm.newAttendees.value = list;
+    this.close();
+}
+// -->
+</script>
+
+<form method="post" action="<?php echo $form_handler; ?>" name="savedattlistForm">
+<?php Util::pformInput(); ?>
+<input type="hidden" name="actionID" value="" />
+<input type="hidden" name="actionValue" value="" />
+
+<div align="center">
+
+<table border="0" width="500" cellspacing="0" cellpadding="2">
+
+<!-- header -->
+<tr><td colspan="4" class="header"><b><?php echo $title ?></b></td></tr>
+
+<!-- attendee list header -->
+<tr class="item">
+ <td nowrap="nowrap" width="2%" align="center"><?php echo $loadimg ?></td>
+ <td nowrap="nowrap" width="2%" align="center"><?php echo $delimg ?></td>
+ <td nowrap="nowrap" width="96%"><b><?php echo htmlspecialchars(_("Attendees")) ?></b></td>
+</tr>
+
+<!-- attendees -->
+<?php $i = 0 ?>
+<?php if (empty($savedattlist)): ?>
+ <tr class="item<?php echo ($i++ % 2) ?>"><td align="center" colspan="3"><i><?php echo htmlspecialchars('-- ' . _("No saved attendee lists are available") . ' --') ?></i></td></tr>
+<?php else: foreach ($savedattlist as $index => $list): ?>
+ <tr class="item<?php echo ($i++ % 2) ?>">
+ <?php
+  echo '<td align="center">', Horde::link("javascript:updateMessage('" . addslashes(implode(', ', $list)) . "')", _("Load this list")), $loadimg, "</a></td>";
+ ?>
+ <?php
+  echo '<td align="center">', Horde::link("javascript:performAction('remove', '" . $index . "')", _("Remove this list")), $delimg, "</a></td>";
+ ?>
+  <td><?php echo implode(', ', $list); ?></td>
+ </tr>
+<?php endforeach; endif; ?>
+</table>
+</div>
+</form>
-- 
tg: (6938161..) t/kronolith/HK/SB/SaveEventAttendees (depends on: master)
-- 
TOPGIT patch commit log
=======================

commit 3715013c5b1c184a72130bab132e3157d7e4b0ca
Author: Gunnar Wrobel <p@rdus.de>
Date:   Fri Jun 26 12:06:46 2009 +0200

    Fixed translations.

commit ced8db79fc783d16931dfcecea9bc823c2f5737f
Author: Gunnar Wrobel <p@rdus.de>
Date:   Fri Jun 26 11:15:43 2009 +0200

    German translations.

commit cd7f4fe16072b7b40a1a75bd5c9a296e23bca779
Author: Gunnar Wrobel <p@rdus.de>
Date:   Sat Mar 14 01:10:10 2009 +0100

    Remove stray .orig file.

commit e508e429dcac35ef7ac223c771a9973f823db53f
Author: Gunnar Wrobel <p@rdus.de>
Date:   Sun Feb 1 22:21:11 2009 +0000

    Added patch kronolith/HK-SB-Fbview_save_attendees.patch  from the mercurial release queue.