Changeset 215

Show
Ignore:
Timestamp:
12/08/07 22:06:28 (1 year ago)
Author:
shupp
Message:

* Domains module now extends System auth container
* domainMenu now Framework_Module_Domains_Menu
* Clean up Domains module
* Home now redirects properly with new auth container

Files:

Legend:

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

    r210 r215  
    11<?php 
    2  
    32/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 
    43 
    54/** 
    6  * Framework_Module_Domains 
    7  * 
     5 * Framework_Module_Domains  
     6 *  
    87 * 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 
    1515 */ 
    1616 
     17 
    1718/** 
    18  * Framework_Module_Domains 
    19  * 
     19 * Framework_Module_Domains  
     20 *  
    2021 * 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 
    2629 */ 
    27 class Framework_Module_Domains extends ToasterAdmin_Common 
     30class Framework_Module_Domains extends ToasterAdmin_Auth_System 
    2831{ 
    2932 
    3033    /** 
    3134     * __default 
     35     * 
     36     * Run listDomains() 
    3237     * 
    3338     * @access      public 
     
    4247     * listDomains  
    4348     *  
     49     * List Domains 
     50     *  
    4451     * @access public 
    4552     * @return void 
     
    4754    public function listDomains() 
    4855    { 
    49         if (!$this->user->isSysAdmin()) { 
    50             throw new Framework_Exception (_('Error: you do not have list domain privileges')); 
    51         } 
    52  
    5356        // Pagination setup 
    5457        $total = $this->user->domainCount(); 
     
    5659 
    5760        // 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']); 
    5962        $domains = array(); 
    6063        $count = 0; 
    61         while (list($key,$val) = each($domain_array)) { 
     64        while (list($key,$val) = each($domainArray)) { 
    6265            $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); 
    6467            $domains[$count]['delete_url'] = htmlspecialchars('./?module=Domains&event=delDomain&domain=' . $key); 
    6568            $count++; 
     
    7982    } 
    8083 
    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    { 
    12294        $form = $this->addDomainForm(); 
    12395        $this->setData('addDomainForm', $form->toHtml()); 
     
    12799    } 
    128100 
    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    { 
    135111        $form = $this->addDomainForm(); 
    136112        if (!$form->validate()) { 
     
    145121            return $this->addDomain(); 
    146122        } 
    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     */ 
    151135    private function addDomainForm() 
    152136    { 
     
    164148    } 
    165149 
    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() 
    167159    { 
    168160        // 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")); 
    177163        } 
    178164 
     
    181167        $this->setData('LANG_delete', _("delete")); 
    182168 
    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)); 
    185170        $this->setData('cancel_url', htmlspecialchars("./?module=Domains&event=cancelDelDomain")); 
    186171        $this->tplFile = 'domainConfirmDelete.tpl'; 
     
    188173    } 
    189174 
    190     function delDomainNow($domain = null) 
     175    /** 
     176     * delDomainNow  
     177     *  
     178     * Delete domain 
     179     *  
     180     * @access public 
     181     * @return void 
     182     */ 
     183    public function delDomainNow() 
    191184    { 
    192185        // 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")); 
    201188        } 
    202189 
    203190        // 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()); 
    207195            return $this->listDomains(); 
    208196        } 
     
    211199    } 
    212200 
     201    /** 
     202     * cancelDelDomain  
     203     *  
     204     * Cancel domain deletion 
     205     *  
     206     * @access public 
     207     * @return void 
     208     */ 
    213209    function cancelDelDomain() { 
    214210        $this->setData('message', _("Domain deletion canceled")); 
  • trunk/Framework/Module/Home.php

    r208 r215  
    3737        $domain = $this->session->domain; 
    3838        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)); 
    4040            return; 
    4141        } else {