Changeset 253

Show
Ignore:
Timestamp:
04/09/08 23:50:33 (9 months ago)
Author:
shupp
Message:

Switched Accounts to smarty block plugin, cleaned up all CS problems

Files:

Legend:

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

    r245 r253  
    66 * This module is for viewing and editing vpopmail accounts 
    77 *  
     8 * PHP Version 5.1.0+ 
     9 *  
     10 * @category  Mail 
    811 * @package   ToasterAdmin 
    912 * @uses      ToasterAdmin_Auth_Domain 
    1013 * @author    Bill Shupp <hostmaster@shupp.org>  
    11  * @copyright 2007 Bill Shupp 
     14 * @copyright 2007-2008 Bill Shupp 
    1215 * @license   GPL 2.0  {@link http://www.gnu.org/licenses/gpl.txt} 
    1316 * @link      http://trac.merchbox.com/trac/toasteradmin 
     
    1922 * This module is for viewing and editing vpopmail accounts 
    2023 *  
     24 * @category  Mail 
    2125 * @package   ToasterAdmin 
    2226 * @uses      ToasterAdmin_Auth_Domain 
    2327 * @author    Bill Shupp <hostmaster@shupp.org>  
    24  * @copyright 2007 Bill Shupp 
     28 * @copyright 2007-2008 Bill Shupp 
    2529 * @license   GPL 2.0  {@link http://www.gnu.org/licenses/gpl.txt} 
    2630 * @link      http://trac.merchbox.com/trac/toasteradmin 
     
    3438     * Throw an exception if no domain was supplied 
    3539     *  
    36      * @access protected 
    37      * @return void 
    38      */ 
    39     function __construct() { 
     40     * @access public 
     41     * @return void 
     42     */ 
     43    public function __construct() 
     44    { 
    4045        parent::__construct(); 
    4146        $this->noDomainSupplied(); 
     
    4550     * __default  
    4651     *  
    47      * @access protected 
    48      * @return void 
    49      */ 
    50     public function __default() { 
    51         $this->listAccounts(); 
    52     } 
    53  
    54     public function listAccounts() { 
     52     * @access public 
     53     * @return void 
     54     */ 
     55    public function __default() 
     56    { 
     57        $this->listAccounts(); 
     58    } 
     59 
     60    /** 
     61     * listAccounts  
     62     *  
     63     * List accounts for the current domain 
     64     *  
     65     * @access public 
     66     * @return void 
     67     */ 
     68    public function listAccounts() 
     69    { 
    5570        // Pagintation setup - let exception bubble up 
    5671        $total = $this->user->userCount($this->domain); 
     
    5873 
    5974        // List Accounts 
    60         $account_array = $this->user->listUsers($this->data['domain'], $this->data['currentPage'], $this->data['limit']); 
    61         $accounts = array(); 
    62         $count = 0; 
    63         while (list($key,$val) = each($account_array)) { 
    64             $accounts[$count]['account'] = $key; 
    65             $accounts[$count]['comment'] = $val['comment']; 
    66             $accounts[$count]['quota'] = $this->user->getQuota($val['quota']); 
    67             $accounts[$count]['edit_url'] = htmlspecialchars("./?module=Accounts&class=Modify&domain={$this->domain}&account=$key&event=modifyAccount"); 
    68             $accounts[$count]['delete_url'] = htmlspecialchars("./?module=Accounts&domain={$this->domain}&account=$key&event=delete"); 
    69             $count++; 
    70         } 
    71         $this->setData('accounts', $accounts); 
    72         $this->setData('add_account_url', htmlspecialchars("./?module=Accounts&event=addAccount&domain={$this->domain}")); 
    73  
    74         // Language 
    75         $this->setData('LANG_Email_Accounts_in_domain', _('Email Accounts in domain')); 
    76         $this->setData('LANG_Accounts_Page', _('Accounts: Page')); 
    77         $this->setData('LANG_Add_Account', _('Add Account')); 
    78         $this->setData('LANG_Domain_Menu', _('Domain Menu')); 
    79         $this->setData('LANG_of', _('of')); 
    80         $this->setData('LANG_Account', _('Account')); 
    81         $this->setData('LANG_Comment', _('Comment')); 
    82         $this->setData('LANG_Quota', _('Quota')); 
    83         $this->setData('LANG_Edit', _('Edit')); 
    84         $this->setData('LANG_Delete', _('Delete')); 
    85         $this->setData('LANG_edit', _('edit')); 
    86         $this->setData('LANG_delete', _('delete')); 
    87  
     75        $a    = array(); 
     76        $c    = 0; 
     77        $list = $this->user->listUsers($this->data['domain'], 
     78            $this->data['currentPage'], $this->data['limit']); 
     79        foreach ($list as $key => $val) { 
     80            $eus  =  "./?module=Accounts&class=Modify&domain={$this->domain}"; 
     81            $eus .= "&account=$key&event=modifyAccount"; 
     82            $dus  = "./?module=Accounts&domain={$this->domain}"; 
     83            $dus .= "&account=$key&event=delete"; 
     84 
     85            $a[$c]['account']    = $key; 
     86            $a[$c]['comment']    = $val['comment']; 
     87            $a[$c]['quota']      = $this->user->getQuota($val['quota']); 
     88            $a[$c]['edit_url']   = htmlspecialchars($eus); 
     89            $a[$c]['delete_url'] = htmlspecialchars($dus); 
     90            $c++; 
     91        } 
     92        $aus = "./?module=Accounts&event=addAccount&domain={$this->domain}"; 
     93        $this->setData('add_account_url', htmlspecialchars($aus)); 
     94        $this->setData('accounts', $a); 
    8895        $this->tplFile = 'listAccounts.tpl'; 
    8996        return; 
     
    96103     * @return void 
    97104     */ 
    98     public function addAccount() { 
    99         $form = $this->addAccountForm(); 
    100         $renderer =& new HTML_QuickForm_Renderer_AssocArray(); 
     105    public function addAccount() 
     106    { 
     107        $form     = $this->addAccountForm(); 
     108        $renderer = new HTML_QuickForm_Renderer_AssocArray(); 
    101109        $form->accept($renderer); 
    102110        $this->setData('form', $renderer->toAssocArray()); 
     
    105113    } 
    106114 
    107     public function addAccountNow() { 
     115    /** 
     116     * addAccountNow  
     117     *  
     118     * Actually add account, then list accounts 
     119     *  
     120     * @access public 
     121     * @return void 
     122     */ 
     123    public function addAccountNow() 
     124    { 
    108125        $form = $this->addAccountForm(); 
    109126        if (!$form->validate()) { 
     
    117134        $emailArray = explode('@', $_REQUEST['account']); 
    118135        try { 
    119             $result = $this->user->addUser($this->domain, $emailArray[0], $_REQUEST['password']); 
     136            $result = $this->user->addUser($this->domain, $emailArray[0], 
     137                $_REQUEST['password']); 
    120138        } catch (Net_Vpopmaild_Exception $e) { 
    121139            $this->setData('message', _("Error: ") . $e->getMessage()); 
     
    127145        } 
    128146        // Update gecos 
    129         $userInfo = $this->user->userInfo($this->domain, $emailArray[0]); 
     147        $userInfo            = $this->user->userInfo($this->domain, $emailArray[0]); 
    130148        $userInfo['comment'] = $_REQUEST['comment']; 
     149 
    131150        $result = $this->user->modUser($this->domain, $userInfo['name'], $userInfo); 
    132151 
     
    136155    } 
    137156 
    138     private function addAccountForm() { 
    139         $this->setData('LANG_Add_Account_to_domain', _("Add Account to domain")); 
    140         $this->setData('LANG_Domain_Menu', _("Domain Menu")); 
    141         $form = new HTML_QuickForm('formAddAccount', 'post', "./?module=Accounts&event=addAccountNow&domain={$this->domain}"); 
    142  
     157    /** 
     158     * addAccountForm  
     159     *  
     160     * Create HTML_QuickForm instance of add account form 
     161     *  
     162     * @access protected 
     163     * @return object HTML_QuickForm object 
     164     */ 
     165    protected function addAccountForm() 
     166    { 
     167        $form = new HTML_QuickForm('formAddAccount', 'post', 
     168            "./?module=Accounts&event=addAccountNow&domain={$this->domain}"); 
    143169        $form->setDefaults(array('account' => '@' . $this->domain)); 
    144170 
     
    150176        $form->registerRule('sameDomain', 'regex', "/@$this->domain$/i"); 
    151177 
    152         $form->addRule('account', "Account is required", 'required', null, 'client'); 
    153         $form->addRule('comment', "Comment is required", 'required', null, 'client'); 
    154         $form->addRule('account', "Account must be the full email address", 'email', null, 'client'); 
    155         $form->addRule('account', 'Error: wrong domain in email address', 'sameDomain'); 
    156         $form->addRule('password', "Password is required", 'required', null, 'client'); 
     178        $form->addRule('account', 
     179            _("Account is required"), 'required', null, 'client'); 
     180        $form->addRule('comment', 
     181            _("Comment is required"), 'required', null, 'client'); 
     182        $form->addRule('account', 
     183            _("Account must be the full email address"), 'email', null, 'client'); 
     184        $form->addRule('account', 
     185            _('Error: wrong domain in email address'), 'sameDomain'); 
     186        $form->addRule('password', 
     187            _("Password is required"), 'required', null, 'client'); 
    157188        return $form; 
    158189    } 
    159190 
    160     public function delete() { 
     191    /** 
     192     * delete  
     193     *  
     194     * Display delete account confirmation 
     195     *  
     196     * @access public 
     197     * @return void 
     198     */ 
     199    public function delete() 
     200    { 
    161201        if (!isset($_REQUEST['account'])) { 
    162202            throw new Framework_Exception (_("Error: no account supplied")); 
    163203        } 
    164204 
    165         $this->setData('LANG_Are_you_sure_you_want_to_delete_this_account', _("Are you sure you want to delete this account")); 
    166         $this->setData('LANG_cancel', _("cancel")); 
    167         $this->setData('LANG_delete', _("delete")); 
    168  
    169205        $this->setData('account', $_REQUEST['account']); 
    170         $this->setData('cancel_url', "./?module=Accounts&event=cancelDelete&domain=" . $this->domain); 
    171         $this->setData('delete_now_url', "./?module=Accounts&event=deleteNow&domain=" . $this->domain . "&account=" . $_REQUEST['account']); 
     206        $this->setData('cancel_url', 
     207            "./?module=Accounts&event=cancelDelete&domain=" . $this->domain); 
     208        $this->setData('delete_now_url', 
     209            "./?module=Accounts&event=deleteNow&domain=" 
     210            . $this->domain . "&account=" . $_REQUEST['account']); 
    172211        $this->tplFile = 'accountConfirmDelete.tpl'; 
    173212    } 
    174213 
    175     function deleteNow() { 
     214    /** 
     215     * deleteNow  
     216     *  
     217     * Actuall delete the account, then list accounts 
     218     *  
     219     * @access public 
     220     * @return void 
     221     */ 
     222    public function deleteNow() 
     223    { 
    176224        if (!isset($_REQUEST['account'])) { 
    177225            throw new Framework_Exception (_("Error: no account supplied")); 
     
    188236    } 
    189237 
    190     function cancelDelete() { 
     238    /** 
     239     * cancelDelete  
     240     *  
     241     * Cancel account deletion and list accounts 
     242     *  
     243     * @access public 
     244     * @return void 
     245     */ 
     246    public function cancelDelete() 
     247    { 
    191248        $this->setData('message', _("Delete Canceled")); 
    192249        $this->listAccounts(); 
  • trunk/Framework/Module/Accounts/Templates/Default/accountConfirmDelete.tpl

    r76 r253  
    11<div class="boxtop"></div> 
    22<div class="box"> 
    3 {$LANG_Are_you_sure_you_want_to_delete_this_account} "{$account}"? 
     3{t}Are you sure you want to delete account{/t} "{$account}"? 
    44<br> 
    5 <a href="{$cancel_url}">{$LANG_cancel}</a> &nbsp | &nbsp <a href="{$delete_now_url}">{$LANG_delete
     5<a href="{$cancel_url}">{t}cancel{/t}</a> &nbsp | &nbsp <a href="{$delete_now_url}">{t}delete{/t
    66</div> 
    77<div class="boxbottom"></div> 
  • trunk/Framework/Module/Accounts/Templates/Default/addAccount.tpl

    r76 r253  
    11<div class="boxtop"></div> 
    2 <div class="box">{$LANG_Add_Account_to_domain} {$domain}</div> 
     2<div class="box">{t}Add Account to domain{/t} {$domain}</div> 
    33<div class="boxbottom"></div> 
    44 
     
    3232 
    3333<div class="boxtop"></div> 
    34 <div class="box"><a href="{$domain_url}">{$LANG_Domain_Menu}</a></div> 
     34<div class="box"><a href="{$domain_url}">{t}Domain Menu{/t}</a></div> 
    3535<div class="boxbottom"></div> 
  • trunk/Framework/Module/Accounts/Templates/Default/listAccounts.tpl

    r76 r253  
    11<div class="boxtop"></div> 
    22<div class="box"> 
    3 {$LANG_Email_Accounts_in_domain} {$domain} 
     3{t}Email Accounts in domain{/t} {$domain} 
    44</div> 
    55<div class="boxbottom"></div> 
     
    77<div class="boxtopDomains"> 
    88<div class="boxtopDomainscontent"> 
    9     <h1>{$LANG_Accounts_Page} {$currentPage} {$LANG_of} {$totalPages}</h1> 
     9    <h1>{t}Accounts Page{/t} {$currentPage} {t}of{/t} {$totalPages}</h1> 
    1010{framework_pager start=$start limit=$limit total=$total}  
    11 <a href="{$add_account_url}">{$LANG_Add_Account}</a> 
     11<a href="{$add_account_url}">{t}Add Account{/t}</a> 
    1212</div> 
    1313</div> 
     
    1717<table border="0" cellspacing="0" cellpadding="0" id="datatable"> 
    1818<tr> 
    19     <td class="domaincell">{$LANG_Account}</td> 
    20     <td class="domaincell">{$LANG_Comment}</td> 
    21     <td class="domaincell">{$LANG_Quota}</td> 
    22     <td class="domaincell">{$LANG_Edit}</td> 
    23     <td class="domaincell">{$LANG_Delete}</td> 
     19    <td class="domaincell">{t}Account{/t}</td> 
     20    <td class="domaincell">{t}Comment{/t}</td> 
     21    <td class="domaincell">{t}Quota{/t}</td> 
     22    <td class="domaincell">{t}Edit{/t}</td> 
     23    <td class="domaincell">{t}Delete{/t}</td> 
    2424</tr> 
    2525 
     
    2929    <td>{$account.comment}</td> 
    3030    <td>{$account.quota}</td> 
    31     <td><a href="{$account.edit_url}">{$LANG_edit}</a></td> 
    32     <td><a href="{$account.delete_url}">{$LANG_delete}</a></td> 
     31    <td><a href="{$account.edit_url}">{t}edit{/t}</a></td> 
     32    <td><a href="{$account.delete_url}">{t}delete{/t}</a></td> 
    3333</tr> 
    3434{/foreach} 
    3535</table> 
    36 <center><a href="{$domain_url}">{$LANG_Domain_Menu}</a></center> 
     36<center><a href="{$domain_url}">{t}Domain Menu{/t}</a></center> 
    3737</div> 
    3838<div class="boxbottom"></div>