[dev] Ingo: activation toggling...

Marc Jauvin marc at register4less.com
Wed Jul 2 10:54:50 PDT 2003


Here is a patch that does the following:

- fix a bug in ingo/lib/Script/sieve.php for the forward section
- add the vacation/forward services to Ingo API (ingo/lib/api.php)
- allow the blacklist/whitelist/vacation/forward to be enabled/disabled
- move the "enable" for vacation OUTSIDE the FORM (put it in front of the
vacation action in the main filters.php screen)


Marc Jauvin <marc at register4less.com> wrote:

> Would it make sense to also add a "enable/disable" icon in front of the
> blacklist/whitelist/vacation items?
>
> The vacation has a "enable" checkbox WITHIN the edit window that could be
> removed in favor of the above.
>
> What do you guys think?
>
> --
> Marc Jauvin
> 450-441-5458
> http://register4less.com
>
> --
> Horde developers mailing list
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: dev-unsubscribe at lists.horde.org
>
>


--
Marc Jauvin
450-441-5458
http://register4less.com
-------------- next part --------------
Index: filters.php
===================================================================
RCS file: /repository/ingo/filters.php,v
retrieving revision 1.33
diff -u -r1.33 filters.php
--- filters.php	1 Jul 2003 06:39:33 -0000	1.33
+++ filters.php	2 Jul 2003 17:46:18 -0000
@@ -184,18 +184,20 @@
         case INGO_STORAGE_ACTION_FORWARD:
             $editurl = Horde::applicationUrl('forward.php');
             $filter_img = Horde::img('forward.gif');
+            break;
 
         default:
             $editurl = Horde::addParameter($rule_url, 'edit', $rule_number);
             $editurl = Horde::addParameter($editurl, 'actionID', 'rule_edit');
             $delurl  = Horde::addParameter($url, 'actionID', 'rule_delete');
             $copyurl = Horde::addParameter($url, 'actionID', 'rule_copy');
-            if (empty($filter['disable'])) {
-                $disableurl = Horde::addParameter($url, 'actionID', 'rule_disable');
-            } else {
-                $enableurl = Horde::addParameter($url, 'actionID', 'rule_enable');
-            }
             break;
+        }
+
+        if (empty($filter['disable'])) {
+            $disableurl = Horde::addParameter($url, 'actionID', 'rule_disable');
+        } else {
+            $enableurl = Horde::addParameter($url, 'actionID', 'rule_enable');
         }
 
         require INGO_TEMPLATES . '/filters/filter.inc';
Index: vacation.php
===================================================================
RCS file: /repository/ingo/vacation.php,v
retrieving revision 1.15
diff -u -r1.15 vacation.php
--- vacation.php	17 Jun 2003 22:18:11 -0000	1.15
+++ vacation.php	2 Jul 2003 17:46:18 -0000
@@ -22,7 +22,6 @@
 switch ($actionID) {
 case 'rule_update':
     $vacation = array();
-    $vacation['active'] = Horde::getFormData('active') == '1';
     $vacation['subject'] = Horde::getFormData('subject');
     $vacation['days'] = Horde::getFormData('days', '7');
     $vacation['ignorelist'] = Horde::getFormData('ignorelist') == '1';
Index: lib/api.php
===================================================================
RCS file: /repository/ingo/lib/api.php,v
retrieving revision 1.13
diff -u -r1.13 api.php
--- lib/api.php	24 Jun 2003 19:46:17 -0000	1.13
+++ lib/api.php	2 Jul 2003 17:46:18 -0000
@@ -43,6 +43,24 @@
     'link' => '%application%/filters.php'
 );
 
