Changeset 257
- Timestamp:
- 04/10/08 22:18:36 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Framework/Module/Accounts/Modify.php
r249 r257 6 6 * Class just for modifying accounts 7 7 * 8 * PHP Version 5.1.0+ 9 * 8 10 * @uses ToasterAdmin_Auth_User 11 * @category Mail 9 12 * @package ToasterAdmin 10 13 * @author Bill Shupp <hostmaster@shupp.org> 11 * @copyright 2007 Bill Shupp14 * @copyright 2007-2008 Bill Shupp 12 15 * @license GPL 2.0 {@link http://www.gnu.org/licenses/gpl.txt} 13 16 * @link http://trac.merchbox.com/trac/toasteradmin … … 19 22 * Class just for modifying accounts 20 23 * 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 27 32 */ 28 33 class Framework_Module_Accounts_Modify extends ToasterAdmin_Auth_User … … 65 70 // Get .qmail info if it exists 66 71 try { 67 $dot_qmail = $this->user->readFile($this->domain, $_REQUEST['account'], '.qmail'); 72 $dot_qmail = $this->user->readFile($this->domain, 73 $_REQUEST['account'], '.qmail'); 68 74 } catch (Net_Vpopmaild_Exception $e) { 69 75 $dot_qmail = ''; … … 71 77 $defaults = $this->parseHomeDotqmail($dot_qmail, $account_info); 72 78 $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(); 75 82 $form->accept($renderer); 76 if (isset($_REQUEST['modified'])) {83 if (isset($_REQUEST['modified'])) { 77 84 $this->setData('message', _('Account Modified Successfully')); 78 85 } … … 90 97 * @param mixed $defaults defaults 91 98 * 92 * @access pr ivate99 * @access protected 93 100 * @return void 94 101 */ 95 private function modifyAccountForm($account, $defaults) { 102 protected function modifyAccountForm($account, $defaults) 103 { 96 104 97 105 // Language stuff 98 $this->setData('LANG_Modify_Account', _("Modify Account"));99 $this->setData('LANG_Domain_Menu', _("Domain Menu"));100 106 if ($this->user->isDomainAdmin($this->domain)) { 101 107 $this->setData('isDomainAdmin', 1); … … 104 110 $this->setData('account', $account); 105 111 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); 107 115 108 116 $form->setDefaults($defaults); … … 111 119 $form->addElement('password', 'password', _("Password")); 112 120 $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'); 116 127 $form->addElement('text', 'forward'); 117 128 $form->addElement('checkbox', 'save_a_copy', _('Save A Copy')); 118 129 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"'); 122 136 $form->addElement('submit', 'submit', _('Modify Account')); 123 137 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'); 127 145 128 146 return $form; … … 154 172 // Get .qmail info if it exists 155 173 try { 156 $dot_qmail = $this->user->readFile($this->domain, $_REQUEST['account'], '.qmail'); 174 $dot_qmail = $this->user->readFile($this->domain, 175 $_REQUEST['account'], '.qmail'); 157 176 } catch (Net_Vpopmaild_Exception $e) { 158 177 $dot_qmail = ''; 159 178 } 160 $def aultsOrig= $this->parseHomeDotqmail($dot_qmail, $account_info);161 $form = $this->modifyAccountForm($account, $def aultsOrig);179 $defs = $this->parseHomeDotqmail($dot_qmail, $account_info); 180 $form = $this->modifyAccountForm($account, $defs); 162 181 if (!$form->validate()) { 163 182 $this->setData('message', _("Error Modifying Account")); … … 191 210 192 211 // Determine new routing 193 $routing = '';212 $routing = ''; 194 213 $save_a_copy = 0; 195 214 if ($_REQUEST['routing'] == 'routing_standard') { … … 199 218 } else if ($_REQUEST['routing'] == 'routing_forwarded') { 200 219 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')); 202 222 return $this->modifyAccount(); 203 223 } else { … … 214 234 $vacation = 0; 215 235 if (isset($_REQUEST['vacation']) && $_REQUEST['vacation'] == 1) { 216 $vacation = 1;236 $vacation = 1; 217 237 $vacation_subject = $_REQUEST['vacation_subject']; 218 $vacation_body = $_REQUEST['vacation_body'];238 $vacation_body = $_REQUEST['vacation_body']; 219 239 } 220 240 221 241 // Are we deleting a vacation message? 222 if ($vacation == 0 && $def aultsOrig['vacation'] == ' checked') {242 if ($vacation == 0 && $defs['vacation'] == ' checked') { 223 243 // Kill old message 224 244 $this->user->rmDir($this->domain, $account_info['name'], 'vacation'); … … 235 255 236 256 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 } 238 260 $vacation_dir = $account_info['user_dir'] . '/vacation'; 261 239 262 $dot_qmail_contents .= '| ' . $this->user->vpopmailRobotProgram; 240 263 $dot_qmail_contents .= ' ' . $this->user->vpopmailRobotTime; … … 247 270 $contents = explode("\n", $dot_qmail_contents); 248 271 // 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); 250 274 251 275 // Add vacation files 252 276 if ($vacation == 1) { 253 $vcontents = "From: " . $account_info['name'] . "@{$this->domain}\n"; 277 $vcontents = "From: " . $account_info['name'] . "@{$this->domain}"; 278 $vcontents .= "\n"; 254 279 $vcontents .= "Subject: $vacation_subject\n\n"; 255 280 $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'; 259 284 // Delete existing file 260 285 try { … … 263 288 } 264 289 // 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); 266 292 // 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); 268 295 } 269 296 } else { 270 297 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); 272 300 } catch (Net_Vpopmaild_Exception $e) { 273 301 } 274 302 } 275 303 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"; 277 306 header("Location: $url"); 278 return $this->modifyAccount();307 return; 279 308 } 280 309 trunk/Framework/Module/Accounts/Templates/Default/modifyAccount.tpl
r223 r257 1 1 <div class="boxtop"></div> 2 2 <div class="box"> 3 <b>{ $LANG_Modify_Account} {$account}@{$domain}</b>3 <b>{t}Modify Account{/t} {$account}@{$domain}</b> 4 4 </div> 5 5 <div class="boxbottom"></div> … … 73 73 </form> 74 74 75 {if $isDomainAdmin}<a href="./?module=Domains&class=Menu&domain={$domain}"><br /><b>{ $LANG_Main_Menu}</b>{/if}75 {if $isDomainAdmin}<a href="./?module=Domains&class=Menu&domain={$domain}"><br /><b>{t}Main Menu{/t}</b>{/if} 76 76 77 77 </div>
