[dev] [turba-patches] hide multiple address books
Francois Marier
francois at nit.ca
Tue Jul 27 18:50:31 PDT 2004
Here are 3 patches for Turba that remove address book selectors from
the UI when there is only one address book to choose from.
The patches "simplify_search" and "simplify_import_export" replace the
selector by a <input type=hidden> tag with the unique source.
The other patch ("remove_browse_controls") remove the options in the
Browse page that don't make sense when you don't have more than one
address book (specifically, the "move" and "copy" options).
Francois
-------------- next part --------------
diff -rpuN -X ../ignorelist ../build/turba/browse.php turba/browse.php
--- ../build/turba/browse.php Tue Mar 23 17:42:36 2004
+++ turba/browse.php Sun Jul 11 16:43:56 2004
@@ -50,6 +50,11 @@ foreach ($cfgSources as $key => $curSour
}
}
+// Hide the list of addressbooks is there is only one available
+if ($source_count == 1) {
+ $add_source_options = '';
+}
+
if ($source_count == 0) {
$notification->push(_("There are no browseable address books."), 'horde.warning');
} else {
-------------- next part --------------
diff -rpuN -X ../ignorelist ../build/turba/data.php turba/data.php
--- ../build/turba/data.php Wed Jun 30 23:41:24 2004
+++ turba/data.php Tue Jul 27 21:33:23 2004
@@ -191,16 +191,19 @@ Turba::menu();
$default_source = $prefs->getValue('default_dir');
if ($next_step == IMPORT_FILE) {
/* Build the directory sources select widget. */
+ $unique_source = '';
$source_options = '';
foreach ($cfgSources as $key => $entry) {
$selected = ($key == $default_source) ? ' selected="selected"' : '';
if (!empty($entry['export'])) {
$source_options .= "<option value=\"$key\"" . $selected . ">";
$source_options .= $entry['title'] . "</option>\n";
+ $unique_source = $key;
}
}
/* Build the directory destination select widget. */
+ $unique_dest = '';
$dest_options = '';
$hasWriteable = false;
foreach ($cfgSources as $key => $entry) {
@@ -208,6 +211,7 @@ if ($next_step == IMPORT_FILE) {
if (empty($entry['readonly']) || (isset($entry['admin']) && in_array(Auth::getAuth(), $entry['admin']))) {
$dest_options .= "<option value=\"$key\" " . $selected . ">";
$dest_options .= $entry['title'] . "</option>\n";
+ $unique_dest = $key;
$hasWriteable = true;
}
}
diff -rpuN -X ../ignorelist ../build/turba/templates/data/export.inc turba/templates/data/export.inc
--- ../build/turba/templates/data/export.inc Thu Feb 12 15:04:57 2004
+++ turba/templates/data/export.inc Tue Jul 27 21:34:38 2004
@@ -17,11 +17,19 @@
<option value="<?php echo EXPORT_TSV ?>"><?php echo _("Tab separated values") ?></option>
<!-- not (yet) implemented -->
<!--<option value="<?php echo EXPORT_VCARD ?>"><?php echo _("vCard") ?></option>-->
- </select><br /><br />
+ </select><br />
+
+<?php if (count($source_options) > 1): ?>
+ <br />
<?php echo _("Select the source to export from:") ?><br />
<select name="source">
<?php echo $source_options ?>
- </select><br /><br />
+ </select><br />
+<?php else: ?>
+ <input type="hidden" name="source" value="<?php echo $unique_source ?>" />
+<?php endif; ?>
+<br />
+
<input type="submit" value="<?php echo _("Export") ?>" class="button" />
</td></tr></table>
</td>
diff -rpuN -X ../ignorelist ../build/turba/templates/data/import.inc turba/templates/data/import.inc
--- ../build/turba/templates/data/import.inc Wed Dec 3 14:09:05 2003
+++ turba/templates/data/import.inc Tue Jul 27 21:34:50 2004
@@ -20,11 +20,19 @@
<option value="vcard"><?php echo _("vCard") ?></option>
<option value="mulberry"><?php echo _("Mulberry Address Book") ?></option>
<option value="pine"><?php echo _("Pine Address Book") ?></option>
- </select><br /><br />
+ </select><br />
+
+<?php if (count($dest_options) > 1): ?>
+ <br />
<?php echo _("Select the destination to import to:") ?><br />
<select name="dest">
<?php echo $dest_options ?>
- </select><br /><br />
+ </select><br />
+<?php else: ?>
+ <input type="hidden" name="dest" value="<?php echo $unique_dest ?>" />
+<?php endif; ?>
+<br />
+
<?php echo _("Select the file to import:") ?><br />
<input type="file" name="import_file" class="fixed" size="40" /><br /><br />
<input type="submit" value="<?php echo _("Next") ?>" class="button" />
-------------- next part --------------
diff -rpuN -X ../ignorelist ../build/turba/templates/browse/search.inc turba/templates/browse/search.inc
--- ../build/turba/templates/browse/search.inc Thu Jul 15 13:46:14 2004
+++ turba/templates/browse/search.inc Thu Jul 15 14:33:03 2004
@@ -23,6 +23,7 @@ foreach ($cfgSources as $key => $entry)
$source_options .= "<option value=\"$key\"$selected>";
$source_options .= $entry['title'] . "</option>\n";
+ $unique_source = $key;
$source_count++;
}
@@ -126,9 +127,15 @@ function updateCriterias()
</td>
</tr>
+ <?php if ($source_count > 1) : ?>
+
<tr><td class="light" align="right"><b><?php echo _("Directory") ?></b></td>
<td align="left"><select name="source" onchange="directory_search.submit()">
<?php echo $source_options ?>
</select></td></tr>
+
+ <?php else: ?>
+ <input type="hidden" name="source" value="<?php echo $unique_source ?>">
+ <?php endif ?>
<?php endif;
More information about the dev
mailing list