IMP_Filter::_processBWlist PHP Method

_processBWlist() protected method

Internal function to handle adding addresses to [black|white]list.
protected _processBWlist ( IMP_Indices $indices, string $descrip, string $reg1, string $reg2, boolean $link ) : boolean
$indices IMP_Indices An indices object.
$descrip string The textual description to use.
$reg1 string The name of the mail/ registry call to use for adding the addresses.
$reg2 string The name of the mail/ registry call to use for linking to the filter management page.
$link boolean Show link to the whitelist management in the notification message?
return boolean True on success.
    protected function _processBWlist($indices, $descrip, $reg1, $reg2, $link)
    {
        if (!count($indices)) {
            return false;
        }
        $addr = new Horde_Mail_Rfc822_List();
        foreach ($indices as $ob) {
            $ob->mbox->uidvalid;
            foreach ($ob->uids as $idx) {
                /* Get the list of from addresses. */
                $h = $GLOBALS['injector']->getInstance('IMP_Factory_Contents')->create($ob->mbox->getIndicesOb($idx))->getHeader();
                if ($f = $h['from']) {
                    $addr->add($f->getAddressList());
                }
            }
        }
        $GLOBALS['registry']->call('mail/' . $reg1, array($addr->bare_addresses));
        /* Add link to filter management page. */
        if ($link && $GLOBALS['registry']->hasMethod('mail/' . $reg2)) {
            $GLOBALS['notification']->push(Horde::url($GLOBALS['registry']->link('mail/' . $reg2))->link(array('title' => sprintf(_("Filters: %s management page"), $descrip))) . sprintf(_("Click to go to %s management page."), $descrip) . '</a>', 'horde.message', array('content.raw'));
        }
        return true;
    }