+$_services['applyVacation'] = array(
+    'args' => array('params'),
+    'type' => 'boolean'
+);
+
+$_services['showVacation'] = array(
+    'link' => '%application%/vacation.php'
+);
+
+$_services['applyForward'] = array(
+    'args' => array('params'),
+    'type' => 'boolean'
+);
+
+$_services['showForward'] = array(
+    'link' => '%application%/forward.php'
+);
+
 function _ingo_blacklistFrom($addresses)
 {
     require_once dirname(__FILE__) . '/../lib/base.php';
Index: lib/Script/sieve.php
===================================================================
RCS file: /repository/ingo/lib/Script/sieve.php,v
retrieving revision 1.34
diff -u -r1.34 sieve.php
--- lib/Script/sieve.php	1 Jul 2003 15:21:04 -0000	1.34
+++ lib/Script/sieve.php	2 Jul 2003 17:46:18 -0000
@@ -120,7 +120,7 @@
             if (!empty($forward['a'])){
                 $action = $addrs = array();
 
-                $forward_addr = preg_split('(\n|\n|\r)', $forward['a']);
+                $forward_addr = $forward['a'];
                 foreach ($forward_addr as $addr) {
                     $addr = trim($addr);
                     if (!empty($addr)) {
@@ -230,61 +230,59 @@
         if ($this->_validRule(INGO_STORAGE_ACTION_VACATION)) {
             $vacation = $ingo_storage->retrieve('vacation');
             $vacationBlocks = array();
-            if (!empty($vacation['active'])) {
-                $action = array();
-                $vals = array('subject' => $vacation['subject'],
-                              'days' => $vacation['days'],
-                              'addresses' => $vacation['addresses'],
-                              'reason' => $vacation['reason']);
-
-                $action[] = &new Sieve_Action_Vacation($vals);
-
-                $listHeaders = array();
-                $listHeaders[] = 'List-Id';
-                $listHeaders[] = 'List-Post';
-                $listHeaders[] = 'List-Subscribe';
-                $listHeaders[] = 'List-Unsubscribe';
-                $listHeaders[] = 'List-Archive';
-                $listHeaders[] = 'List-Help';
-                $listHeaders[] = 'X-List-Name';
-
-                $tests = array();
-                if ($vacation['ignorelist']) {
-                    $tmp = &new Sieve_Test_Exists(array('headers' => implode("\n", $listHeaders)));
-                    $tests[] = &new Sieve_Test_Not($tmp);
-                    $vals = array('headers' => 'Precedence',
-                                  'match-type' => ':is',
-                                  'strings' => 'list,bulk',
-                                  'comparator' => 'i;ascii-casemap');
-                    $tmp = &new Sieve_Test_Header($vals);
-                    $tests[] = new Sieve_Test_Not($tmp);
-                }
-
-                $excludes = preg_split('(\n|\n|\r)', $vacation['excludes']);
-                $addrs = array();
-                foreach ($excludes as $addr) {
-                    $addr = trim($addr);
-                    if (!empty($addr)) {
-                        $addrs[] = $addr;
-                    }
-                }
+            $action = array();
+            $vals = array('subject' => $vacation['subject'],
+                          'days' => $vacation['days'],
+                          'addresses' => $vacation['addresses'],
+                          'reason' => $vacation['reason']);
+
+            $action[] = &new Sieve_Action_Vacation($vals);
+
+            $listHeaders = array();
+            $listHeaders[] = 'List-Id';
+            $listHeaders[] = 'List-Post';
+            $listHeaders[] = 'List-Subscribe';
+            $listHeaders[] = 'List-Unsubscribe';
+            $listHeaders[] = 'List-Archive';
+            $listHeaders[] = 'List-Help';
+            $listHeaders[] = 'X-List-Name';
+
+            $tests = array();
+            if ($vacation['ignorelist']) {
+                $tmp = &new Sieve_Test_Exists(array('headers' => implode("\n", $listHeaders)));
+                $tests[] = &new Sieve_Test_Not($tmp);
+                $vals = array('headers' => 'Precedence',
+                              'match-type' => ':is',
+                              'strings' => 'list,bulk',
+                              'comparator' => 'i;ascii-casemap');
+                $tmp = &new Sieve_Test_Header($vals);
+                $tests[] = new Sieve_Test_Not($tmp);
+            }
 
-                if (count($addrs) > 0) {
-                    $tmp = &new Sieve_Test_Address(array('headers' => "From\nSender\nResent-From", 'addresses' => implode("\n", $addrs)));
-                    $tests[] = &new Sieve_Test_Not($tmp);
+            $excludes = preg_split('(\n|\n|\r)', $vacation['excludes']);
+            $addrs = array();
+            foreach ($excludes as $addr) {
+                $addr = trim($addr);
+                if (!empty($addr)) {
+                    $addrs[] = $addr;
                 }
+            }
 
-                $comment = &new Sieve_Comment(_("Vacation Message"));
-                $vacationBlocks[] = $comment;
+            if (count($addrs) > 0) {
+                $tmp = &new Sieve_Test_Address(array('headers' => "From\nSender\nResent-From", 'addresses' => implode("\n", $addrs)));
+                $tests[] = &new Sieve_Test_Not($tmp);
+            }
 
-                if (count($tests) > 0) {
-                    $test = &new Sieve_Test_Allof($tests);
-                    $if = &new Sieve_If($test);
-                    $if->setActions($action);
-                    $vacationBlocks[] = $if;
-                } else {
-                    $vacationBlocks[] = $action[0];
-                }
+            $comment = &new Sieve_Comment(_("Vacation Message"));
+            $vacationBlocks[] = $comment;
+
+            if (count($tests) > 0) {
+                $test = &new Sieve_Test_Allof($tests);
+                $if = &new Sieve_If($test);
+                $if->setActions($action);
+                $vacationBlocks[] = $if;
+            } else {
+                $vacationBlocks[] = $action[0];
             }
         }
 
Index: templates/vacation/vacation.inc
===================================================================
RCS file: /repository/ingo/templates/vacation/vacation.inc,v
retrieving revision 1.9
diff -u -r1.9 vacation.inc
--- templates/vacation/vacation.inc	27 Jun 2003 06:52:59 -0000	1.9
+++ templates/vacation/vacation.inc	2 Jul 2003 17:46:18 -0000
@@ -13,12 +13,6 @@
       <table width="100%" cellspacing="0" cellpadding="0" class='item'>
         <tr>
           <td>
-            <input type="checkbox" name="active" value="1" <?php echo (array_key_exists('active', $vacation) && $vacation['active'] == '1') ? 'checked' : '' ?> />
-            <?php echo _("Enable Vacation messages") ?>
-          </td>
-        </tr>
-        <tr>
-          <td>
             <?php echo _("My email addresses") ?>:
             <br/>
             <textarea name="addresses" rows="5" cols="40"><?php echo $vacation['addresses'] ?></textarea>


More information about the dev mailing list