Changeset 270

Show
Ignore:
Timestamp:
04/11/08 00:58:01 (9 months ago)
Author:
shupp
Message:

CS fixes for Forwards module

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Framework/Module/Forwards.php

    r251 r270  
    88 * This module is for viewing and editing vpopmail forwards 
    99 *  
    10  * PHP Version 5 
     10 * PHP Version 5.1.0+ 
    1111 *  
    12  * @uses      ToasterAdmin_Auth_Domain 
    13  * @package   ToasterAdmin 
    14  * @author    Bill Shupp <hostmaster@shupp.org>  
    15  * @copyright 2007 Bill Shupp 
    16  * @license   GPL 2.0  {@link http://www.gnu.org/licenses/gpl.txt} 
    17  * @link      http://trac.merchbox.com/trac/toasteradmin 
     12 * @uses       ToasterAdmin_Auth_Domain 
     13 * @category   Mail 
     14 * @package    ToasterAdmin 
     15 * @subpackage Module 
     16 * @author     Bill Shupp <hostmaster@shupp.org>  
     17 * @copyright  2007-2008 Bill Shupp 
     18 * @license    GPL 2.0  {@link http://www.gnu.org/licenses/gpl.txt} 
     19 * @link       http://trac.merchbox.com/trac/toasteradmin 
    1820 */ 
    1921 
     
    2325 * This module is for viewing and editing vpopmail forwards 
    2426 *  
    25  * @uses      ToasterAdmin_Auth_Domain 
    26  * @package   ToasterAdmin 
    27  * @author    Bill Shupp <hostmaster@shupp.org>  
    28  * @copyright 2007 Bill Shupp 
    29  * @license   GPL 2.0  {@link http://www.gnu.org/licenses/gpl.txt} 
    30  * @link      http://trac.merchbox.com/trac/toasteradmin 
     27 * @uses       ToasterAdmin_Auth_Domain 
     28 * @category   Mail 
     29 * @package    ToasterAdmin 
     30 * @subpackage Module 
     31 * @author     Bill Shupp <hostmaster@shupp.org>  
     32 * @copyright  2007-2008 Bill Shupp 
     33 * @license    GPL 2.0  {@link http://www.gnu.org/licenses/gpl.txt} 
     34 * @link       http://trac.merchbox.com/trac/toasteradmin 
    3135 */ 
    3236class Framework_Module_Forwards extends ToasterAdmin_Auth_Domain 
     
    4145     * @return void 
    4246     */ 
    43     public function __construct() { 
     47    public function __construct() 
     48    { 
    4449        parent::__construct(); 
    4550        $this->noDomainSupplied(); 
     
    5459     * @return void 
    5560     */ 
    56     public function __default() { 
     61    public function __default() 
     62    { 
    5763        return $this->listForwards(); 
    5864    } 
     
    6672     * @return void 
    6773     */ 
    68     public function listForwards() { 
    69      
     74    public function listForwards() 
     75    { 
    7076        // Pagintation setup 
    7177        $full_alias_array = $this->user->listAlias($this->domain); 
    7278        // Format the valias outpt from vpopmaild 
    73         $aliasesParsed = $this->user->parseAliases($full_alias_array, 'forwards'); 
    74         $total = count($aliasesParsed); 
     79        $parsed = $this->user->parseAliases($full_alias_array, 'forwards'); 
     80        $total = count($parsed); 
    7581        $this->paginate($total); 
    7682 
    7783        // List Accounts 
    78         $alias_array = $this->user->paginateArray($aliasesParsed, $this->data['currentPage'], $this->data['limit']); 
    79      
     84        $alias_array = $this->user->paginateArray($parsed, 
     85            $this->data['currentPage'], $this->data['limit']); 
    8086        if (count($alias_array) == 0) { 
    8187            $this->setData('message', _("No Forwards.  Care to add one?")); 
     
    8389        } 
    8490     
    85         $aliases = array(); 
    86         $count = 0; 
    87         while (list($key,$val) = each($alias_array)) { 
    88             $forwardName = ereg_replace('@.*$', '', $key); 
    89             $aliases[$count]['name'] = $forwardName; 
    90             $aliases[$count]['contents'] = $this->user->getAliasContents($val); 
    91             $aliases[$count]['edit_url'] = htmlspecialchars("./?module=Forwards&domain={$this->domain}&forward=$forwardName&event=modifyForward"); 
    92             $aliases[$count]['delete_url'] = htmlspecialchars("./?module=Forwards&domain={$this->domain}&forward=$forwardName&event=deleteForward"); 
    93             $count++; 
    94         } 
    95         $this->setData('forwards', $aliases); 
    96  
    97         $this->setData('add_forward_url', htmlspecialchars("./?module=Forwards&event=addForward&domain={$this->domain}")); 
    98  
    99         $this->setData('LANG_Forward', _("Forward")); 
    100         $this->setData('LANG_Recipient', _("Recipient")); 
    101         $this->setData('LANG_Edit', _("Edit")); 
    102         $this->setData('LANG_Delete', _("Delete")); 
    103  
    104         $this->setData('LANG_Forwards_for_domain', _("Forwards for domain")); 
    105         $this->setData('LANG_Forwards_Page', _("Forwards Page")); 
    106         $this->setData('LANG_of', _("of")); 
    107         $this->setData('LANG_Add_Forward', _("Add Forward")); 
    108         $this->setData('LANG_edit', _("edit")); 
    109         $this->setData('LANG_delete', _("delete")); 
    110         $this->setData('LANG_Domain_Menu', _("Domain Menu")); 
     91        $a = array(); 
     92        $c = 0; 
     93        foreach ($alias_array as $key => $val) { 
     94            $fn    = ereg_replace('@.*$', '', $key); 
     95            $eurl  = "./?module=Forwards&domain={$this->domain}"; 
     96            $eurl .= "&forward=$fn&event=modifyForward"; 
     97            $durl  = "./?module=Forwards&domain={$this->domain}"; 
     98            $durl .= "&forward=$fn&event=deleteForward"; 
     99 
     100            $a[$c]['name']       = $fn; 
     101            $a[$c]['contents']   = $this->user->getAliasContents($val); 
     102            $a[$c]['edit_url']   = htmlspecialchars($eurl); 
     103            $a[$c]['delete_url'] = htmlspecialchars($durl); 
     104            $c++; 
     105        } 
     106        $this->setData('forwards', $a); 
     107 
     108        $furl = "./?module=Forwards&event=addForward&domain={$this->domain}"; 
     109        $this->setData('add_forward_url', htmlspecialchars($furl)); 
    111110        $this->tplFile = 'listForwards.tpl'; 
    112111    } 
     
    120119     * @return mixed void on success, PEAR_Error on failure 
    121120     */ 
    122     public function addForward() { 
    123         $form = $this->addForwardForm(); 
    124         $renderer =& new HTML_QuickForm_Renderer_AssocArray(); 
     121    public function addForward() 
     122    { 
     123        $form     = $this->addForwardForm(); 
     124        $renderer = new HTML_QuickForm_Renderer_AssocArray(); 
    125125        $form->accept($renderer); 
    126126        $this->setData('form', $renderer->toAssocArray()); 
     
    134134     * Create Add Forward Form 
    135135     *  
    136      * @access private 
     136     * @access protected 
    137137     * @return object $form HTML_QuickForm Object 
    138138     */ 
    139     private function addForwardForm() { 
    140         // Lang 
    141         $this->setData('LANG_Forward_Name', _("Forward Name")); 
    142         $this->setData('LANG_Add_Forward', _("Add Forward")); 
    143         $this->setData('LANG_Domain_Menu', _("Domain Menu")); 
    144  
    145         $form = & new HTML_QuickForm('form', 'post', './?module=Forwards&event=addForwardNow'); 
    146  
    147         $form->registerRule('validForwardName', 'regex', "/^[a-z0-9]+([_\\.-][a-z0-9]+)*$/i"); 
     139    protected function addForwardForm() 
     140    { 
     141        $form = new HTML_QuickForm('form', 'post', 
     142            './?module=Forwards&event=addForwardNow'); 
     143 
     144        $form->registerRule('validForwardName', 'regex', 
     145            "/^[a-z0-9]+([_\\.-][a-z0-9]+)*$/i"); 
    148146 
    149147        $form->addElement('hidden', 'domain', $this->domain); 
     
    152150        $form->addElement('submit', 'submit', _("Add")); 
    153151 
    154         $form->addRule('forward', _("Forward is required"), 'required', null, 'client'); 
    155         $form->addRule('forward', _("Forward name is invalid (should be forward name only, not full email address"), 'validForwardName'); 
    156         $form->addRule('destination', _("Destination is required"), 'required', null, 'client'); 
    157         $form->addRule('destination', _("Destination must be a full email address"), 'email', null, 'client'); 
     152        $form->addRule('forward', 
     153            _("Forward is required"), 'required', null, 'client'); 
     154        $form->addRule('forward', 
     155            _("Forward name is invalid (should be forward name only, not full email address"), 'validForwardName'); 
     156        $form->addRule('destination', 
     157            _("Destination is required"), 'required', null, 'client'); 
     158        $form->addRule('destination', 
     159            _("Destination must be a full email address"), 'email', null, 'client'); 
    158160 
    159161        return $form; 
     
    168170     * @return mixed PEAR_Error on failure, listForwards() on success 
    169171     */ 
    170     public function addForwardNow() { 
     172    public function addForwardNow() 
     173    { 
    171174        $form = $this->addForwardForm(); 
    172175        if (!$form->validate()) { 
     
    212215 
    213216        $contents = array('&' . $this->data['destination']); 
    214         $result = $this->user->writeFile($contents, $this->domain, '', $file); 
     217        $result   = $this->user->writeFile($contents, $this->domain, '', $file); 
    215218        return true; 
    216219    } 
     
    228231        $file = '.qmail-' . $this->data['forward']; 
    229232        // Let exception bubble up 
    230         $contents = $this->user->readFile($this->domain, '', $file); 
     233        $contents    = $this->user->readFile($this->domain, '', $file); 
    231234        $destination = '&' . $this->data['destination']; 
    232235        // Now build a new array without that forward 
     
    245248     * @return mixed true on success, PEAR_Error on failure 
    246249     */ 
    247     protected function deleteForwardLine() { 
    248         $contents = $this->user->readFile($this->domain, '', ".qmail-" . $this->data['forward']); 
     250    protected function deleteForwardLine() 
     251    { 
     252        $contents = $this->user->readFile($this->domain, '', 
     253            ".qmail-" . $this->data['forward']); 
    249254     
    250255        // Now build a new array without that forward 
     
    258263        } 
    259264        $newContents = array(); 
    260         $count = 1; 
     265        $count       = 1; 
    261266        while (list($key, $val) = each($contents)) { 
    262267            if ($val == $this->data['line']) continue; 
     
    264269            $count++; 
    265270        } 
    266         $result = $this->user->writeFile($newContents, $this->domain, '', ".qmail-" . $this->data['forward']); 
     271        $result = $this->user->writeFile($newContents, 
     272            $this->domain, '', ".qmail-" . $this->data['forward']); 
    267273        return true; 
    268274    } 
     
    275281     * @return mixed void on success, PEAR_Error on failure 
    276282     */ 
    277     function modifyForward() { 
     283    function modifyForward() 
     284    { 
    278285        // Make sure forward was supplied 
    279286        if (!isset($_REQUEST['forward'])) { 
     
    291298        $this->setData('forward_contents', $this->returnForwardArray($contents)); 
    292299 
    293         $form = $this->modifyForwardForm(); 
    294         $renderer =& new HTML_QuickForm_Renderer_AssocArray(); 
     300        $form     = $this->modifyForwardForm(); 
     301        $renderer = new HTML_QuickForm_Renderer_AssocArray(); 
    295302        $form->accept($renderer); 
    296303        $this->setData('form', $renderer->toAssocArray()); 
     
    301308     * returnForwardArray  
    302309     *  
    303      * @param mixed $contents  
     310     * @param mixed $contents dot-qmail file contents 
     311     *  
    304312     * @access protected 
    305313     * @return array $forward_array 
    306314     */ 
    307     protected function returnForwardArray($contents) { 
    308         $count = 0; 
    309         $forward_array = array(); 
    310         while (list($key,$val) = each($contents)) { 
    311             $forward_array[$count]['destination'] = $this->user->displayForwardLine($val); 
    312             $forward_array[$count]['delete_url'] = htmlspecialchars("./?module=Forwards&event=deleteForwardLineNow&domain={$this->domain}&forward=" . $_REQUEST['forward'] . "&line=" . urlencode($val)); 
    313             $count++; 
    314         } 
    315         return $forward_array; 
     315    protected function returnForwardArray($contents) 
     316    { 
     317        $c = 0; 
     318        $a = array(); 
     319        foreach ($contents as $key => $val) { 
     320            $durl  = "./?module=Forwards&event=deleteForwardLineNow"; 
     321            $durl .= "&domain={$this->domain}&forward=" . $_REQUEST['forward']; 
     322            $durl .= "&line=" . urlencode($val); 
     323 
     324            $a[$c]['destination'] = $this->user->displayForwardLine($val); 
     325            $a[$c]['delete_url']  = htmlspecialchars($durl); 
     326            $c++; 
     327        } 
     328        return $a; 
    316329    } 
    317330 
     
    322335     * @return mixed void on success, PEAR_Error on failure 
    323336     */ 
    324     function modifyForwardNow() { 
     337    function modifyForwardNow() 
     338    { 
    325339        $forward = ereg_replace('^.qmail-', '', $_REQUEST['forward']); 
    326340        $this->setData('forward', $forward); 
     
    355369     * modifyForwardForm  
    356370     *  
    357      * @access public 
    358      * @return object $form 
    359      */ 
    360     function modifyForwardForm() { 
    361         // Lang 
    362         $this->setData('LANG_Modify_Forward', _("Modify Forward")); 
    363         $this->setData('LANG_Destination', _("Destination")); 
    364         $this->setData('LANG_Delete', _("Delete")); 
    365         $this->setData('LANG_delete', _("delete")); 
    366         $this->setData('LANG_Forwards_Menu', _("Forwards Menu")); 
    367         $this->setData('LANG_Add_Destination', _("Add Destination")); 
    368         $this->setData('forwards_url', htmlspecialchars("./?module=Forwards&domain={$this->domain}")); 
     371     * Display modify forward form 
     372     *  
     373     * @access public 
     374     * @return object $form HTML_QuickForm object 
     375     */ 
     376    function modifyForwardForm() 
     377    { 
     378        $this->setData('forwards_url', 
     379            htmlspecialchars("./?module=Forwards&domain={$this->domain}")); 
    369380 
    370381        // Form 
    371         $form = & new HTML_QuickForm('form', 'post', './?module=Forwards&event=modifyForwardNow'); 
     382        $form = new HTML_QuickForm('form', 'post', 
     383            './?module=Forwards&event=modifyForwardNow'); 
    372384 
    373385        $form->addElement('hidden', 'domain', $this->domain); 
     
    377389 
    378390        $form->addRule('forward', _("Forward is required"), 'required'); 
    379         $form->addRule('destination', _("Destination is required"), 'required', null, 'client'); 
    380         $form->addRule('destination', _("Destination must be a full email address"), 'email', null, 'client'); 
     391        $form->addRule('destination', 
     392            _("Destination is required"), 'required', null, 'client'); 
     393        $form->addRule('destination', 
     394            _("Destination must be a full email address"), 'email', null, 'client'); 
    381395 
    382396        return $form; 
     
    389403     * @return mixed result of modifyForward on success, PEAR_Error on failure 
    390404     */ 
    391     function deleteForwardLineNow() { 
     405    function deleteForwardLineNow() 
     406    { 
    392407        // Make sure forward was supplied 
    393408        if (!isset($_REQUEST['forward'])) { 
     
    430445     * @return mixed listForwards() on success, PEAR_Error on failure 
    431446     */ 
    432     protected function deleteForward() { 
     447    protected function deleteForward() 
     448    { 
    433449        // Make sure forward was supplied 
    434450        if (!isset($_REQUEST['forward'])) { 
     
    436452            return $this->listForwards(); 
    437453        } 
    438         $forward = ereg_replace('^.qmail-', '', $_REQUEST['forward']); 
     454        $forward = ereg_replace('^.qmail-', '', $_REQUEST['forward']); 
    439455        $contents = $this->user->readFile($this->domain, '', ".qmail-" . $forward); 
    440         $result = $this->user->rmFile($this->domain, '', '.qmail-' . $forward); 
     456        $result   = $this->user->rmFile($this->domain, '', '.qmail-' . $forward); 
    441457        $this->setData('message', _("Forward Deleted Successfully")); 
    442458        return $this->listForwards(); 
  • trunk/Framework/Module/Forwards/Templates/Default/addForward.tpl

    r81 r270  
    11<div class="boxtop"></div> 
    2 <div class="box">{$LANG_Add_Forward}</div> 
     2<div class="box">{t}Add Forward{/t}</div> 
    33<div class="boxbottom"></div> 
    44 
     
    3636<br /> 
    3737<br /> 
    38 <a href="{$domain_url}">{$LANG_Domain_Menu}</a> 
     38<a href="{$domain_url}">{t}Domain Menu{/t}</a> 
    3939 
    4040 
  • trunk/Framework/Module/Forwards/Templates/Default/listForwards.tpl

    r81 r270  
    11<div class="boxtop"></div> 
    22<div class="box"> 
    3 <strong>{$LANG_Forwards_for_domain} {$domain}</strong> 
     3<strong>{t}Forwards for domain{/t} {$domain}</strong> 
    44</div> 
    55<div class="boxbottom"></div> 
     
    77<div class="boxtopDomains"> 
    88<div class="boxtopDomainscontent"> 
    9     <h1>{$LANG_Forwards_Page} {$currentPage} {$LANG_of} {$totalPages}</h1> 
     9    <h1>{t}Forwards Page:{/t} {$currentPage} {t}of{/t} {$totalPages}</h1> 
    1010    {framework_pager start=$start limit=$limit total=$total}  
    11 <a href="{$add_forward_url}">{$LANG_Add_Forward}</a> 
     11<a href="{$add_forward_url}">{t}Add Forward{/t}</a> 
    1212</div> 
    1313</div> 
     
    1616<table border="0" cellspacing="0" cellpadding="4"> 
    1717<tr> 
    18     <td class="title">{$LANG_Forward}</td> 
    19     <td class="title" wrap>{$LANG_Recipient}</td> 
    20     <td class="title">{$LANG_Edit}</td> 
    21     <td class="title">{$LANG_Delete}</td> 
     18    <td class="title">{t}Forward{/t}</td> 
     19    <td class="title" wrap>{t}Recipient{/t}</td> 
     20    <td class="title">{t}Edit{/t}</td> 
     21    <td class="title">{t}Delete{/t}</td> 
    2222</tr> 
    2323{foreach from=$forwards item=forward} 
     
    2525    <td>{$forward.name}</td> 
    2626    <td>{$forward.contents}</td> 
    27     <td align="center"><a href="{$forward.edit_url}">{$LANG_edit}</a></td> 
    28     <td align="center"><a href="{$forward.delete_url}">{$LANG_delete}</a></td> 
     27    <td align="center"><a href="{$forward.edit_url}">{t}edit{/t}</a></td> 
     28    <td align="center"><a href="{$forward.delete_url}">{t}delete{/t}</a></td> 
    2929</tr> 
    3030{/foreach} 
    3131</table> 
    32 <a href="{$domain_url}">{$LANG_Domain_Menu}</a> 
     32<a href="{$domain_url}">{t}Domain Menu{/t}</a> 
    3333</div> 
    3434<div class="boxbottom"></div> 
  • trunk/Framework/Module/Forwards/Templates/Default/modifyForward.tpl

    r81 r270  
    11<div class="boxtop"></div> 
    2 <div class="box"><b>{$LANG_Modify_Forward} "{$forward}@{$domain}"</b></div> 
     2<div class="box"><b>{t}Modify Forward{/t} "{$forward}@{$domain}"</b></div> 
    33<div class="boxbottom"></div> 
    44 
     
    77<table border="0" cellspacing="0" cellpadding="3"> 
    88<tr> 
    9 <td>{$LANG_Destination}</td> 
    10 <td>{$LANG_Delete}</td> 
     9<td>{t}Destination{/t}</td> 
     10<td>{t}Delete{/t}</td> 
    1111</tr> 
    1212 
     
    1414<tr> 
    1515    <td>{$line.destination}</td> 
    16     <td align="center"><a href="{$line.delete_url}"><img src="images/trash.png" border="0" alt="{$LANG_delete}" /></a></td> 
     16    <td align="center"><a href="{$line.delete_url}"><img src="images/trash.png" border="0" alt="{t}delete{/t}" /></a></td> 
    1717</tr> 
    1818{/foreach} 
     
    2626<hr> 
    2727<div> 
    28 <b>{$LANG_Add_Destination}</b> 
     28<b>{t}Add Destination{/t}</b> 
    2929<table border="0"> 
    3030 
     
    4545</div> 
    4646</form> 
    47 <a href="{$forwards_url}">{$LANG_Forwards_Menu}</a> 
     47<a href="{$forwards_url}">{t}Forwards Menu{/t}</a> 
    4848</div> 
    4949<div class="boxbottom"></div> 
  • trunk/Framework/Module/Responders.php

    r265 r270  
    9393            $c++; 
    9494        } 
    95         $aurl = "./?module=Responders&event=addResponder&domain={$this->domain}"; 
     95        $aurl = "./?module=Responders&event=addResponder&domain={$this->domain}"; 
    9696        $this->setData('add_url', htmlspecialchars($aurl)); 
    9797        $this->setData('autoresponders', $a);