[sork] problem with forwards SQL driver

Ilya mail at krel.org
Thu Jan 1 16:25:10 PST 2004


attached are diffs for vacation and forwards to enable user at realm functionality
back.

On Thu, Jan 01, 2004 at 03:47:53PM -0500, Ilya wrote:
> here you go:
> forwards/lib/Driver
> diff sql.php.old sql.php
> 
> 117c117,118
> <         if ($keeplocal === 'ON') {
> ---
> >         if ($keeplocal === 'on') {
> >
> 
> On Thu, Jan 01, 2004 at 02:25:15PM +0100, Jan Schneider wrote:
> > Zitat von Ilya <mail at krel.org>:
> > 
> > > The same problem with realm is with forwards, also "keeplocal" feature is
> > > not working.
> > > Its being checked against "ON" but its actualy "on"
> > 
> > Can you be more specific? The only place I found where the value is checked,
> > it checks for 'on'.
> > 
> > Jan.
> > 
> > --
> > http://www.horde.org - The Horde Project
> > http://www.ammma.de - Neue Wege des Lernens
> > http://www.tip4all.de - Deine private Tippgemeinschaft
> > -- 
> > Sork mailing list
> > Frequently Asked Questions: http://horde.org/faq/
> > To unsubscribe, mail: sork-unsubscribe at lists.horde.org
> -- 
> Sork mailing list
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: sork-unsubscribe at lists.horde.org
-------------- next part --------------
--- sql.php.old	Thu Jan  1 18:26:40 2004
+++ sql.php	Thu Jan  1 19:07:25 2004
@@ -54,16 +54,19 @@
             $mymessage = $message;
         }
 
+        // Build username.
+        $myuser = $this->_buildUsername($user, $realm);
+
         /* Build the SQL query. */
         $query = 'UPDATE ' . $this->params['table'];
         $query .= ' SET ' . $this->params['vacation'] . ' = ' . $this->_db->quote('y');
-        $query .= ' WHERE ' . $this->params['user_col'] . ' = ' . $this->_db->quote($user);
+        $query .= ' WHERE ' . $this->params['user_col'] . ' = ' . $this->_db->quote($myuser);
         $query .= ' AND ' . $this->params['pass_col'] . ' = ' . $this->_db->quote(md5($password));
 
         $query1 = 'UPDATE ' . $this->params['table'];
         $query1 .= ' SET ' . $this->params['message'] . ' = ' . $this->_db->quote($mymessage);
         $query1 .= ' ,  ' . $this->params['subject'] . ' = ' . $this->_db->quote($mysubject);
-        $query1 .= ' WHERE ' . $this->params['user_col'] . ' = ' . $this->_db->quote($user);
+        $query1 .= ' WHERE ' . $this->params['user_col'] . ' = ' . $this->_db->quote($myuser);
         $query1 .= ' AND ' . $this->params['pass_col'] . ' = ' . $this->_db->quote(md5($password));
 
         /* Execute the query. */
@@ -100,11 +103,14 @@
         /* _connect() will die with Horde::fatal() upon failure. */
         $this->_connect();
 
+        // Build username.
+        $myuser = $this->_buildUsername($user, $realm);
+
         /* Build the SQL query. */
         $query = 'UPDATE ' . $this->params['table'];
         $query .= ' SET ' . $this->params['vacation'] . ' = ' . $this->_db->quote('n');
         $query .= ' ,  ' . $this->params['message'] . ' = ' . $this->_db->quote('');
-        $query .= ' WHERE ' . $this->params['user_col'] . ' = ' . $this->_db->quote($user);
+        $query .= ' WHERE ' . $this->params['user_col'] . ' = ' . $this->_db->quote($myuser);
         $query .= ' AND ' . $this->params['pass_col'] . ' = ' . $this->_db->quote(md5($password));
 
         /* Execute the query. */
@@ -140,10 +146,13 @@
         /* _connect() will die with Horde::fatal() upon failure. */
         $this->_connect();
 
+        // Build username.
+        $myuser = $this->_buildUsername($user, $realm);
+
         /* Build the SQL query. */
         $query = 'SELECT ' . $this->params['vacation'] . ' AS vacation, ' . $this->params['message'] . ' AS message';
         $query .= ' FROM ' . $this->params['table'];
-        $query .= ' WHERE ' . $this->params['user_col'] . ' = ' . $this->_db->quote($user);
+        $query .= ' WHERE ' . $this->params['user_col'] . ' = ' . $this->_db->quote($myuser);
         $query .= ' AND password = ' . $this->_db->quote(md5($password));
 
         /* Execute the query. */
@@ -210,4 +219,18 @@
         return true;
     }
 
+    /**
+     * Builds a username based on presense of realm
+     * @return string user at realm or user
+     */
+     function _buildUsername($user, $realm)
+     {
+        if ($realm === 'default' ||
+            $realm === '') {
+            return $user;
+        } else {
+            return $user . "@" . $realm;
+        }
+     }
+         
 }
