Changeset 270
- Timestamp:
- 04/11/08 00:58:01 (9 months ago)
- Files:
-
- trunk/Framework/Module/Forwards.php (modified) (24 diffs)
- trunk/Framework/Module/Forwards/Templates/Default/addForward.tpl (modified) (2 diffs)
- trunk/Framework/Module/Forwards/Templates/Default/listForwards.tpl (modified) (4 diffs)
- trunk/Framework/Module/Forwards/Templates/Default/modifyForward.tpl (modified) (5 diffs)
- trunk/Framework/Module/Responders.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Framework/Module/Forwards.php
r251 r270 8 8 * This module is for viewing and editing vpopmail forwards 9 9 * 10 * PHP Version 5 10 * PHP Version 5.1.0+ 11 11 * 12 * @uses ToasterAdmin_Auth_Domain 13 * @package ToasterAdmin 14 * @author Bill Shupp <hostmaster@shupp.org> 15 * @copyright 2007 Bill Shupp 16 * @license GPL 2.0 {@link http://www.gnu.org/licenses/gpl.txt} 17 * @link http://trac.merchbox.com/trac/toasteradmin 12 * @uses ToasterAdmin_Auth_Domain 13 * @category Mail 14 * @package ToasterAdmin 15 * @subpackage Module 16 * @author Bill Shupp <hostmaster@shupp.org> 17 * @copyright 2007-2008 Bill Shupp 18 * @license GPL 2.0 {@link http://www.gnu.org/licenses/gpl.txt} 19 * @link http://trac.merchbox.com/trac/toasteradmin 18 20 */ 19 21 … … 23 25 * This module is for viewing and editing vpopmail forwards 24 26 * 25 * @uses ToasterAdmin_Auth_Domain 26 * @package ToasterAdmin 27 * @author Bill Shupp <hostmaster@shupp.org> 28 * @copyright 2007 Bill Shupp 29 * @license GPL 2.0 {@link http://www.gnu.org/licenses/gpl.txt} 30 * @link http://trac.merchbox.com/trac/toasteradmin 27 * @uses ToasterAdmin_Auth_Domain 28 * @category Mail 29 * @package ToasterAdmin 30 * @subpackage Module 31 * @author Bill Shupp <hostmaster@shupp.org> 32 * @copyright 2007-2008 Bill Shupp 33 * @license GPL 2.0 {@link http://www.gnu.org/licenses/gpl.txt} 34 * @link http://trac.merchbox.com/trac/toasteradmin 31 35 */ 32 36 class Framework_Module_Forwards extends ToasterAdmin_Auth_Domain … … 41 45 * @return void 42 46 */ 43 public function __construct() { 47 public function __construct() 48 { 44 49 parent::__construct(); 45 50 $this->noDomainSupplied(); … … 54 59 * @return void 55 60 */ 56 public function __default() { 61 public function __default() 62 { 57 63 return $this->listForwards(); 58 64 } … … 66 72 * @return void 67 73 */ 68 public function listForwards() {69 74 public function listForwards() 75 { 70 76 // Pagintation setup 71 77 $full_alias_array = $this->user->listAlias($this->domain); 72 78 // Format the valias outpt from vpopmaild 73 $ aliasesParsed = $this->user->parseAliases($full_alias_array, 'forwards');74 $total = count($aliasesParsed);79 $parsed = $this->user->parseAliases($full_alias_array, 'forwards'); 80 $total = count($parsed); 75 81 $this->paginate($total); 76 82 77 83 // List Accounts 78 $alias_array = $this->user->paginateArray($ aliasesParsed, $this->data['currentPage'], $this->data['limit']);79 84 $alias_array = $this->user->paginateArray($parsed, 85 $this->data['currentPage'], $this->data['limit']); 80 86 if (count($alias_array) == 0) { 81 87 $this->setData('message', _("No Forwards. Care to add one?")); … … 83 89 } 84 90 85 $aliases = array(); 86 $count = 0; 87 while (list($key,$val) = each($alias_array)) { 88 $forwardName = ereg_replace('@.*$', '', $key); 89 $aliases[$count]['name'] = $forwardName; 90 $aliases[$count]['contents'] = $this->user->getAliasContents($val); 91 $aliases[$count]['edit_url'] = htmlspecialchars("./?module=Forwards&domain={$this->domain}&forward=$forwardName&event=modifyForward"); 92 $aliases[$count]['delete_url'] = htmlspecialchars("./?module=Forwards&domain={$this->domain}&forward=$forwardName&event=deleteForward"); 93 $count++; 94 } 95 $this->setData('forwards', $aliases); 96 97 $this->setData('add_forward_url', htmlspecialchars("./?module=Forwards&event=addForward&domain={$this->domain}")); 98 99 $this->setData('LANG_Forward', _("Forward")); 100 $this->setData('LANG_Recipient', _("Recipient")); 101 $this->setData('LANG_Edit', _("Edit")); 102 $this->setData('LANG_Delete', _("Delete")); 103 104 $this->setData('LANG_Forwards_for_domain', _("Forwards for domain")); 105 $this->setData('LANG_Forwards_Page', _("Forwards Page")); 106 $this->setData('LANG_of', _("of")); 107 $this->setData('LANG_Add_Forward', _("Add Forward")); 108 $this->setData('LANG_edit', _("edit")); 109 $this->setData('LANG_delete', _("delete")); 110 $this->setData('LANG_Domain_Menu', _("Domain Menu")); 91 $a = array(); 92 $c = 0; 93 foreach ($alias_array as $key => $val) { 94 $fn = ereg_replace('@.*$', '', $key); 95 $eurl = "./?module=Forwards&domain={$this->domain}"; 96 $eurl .= "&forward=$fn&event=modifyForward"; 97 $durl = "./?module=Forwards&domain={$this->domain}"; 98 $durl .= "&forward=$fn&event=deleteForward"; 99 100 $a[$c]['name'] = $fn; 101 $a[$c]['contents'] = $this->user->getAliasContents($val); 102 $a[$c]['edit_url'] = htmlspecialchars($eurl); 103 $a[$c]['delete_url'] = htmlspecialchars($durl); 104 $c++; 105 } 106 $this->setData('forwards', $a); 107 108 $furl = "./?module=Forwards&event=addForward&domain={$this->domain}"; 109 $this->setData('add_forward_url', htmlspecialchars($furl)); 111 110 $this->tplFile = 'listForwards.tpl'; 112 111 } … … 120 119 * @return mixed void on success, PEAR_Error on failure 121 120 */ 122 public function addForward() { 123 $form = $this->addForwardForm(); 124 $renderer =& new HTML_QuickForm_Renderer_AssocArray(); 121 public function addForward() 122 { 123 $form = $this->addForwardForm(); 124 $renderer = new HTML_QuickForm_Renderer_AssocArray(); 125 125 $form->accept($renderer); 126 126 $this->setData('form', $renderer->toAssocArray()); … … 134 134 * Create Add Forward Form 135 135 * 136 * @access pr ivate136 * @access protected 137 137 * @return object $form HTML_QuickForm Object 138 138 */ 139 private function addForwardForm() { 140 // Lang 141 $this->setData('LANG_Forward_Name', _("Forward Name")); 142 $this->setData('LANG_Add_Forward', _("Add Forward")); 143 $this->setData('LANG_Domain_Menu', _("Domain Menu")); 144 145 $form = & new HTML_QuickForm('form', 'post', './?module=Forwards&event=addForwardNow'); 146 147 $form->registerRule('validForwardName', 'regex', "/^[a-z0-9]+([_\\.-][a-z0-9]+)*$/i"); 139 protected function addForwardForm() 140 { 141 $form = new HTML_QuickForm('form', 'post', 142 './?module=Forwards&event=addForwardNow'); 143 144 $form->registerRule('validForwardName', 'regex', 145 "/^[a-z0-9]+([_\\.-][a-z0-9]+)*$/i"); 148 146 149 147 $form->addElement('hidden', 'domain', $this->domain); … … 152 150 $form->addElement('submit', 'submit', _("Add")); 153 151 154 $form->addRule('forward', _("Forward is required"), 'required', null, 'client'); 155 $form->addRule('forward', _("Forward name is invalid (should be forward name only, not full email address"), 'validForwardName'); 156 $form->addRule('destination', _("Destination is required"), 'required', null, 'client'); 157 $form->addRule('destination', _("Destination must be a full email address"), 'email', null, 'client'); 152 $form->addRule('forward', 153 _("Forward is required"), 'required', null, 'client'); 154 $form->addRule('forward', 155 _("Forward name is invalid (should be forward name only, not full email address"), 'validForwardName'); 156 $form->addRule('destination', 157 _("Destination is required"), 'required', null, 'client'); 158 $form->addRule('destination', 159 _("Destination must be a full email address"), 'email', null, 'client'); 158 160 159 161 return $form; … … 168 170 * @return mixed PEAR_Error on failure, listForwards() on success 169 171 */ 170 public function addForwardNow() { 172 public function addForwardNow() 173 { 171 174 $form = $this->addForwardForm(); 172 175 if (!$form->validate()) { … … 212 215 213 216 $contents = array('&' . $this->data['destination']); 214 $result = $this->user->writeFile($contents, $this->domain, '', $file);217 $result = $this->user->writeFile($contents, $this->domain, '', $file); 215 218 return true; 216 219 } … … 228 231 $file = '.qmail-' . $this->data['forward']; 229 232 // Let exception bubble up 230 $contents = $this->user->readFile($this->domain, '', $file);233 $contents = $this->user->readFile($this->domain, '', $file); 231 234 $destination = '&' . $this->data['destination']; 232 235 // Now build a new array without that forward … … 245 248 * @return mixed true on success, PEAR_Error on failure 246 249 */ 247 protected function deleteForwardLine() { 248 $contents = $this->user->readFile($this->domain, '', ".qmail-" . $this->data['forward']); 250 protected function deleteForwardLine() 251 { 252 $contents = $this->user->readFile($this->domain, '', 253 ".qmail-" . $this->data['forward']); 249 254 250 255 // Now build a new array without that forward … … 258 263 } 259 264 $newContents = array(); 260 $count = 1;265 $count = 1; 261 266 while (list($key, $val) = each($contents)) { 262 267 if ($val == $this->data['line']) continue; … … 264 269 $count++; 265 270 } 266 $result = $this->user->writeFile($newContents, $this->domain, '', ".qmail-" . $this->data['forward']); 271 $result = $this->user->writeFile($newContents, 272 $this->domain, '', ".qmail-" . $this->data['forward']); 267 273 return true; 268 274 } … … 275 281 * @return mixed void on success, PEAR_Error on failure 276 282 */ 277 function modifyForward() { 283 function modifyForward() 284 { 278 285 // Make sure forward was supplied 279 286 if (!isset($_REQUEST['forward'])) { … … 291 298 $this->setData('forward_contents', $this->returnForwardArray($contents)); 292 299 293 $form = $this->modifyForwardForm();294 $renderer = &new HTML_QuickForm_Renderer_AssocArray();300 $form = $this->modifyForwardForm(); 301 $renderer = new HTML_QuickForm_Renderer_AssocArray(); 295 302 $form->accept($renderer); 296 303 $this->setData('form', $renderer->toAssocArray()); … … 301 308 * returnForwardArray 302 309 * 303 * @param mixed $contents 310 * @param mixed $contents dot-qmail file contents 311 * 304 312 * @access protected 305 313 * @return array $forward_array 306 314 */ 307 protected function returnForwardArray($contents) { 308 $count = 0; 309 $forward_array = array(); 310 while (list($key,$val) = each($contents)) { 311 $forward_array[$count]['destination'] = $this->user->displayForwardLine($val); 312 $forward_array[$count]['delete_url'] = htmlspecialchars("./?module=Forwards&event=deleteForwardLineNow&domain={$this->domain}&forward=" . $_REQUEST['forward'] . "&line=" . urlencode($val)); 313 $count++; 314 } 315 return $forward_array; 315 protected function returnForwardArray($contents) 316 { 317 $c = 0; 318 $a = array(); 319 foreach ($contents as $key => $val) { 320 $durl = "./?module=Forwards&event=deleteForwardLineNow"; 321 $durl .= "&domain={$this->domain}&forward=" . $_REQUEST['forward']; 322 $durl .= "&line=" . urlencode($val); 323 324 $a[$c]['destination'] = $this->user->displayForwardLine($val); 325 $a[$c]['delete_url'] = htmlspecialchars($durl); 326 $c++; 327 } 328 return $a; 316 329 } 317 330 … … 322 335 * @return mixed void on success, PEAR_Error on failure 323 336 */ 324 function modifyForwardNow() { 337 function modifyForwardNow() 338 { 325 339 $forward = ereg_replace('^.qmail-', '', $_REQUEST['forward']); 326 340 $this->setData('forward', $forward); … … 355 369 * modifyForwardForm 356 370 * 357 * @access public 358 * @return object $form 359 */ 360 function modifyForwardForm() { 361 // Lang 362 $this->setData('LANG_Modify_Forward', _("Modify Forward")); 363 $this->setData('LANG_Destination', _("Destination")); 364 $this->setData('LANG_Delete', _("Delete")); 365 $this->setData('LANG_delete', _("delete")); 366 $this->setData('LANG_Forwards_Menu', _("Forwards Menu")); 367 $this->setData('LANG_Add_Destination', _("Add Destination")); 368 $this->setData('forwards_url', htmlspecialchars("./?module=Forwards&domain={$this->domain}")); 371 * Display modify forward form 372 * 373 * @access public 374 * @return object $form HTML_QuickForm object 375 */ 376 function modifyForwardForm() 377 { 378 $this->setData('forwards_url', 379 htmlspecialchars("./?module=Forwards&domain={$this->domain}")); 369 380 370 381 // Form 371 $form = & new HTML_QuickForm('form', 'post', './?module=Forwards&event=modifyForwardNow'); 382 $form = new HTML_QuickForm('form', 'post', 383 './?module=Forwards&event=modifyForwardNow'); 372 384 373 385 $form->addElement('hidden', 'domain', $this->domain); … … 377 389 378 390 $form->addRule('forward', _("Forward is required"), 'required'); 379 $form->addRule('destination', _("Destination is required"), 'required', null, 'client'); 380 $form->addRule('destination', _("Destination must be a full email address"), 'email', null, 'client'); 391 $form->addRule('destination', 392 _("Destination is required"), 'required', null, 'client'); 393 $form->addRule('destination', 394 _("Destination must be a full email address"), 'email', null, 'client'); 381 395 382 396 return $form; … … 389 403 * @return mixed result of modifyForward on success, PEAR_Error on failure 390 404 */ 391 function deleteForwardLineNow() { 405 function deleteForwardLineNow() 406 { 392 407 // Make sure forward was supplied 393 408 if (!isset($_REQUEST['forward'])) { … … 430 445 * @return mixed listForwards() on success, PEAR_Error on failure 431 446 */ 432 protected function deleteForward() { 447 protected function deleteForward() 448 { 433 449 // Make sure forward was supplied 434 450 if (!isset($_REQUEST['forward'])) { … … 436 452 return $this->listForwards(); 437 453 } 438 $forward = ereg_replace('^.qmail-', '', $_REQUEST['forward']);454 $forward = ereg_replace('^.qmail-', '', $_REQUEST['forward']); 439 455 $contents = $this->user->readFile($this->domain, '', ".qmail-" . $forward); 440 $result = $this->user->rmFile($this->domain, '', '.qmail-' . $forward);456 $result = $this->user->rmFile($this->domain, '', '.qmail-' . $forward); 441 457 $this->setData('message', _("Forward Deleted Successfully")); 442 458 return $this->listForwards(); trunk/Framework/Module/Forwards/Templates/Default/addForward.tpl
r81 r270 1 1 <div class="boxtop"></div> 2 <div class="box">{ $LANG_Add_Forward}</div>2 <div class="box">{t}Add Forward{/t}</div> 3 3 <div class="boxbottom"></div> 4 4 … … 36 36 <br /> 37 37 <br /> 38 <a href="{$domain_url}">{ $LANG_Domain_Menu}</a>38 <a href="{$domain_url}">{t}Domain Menu{/t}</a> 39 39 40 40 trunk/Framework/Module/Forwards/Templates/Default/listForwards.tpl
r81 r270 1 1 <div class="boxtop"></div> 2 2 <div class="box"> 3 <strong>{ $LANG_Forwards_for_domain} {$domain}</strong>3 <strong>{t}Forwards for domain{/t} {$domain}</strong> 4 4 </div> 5 5 <div class="boxbottom"></div> … … 7 7 <div class="boxtopDomains"> 8 8 <div class="boxtopDomainscontent"> 9 <h1>{ $LANG_Forwards_Page} {$currentPage} {$LANG_of} {$totalPages}</h1>9 <h1>{t}Forwards Page:{/t} {$currentPage} {t}of{/t} {$totalPages}</h1> 10 10 {framework_pager start=$start limit=$limit total=$total} 11 <a href="{$add_forward_url}">{ $LANG_Add_Forward}</a>11 <a href="{$add_forward_url}">{t}Add Forward{/t}</a> 12 12 </div> 13 13 </div> … … 16 16 <table border="0" cellspacing="0" cellpadding="4"> 17 17 <tr> 18 <td class="title">{ $LANG_Forward}</td>19 <td class="title" wrap>{ $LANG_Recipient}</td>20 <td class="title">{ $LANG_Edit}</td>21 <td class="title">{ $LANG_Delete}</td>18 <td class="title">{t}Forward{/t}</td> 19 <td class="title" wrap>{t}Recipient{/t}</td> 20 <td class="title">{t}Edit{/t}</td> 21 <td class="title">{t}Delete{/t}</td> 22 22 </tr> 23 23 {foreach from=$forwards item=forward} … … 25 25 <td>{$forward.name}</td> 26 26 <td>{$forward.contents}</td> 27 <td align="center"><a href="{$forward.edit_url}">{ $LANG_edit}</a></td>28 <td align="center"><a href="{$forward.delete_url}">{ $LANG_delete}</a></td>27 <td align="center"><a href="{$forward.edit_url}">{t}edit{/t}</a></td> 28 <td align="center"><a href="{$forward.delete_url}">{t}delete{/t}</a></td> 29 29 </tr> 30 30 {/foreach} 31 31 </table> 32 <a href="{$domain_url}">{ $LANG_Domain_Menu}</a>32 <a href="{$domain_url}">{t}Domain Menu{/t}</a> 33 33 </div> 34 34 <div class="boxbottom"></div> trunk/Framework/Module/Forwards/Templates/Default/modifyForward.tpl
r81 r270 1 1 <div class="boxtop"></div> 2 <div class="box"><b>{ $LANG_Modify_Forward} "{$forward}@{$domain}"</b></div>2 <div class="box"><b>{t}Modify Forward{/t} "{$forward}@{$domain}"</b></div> 3 3 <div class="boxbottom"></div> 4 4 … … 7 7 <table border="0" cellspacing="0" cellpadding="3"> 8 8 <tr> 9 <td>{ $LANG_Destination}</td>10 <td>{ $LANG_Delete}</td>9 <td>{t}Destination{/t}</td> 10 <td>{t}Delete{/t}</td> 11 11 </tr> 12 12 … … 14 14 <tr> 15 15 <td>{$line.destination}</td> 16 <td align="center"><a href="{$line.delete_url}"><img src="images/trash.png" border="0" alt="{ $LANG_delete}" /></a></td>16 <td align="center"><a href="{$line.delete_url}"><img src="images/trash.png" border="0" alt="{t}delete{/t}" /></a></td> 17 17 </tr> 18 18 {/foreach} … … 26 26 <hr> 27 27 <div> 28 <b>{ $LANG_Add_Destination}</b>28 <b>{t}Add Destination{/t}</b> 29 29 <table border="0"> 30 30 … … 45 45 </div> 46 46 </form> 47 <a href="{$forwards_url}">{ $LANG_Forwards_Menu}</a>47 <a href="{$forwards_url}">{t}Forwards Menu{/t}</a> 48 48 </div> 49 49 <div class="boxbottom"></div> trunk/Framework/Module/Responders.php
r265 r270 93 93 $c++; 94 94 } 95 $aurl = "./?module=Responders&event=addResponder&domain={$this->domain}";95 $aurl = "./?module=Responders&event=addResponder&domain={$this->domain}"; 96 96 $this->setData('add_url', htmlspecialchars($aurl)); 97 97 $this->setData('autoresponders', $a);
