[sork] sqlprocmail forwards driver (1)

Carlos Alberto Barcenilla barce at dearriba.com
Mon Apr 7 23:14:30 PDT 2003


Hi

  I wrote a forwards driver which I named 'sqlprocmail'. Having no 
chance to use the FTP-based forwards driver I chose to write my own driver.
  sqlprocmail stores the forwarding  information in a database table, 
then, an external script (actually written in Perl, attached to thie 
message) takes that data from the database and generates .procmailrc 
files in each user's home directory.

   Though it's a beta module it's working fine at my installation. If 
you like you can include it in the forwards CVS.

   In addition I fixed a few bugs in the forwards code, spanish 
translation and I'm proposing a little change in the drivers (making 
optional the password input box).

    I hear your comments!

Carlos

Driver sqlprocmail.php
This driver is based on sql.php, t

*File: forwards/conf/conf.php

*$conf['server']['driver'] = 'sqlprocmail';*

*/*

PostgreSQL statement to create the SQL table

CREATE TABLE "horde_forwards" (
        "username" character varying(80) NOT NULL,
        "forwardto" character varying(80),
        "keeplocal" character varying(1),
        "forward" character varying(1),
        "newentry" character varying(1),
        Constraint "horde_forwards_pkey" Primary Key ("username")
);

Fields:
username: username at realm
forwardto: email address where messages should be forwarded to.
keeplocal: 'y' or 'n'. Should we keep a local copy of messages?
forward: 'y' of 'n'. Should we forward this user's messages?
newentry: 'y' or 'n'. Is this a new or recently modified entry?

*/

$conf['server']['params'] = array();
$conf['server']['params']['phptype'] = 'pgsql';
$conf['server']['params']['hostspec'] = 'sqlhost.frlp.utn.edu.ar';
$conf['server']['params']['username'] = 'horde';
$conf['server']['params']['password'] = 'horde-password';
$conf['server']['params']['database'] = 'horde';
$conf['server']['params']['port'] = '5432';
$conf['server']['params']['table'] = 'horde_forwards';
$conf['server']['params']['forward_col'] = 'forward';
$conf['server']['params']['forwardto_col'] = 'forwardto';
$conf['server']['params']['username_col'] = 'username';
$conf['server']['params']['keeplocal_col'] = 'keeplocal';
$conf['server']['params']['newentry_col'] = 'newentry';



*File: forwards/templates/main/main.inc*
Changes:
    - fixed problem displaying the "keeplocal" checkbox.
    - added support for the proposed noPassword field for the class 
Forwards_Driver (this driver does not need to enter the password, it 
relies in Auth::getAuth, if the noPassword field is true the password 
input box is not showed and the password is not checked).

diff -ru cvs/forwards/templates/main/main.inc 
forwards/templates/main/main.inc
--- cvs/forwards/templates/main/main.inc        2003-01-20 
02:23:11.000000000 -0
300
+++ forwards/templates/main/main.inc    2003-04-04 21:29:09.000000000 -0300
@@ -39,7 +39,7 @@
   <?php echo _("Set/install a forward to:") ?> &nbsp;
   <input type="text" name="where" value="<?php echo $current_target ?>" 
size="6
3" maxlength="150">
   <blockquote>
-    <input type="checkbox" name="metoo">
+    <input type="checkbox" name="metoo" <?php echo $current_keeplocal ? 
'checke
d' : '' ?> >
     <?php echo _("Keep a copy in your mailbox (default <b>no</b>)") ?>
   </blockquote>

@@ -47,12 +47,14 @@
   <?php echo _("Unset/remove a forward") ?>

   <br /><br />
+<?php if (!$driver->noPassword) { ?>
   <?php echo _("For your protection and safety, you must identify 
yourself with
 your login password to verify this change.") ?> &nbsp;
   <?php echo _("Then submit the form so that your forward can be 
updated.") ?>
   <br />
   <input type="hidden" name="userid" value="<?php echo Auth::getAuth() ?>">
   <?php echo _("Your password:") ?> &nbsp;
   <input type="password" name="oldpassword" size="16" maxlength="32"> 
&nbsp;
+<?php } // if ?>
   <input class="button" type="submit" name="submit" value="<?php echo 
_("Submit
") ?>" onclick="return submit_form();">
   </form>
 </td>

*File: forwards/main.php forwards/main.php*
Changes:
    - added support for the proposed noPassword field for the class 
Forwards_Driver (this driver does not need to enter the password, it 
relies in Auth::getAuth, if the noPassword field is true the password 
input box is not showed and the password is not checked).

diff -ru cvs/forwards/main.php forwards/main.php
--- cvs/forwards/main.php       2003-01-20 02:30:42.000000000 -0300
+++ forwards/main.php   2003-04-05 00:41:13.000000000 -0300
@@ -40,7 +40,7 @@
         $forwardmode = "error";
     }
     $oldpassword=Horde::getFormData('oldpassword', false);
-    if (!$oldpassword) {
+    if ((!$driver->noPassword) && !$oldpassword) {
         Horde::raiseMessage(_("You must give your 
password"),HORDE_WARNING);
         $forwardmode = "error";
     }

*File: forwards/po/es_ES.po*
Changes:
    - fixed translation errors.

--- cvs/forwards/po/es_ES.po    2002-09-10 19:33:53.000000000 -0300
+++ forwards/po/es_ES.po        2003-04-04 22:39:23.000000000 -0300
@@ -105,8 +105,8 @@
 msgid "Set the language that menu items, explanations, and help are in."
 msgstr "Establece el lenguaje en que están los items del menú, las 
explicacione
s y la ayuda."

-msgid "Set/install a forward"
-msgstr "Establece/remueve un reenvío de correo"
+msgid "Set/install a forward to:"
+msgstr "Establece/instala un reenvío de correo a:"

 msgid "Some of Forwards module's configuration files are missing:"
 msgstr "Algunos de los archivos de configuración del módulo de reenvío 
no se en
cuentran:"
@@ -154,7 +154,7 @@
 "opciones para todos los guiones de reenvío."

 msgid "Unset/remove a forward"
-msgstr "Establecer/remover un reenvío de correo"
+msgstr "Desactivar/remover un reenvío de correo"

 msgid "Warning"
 msgstr "Advertencia"




More information about the sork mailing list