Pass only the correct data to each of the owner fields.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 14 Aug 2010 22:45:27 +0000 (18:45 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 14 Aug 2010 22:48:32 +0000 (18:48 -0400)
This fixes the problem of the form failing validation, but it is still broken
in the sense that once an owner is set for either of the fields, it is impossible to
remove all owners from that field. This is because if the multienum is empty,
the default value is applied to it when it is submitted.

whups/lib/Forms/EditTicket.php

index f1705e6..1e80d44 100644 (file)
@@ -122,7 +122,16 @@ class EditTicketForm extends Horde_Form {
                                                           'multienum',
                                                           false, false, null,
                                                           array($f_users));
-                            $owners->setDefault($whups_driver->getOwners($vars->get('id')));
+                            $ticketOwners = array();
+                            $ticketGroups = array();
+                            foreach($whups_driver->getOwners($vars->get('id')) as $owner) {
+                                if (strpos($owner, 'user:') !== false) {
+                                    $ticketOwners[] = $owner;
+                                } else {
+                                    $ticketGroups[] = $owner;
+                                }
+                            }
+                            $owners->setDefault($ticketOwners);
                         }
 
                         if (count($f_groups)) {
@@ -133,7 +142,7 @@ class EditTicketForm extends Horde_Form {
                                                                 false, false,
                                                                 null,
                                                                 array($f_groups));
-                            $group_owners->setDefault($whups_driver->getOwners($vars->get('id')));
+                            $group_owners->setDefault($ticketGroups);
                         }
                     }
                     break;