Re: Re: [hermes] Making clients

Bo Daley <[email protected]>
Newsgroups gmane.comp.horde.whups
Message-ID <[email protected]>
Quoting Chuck Hagenbuch <[email protected]>:

> > OK here it is. This is only a slight modification on what I sent earlier,
> but
>
> Alright, I've had a quick glance over it, and the only thing I'm reluctant to
> commit is the patch to Links_sql; I really don't like the assumption of
> wildcards. I'd *probably* be okay with an explicit (non-default) wildcard. So
> I'm not going to commit that piece for now.

great -- the logic does require some method of performing multiple link
deletions though (as there may have been several clients attached to a module
before it was edited), so I'm attaching a patch that provides link deletions
using the '*' character as a wildcard.

thanks!

bo.


--
Bo Daley
Tilda Communications
http://www.tilda.com.au
[email protected]


-- 
Whups mailing list
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: [email protected]
Links_wildcards.php.diff (text/diff, 2.4 KB)
Index: lib/Links/sql.php
===================================================================
RCS file: /repository/horde/lib/Links/sql.php,v
retrieving revision 1.8
diff -u -r1.8 sql.php
--- lib/Links/sql.php	19 Jun 2003 18:47:46 -0000	1.8
+++ lib/Links/sql.php	18 Jul 2003 01:54:03 -0000
@@ -107,13 +107,22 @@
     {
         $this->_connect();
 
-        $query = sprintf('DELETE FROM %s WHERE link_type = %s AND link_from_provider = %s AND link_from_parameter = %s AND link_to_provider = %s AND link_to_parameter = %s',
+        /* Treat '*' in $from_parameters and $to_parameters as wildcard 
+           so we can delete multiple links at once. */
+        $from_param_txt = '';
+        $to_param_txt = '';
+        if ($from_parameters != '*') {
+            $from_param_txt = ' AND link_from_parameter = ' . $this->_db->quote(serialize($from_parameters));
+        }
+        if ($to_parameters != '*') {
+            $to_param_txt = ' AND link_to_parameter = ' . $this->_db->quote(serialize($to_parameters));
+        }
+
+        $query = sprintf('DELETE FROM %s WHERE link_type = %s AND link_from_provider = %s ' . $from_param_txt . ' AND link_to_provider = %s ' . $to_param_txt,
             $this->_params['table'],
             $this->_db->quote($link_type),
             $this->_db->quote($from_application),
-            $this->_db->quote(serialize($from_parameters)),
-            $this->_db->quote($to_application),
-            $this->_db->quote(serialize($to_parameters))
+            $this->_db->quote($to_application)
         );
 
         $result = $this->_db->query($query);
Index: whups/admin.php
===================================================================
RCS file: /repository/whups/admin.php,v
retrieving revision 1.44
diff -u -r1.44 admin.php
--- whups/admin.php	17 Jul 2003 16:38:43 -0000	1.44
+++ whups/admin.php	18 Jul 2003 01:54:04 -0000
@@ -306,7 +306,7 @@
                      $to_application = 'contacts';
                      $link_type = 'client';
                      /* Delete all current client links for this module. */
-                     $delete_status = $links->deleteLink($from_application, $from_parameters, $to_application, '', $link_type);
+                     $delete_status = $links->deleteLink($from_application, $from_parameters, $to_application, '*', $link_type);
 
                      /* Now add in all the new client links. */
                      foreach ($clients as $client) {
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.