Changeset 271
- Timestamp:
- 04/11/08 10:55:28 (9 months ago)
- Files:
-
- trunk/ToasterAdmin/Common.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ToasterAdmin/Common.php
r221 r271 1 1 <?php 2 /** 3 * ToasterAdmin_Common 4 * 5 * PHP Version 5.1.0+ 6 * 7 * @uses Framework_Auth_User 8 * @abstract 9 * @category Mail 10 * @package ToasterAdmin 11 * @author Bill Shupp <hostmaster@shupp.org> 12 * @copyright 2008 Bill Shupp 13 * @license GPL 2.0 {@link http://www.gnu.org/licenses/gpl.txt} 14 * @link http://trac.merchbox.com/trac/toasteradmin 15 * @todo Check arguments to sameDomain() - first argument is not used 16 */ 2 17 18 /** 19 * ToasterAdmin_Common 20 * 21 * Common helper functions used by modules. 22 * 23 * @uses Framework_Auth_User 24 * @abstract 25 * @category Mail 26 * @package ToasterAdmin 27 * @author Bill Shupp <hostmaster@shupp.org> 28 * @copyright 2008 Bill Shupp 29 * @license GPL 2.0 {@link http://www.gnu.org/licenses/gpl.txt} 30 * @link http://trac.merchbox.com/trac/toasteradmin 31 */ 3 32 abstract class ToasterAdmin_Common extends Framework_Auth_User 4 33 { … … 20 49 * @return void 21 50 */ 22 public function __construct() { 51 public function __construct() 52 { 23 53 parent::__construct(); 24 54 if (isset($_REQUEST['domain'])) { … … 26 56 } 27 57 $this->setData('domain', $this->domain); 28 $this->setData('domain_url', htmlspecialchars('./?module=Domains&class=Menu&domain=' . $this->domain)); 58 $durl = './?module=Domains&class=Menu&domain=' . $this->domain; 59 $this->setData('domain_url', htmlspecialchars($durl)); 29 60 } 30 61 31 62 32 public function paginate($total) { 63 /** 64 * paginate 65 * 66 * Set pagination data 67 * 68 * @param mixed $total total number of items 69 * 70 * @access public 71 * @return void 72 */ 73 public function paginate($total) 74 { 33 75 $this->setData('total', $total); 34 76 $this->setData('limit', (integer)Framework::$site->config->maxPerPage); 35 77 $start = !empty($_REQUEST['start']) ? (int)$_REQUEST['start'] : 0; 36 78 $this->setData('start', $start); 37 $this->setData('currentPage', ceil($this->data['start'] / $this->data['limit']) + 1); 38 $this->setData('totalPages', ceil($this->data['total'] / $this->data['limit'])); 79 $this->setData('currentPage', 80 ceil($this->data['start'] / $this->data['limit']) + 1); 81 $this->setData('totalPages', 82 ceil($this->data['total'] / $this->data['limit'])); 39 83 } 40 84 … … 45 89 * 46 90 * @access protected 47 * @return mixed PEAR_Error if they do NOT have domain admin privs, false if they do 91 * @throws Framework_Exception on failure 92 * @return void 48 93 */ 49 protected function noDomainPrivs() { 94 protected function noDomainPrivs() 95 { 50 96 // Verify that they have access 51 97 if (!$this->user->isDomainAdmin($this->domain)) { 52 return PEAR::raiseError(_('Error: you do not have edit privileges on domain ') . $this->domain); 98 $message = _('Error: you do not have edit privileges on domain '); 99 throw new Framework_Exception($message . $this->domain); 53 100 } 54 return false;55 101 } 56 102 … … 64 110 * @throws Framework_Exception on failure 65 111 */ 66 protected function noDomainSupplied() { 112 protected function noDomainSupplied() 113 { 67 114 if (is_null($this->domain)) { 68 115 throw new Framework_Exception (_('Error no domain supplied')); … … 73 120 * sameDomain 74 121 * 75 * @param mixed $name 76 * @param mixed $value 122 * Compare email domin to $this->value 123 * 124 * @param mixed $name not sure 125 * @param mixed $value email address 126 * 77 127 * @static 78 128 * @access public 79 129 * @return void 80 130 */ 81 static public function sameDomain ($name, $value) { 131 static public function sameDomain($name, $value) 132 { 82 133 $emailArray = explode('@', $value); 83 134 if ($emailArray[1] == $this->domain) return true; 84 135 return false; 85 136 } 86 87 137 } 88 138 ?>
