From de4c101c7f7fbbc2522a143eae9479b0dc55e93b Mon Sep 17 00:00:00 2001 From: pdontthink Date: Thu, 26 Jun 2008 00:09:22 +0000 Subject: [PATCH] Add ability to turn off edit list delete checkbox git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13197 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/options.php | 22 ++++++++++++++++++- templates/default/edit_list_widget.tpl | 15 ++++++++----- .../default/edit_list_widget_list_style.tpl | 9 +++++--- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/functions/options.php b/functions/options.php index d7d8b625..61ddf027 100644 --- a/functions/options.php +++ b/functions/options.php @@ -133,6 +133,13 @@ class SquirrelOption { * @var boolean */ var $use_add_widget; + /** + * Indicates if the Delete widget should be included + * with edit lists. + * + * @var boolean + */ + var $use_delete_widget; /** * text displayed to the user * @@ -223,6 +230,7 @@ class SquirrelOption { $this->comment = ''; $this->layout_type = 0; $this->use_add_widget = TRUE; + $this->use_delete_widget = TRUE; $this->aExtraAttribs = array(); $this->post_script = ''; @@ -309,6 +317,11 @@ class SquirrelOption { $this->use_add_widget = $use_add_widget; } + /* Set the "use delete widget" value for this option. */ + function setUseDeleteWidget($use_delete_widget) { + $this->use_delete_widget = $use_delete_widget; + } + /** * Set the layout type for this option. * @param int $layout_type @@ -754,6 +767,7 @@ class SquirrelOption { //FIXME: $this->aExtraAttribs probably should only be used in one place $oTemplate->assign('input_widget', addInput('add_' . $this->name, '', 38, 0, $this->aExtraAttribs)); $oTemplate->assign('use_input_widget', $this->use_add_widget); + $oTemplate->assign('use_delete_widget', $this->use_delete_widget); $oTemplate->assign('trailing_text', $this->trailing_text); $oTemplate->assign('possible_values', $this->possible_values); @@ -844,7 +858,8 @@ function save_option($option) { // delete selected elements if needed // - if (is_array($option->new_value) + if ((isset($option->use_delete_widget) && $option->use_delete_widget) + && is_array($option->new_value) && sqGetGlobalVar('delete_' . $option->name, $ignore, SQ_POST)) $option->possible_values = array_diff($option->possible_values, $option->new_value); @@ -967,6 +982,11 @@ function create_option_groups($optgrps, $optvals) { $next_option->setUseAddWidget($optset['use_add_widget']); } + /* If provided, set the use_delete_widget value for this option. */ + if (isset($optset['use_delete_widget'])) { + $next_option->setUseDeleteWidget($optset['use_delete_widget']); + } + /* If provided, set the comment for this option. */ if (isset($optset['comment'])) { $next_option->setComment($optset['comment']); diff --git a/templates/default/edit_list_widget.tpl b/templates/default/edit_list_widget.tpl index 9c48bb2a..1d780390 100644 --- a/templates/default/edit_list_widget.tpl +++ b/templates/default/edit_list_widget.tpl @@ -11,8 +11,11 @@ * string $input_widget A preconstructed input text box used * for adding new elements to the edit list * boolean $use_input_widget Whether or not to present the $input_widget - * string $select_widget A preconstructed input text box used - * string $checkbox_widget A preconstructed input text box used + * boolean $use_delete_widget Whether or not to present the $checkbox_widget + * string $select_widget A preconstructed select widget containing + * all the elements in the list + * string $checkbox_widget A preconstructed checkbox used for deleting + * elements from the edit list * string $trailing_text Any text given by the caller to be displayed * after the edit list input * array $possible_values The original list of options in the edit list, @@ -35,6 +38,8 @@ extract($t); if ($use_input_widget) echo _("Add") . ' ' . $input_widget . '
'; -echo $select_widget - . '
' . $checkbox_widget . ' '; +echo $select_widget; + +if (!empty($possible_values) && $use_delete_widget) + echo '
' . $checkbox_widget . ' '; diff --git a/templates/default/edit_list_widget_list_style.tpl b/templates/default/edit_list_widget_list_style.tpl index 53e547b0..6fefc20c 100644 --- a/templates/default/edit_list_widget_list_style.tpl +++ b/templates/default/edit_list_widget_list_style.tpl @@ -11,8 +11,11 @@ * string $input_widget A preconstructed input text box used * for adding new elements to the edit list * boolean $use_input_widget Whether or not to present the $input_widget - * string $select_widget A preconstructed input text box used - * string $checkbox_widget A preconstructed input text box used + * boolean $use_delete_widget Whether or not to present the $checkbox_widget + * string $select_widget A preconstructed select widget containing + * all the elements in the list + * string $checkbox_widget A preconstructed checkbox used for deleting + * elements from the edit list * string $trailing_text Any text given by the caller to be displayed * after the edit list input * array $possible_values The original list of options in the edit list, @@ -56,7 +59,7 @@ foreach ($possible_values as $key => $value) { echo ''; -if (!empty($possible_values)) +if (!empty($possible_values) && $use_delete_widget) echo $checkbox_widget . ' '; -- 2.25.1