Changeset 257

Show
Ignore:
Timestamp:
04/10/08 22:18:36 (9 months ago)
Author:
shupp
Message:

CS fixes for Accounts_Modify. Moved LANG variables into templates.

Files:

Legend:

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

    r249 r257  
    66 * Class just for modifying accounts 
    77 *  
     8 * PHP Version 5.1.0+ 
     9 *  
    810 * @uses      ToasterAdmin_Auth_User 
     11 * @category  Mail 
    912 * @package   ToasterAdmin 
    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 * Class just for modifying accounts 
    2023 *  
    21  * @uses      ToasterAdmin_Auth_User 
    22  * @package   ToasterAdmin 
    23  * @author    Bill Shupp <hostmaster@shupp.org>  
    24  * @copyright 2007 Bill Shupp 
    25  * @license   GPL 2.0  {@link http://www.gnu.org/licenses/gpl.txt} 
    26  * @link      http://trac.merchbox.com/trac/toasteradmin 
     24 * @uses       ToasterAdmin_Auth_User 
     25 * @category   Mail 
     26 * @package    ToasterAdmin 
     27 * @subpackage Module 
     28 * @author     Bill Shupp <hostmaster@shupp.org>  
     29 * @copyright  2007-2008 Bill Shupp 
     30 * @license    GPL 2.0  {@link http://www.gnu.org/licenses/gpl.txt} 
     31 * @link       http://trac.merchbox.com/trac/toasteradmin 
    2732 */ 
    2833class Framework_Module_Accounts_Modify extends ToasterAdmin_Auth_User 
     
    6570        // Get .qmail info if it exists 
    6671        try { 
    67             $dot_qmail = $this->user->readFile($this->domain, $_REQUEST['account'], '.qmail'); 
     72            $dot_qmail = $this->user->readFile($this->domain, 
     73                $_REQUEST['account'], '.qmail'); 
    6874        } catch (Net_Vpopmaild_Exception $e) { 
    6975            $dot_qmail = ''; 
     
    7177        $defaults = $this->parseHomeDotqmail($dot_qmail, $account_info); 
    7278        $this->user->recordio(print_r($defaults, 1)); 
    73         $form = $this->modifyAccountForm($account, $defaults); 
    74         $renderer =& new HTML_QuickForm_Renderer_AssocArray(); 
     79 
     80        $form     = $this->modifyAccountForm($account, $defaults); 
     81        $renderer = new HTML_QuickForm_Renderer_AssocArray(); 
    7582        $form->accept($renderer); 
    76         if(isset($_REQUEST['modified'])) { 
     83        if (isset($_REQUEST['modified'])) { 
    7784            $this->setData('message', _('Account Modified Successfully')); 
    7885        } 
     
    9097     * @param mixed $defaults defaults 
    9198     *  
    92      * @access private 
     99     * @access protected 
    93100     * @return void 
    94101     */ 
    95     private function modifyAccountForm($account, $defaults) { 
     102    protected function modifyAccountForm($account, $defaults) 
     103    { 
    96104 
    97105        // Language stuff 
    98         $this->setData('LANG_Modify_Account', _("Modify Account")); 
    99         $this->setData('LANG_Domain_Menu', _("Domain Menu")); 
    100106        if ($this->user->isDomainAdmin($this->domain)) { 
    101107            $this->setData('isDomainAdmin', 1); 
     
    104110        $this->setData('account', $account); 
    105111 
    106         $form = new HTML_QuickForm('formModifyAccount', 'post', "./?module=Accounts&class=Modify&event=modifyAccountNow&domain={$this->domain}&account=$account"); 
     112        $url  =  "./?module=Accounts&class=Modify&event=modifyAccountNow"; 
     113        $url .= "&domain={$this->domain}&account=$account"; 
     114        $form = new HTML_QuickForm('formModifyAccount', 'post', $url); 
    107115 
    108116        $form->setDefaults($defaults); 
     
    111119        $form->addElement('password', 'password', _("Password")); 
    112120        $form->addElement('password', 'password2', _("Re-Type Password")); 
    113         $form->addElement('radio', 'routing', 'Mail Routing', _('Standard (No Forwarding)'), 'routing_standard'); 
    114         $form->addElement('radio', 'routing', '', _('All Mail Deleted'), 'routing_deleted'); 
    115         $form->addElement('radio', 'routing', '', _('Forward to:'), 'routing_forwarded'); 
     121        $form->addElement('radio', 'routing', 'Mail Routing', 
     122            _('Standard (No Forwarding)'), 'routing_standard'); 
     123        $form->addElement('radio', 'routing', '', 
     124            _('All Mail Deleted'), 'routing_deleted'); 
     125        $form->addElement('radio', 'routing', '', 
     126            _('Forward to:'), 'routing_forwarded'); 
    116127        $form->addElement('text', 'forward'); 
    117128        $form->addElement('checkbox', 'save_a_copy', _('Save A Copy')); 
    118129 
    119         $form->addElement('checkbox', 'vacation', _('Send a Vacation Auto-Response')); 
    120         $form->addElement('text', 'vacation_subject', _('Vacation Subject:')); 
    121         $form->addElement('textarea', 'vacation_body', _('Vacation Message:'), 'rows="10" cols="40"'); 
     130        $form->addElement('checkbox', 'vacation', 
     131            _('Send a Vacation Auto-Response')); 
     132        $form->addElement('text', 'vacation_subject', 
     133            _('Vacation Subject:')); 
     134        $form->addElement('textarea', 'vacation_body', 
     135            _('Vacation Message:'), 'rows="10" cols="40"'); 
    122136        $form->addElement('submit', 'submit', _('Modify Account')); 
    123137 
    124         $form->addRule(array('password', 'password2'), _('The passwords do not match'), 'compare', null, 'client'); 
    125         $form->addRule('routing', _('Please select a mail routing type'), 'required', null, 'client'); 
    126         $form->addRule('forward', _('"Forward to" must be a valid email address'), 'email', null, 'client'); 
     138        $form->addRule(array('password', 'password2'), 
     139            _('The passwords do not match'), 'compare', null, 'client'); 
     140        $form->addRule('routing', 
     141            _('Please select a mail routing type'), 'required', null, 'client'); 
     142        $form->addRule('forward', 
     143            _('"Forward to" must be a valid email address'), 
     144            'email', null, 'client'); 
    127145 
    128146        return $form; 
     
    154172        // Get .qmail info if it exists 
    155173        try { 
    156             $dot_qmail = $this->user->readFile($this->domain, $_REQUEST['account'], '.qmail'); 
     174            $dot_qmail = $this->user->readFile($this->domain, 
     175                $_REQUEST['account'], '.qmail'); 
    157176        } catch (Net_Vpopmaild_Exception $e) { 
    158177            $dot_qmail = ''; 
    159178        } 
    160         $defaultsOrig = $this->parseHomeDotqmail($dot_qmail, $account_info); 
    161         $form = $this->modifyAccountForm($account, $defaultsOrig); 
     179        $defs = $this->parseHomeDotqmail($dot_qmail, $account_info); 
     180        $form = $this->modifyAccountForm($account, $defs); 
    162181        if (!$form->validate()) { 
    163182            $this->setData('message', _("Error Modifying Account")); 
     
    191210 
    192211        // Determine new routing 
    193         $routing = ''; 
     212        $routing     = ''; 
    194213        $save_a_copy = 0; 
    195214        if ($_REQUEST['routing'] == 'routing_standard') { 
     
    199218        } else if ($_REQUEST['routing'] == 'routing_forwarded') { 
    200219            if (empty($_REQUEST['forward'])) { 
    201                 $this->setData('message', _('Error: you must supply a forward address')); 
     220                $this->setData('message', 
     221                    _('Error: you must supply a forward address')); 
    202222                return $this->modifyAccount(); 
    203223            } else { 
     
    214234        $vacation = 0; 
    215235        if (isset($_REQUEST['vacation']) && $_REQUEST['vacation'] == 1) { 
    216             $vacation = 1; 
     236            $vacation         = 1; 
    217237            $vacation_subject = $_REQUEST['vacation_subject']; 
    218             $vacation_body = $_REQUEST['vacation_body']; 
     238            $vacation_body    = $_REQUEST['vacation_body']; 
    219239        } 
    220240 
    221241        // Are we deleting a vacation message? 
    222         if ($vacation == 0 && $defaultsOrig['vacation'] == ' checked') { 
     242        if ($vacation == 0 && $defs['vacation'] == ' checked') { 
    223243            // Kill old message 
    224244            $this->user->rmDir($this->domain, $account_info['name'], 'vacation'); 
     
    235255 
    236256        if ($vacation == 1) { 
    237             if (strlen($dot_qmail_contents) > 0) $dot_qmail_contents .= "\n"; 
     257            if (strlen($dot_qmail_contents) > 0) { 
     258                $dot_qmail_contents .= "\n"; 
     259            } 
    238260            $vacation_dir = $account_info['user_dir'] . '/vacation'; 
     261 
    239262            $dot_qmail_contents .= '| ' . $this->user->vpopmailRobotProgram; 
    240263            $dot_qmail_contents .= ' ' . $this->user->vpopmailRobotTime; 
     
    247270            $contents = explode("\n", $dot_qmail_contents); 
    248271            // Write .qmail file 
    249             $result = $this->user->writeFile($contents, $this->domain, $account_info['name'], $dot_qmail_file); 
     272            $result = $this->user->writeFile($contents, $this->domain, 
     273                $account_info['name'], $dot_qmail_file); 
    250274 
    251275            // Add vacation files 
    252276            if ($vacation == 1) { 
    253                 $vcontents = "From: " . $account_info['name'] . "@{$this->domain}\n"; 
     277                $vcontents  = "From: " . $account_info['name'] . "@{$this->domain}"; 
     278                $vcontents .= "\n"; 
    254279                $vcontents .= "Subject: $vacation_subject\n\n"; 
    255280                $vcontents .= $vacation_body; 
    256                 $contents = explode("\n", $vcontents); 
    257                 $vdir = 'vacation'; 
    258                 $message = 'vacation/message'; 
     281                $contents   = explode("\n", $vcontents); 
     282                $vdir       = 'vacation'; 
     283                $message    = 'vacation/message'; 
    259284                // Delete existing file 
    260285                try { 
     
    263288                } 
    264289                // Make vacation directory 
    265                 $result = $this->user->mkDir($this->domain, $account_info['name'], $vdir); 
     290                $result = $this->user->mkDir($this->domain, 
     291                    $account_info['name'], $vdir); 
    266292                // Write vacation message 
    267                 $result = $this->user->writeFile($contents, $this->domain, $account_info['name'], $message); 
     293                $result = $this->user->writeFile($contents, $this->domain, 
     294                    $account_info['name'], $message); 
    268295            } 
    269296        } else { 
    270297            try { 
    271                 $this->user->rmFile($this->domain, $account_info['name'], $dot_qmail_file); 
     298                $this->user->rmFile($this->domain, 
     299                    $account_info['name'], $dot_qmail_file); 
    272300            } catch (Net_Vpopmaild_Exception $e) { 
    273301            } 
    274302        } 
    275303 
    276         $url = "./?module=Accounts&class=Modify&event=modifyAccount&domain={$this->domain}&account={$account_info['name']}&modified=1"; 
     304        $url  = "./?module=Accounts&class=Modify&event=modifyAccount"; 
     305        $url .= "&domain={$this->domain}&account={$account_info['name']}&modified=1"; 
    277306        header("Location: $url"); 
    278         return $this->modifyAccount()
     307        return
    279308    } 
    280309 
  • trunk/Framework/Module/Accounts/Templates/Default/modifyAccount.tpl

    r223 r257  
    11<div class="boxtop"></div> 
    22<div class="box"> 
    3 <b>{$LANG_Modify_Account} {$account}@{$domain}</b> 
     3<b>{t}Modify Account{/t} {$account}@{$domain}</b> 
    44</div> 
    55<div class="boxbottom"></div> 
     
    7373</form> 
    7474 
    75 {if $isDomainAdmin}<a href="./?module=Domains&amp;class=Menu&amp;domain={$domain}"><br /><b>{$LANG_Main_Menu}</b>{/if} 
     75{if $isDomainAdmin}<a href="./?module=Domains&amp;class=Menu&amp;domain={$domain}"><br /><b>{t}Main Menu{/t}</b>{/if} 
    7676 
    7777</div>