[Phamm] [PATCH] phamm-0.5.15: fix interface for the confusing checkbox to unset multiple valued attribute
kabe at sra-tohoku.co.jp
kabe at sra-tohoku.co.jp
Wed Feb 4 16:41:10 CET 2009
For multiple valued LDAP attribute, current Phamm presents
(e.g for alias user modification)
(o) ALIAS Destination [ <blank textarea> ]
[ ] current at setting1.com
[ ] current at setting2.com
which the checkbox is *checked to delete* the existing value,
which was unnecessarily confusing.
The patch will change the interface to present
(o) ALIAS Destination [ <blank textarea> ]
[X] current at setting1.com
[X] current at setting2.com
which should be much more comprehensible.
Now you would uncheck the checkbox to delete the value.
Bonus: You can replace the value in single step by filling the textarea and
unchecking all of the checkboxes.
(previously, for LDAP MUST attributes like maildrop:,
you had to fill new value in textarea, [Modify account],
check the old values to delete, [Modify account])
--
kabe
--- phamm-0.5.15/lib/xhtml.php.dis2 2009-02-05 00:22:20.000000000 +0900
+++ phamm-0.5.15/lib/xhtml.php 2009-02-04 23:42:15.000000000 +0900
@@ -595,7 +595,7 @@
{
for ($i=0; $i < $value["count"]; $i++)
{
- $tag .= '<input type="checkbox" name="values_multi_del['.$p_name.']['.$name.'][]" value="'.$value[$i].'" />';
+ $tag .= '<input type="checkbox" name="values_multi_chk['.$p_name.']['.$name.'][]" value="'.$value[$i].'" checked />';
$tag .= $value[$i]."<br/>";
}
}
@@ -603,7 +603,7 @@
elseif (isset($attr["SUBORDINATEDDELETE"]) && $value)
{
- $tag .= '<input type="checkbox" name="values_multi_del['.$p_name.']['.$name.']" value="'.$value.'" id="subordinatedelete" />';
+ $tag .= '<input type="checkbox" name="values_multi_chk['.$p_name.']['.$name.']" value="'.$value.'" id="subordinatedelete" checked />';
$tag .= $value."<br/>";
}
--- phamm-0.5.15/www-data/main.php.dis2 2008-12-21 21:18:08.000000000 +0900
+++ phamm-0.5.15/www-data/main.php 2009-02-05 00:18:34.000000000 +0900
@@ -622,7 +622,7 @@
$values = $_POST["values"];
$values_date = (isset($_POST["values_date"]) ? $_POST["values_date"] : null);
$values_multi = (isset($_POST["values_multi"]) ? $_POST["values_multi"] : null);
- $values_multi_del = (isset($_POST["values_multi_del"]) ? $_POST["values_multi_del"] : null);
+ $values_multi_chk = (isset($_POST["values_multi_chk"]) ? $_POST["values_multi_chk"] : null);
$confirm = $_POST["confirm"];
$account = (isset($_POST["account_new"]) ? $_POST["account_new"] : null);
@@ -636,6 +636,7 @@
$values_multi_purged_one = array();
$values_date_purged_one = array();
$values_multi_purged = array();
+ $values_multi_chk_purged = array();
$values_date_purged = array();
$entry["sn"] = $sn;
@@ -672,6 +673,7 @@
$values_purged = purge_empty_values($values[$p_name]);
if (isset($values_multi[$p_name]))
+ // $values_multi[$p_name][<attrname>] = "string[,string]"
$values_multi_purged_one = purge_empty_values($values_multi[$p_name]);
if (isset($values_date[$p_name]))
$values_date_purged_one = purge_empty_values($values_date[$p_name]);
@@ -680,13 +682,16 @@
$entry = array_merge($entry,$values_purged);
$values_multi_purged = array_merge($values_multi_purged,$values_multi_purged_one);
$values_date_purged = array_merge($values_date_purged,$values_date_purged_one);
-
- // Del Values from checkbox
- if (isset($values_multi_del[$p_name]))
- {
- $rd = phamm_mod_del ('mail='.$mail.',vd='.$domain.','.LDAP_BASE,$values_multi_del[$p_name]);
+
+ // Purge and strip_tags() the checkbox array
+ // $values_multi_chk[$p_name][<attrname>][] = "string"
+ // $values_multi_chk_purged[<attrname>][] = "string"
+ if (isset($values_multi_chk[$p_name])) {
+ foreach ($values_multi_chk[$p_name] as $mv_name => $mv_array) {
+ $values_multi_chk_purged[$mv_name] = purge_empty_values($values_multi_chk[$p_name][$mv_name]);
+ }
}
- }
+ }//$p_name
}
$mail = $account;
@@ -701,6 +706,7 @@
}
// Add Values from textarea...
+ $entry_add = array();
if (count($values_multi_purged) > 0)
{
foreach ($values_multi_purged as $mv_name => $mv_array)
@@ -713,18 +719,29 @@
$values_multi_array = explode (",",$values_multi_string);
- for ($i=0; $i < count($values_multi_array); $i++)
- $entry_add[$mv_name][$i] = $values_multi_array[$i];
+ foreach ($values_multi_array as $mv_val)
+ $entry_add[$mv_name][] = $mv_val;
}
-
- if (count($values_multi_array) > 0)
- {
- $ra = phamm_mod_add ('mail='.$mail.',vd='.$domain.','.LDAP_BASE,$entry_add);
- }
-
}
+ // Add Values from checkbox list...
+ if (count($values_multi_chk_purged) > 0)
+ {
+ foreach ($values_multi_chk_purged as $mv_name => $mv_array)
+ {
+ foreach ($mv_array as $mv_val)
+ // using array_merge() will nullify output if $entry_add was empty
+ $entry_add[$mv_name][] = $mv_val;
+ }
+ }
+ // Store the multi values
+ if (count($entry_add) > 0)
+ {
+ $ra = phamm_modify ('mail='.$mail.',vd='.$domain.','.LDAP_BASE,$entry_add);
+ // TODO: pick the $ra error
+ }
+ unset($entry_add);
- // This swith action to change mail or postmaster value
+ // This switch action to change mail or postmaster value
if ($mail)
{
$entry["lastChange"] = time();
More information about the Phamm
mailing list