Changeset 215
- Timestamp:
- 12/08/07 22:06:28 (1 year ago)
- Files:
-
- trunk/Framework/Module/Domains.php (modified) (11 diffs)
- trunk/Framework/Module/Domains/Menu.php (added)
- trunk/Framework/Module/Home.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Framework/Module/Domains.php
r210 r215 1 1 <?php 2 3 2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 4 3 5 4 /** 6 * Framework_Module_Domains 7 * 5 * Framework_Module_Domains 6 * 8 7 * This module is for viewing and editing vpopmail domains 9 * 10 * @author Bill Shupp <hostmaster@shupp.org> 11 * @copyright Bill Shupp 2006-2007 12 * @package ToasterAdmin 13 * @version 1.0 14 * @filesource 8 * 9 * @uses ToasterAdmin_Auth_System 10 * @package ToasterAdmin 11 * @author Bill Shupp <hostmaster@shupp.org> 12 * @copyright 2007 Bill Shupp 13 * @license GPL 2.0 {@link http://www.gnu.org/licenses/gpl.txt} 14 * @link http://trac.merchbox.com/trac/toasteradmin 15 15 */ 16 16 17 17 18 /** 18 * Framework_Module_Domains 19 * 19 * Framework_Module_Domains 20 * 20 21 * This module is for viewing and editing vpopmail domains 21 * 22 * @author Bill Shupp <hostmaster@shupp.org> 23 * @package ToasterAdmin 24 * @version 1.0 25 * 22 * 23 * @uses ToasterAdmin_Auth_System 24 * @package ToasterAdmin 25 * @author Bill Shupp <hostmaster@shupp.org> 26 * @copyright 2007 Bill Shupp 27 * @license GPL 2.0 {@link http://www.gnu.org/licenses/gpl.txt} 28 * @link http://trac.merchbox.com/trac/toasteradmin 26 29 */ 27 class Framework_Module_Domains extends ToasterAdmin_ Common30 class Framework_Module_Domains extends ToasterAdmin_Auth_System 28 31 { 29 32 30 33 /** 31 34 * __default 35 * 36 * Run listDomains() 32 37 * 33 38 * @access public … … 42 47 * listDomains 43 48 * 49 * List Domains 50 * 44 51 * @access public 45 52 * @return void … … 47 54 public function listDomains() 48 55 { 49 if (!$this->user->isSysAdmin()) {50 throw new Framework_Exception (_('Error: you do not have list domain privileges'));51 }52 53 56 // Pagination setup 54 57 $total = $this->user->domainCount(); … … 56 59 57 60 // Build domain list 58 $domain _array = $this->user->listDomains($this->data['currentPage'],$this->data['limit']);61 $domainArray = $this->user->listDomains($this->data['currentPage'],$this->data['limit']); 59 62 $domains = array(); 60 63 $count = 0; 61 while (list($key,$val) = each($domain _array)) {64 while (list($key,$val) = each($domainArray)) { 62 65 $domains[$count]['name'] = $key; 63 $domains[$count]['edit_url'] = htmlspecialchars('./?module=Domains& event=domainMenu&domain=' . $key);66 $domains[$count]['edit_url'] = htmlspecialchars('./?module=Domains&class=domainMenu&domain=' . $key); 64 67 $domains[$count]['delete_url'] = htmlspecialchars('./?module=Domains&event=delDomain&domain=' . $key); 65 68 $count++; … … 79 82 } 80 83 81 function domainMenu($domain = null) 82 { 83 // Make sure the domain was supplied 84 if ($domain == null) { 85 if (empty($_REQUEST['domain'])) 86 throw new Framework_Exception (_("Error: no domain supplied")); 87 $domain = $_REQUEST['domain']; 88 } 89 90 if (!$this->user->isDomainAdmin($domain)) { 91 throw new Framework_Exception (_('Error: you do not have edit privileges on domain ') . $domain); 92 } 93 94 if ($this->user->isSysAdmin()) { 95 $this->setData('isSysAdmin', 1); 96 } 97 // Setup URLs 98 $this->setData('domain', $domain); 99 $this->setData('list_accounts_url', htmlspecialchars('./?module=Accounts&domain=' . $this->data['domain'])); 100 $this->setData('list_forwards_url', htmlspecialchars('./?module=Forwards&domain=' . $this->data['domain'])); 101 $this->setData('list_responders_url', htmlspecialchars('./?module=Responders&domain=' . $this->data['domain'])); 102 // $this->setData('list_lists_url', htmlspecialchars('./?module=Lists&domain=' . $this->data['domain'])); 103 104 // Language 105 $this->setData('LANG_Email_Accounts', _('Email Accounts')); 106 $this->setData('LANG_Forwards', _('Forwards')); 107 $this->setData('LANG_Auto_Responders', _('Auto-Responders')); 108 $this->setData('LANG_Mailing_Lists', _('Mailing Lists')); 109 $this->setData('LANG_Main_Menu', _('Main Menu')); 110 111 $this->tplFile = 'domainMenu.tpl'; 112 return; 113 } 114 115 function addDomain() 116 { 117 if (!$this->user->isSysAdmin()) { 118 throw new Framework_Exception (_('Error: you do not have add domain privileges')); 119 } 120 // Create form 121 84 /** 85 * addDomain 86 * 87 * Display add domain form 88 * 89 * @access public 90 * @return void 91 */ 92 public function addDomain() 93 { 122 94 $form = $this->addDomainForm(); 123 95 $this->setData('addDomainForm', $form->toHtml()); … … 127 99 } 128 100 129 function addDomainNow() 130 { 131 if (!$this->user->isSysAdmin()) { 132 throw new Framework_Exception (_('Error: you do not have add domain privileges')); 133 } 134 101 /** 102 * addDomainNow 103 * 104 * Add Domain 105 * 106 * @access public 107 * @return void 108 */ 109 public function addDomainNow() 110 { 135 111 $form = $this->addDomainForm(); 136 112 if (!$form->validate()) { … … 145 121 return $this->addDomain(); 146 122 } 147 $this->setData('message', _("Domain added successfully")); 148 return $this->domainMenu(); 149 } 150 123 header('./?module=Domains&class=Menu&success'); 124 return; 125 } 126 127 /** 128 * addDomainForm 129 * 130 * create add domain form 131 * 132 * @access private 133 * @return void 134 */ 151 135 private function addDomainForm() 152 136 { … … 164 148 } 165 149 166 function delDomain($domain = null) 150 /** 151 * delDomain 152 * 153 * Show delete domain link 154 * 155 * @access public 156 * @return void 157 */ 158 public function delDomain() 167 159 { 168 160 // Make sure the domain was supplied 169 if ($domain == null) { 170 if (empty($_REQUEST['domain'])) 171 throw new Framework_Exception (_("Error: no domain supplied")); 172 $domain = $_REQUEST['domain']; 173 } 174 175 if (!$this->user->isDomainAdmin($domain)) { 176 throw new Framework_Exception (_('Error: you do not have edit privileges on domain ') . $domain); 161 if ($this->domain == null) { 162 throw new Framework_Exception (_("Error: no domain supplied")); 177 163 } 178 164 … … 181 167 $this->setData('LANG_delete', _("delete")); 182 168 183 $this->setData('domain', $_REQUEST['domain']); 184 $this->setData('delete_url', htmlspecialchars("./?module=Domains&event=delDomainNow&domain=" . $domain)); 169 $this->setData('delete_url', htmlspecialchars("./?module=Domains&event=delDomainNow&domain=" . $this->domain)); 185 170 $this->setData('cancel_url', htmlspecialchars("./?module=Domains&event=cancelDelDomain")); 186 171 $this->tplFile = 'domainConfirmDelete.tpl'; … … 188 173 } 189 174 190 function delDomainNow($domain = null) 175 /** 176 * delDomainNow 177 * 178 * Delete domain 179 * 180 * @access public 181 * @return void 182 */ 183 public function delDomainNow() 191 184 { 192 185 // Make sure the domain was supplied 193 if ($domain == null) { 194 if (empty($_REQUEST['domain'])) 195 throw new Framework_Exception (_("Error: no domain supplied")); 196 $domain = $_REQUEST['domain']; 197 } 198 199 if (!$this->user->isDomainAdmin($domain)) { 200 throw new Framework_Exception (_('Error: you do not have edit privileges on domain ') . $domain); 186 if ($this->domain == null) { 187 throw new Framework_Exception (_("Error: no domain supplied")); 201 188 } 202 189 203 190 // Delete domain 204 $result = $this->user->delDomain($domain); 205 if (PEAR::isError($result)) { 206 $this->setData('message', _("Error: ") . $result->getMessage()); 191 try { 192 $result = $this->user->delDomain($this->domain); 193 } catch (Exception $e) { 194 $this->setData('message', _("Error: ") . $e->getMessage()); 207 195 return $this->listDomains(); 208 196 } … … 211 199 } 212 200 201 /** 202 * cancelDelDomain 203 * 204 * Cancel domain deletion 205 * 206 * @access public 207 * @return void 208 */ 213 209 function cancelDelDomain() { 214 210 $this->setData('message', _("Domain deletion canceled")); trunk/Framework/Module/Home.php
r208 r215 37 37 $domain = $this->session->domain; 38 38 if ($this->user->isDomainAdmin($domain)) { 39 header("Location: ./?module=Domains& event=domainMenu&domain=" . urlencode($domain));39 header("Location: ./?module=Domains&class=Menu&domain=" . urlencode($domain)); 40 40 return; 41 41 } else {
