Changeset 17

Show
Ignore:
Timestamp:
02/08/08 00:57:36 (5 years ago)
Author:
Seldaek
Message:

+ adds Debug (command is 'mem') plugin
+ adds Users (internal static use only) plugin
* bugfix in AdminCommand?
* added .adminOps to AdminCommand? (and child classes)

Location:
trunk/Phergie/Event/Handler
Files:
2 added
1 modified

Legend:

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

    r16 r17  
    55*/ 
    66require_once 'Phergie/Event/Handler.php'; 
     7 
     8/** 
     9* @see Phergie_Event_Handler_Users 
     10*/ 
     11require_once 'Phergie/Event/Handler/Users.php'; 
    712 
    813/** 
     
    2934{ 
    3035        protected $_admins = array(); 
     36        protected $_adminOps = array(); 
    3137 
    3238    public function isAdmin(Phergie_Event_Request $event, $__class__ = __CLASS__) 
    3339    { 
    3440        $class = substr($__class__, 22); 
    35         if ($this->_admins[$class] === null) { 
     41        if (!isset($this->_admins[$class])) { 
    3642                $this->initialize($class); 
    3743        } 
    3844        $mask = $event->getNick() .'!'. $event->getUsername() .'@'. $event->getHost(); 
     45                // Check if is op and ops are admins 
     46                if($this->_adminOps[$class] === true && Phergie_Event_Handler_Users::isOp($event->getNick(), $event->getArgument(0)) === true) { 
     47                        return true; 
     48                } 
    3949        // Try to match mask against admin masks 
    4050        foreach ($this->_admins[$class] as $admin) { 
     
    4858    protected function initialize($class) 
    4959    { 
     60        // Set adminOps values 
     61        $ini = $this->getIni($class.'.adminOps'); 
     62        if ($ini===null) { 
     63                $ini = $this->getIni('AdminCommand.adminOps'); 
     64        } 
     65        if ($ini==='true' || $ini==='1') { 
     66                $this->_adminOps[$class] = true; 
     67        } else { 
     68                $this->_adminOps[$class] = false; 
     69        } 
     70 
     71        // Set admins values 
    5072        $ini = $this->getIni($class.'.admins'); 
    51         if(empty($ini)) 
     73        if ($ini===null) { 
    5274                $ini = $this->getIni('AdminCommand.admins'); 
     75        } 
    5376        $admins = explode(',', $ini); 
    54         $this->_admins = array(); 
    5577        foreach ($admins as $admin) { 
    5678                // Find out which chars are present in the config mask and exclude them from the regex match 
     
    7092                ); 
    7193                // Replace * so that they match correctly in a regex 
    72                 $this->_admins[] = str_replace('*', ($excluded === '' ? '.*' : '[^'.$excluded.']*'), $admin); 
     94                $this->_admins[$class][] = str_replace('*', ($excluded === '' ? '.*' : '[^'.$excluded.']*'), $admin); 
    7395        } 
    7496    }