Show
Ignore:
Timestamp:
02/07/08 16:17:53 (5 years ago)
Author:
Seldaek
Message:

* change in AdminCommand? to allow plugins extending it to have their own .admins setting

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/Phergie/Event/Handler/AdminCommand.php

    r11 r16  
    2828abstract class Phergie_Event_Handler_AdminCommand extends Phergie_Event_Handler 
    2929{ 
    30         protected $_admins = null; 
     30        protected $_admins = array(); 
    3131 
    32     public function isAdmin(Phergie_Event_Request $event) 
     32    public function isAdmin(Phergie_Event_Request $event, $__class__ = __CLASS__) 
    3333    { 
    34         if ($this->_admins === null) { 
    35                 $this->initialize(); 
     34        $class = substr($__class__, 22); 
     35        if ($this->_admins[$class] === null) { 
     36                $this->initialize($class); 
    3637        } 
    3738        $mask = $event->getNick() .'!'. $event->getUsername() .'@'. $event->getHost(); 
    3839        // Try to match mask against admin masks 
    39         foreach ($this->_admins as $admin) { 
     40        foreach ($this->_admins[$class] as $admin) { 
    4041                if (preg_match('{^'.$admin.'$}', $mask)) { 
    4142                        return true; 
     
    4546    } 
    4647 
    47     protected function initialize() 
     48    protected function initialize($class) 
    4849    { 
    49         $admins = explode(',', $this->getIni('AdminCommand.admins')); 
     50        $ini = $this->getIni($class.'.admins'); 
     51        if(empty($ini)) 
     52                $ini = $this->getIni('AdminCommand.admins'); 
     53        $admins = explode(',', $ini); 
    5054        $this->_admins = array(); 
    5155        foreach ($admins as $admin) {