Re: linking clients to tickets
Bo Daley <[email protected]>
| Newsgroups | gmane.comp.horde.whups |
|---|---|
| Message-ID | <[email protected]> |
Quoting Chuck Hagenbuch <[email protected]>: > > In a couple of places I did make the assumption that tickets would only > have one client > If we can avoid making that assumption, I think we should. this patch allows multiple clients to be allocated to a ticket. It required a small change to Horde_Form to make the preserve() function accept array values. -- I'm not sure that the way I modified Horde_Form is the best way to handle this though.. any suggestions? thanks, bo. -- Whups mailing list Frequently Asked Questions: http://horde.org/faq/ To unsubscribe, mail: [email protected]
multiple_clients.diff
(text/diff, 4.1 KB)
Index: lib/Form.php
===================================================================
RCS file: /repository/horde/lib/Form.php,v
retrieving revision 1.120
diff -u -r1.120 Form.php
--- lib/Form.php 29 Jul 2003 18:59:34 -0000 1.120
+++ lib/Form.php 4 Aug 2003 03:10:42 -0000
@@ -612,9 +612,15 @@
function _preserveVarByPost($varname, $value)
{
$varname = htmlspecialchars($varname);
- $value = htmlspecialchars($value);
-
- echo '<input type="hidden" name="' . $varname . '" value="' . $value . "\" />\n";
+ if (is_array($value)) {
+ foreach ($value as $val) {
+ $val = htmlspecialchars($val);
+ echo '<input type="hidden" name="' . $varname . '[]" value="' . $val . "\" />\n";
+ }
+ } else {
+ $value = htmlspecialchars($value);
+ echo '<input type="hidden" name="' . $varname . '" value="' . $value . "\" />\n";
+ }
}
}
Index: whups/create.php
===================================================================
RCS file: /repository/whups/create.php,v
retrieving revision 1.35
diff -u -r1.35 create.php
--- whups/create.php 30 Jul 2003 03:15:12 -0000 1.35
+++ whups/create.php 4 Aug 2003 03:10:43 -0000
@@ -165,17 +165,22 @@
$to_application = 'contacts';
$link_type = 'client';
/* Now add in the new client link. */
- $client_id = $info['client'];
- settype($client_id, 'string');
- $to_parameters = array('source' => $clientsource, 'id' => $client_id);
- $status = $links->addLink($from_application, $from_parameters, $to_application, $to_parameters, $link_type);
- if (is_a($status, 'PEAR_Error')) {
- $notification->push($status, 'horde.error');
- } elseif ($registry->hasMethod($to_application . '/getLinkSummary')) {
- $link_summary = $registry->call($to_application . '/getLinkSummary', $to_parameters);
- $notification->push(sprintf(_("Added a %s link to %s."), $link_type, $link_summary), 'horde.success');
- } else {
- $notification->push(_("Link added."), 'horde.success');
+ $clients = $info['client'];
+ if (!is_array($clients)) {
+ $clients = array($clients);
+ }
+ foreach ($clients as $client_id) {
+ settype($client_id, 'string');
+ $to_parameters = array('source' => $clientsource, 'id' => $client_id);
+ $status = $links->addLink($from_application, $from_parameters, $to_application, $to_parameters, $link_type);
+ if (is_a($status, 'PEAR_Error')) {
+ $notification->push($status, 'horde.error');
+ } elseif ($registry->hasMethod($to_application . '/getLinkSummary')) {
+ $link_summary = $registry->call($to_application . '/getLinkSummary', $to_parameters);
+ $notification->push(sprintf(_("Added a %s link to %s."), $link_type, $link_summary), 'horde.success');
+ } else {
+ $notification->push(_("Link added."), 'horde.success');
+ }
}
}
break;
Index: whups/lib/Create.php
===================================================================
RCS file: /repository/whups/lib/Create.php,v
retrieving revision 1.37
diff -u -r1.37 Create.php
--- whups/lib/Create.php 30 Jul 2003 03:15:13 -0000 1.37
+++ whups/lib/Create.php 4 Aug 2003 03:10:43 -0000
@@ -65,7 +65,7 @@
$clienttype = 'invalid';
$client_params = array(_("There are no clients associated with this module; until there are, you cannot create any tickets in this module."));
} else {
- $clienttype = 'enum';
+ $clienttype = 'multienum';
$client_params = array($clientlist);
}
$this->addVariable(_("Client"), 'client', $clienttype, true, false, null, $client_params);