// the below entries.
// Filter rules.
+require_once dirname(__FILE__) . '/../lib/Storage.php';
$_prefs['rules'] = array(
'value' => 'a:5:{i:0;a:2:{s:4:"name";s:9:"Whitelist";s:6:"action";i:' . Ingo_Storage::ACTION_WHITELIST . ';}i:1;a:3:{s:4:"name";s:8:"Vacation";s:6:"action";i:' . Ingo_Storage::ACTION_VACATION . ';s:7:"disable";b:1;}i:2;a:2:{s:4:"name";s:9:"Blacklist";s:6:"action";i:' . Ingo_Storage::ACTION_BLACKLIST . ';}i:3;a:3:{s:4:"name";s:11:"Spam Filter";s:6:"action";i:' . Ingo_Storage::ACTION_SPAM . ';s:7:"disable";b:1;}i:4;a:2:{s:4:"name";s:7:"Forward";s:6:"action";i:' . Ingo_Storage::ACTION_FORWARD . ';}}',
'locked' => false,
*/
require_once dirname(__FILE__) . '/lib/base.php';
+require_once 'Horde/Help.php';
+require_once 'Horde/Variables.php';
/* Redirect if forward is not available. */
if (!in_array(Ingo_Storage::ACTION_FORWARD, $_SESSION['ingo']['script_categories'])) {
$fwd_rule = $filters->getRule($fwd_id);
/* Load libraries. */
-require_once 'Horde/Variables.php';
$vars = &Variables::getDefaultVariables();
if ($vars->get('submitbutton') == _("Return to Rules List")) {
header('Location: ' . Horde::applicationUrl('filters.php', true));
is_readable(INGO_BASE . '/config/fields.php'));
if (!$ingo_configured) {
- require INGO_BASE . '/../lib/Test.php';
+ if (!defined('HORDE_BASE')) {
+ /* Temporary fix - if horde does not live directly under the imp
+ * directory, the HORDE_BASE constant should be defined in
+ * imp/lib/base.local.php. */
+ if (file_exists(INGO_BASE . '/lib/base.local.php')) {
+ include INGO_BASE . '/lib/base.local.php';
+ } else {
+ define('HORDE_BASE', INGO_BASE . '/..');
+ }
+ }
+
+ require HORDE_BASE . '/lib/Test.php';
Horde_Test::configFilesMissing('Ingo', INGO_BASE,
array('conf.php', 'prefs.php', 'backends.php'),
array('fields.php' => 'This file defines types of credentials that a backend might request.'));
*
* @return boolean True if the address is not empty.
*/
- static protected function _filterEmptyAddress($address)
+ static public function filterEmptyAddress($address)
{
$address = trim($address);
- return !empty($address) && $address != '@';
+ return !empty($address) && ($address != '@');
}
/**
if (!is_a($blacklist_url = $GLOBALS['registry']->link('mail/showBlacklist'), 'PEAR_Error')) {
$menu->add(Horde::url($blacklist_url), _("_Blacklist"), 'blacklist.png');
}
- if (in_array(INGO_STORAGE_ACTION_VACATION, $_SESSION['ingo']['script_categories'])) {
+ if (in_array(Ingo_Storage::ACTION_VACATION, $_SESSION['ingo']['script_categories'])) {
$menu->add(Horde::applicationUrl('vacation.php'), _("_Vacation"), 'vacation.png');
}
- if (in_array(INGO_STORAGE_ACTION_FORWARD, $_SESSION['ingo']['script_categories'])) {
+ if (in_array(Ingo_Storage::ACTION_FORWARD, $_SESSION['ingo']['script_categories'])) {
$menu->add(Horde::applicationUrl('forward.php'), _("_Forward"), 'forward.png');
}
- if (in_array(INGO_STORAGE_ACTION_SPAM, $_SESSION['ingo']['script_categories'])) {
+ if (in_array(Ingo_Storage::ACTION_SPAM, $_SESSION['ingo']['script_categories'])) {
$menu->add(Horde::applicationUrl('spam.php'), _("S_pam"), 'spam.png');
}
if ($_SESSION['ingo']['script_generate'] &&
/* Disable categories as specified in preferences */
$disabled = array();
if ($prefs->isLocked('blacklist')) {
- $disabled[] = INGO_STORAGE_ACTION_BLACKLIST;
+ $disabled[] = Ingo_Storage::ACTION_BLACKLIST;
}
if ($prefs->isLocked('whitelist')) {
- $disabled[] = INGO_STORAGE_ACTION_WHITELIST;
+ $disabled[] = Ingo_Storage::ACTION_WHITELIST;
}
if ($prefs->isLocked('vacation')) {
- $disabled[] = INGO_STORAGE_ACTION_VACATION;
+ $disabled[] = Ingo_Storage::ACTION_VACATION;
}
if ($prefs->isLocked('forward')) {
- $disabled[] = INGO_STORAGE_ACTION_FORWARD;
+ $disabled[] = Ingo_Storage::ACTION_FORWARD;
}
if ($prefs->isLocked('spam')) {
- $disabled[] = INGO_STORAGE_ACTION_SPAM;
+ $disabled[] = Ingo_Storage::ACTION_SPAM;
}
/* Set the list of categories this driver supports. */
/**
* Destructor.
*/
- protected function __destruct()
+ public function __destruct()
{
$cache = &Horde_SessionObjects::singleton();
* Retrieves the specified data.
*
* @param integer $field The field name of the desired data
- * (INGO_STORAGE_ACTION_* constants).
+ * (ACTION_* constants).
* @param boolean $cache Use the cached object?
* @param boolean $readonly Whether to disable any write operations.
*
/**
* Returns information on a given action constant.
*
- * @param integer $action The INGO_STORAGE_ACTION_* value.
+ * @param integer $action The ACTION_* value.
*
* @return stdClass Object with the following values:
* <pre>
public function getBlacklist()
{
- return array_filter($this->_addr, array('Ingo', '_filterEmptyAddress'));
+ return empty($this->_addr)
+ ? array()
+ : array_filter($this->_addr, array('Ingo', 'filterEmptyAddress'));
}
public function getBlacklistFolder()
public function setWhitelist($data, $sort = true)
{
$addr = &$this->_addressList($data, $sort);
- $addr = array_filter($addr, array('Ingo', '_filterEmptyAddress'));
+ $addr = array_filter($addr, array('Ingo', 'filterEmptyAddress'));
if (!empty($GLOBALS['conf']['storage']['maxwhitelist'])) {
$addr_count = count($addr);
if ($addr_count > $GLOBALS['conf']['storage']['maxwhitelist']) {
public function getWhitelist()
{
- return array_filter($this->_addr, array('Ingo', '_filterEmptyAddress'));
+ return empty($this->_addr)
+ ? array()
+ : array_filter($this->_addr, array('Ingo', 'filterEmptyAddress'));
}
}
{
return array(
'name' => _("New Rule"),
- 'combine' => INGO_STORAGE_COMBINE_ALL,
+ 'combine' => self::COMBINE_ALL,
'conditions' => array(),
- 'action' => INGO_STORAGE_ACTION_KEEP,
+ 'action' => self::ACTION_KEEP,
'action-value' => '',
'stop' => true,
'flags' => 0,
* number.
*
* @param integer $action The field type of the searched rule
- * (INGO_STORAGE_ACTION_* constants).
+ * (ACTION_* constants).
*
* @return integer The number of the first matching rule or null.
*/
* Searches for and returns the first rule of a certain action type.
*
* @param integer $action The field type of the searched rule
- * (INGO_STORAGE_ACTION_* constants).
+ * (ACTION_* constants).
*
* @return array The first matching rule hash or null.
*/
$vacation->setVacationReason("Because I don't like working!");
$this->store($vacation);
- $this->_enableRule(INGO_STORAGE_ACTION_VACATION);
+ $this->_enableRule(Ingo_Storage::ACTION_VACATION);
$this->assertScript(':0
{
$vacation->setVacationReason("Because I don't like working!");
$this->store($vacation);
- $this->_enableRule(INGO_STORAGE_ACTION_VACATION);
+ $this->_enableRule(Ingo_Storage::ACTION_VACATION);
$this->assertScript('require "vacation";
if allof ( not exists ["list-help", "list-unsubscribe", "list-subscribe", "list-owner", "list-post", "list-archive", "list-id"], not header :comparator "i;ascii-casemap" :is "Precedence" "list,bulk" ) {
$spam->setSpamFolder("Junk");
$this->store($spam);
- $this->_enableRule(INGO_STORAGE_ACTION_SPAM);
+ $this->_enableRule(Ingo_Storage::ACTION_SPAM);
$this->assertScript('require "fileinto";
if header :comparator "i;ascii-casemap" :contains "X-Spam-Level" "*******" {
fileinto "Junk";
require_once 'Horde/Variables.php';
/* Get the spam object and rule. */
-$spam = &$ingo_storage->retrieve(INGO_STORAGE_ACTION_SPAM);
-$filters = &$ingo_storage->retrieve(INGO_STORAGE_ACTION_FILTERS);
-$spam_id = $filters->findRuleId(INGO_STORAGE_ACTION_SPAM);
+$spam = &$ingo_storage->retrieve(Ingo_Storage::ACTION_SPAM);
+$filters = &$ingo_storage->retrieve(Ingo_Storage::ACTION_FILTERS);
+$spam_id = $filters->findRuleId(Ingo_Storage::ACTION_SPAM);
$spam_rule = $filters->getRule($spam_id);
$vars = &Variables::getDefaultVariables();
<tr style="vertical-align:top">
<?php if ($cond_num > 0): ?>
<td>
- <strong><?php echo ($rule['combine'] == INGO_STORAGE_COMBINE_ALL) ? _("and") : _("or") ?></strong>
+ <strong><?php echo ($rule['combine'] == Ingo_Storage::COMBINE_ALL) ? _("and") : _("or") ?></strong>
</td>
<?php elseif (($cond_num == 0) && !$lastfield): ?>
<td> </td>
<table cellspacing="0">
<tr>
<td>
- <input type="checkbox" id="seen" name="flags[]" value="<?php echo INGO_STORAGE_FLAG_SEEN ?>"<?php echo (INGO_STORAGE_FLAG_SEEN & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('seen', _("Seen")) ?>
+ <input type="checkbox" id="seen" name="flags[]" value="<?php echo Ingo_Storage::FLAG_SEEN ?>"<?php echo (Ingo_Storage::FLAG_SEEN & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('seen', _("Seen")) ?>
</td><td>
- <input type="checkbox" id="flagged" name="flags[]" value="<?php echo INGO_STORAGE_FLAG_FLAGGED ?>"<?php echo (INGO_STORAGE_FLAG_FLAGGED & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('flagged', _("Flagged For Followup")) ?>
+ <input type="checkbox" id="flagged" name="flags[]" value="<?php echo Ingo_Storage::FLAG_FLAGGED ?>"<?php echo (Ingo_Storage::FLAG_FLAGGED & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('flagged', _("Flagged For Followup")) ?>
</td><td>
- <input type="checkbox" id="answered" name="flags[]" value="<?php echo INGO_STORAGE_FLAG_ANSWERED ?>"<?php echo (INGO_STORAGE_FLAG_ANSWERED & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('answered', _("Answered")) ?>
+ <input type="checkbox" id="answered" name="flags[]" value="<?php echo Ingo_Storage::FLAG_ANSWERED ?>"<?php echo (Ingo_Storage::FLAG_ANSWERED & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('answered', _("Answered")) ?>
</td><td>
- <input type="checkbox" id="deleted" name="flags[]" value="<?php echo INGO_STORAGE_FLAG_DELETED ?>"<?php echo (INGO_STORAGE_FLAG_DELETED & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('deleted', _("Deleted")) ?>
+ <input type="checkbox" id="deleted" name="flags[]" value="<?php echo Ingo_Storage::FLAG_DELETED ?>"<?php echo (Ingo_Storage::FLAG_DELETED & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('deleted', _("Deleted")) ?>
</td>
</tr>
</table>
<td>
<em><?php echo _("For an incoming message that matches:") ?></em>
<br />
- <input id="all" onclick="document.rule.submit(); return true;" type="radio" name="combine" value="<?php echo INGO_STORAGE_COMBINE_ALL ?>"<?php echo ($rule['combine'] == INGO_STORAGE_COMBINE_ALL) ? ' checked="checked"' : '' ?> /><?php echo Horde::label('all', _("All of the following")) ?>
- <input id="any" onclick="document.rule.submit(); return true;" type="radio" name="combine" value="<?php echo INGO_STORAGE_COMBINE_ANY ?>"<?php echo ($rule['combine'] == INGO_STORAGE_COMBINE_ANY) ? ' checked="checked"' : '' ?> /><?php echo Horde::label('any', _("Any of the following")) ?>
+ <input id="all" onclick="document.rule.submit(); return true;" type="radio" name="combine" value="<?php echo Ingo_Storage::COMBINE_ALL ?>"<?php echo ($rule['combine'] == Ingo_Storage::COMBINE_ALL) ? ' checked="checked"' : '' ?> /><?php echo Horde::label('all', _("All of the following")) ?>
+ <input id="any" onclick="document.rule.submit(); return true;" type="radio" name="combine" value="<?php echo Ingo_Storage::COMBINE_ANY ?>"<?php echo ($rule['combine'] == Ingo_Storage::COMBINE_ANY) ? ' checked="checked"' : '' ?> /><?php echo Horde::label('any', _("Any of the following")) ?>
</td>
<td width="40" class="rightAlign">
<?php echo Help::link('ingo', 'rule-combine') ?>
*/
require_once dirname(__FILE__) . '/lib/base.php';
+require_once 'Horde/Help.php';
+require_once 'Horde/Variables.php';
/* Redirect if vacation is not available. */
if (!in_array(Ingo_Storage::ACTION_VACATION, $_SESSION['ingo']['script_categories'])) {
$vac_rule = $filters->getRule($vac_id);
/* Load libraries. */
-require_once 'Horde/Variables.php';
$vars = Variables::getDefaultVariables();
if ($vars->get('submitbutton') == _("Return to Rules List")) {
header('Location: ' . Horde::applicationUrl('filters.php', true));