[ingo] rule-overview enhancement - how to create patch?

Oliver Kuhl okuhl at netcologne.de
Fri Jun 20 11:21:33 PDT 2003


Hi!

> | I want to send a patch. But how do I create it? I tried "cvs diff", etc.
> | Can anyone send me an exact command?
>
> diff -u alteredfile originalfile
Ok, thank you. I did an "cvs -u > ingo.patch" and deleted the lines which were
wrong. Now I hope it works. So here comes the patch!

What does the patch?
- show a short summary of the rules for each filter in the filter-list
- provide another checkbox in the prefs to switch it on and off

Right now flags used within a filter are not shown. Maybe I'll work on it later.

Maybe you'll like it. ;-)

Gruss,
  Ollie.
-------------- next part --------------
--- filters.php	17 Jun 2003 22:18:10 -0000	1.25
+++ filters.php	20 Jun 2003 18:12:58 -0000
@@ -124,6 +124,36 @@
     $i = 0;
     $rule_count = array_sum(array_map(create_function('$a', "return (in_array(\$a['action'], \$_SESSION['ingo']['script_categories'])) ? 1 : 0;"), $rules));
 
+    $actions = array(
+    INGO_STORAGE_ACTION_KEEP => array(
+        'label' => _("Deliver this message into my INBOX"),
+        'type' => false,
+        'flags' => true
+    ),
+    INGO_STORAGE_ACTION_MOVE => array(
+        'label' => _("Deliver to this mailbox"),
+        'type' => 'folder',
+        'flags' => true
+    ),
+    INGO_STORAGE_ACTION_DISCARD => array(
+        'label' => _("Discard this message"),
+        'type' => false
+    ),
+    INGO_STORAGE_ACTION_REDIRECT => array(
+        'label' => _("Redirect this message to"),
+        'type' => 'text'
+    ),
+    INGO_STORAGE_ACTION_REDIRECTKEEP => array(
+        'label' => _("Deliver into my INBOX and Redirect to"),
+        'type' => 'text',
+        'flags' => true
+    ),
+    INGO_STORAGE_ACTION_REJECT => array(
+        'label' => _("Reject this message with reason"),
+        'type' => 'text'
+    )
+    );
+
     foreach ($rules as $rule_number => $filter) {
         /* Skip non-display categories. */
         if (!in_array($filter['action'], $_SESSION['ingo']['script_categories'])) {
@@ -135,6 +165,23 @@
         $copyurl = Horde::addParameter($url, 'actionID', 'rule_copy');
         $upurl   = Horde::addParameter($url, 'actionID', 'action_up');
         $downurl = Horde::addParameter($url, 'actionID', 'action_down');
+
+        $filterdescr = "";
+        foreach($filter['conditions'] as $condid => $cond) {
+            $filterdescr .= sprintf("- %s %s \"%s\"", _($cond['field']), _($cond['match']), $cond['value']);
+            $filterdescr .= $cond['case'] ? " ["._("Case Sensitive")."]" : "";
+            if ( $condid < sizeof($filter['conditions'])-1 ) {
+                $filterdescr .= sprintf(" <i>%s</i> <br>", $filter['combine'] == INGO_STORAGE_COMBINE_ALL ? _("and"):_("or") );
+            } else {
+                $filterdescr .= "<br>";
+            }
+        }
+
+        $filterdescr .= $actions[$filter['action']]['label'];
+        $filterdescr .= $filter['action-value'] ? ": ".$filter['action-value'] : "";
+        $filterdescr .= $filter['stop'] ? " [stop]" : "";
+        $filterdescr .= "<br><br>";
+
         $i++;
         switch ($filter['action']) {
         case INGO_STORAGE_ACTION_BLACKLIST:
--- templates/filters/filter.inc	5 Jun 2003 02:54:46 -0000	1.8
+++ templates/filters/filter.inc	20 Jun 2003 18:12:58 -0000
@@ -2,13 +2,16 @@
   <td class="item<?php echo $i % 2 ?>">
     <table width="100%" cellpadding="0" cellspacing="0">
       <tr>
-        <td width="70px" align="left">
+        <td width="70px" align="left" valign="top">
           <?php echo Horde::link($editurl, sprintf(_("Edit %s"), $filter['name'])) ?><?php echo Horde::img('edit.gif', sprintf(_("Edit %s"), $filter['name'])) ?></a>
           <?php echo Horde::link($delurl, sprintf(_("Delete %s"), $filter['name'])) ?><?php echo Horde::img('delete.gif', sprintf(_("Delete %s"), $filter['name'])) ?></a>
           <?php echo Horde::link($copyurl, sprintf(_("Copy %s"), $filter['name'])) ?><?php echo Horde::img('copy.gif', sprintf(_("Copy %s"), $filter['name'])) ?></a>
         </td>
         <td>
-          <?php echo Horde::link($editurl, sprintf(_("Edit %s"), $filter['name'])) ?><?php echo $filter['name'] ?></a>
+          <b><?php echo Horde::link($editurl, sprintf(_("Edit %s"), $filter['name'])) ?><?php echo $filter['name'] ?></b></a>
+<?php if ($prefs->getValue('show_rulesummary')): ?>
+             <?php echo("<br>".$filterdescr); ?>
+<?php endif; ?>
         </td>
         <td width="50px" align="left">
 <?php if ($i > 1): ?>


More information about the ingo mailing list