-------------- next part --------------
--- sql.php.old	Thu Jan  1 19:12:05 2004
+++ sql.php	Thu Jan  1 19:17:48 2004
@@ -106,15 +106,18 @@
         /* _connect() will die with Horde::fatal() upon failure. */
         $this->_connect();
         $local_target=$user . '@' . $realm;
+        
+        // Build username.
+        $myuser = $this->_buildUsername($user, $realm);
 
         /* Build the SQL query. */
         $query = 'UPDATE ' . $this->_params['table'];
         $query .= ' SET ' . $this->_params['forward'] . ' = ' . $this->_db->quote("y");
-        $query .= ' WHERE ' . $this->_params['user_col'] . ' = ' . $this->_db->quote($user);
+        $query .= ' WHERE ' . $this->_params['user_col'] . ' = ' . $this->_db->quote($myuser);
         $query .= ' AND ' . $this->_params['pass_col'] . ' = ' . $this->_db->quote(md5($password));
 
         $query1 = 'UPDATE ' . $this->_params['table'];
-        if ($keeplocal === 'ON') {
+        if ($keeplocal === 'on') {
             if(!strstr($target,$local_target)) {
                 $query1 .= ' SET ' . $this->_params['altemail'] . ' = ' .
                     $this->_db->quote($target . ',' . $local_target);
@@ -122,7 +125,7 @@
         } else {
             $query1 .= ' SET ' . $this->_params['altemail'] . ' = ' . $this->_db->quote($target);
         }
-        $query1 .= ' WHERE ' . $this->_params['user_col'] . ' = ' . $this->_db->quote($user);
+        $query1 .= ' WHERE ' . $this->_params['user_col'] . ' = ' . $this->_db->quote($myuser);
         $query1 .= ' and ' . $this->_params['pass_col'] . ' = ' . $this->_db->quote(md5($password));
 
         /* Execute the query. */
@@ -160,11 +163,14 @@
         /* _connect() will die with Horde::fatal() upon failure. */
         $this->_connect();
 
+        // Build username.
+        $myuser = $this->_buildUsername($user, $realm);
+
         /* Build the SQL query. */
         $query = 'UPDATE ' . $this->_params['table'];
         $query .= ' SET ' . $this->_params['forward'] . ' = ' . $this->_db->quote("n");
         $query .= ' ,  ' . $this->_params['altemail'] . ' = ' . $this->_db->quote("");
-        $query .= ' WHERE ' . $this->_params['user_col'] . ' = ' . $this->_db->quote($user);
+        $query .= ' WHERE ' . $this->_params['user_col'] . ' = ' . $this->_db->quote($myuser);
         $query .= ' and ' . $this->_params['pass_col'] . ' = ' . $this->_db->quote(md5($password));
 
         /* Execute the query. */
@@ -197,8 +203,11 @@
      */
     function isEnabledForwarding($user, $realm, $password)
     {
+        // Build username.
+        $myuser = $this->_buildUsername($user, $realm);
+
         // get current details
-        $current_details = $this->_getUserDetails($user, $realm, $password);
+        $current_details = $this->_getUserDetails($myuser, $realm, $password);
         if ($current_details === false) {
             //$this->_err_str = _("Not able to retrieve current details.");
             return false;
@@ -225,8 +234,11 @@
      */
     function isKeepLocal($user, $realm, $password)
     {
+        // Build username.
+        $myuser = $this->_buildUsername($user, $realm);
+
         // get current details
-        $current_details = $this->_getUserDetails($user, $realm, $password);
+        $current_details = $this->_getUserDetails($myuser, $realm, $password);
         if ($current_details === false) {
             //$this->_err_str = _("Not able to retrieve current details.");
             return false;
@@ -272,10 +284,13 @@
         /* _connect() will die with Horde::fatal() upon failure. */
         $this->_connect();
 
+        // Build username.
+        $myuser = $this->_buildUsername($user, $realm);
+
         /* Build the SQL query. */
         $query = 'SELECT * FROM ' . $this->_params['table'];
-        $query .= ' WHERE ' . $this->_params['user_col'] . ' = ' . $this->_db->quote($user);
-       $query .= ' AND password = ' . $this->_db->quote(md5($password));
+        $query .= ' WHERE ' . $this->_params['user_col'] . ' = ' . $this->_db->quote($myuser);
+        $query .= ' AND password = ' . $this->_db->quote(md5($password));
 
         /* Execute the query. */
         $result = $this->_db->query($query);
@@ -296,4 +311,17 @@
         return false;
     }
 
+    /**
+     * Builds a username based on presense of realm
+     * @return string user at realm or user
+     */
+     function _buildUsername($user, $realm)
+     {
+        if ($realm === 'default' ||
+            $realm === '') {
+            return $user;
+        } else {
+            return $user . "@" . $realm;
+        }
+     }
 }


More information about the sork mailing list