[patch] Use client-adding logic in driver

"Jason M. Felice" <[email protected]>
Newsgroups gmane.comp.horde.whups
Message-ID <[email protected]>
create.php was manually adding clients still.  This patch removes that
duplicate logic and makes the driver's addTicket() call the driver's
updateClients() to set clients.  This also means you can set clients from
whups' API.


-- 
Whups mailing list
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: [email protected]
whups-create-clients.diff (text/plain, 2.8 KB)
patchwork diff create.php
--- create.php	Fri Dec  5 09:38:09 2003
+++ create.php	Fri Dec  5 10:06:04 2003
@@ -151,40 +151,6 @@
     $message = sprintf(_("Your ticket id is %s. "), $tid);
     $message .= _("An appropriate person has been notified of this request.");
     $notification->push($message, 'horde.success');
-
-    if ($GLOBALS['registry']->hasMethod('clients/getClientSource')) {
-        /* Add a link from this ticket to the selected client. */
-        if (!empty($info['client'])) {
-            $clientsource = $GLOBALS['registry']->call('clients/getClientSource');
-            require_once HORDE_BASE . '/lib/Links.php';
-            $links = &Horde_Links::singleton($registry->getApp());
-
-            $link_data = array('link_params' => array('link_type' => 'client', 
-                                                      'from_application' => 'tickets', 
-                                                      'to_application' => 'clients'),
-                               'from_params' => array('from_key' => 'ticket_id',  
-                                                      'from_value' => $tid));
-
-            /* Now add in the new client link(s). */
-            $clients = $info['client'];
-            if (!is_array($clients)) {
-                $clients = array($clients);
-            }
-            foreach ($clients as $client_id) {
-                $link_data['to_params'] = array('source' => $clientsource, 'to_value' => $client_id);
-                $status = $links->addLink($link_data);
-                if (is_a($status, 'PEAR_Error')) {
-                    $notification->push($status, 'horde.error');
-                } elseif ($registry->hasMethod('clients' . '/getLinkSummary')) {
-                    $link_summary = $registry->call('clients' . '/getLinkSummary', array($link_data));
-                    $notification->push(sprintf(_("Added a %s link to %s."), 'client', $link_summary), 'horde.success');
-                } else {
-                    $notification->push(_("Link added."), 'horde.success');
-                }
-            }
-        }
-    }
-
     $url = Horde::applicationUrl('details.php', true);
     $url = Util::addParameter($url, 'id', $tid);
     header('Location: ' . $url);
patchwork diff lib/Driver/sql.php
--- lib/Driver/sql.php	Fri Dec  5 10:17:20 2003
+++ lib/Driver/sql.php	Fri Dec  5 10:07:56 2003
@@ -232,6 +232,14 @@
             return $result;
         }
 
+        // Assign clients.
+        if ($GLOBALS['registry']->hasMethod('clients/getClientSource')) {
+            if (!empty($info['client'])) {
+                $clients = $info['client'];
+                $this->updateClients($new_id, 'ticket', $clients);
+            }
+        }
+
         $minfo = $this->getModule($module);
         $this->notifyTicket($new_id, $summary, $minfo['name'], Auth::getAuth());
         if (!empty($owner)) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.