Changeset 253
- Timestamp:
- 04/09/08 23:50:33 (9 months ago)
- Files:
-
- trunk/Framework/Module/Accounts.php (modified) (12 diffs)
- trunk/Framework/Module/Accounts/Templates/Default/accountConfirmDelete.tpl (modified) (1 diff)
- trunk/Framework/Module/Accounts/Templates/Default/addAccount.tpl (modified) (2 diffs)
- trunk/Framework/Module/Accounts/Templates/Default/listAccounts.tpl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Framework/Module/Accounts.php
r245 r253 6 6 * This module is for viewing and editing vpopmail accounts 7 7 * 8 * PHP Version 5.1.0+ 9 * 10 * @category Mail 8 11 * @package ToasterAdmin 9 12 * @uses ToasterAdmin_Auth_Domain 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 * This module is for viewing and editing vpopmail accounts 20 23 * 24 * @category Mail 21 25 * @package ToasterAdmin 22 26 * @uses ToasterAdmin_Auth_Domain 23 27 * @author Bill Shupp <hostmaster@shupp.org> 24 * @copyright 2007 Bill Shupp28 * @copyright 2007-2008 Bill Shupp 25 29 * @license GPL 2.0 {@link http://www.gnu.org/licenses/gpl.txt} 26 30 * @link http://trac.merchbox.com/trac/toasteradmin … … 34 38 * Throw an exception if no domain was supplied 35 39 * 36 * @access protected 37 * @return void 38 */ 39 function __construct() { 40 * @access public 41 * @return void 42 */ 43 public function __construct() 44 { 40 45 parent::__construct(); 41 46 $this->noDomainSupplied(); … … 45 50 * __default 46 51 * 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 { 55 70 // Pagintation setup - let exception bubble up 56 71 $total = $this->user->userCount($this->domain); … … 58 73 59 74 // 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); 88 95 $this->tplFile = 'listAccounts.tpl'; 89 96 return; … … 96 103 * @return void 97 104 */ 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(); 101 109 $form->accept($renderer); 102 110 $this->setData('form', $renderer->toAssocArray()); … … 105 113 } 106 114 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 { 108 125 $form = $this->addAccountForm(); 109 126 if (!$form->validate()) { … … 117 134 $emailArray = explode('@', $_REQUEST['account']); 118 135 try { 119 $result = $this->user->addUser($this->domain, $emailArray[0], $_REQUEST['password']); 136 $result = $this->user->addUser($this->domain, $emailArray[0], 137 $_REQUEST['password']); 120 138 } catch (Net_Vpopmaild_Exception $e) { 121 139 $this->setData('message', _("Error: ") . $e->getMessage()); … … 127 145 } 128 146 // Update gecos 129 $userInfo = $this->user->userInfo($this->domain, $emailArray[0]);147 $userInfo = $this->user->userInfo($this->domain, $emailArray[0]); 130 148 $userInfo['comment'] = $_REQUEST['comment']; 149 131 150 $result = $this->user->modUser($this->domain, $userInfo['name'], $userInfo); 132 151 … … 136 155 } 137 156 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}"); 143 169 $form->setDefaults(array('account' => '@' . $this->domain)); 144 170 … … 150 176 $form->registerRule('sameDomain', 'regex', "/@$this->domain$/i"); 151 177 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'); 157 188 return $form; 158 189 } 159 190 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 { 161 201 if (!isset($_REQUEST['account'])) { 162 202 throw new Framework_Exception (_("Error: no account supplied")); 163 203 } 164 204 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 169 205 $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']); 172 211 $this->tplFile = 'accountConfirmDelete.tpl'; 173 212 } 174 213 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 { 176 224 if (!isset($_REQUEST['account'])) { 177 225 throw new Framework_Exception (_("Error: no account supplied")); … … 188 236 } 189 237 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 { 191 248 $this->setData('message', _("Delete Canceled")); 192 249 $this->listAccounts(); trunk/Framework/Module/Accounts/Templates/Default/accountConfirmDelete.tpl
r76 r253 1 1 <div class="boxtop"></div> 2 2 <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}"? 4 4 <br> 5 <a href="{$cancel_url}">{ $LANG_cancel}</a>   |   <a href="{$delete_now_url}">{$LANG_delete}5 <a href="{$cancel_url}">{t}cancel{/t}</a>   |   <a href="{$delete_now_url}">{t}delete{/t} 6 6 </div> 7 7 <div class="boxbottom"></div> trunk/Framework/Module/Accounts/Templates/Default/addAccount.tpl
r76 r253 1 1 <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> 3 3 <div class="boxbottom"></div> 4 4 … … 32 32 33 33 <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> 35 35 <div class="boxbottom"></div> trunk/Framework/Module/Accounts/Templates/Default/listAccounts.tpl
r76 r253 1 1 <div class="boxtop"></div> 2 2 <div class="box"> 3 { $LANG_Email_Accounts_in_domain} {$domain}3 {t}Email Accounts in domain{/t} {$domain} 4 4 </div> 5 5 <div class="boxbottom"></div> … … 7 7 <div class="boxtopDomains"> 8 8 <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> 10 10 {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> 12 12 </div> 13 13 </div> … … 17 17 <table border="0" cellspacing="0" cellpadding="0" id="datatable"> 18 18 <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> 24 24 </tr> 25 25 … … 29 29 <td>{$account.comment}</td> 30 30 <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> 33 33 </tr> 34 34 {/foreach} 35 35 </table> 36 <center><a href="{$domain_url}">{ $LANG_Domain_Menu}</a></center>36 <center><a href="{$domain_url}">{t}Domain Menu{/t}</a></center> 37 37 </div> 38 38 <div class="boxbottom"></div>
