Changeset 193

Show
Ignore:
Timestamp:
07/11/07 19:21:21 (2 years ago)
Author:
shupp
Message:

update modules to use ToasterAdmin?_Common, more toasterAdmin to ToasterAdmin? changes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Framework/Module/Accounts.php

    r186 r193  
    2222 * @license GPL 2.0  {@link http://www.gnu.org/licenses/gpl.txt} 
    2323 */ 
    24 class Framework_Module_Accounts extends Framework_Auth_User 
     24class Framework_Module_Accounts extends ToasterAdmin_Common 
    2525{ 
    26  
    27     /** 
    28      *  $domain is set from $_REQUEST['domain']; 
    29      */ 
    30     public $domain = null; 
    3126 
    3227    /** 
     
    4035    function __construct() { 
    4136        parent::__construct(); 
    42         // Make sure domain was supplied 
    43         if (!isset($_REQUEST['domain'])) 
    44             throw new Framework_Exception(_("Error: no domain supplied")); 
    45         $this->domain = $_REQUEST['domain']; 
    46         $this->setData('domain', $this->domain); 
    47         $this->setData('domain_url', htmlspecialchars('./?module=Domains&event=domainMenu&domain=' . $this->domain)); 
    48     } 
    49  
    50     /** 
    51      * checkPrivileges  
    52      *  
    53      * @access protected 
    54      * @return void 
    55      */ 
    56     protected function checkPrivileges() { 
    57         // Verify that they have access to this domain 
    58         if (!$this->user->isDomainAdmin($this->domain)) { 
    59             return PEAR::raiseError(_('Error: you do not have edit privileges on domain ') . $this->domain); 
    60         } 
    61     } 
    62  
     37        if (($result = $this->noDomainSupplied())) { 
     38            return $result; 
     39        } 
     40    } 
    6341 
    6442    /** 
     
    7452    function listAccounts() { 
    7553 
    76         $privs = $this->checkPrivileges(); 
    77         if (PEAR::isError($privs)) return privs; 
     54        if (($result = $this->noDomainPrivs())) { 
     55            return $result; 
     56        } 
    7857 
    7958        // Pagintation setup 
    8059        $total = $this->user->userCount($this->domain); 
    81         if (PEAR::isError($total)) return $total; 
     60        if (PEAR::isError($total)) { 
     61            return $total; 
     62        } 
    8263        $this->paginate($total); 
    8364 
     
    123104    function addAccount() { 
    124105 
    125         $privs = $this->checkPrivileges(); 
    126         if (PEAR::isError($privs)) return privs; 
     106        if (($result = $this->noDomainPrivs())) { 
     107            return $result; 
     108        } 
    127109 
    128110        $form = $this->addAccountForm(); 
     
    134116    } 
    135117 
    136     static function sameDomain ($name, $value) { 
    137         $emailArray = explode('@', $value); 
    138         if ($emailArray[1] == $this->domain) { 
    139             return true; 
    140         } else { 
    141             return false; 
    142         } 
    143     } 
    144  
    145118    function addAccountNow() { 
    146119 
    147         $privs = $this->checkPrivileges(); 
    148         if (PEAR::isError($privs)) return privs; 
     120        if (($result = $this->noDomainPrivs())) { 
     121            return $result; 
     122        } 
    149123 
    150124        $form = $this->addAccountForm(); 
     
    202176    function delete() { 
    203177 
    204         $privs = $this->checkPrivileges(); 
    205         if (PEAR::isError($privs)) return privs; 
     178        if (($result = $this->noDomainPrivs())) { 
     179            return $result; 
     180        } 
    206181 
    207182        if (!isset($_REQUEST['account'])) { 
     
    221196    function deleteNow() { 
    222197 
    223         $privs = $this->checkPrivileges(); 
    224         if (PEAR::isError($privs)) return privs; 
     198        if (($result = $this->noDomainPrivileges())) { 
     199            return $result; 
     200        } 
    225201 
    226202        if (!isset($_REQUEST['account'])) { 
     
    244220    function cancelDelete() { 
    245221 
    246         $privs = $this->checkPrivileges(); 
    247         if (PEAR::isError($privs)) return privs; 
     222        if (($result = $this->noDomainPrivileges())) { 
     223            return $result; 
     224        } 
    248225 
    249226        $this->setData('message', _("Delete Canceled")); 
  • trunk/Framework/Module/Domains.php

    r184 r193  
    2525 * 
    2626 */ 
    27 class Framework_Module_Domains extends Framework_Auth_User 
     27class Framework_Module_Domains extends ToasterAdmin_Common 
    2828{ 
    2929    /** 
  • trunk/Framework/Module/Forwards.php

    r184 r193  
    2222 * @license GPL 2.0  {@link http://www.gnu.org/licenses/gpl.txt} 
    2323 */ 
    24 class Framework_Module_Forwards extends Framework_Auth_User 
     24class Framework_Module_Forwards extends ToasterAdmin_Common 
    2525{ 
    26  
    27     /** 
    28      *  $domain is set from $_REQUEST['domain']; 
    29      */ 
    30     public $domain = null; 
    3126 
    3227    /** 
     
    4136        parent::__construct(); 
    4237        // Make sure doamin was supplied 
    43         if (!isset($_REQUEST['domain']))  
    44             throw new Framework_Exception(_("Error: no domain supplied")); 
    45         $this->domain = $_REQUEST['domain']; 
    46         $this->setData('domain', $this->domain); 
    47         $this->setData('domain_url', htmlspecialchars('./?module=Domains&event=domainMenu&domain=' . $this->domain)); 
     38        if (($result = $this->noDomainSupplied())) { 
     39            return $result; 
     40        } 
     41        // Make sure they are authorized 
     42        if (($result = $this->noDomainPrivileges())) { 
     43            return $result; 
     44        } 
    4845    } 
    4946 
  • trunk/Framework/Module/MailingLists.php

    r190 r193  
    2121 * @license GPL 2.0  {@link http://www.gnu.org/licenses/gpl.txt} 
    2222 */ 
    23 class Framework_Module_MailingLists extends Framwork_Auth_User 
     23class Framework_Module_MailingLists extends ToasterAdmin_Common 
    2424{ 
    2525    public function __construct() { 
  • trunk/Framework/Module/Responders.php

    r184 r193  
    44 * Responders Module 
    55 *  
    6  * @uses Framework_Auth_User 
     6 * @uses ToasterAdmin_Common 
    77 * @package ToasterAdmin 
    88 * @copyright 2006-2007 Bill Shupp 
     
    1414 * Framework_Module_Responders  
    1515 *  
    16  * @uses Framework_Auth_User 
     16 * @uses ToasterAdmin_Common 
    1717 * @package ToasterAdmin 
    1818 * @copyright 2006-2007 Bill Shupp 
     
    2020 * @license GPL 2.0  {@link http://www.gnu.org/licenses/gpl.txt} 
    2121 */ 
    22 class Framework_Module_Responders extends Framework_Auth_User 
     22class Framework_Module_Responders extends ToasterAdmin_Common 
    2323{ 
    24  
    25     /** 
    26      *  $domain is set from $_REQUEST['domain']; 
    27      */ 
    28     public $domain = null; 
    2924 
    3025    /** 
     
    3833    function __construct() { 
    3934        parent::__construct(); 
     35        // Make they have access 
     36        if (($result = $this->noDomainPrivileges())) { 
     37            return $result; 
     38        } 
    4039        // Make sure doamin was supplied 
    41         if (!isset($_REQUEST['domain'])) 
    42             throw new Framework_Exception(_("Error: no domain supplied")); 
    43         $this->domain = $_REQUEST['domain']; 
    44         $this->setData('domain', $this->domain); 
    45         $this->setData('domain_url', htmlspecialchars('./?module=Domains&event=domainMenu&domain=' . $this->domain)); 
    46     } 
    47  
    48     /** 
    49      * checkPrivileges  
    50      *  
    51      * @access protected 
    52      * @return void 
    53      */ 
    54     protected function checkPrivileges() { 
    55         // Verify that they have access to this domain 
    56         if (!$this->user->isDomainAdmin($this->domain)) { 
    57             return PEAR::raiseError(_('Error: you do not have edit privileges on domain ') . $this->domain); 
    58         } 
    59     } 
    60  
    61     /** 
    62      * sameDomain  
    63      *  
    64      * @param mixed $name  
    65      * @param mixed $value  
    66      * @access public 
    67      * @return bool 
    68      */ 
    69     public function sameDomain ($name, $value) { 
    70         $emailArray = explode('@', $value); 
    71         if ($emailArray[1] == $this->domain) return true; 
    72         return false; 
     40        if (($result = $this->noDomainSupplied())) { 
     41            return $result; 
     42        } 
    7343    } 
    7444 
     
    246216            return PEAR::raiseError(_("Error: no Auto-Responder supplied")); 
    247217        } 
    248         // Check privs 
    249         if (!$this->user->isUserAdmin($account, $this->domain)) { 
    250             return PEAR::raiseError(_('Error: you do not have edit privileges on domain ') . $this->domain); 
    251         } 
    252218        $array = explode('@', $_REQUEST['autoresponder']); 
    253219        // Setup defaults 
     
    274240        if (!isset($_REQUEST['autoresponder'])) { 
    275241            return PEAR::raiseError(_("Error: no Auto-Responder supplied")); 
    276         } 
    277         // Check privs 
    278         if (!$this->user->isUserAdmin($account, $this->domain)) { 
    279             return PEAR::raiseError(_('Error: you do not have edit privileges on domain ') . $this->domain); 
    280242        } 
    281243        $array = explode('@', $_REQUEST['autoresponder']); 
  • trunk/Framework/Object/Web.php

    r163 r193  
    5656        parent::__construct(); 
    5757        $neg =& new Framework_User_Lang; 
    58         $this->user = Framework_User_toasterAdmin::singleton(); 
     58        $this->user = Framework_User::singleton(); 
    5959        $this->session = Framework_Session::singleton(); 
    60     } 
    61  
    62     public function paginate($total) { 
    63         $this->setData('total', $total); 
    64         $this->setData('limit', (integer)Framework::$site->config->maxPerPage); 
    65         if (isset($_REQUEST['start']) && !ereg('[^0-9]', $_REQUEST['start'])) { 
    66             if ($_REQUEST['start'] == 0) { 
    67                 $start = 1; 
    68             } else { 
    69                 $start = $_REQUEST['start']; 
    70             } 
    71         } 
    72         if (!isset($start)) $start = 1; 
    73         $this->setData('start', $start); 
    74         $this->setData('currentPage', ceil($this->data['start'] / $this->data['limit'])); 
    75         $this->setData('totalPages', ceil($this->data['total'] / $this->data['limit'])); 
    7660    } 
    7761} 
  • trunk/Framework/Site/Default/config.xml

    r177 r193  
    1414    <logFile>/tmp/framework.log</logFile> 
    1515    <user> 
    16         <userClass>toasterAdmin</userClass> 
     16        <userClass>ToasterAdmin</userClass> 
    1717        <userLocaleDir>Framework/Site/Default/locale</userLocaleDir> 
    1818    </user> 
  • trunk/ToasterAdmin/Common.php

    r192 r193  
    11<?php 
    22 
    3 class ToasterAdmin_Common extends Framework_User_ToasterAdmin 
     3abstract class ToasterAdmin_Common extends Framework_Auth_User 
    44{ 
    55 
     
    7878    } 
    7979 
     80    /** 
     81     * sameDomain  
     82     *  
     83     * @param mixed $name  
     84     * @param mixed $value  
     85     * @static 
     86     * @access public 
     87     * @return void 
     88     */ 
     89    static public function sameDomain ($name, $value) { 
     90        $emailArray = explode('@', $value); 
     91        if ($emailArray[1] == $this->domain) return true; 
     92        return false; 
     93    } 
     94 
    8095} 
    8196?> 
    82