Changeset 17
- Timestamp:
- 02/08/08 00:57:36 (5 years ago)
- Location:
- trunk/Phergie/Event/Handler
- Files:
-
- 2 added
- 1 modified
-
AdminCommand.php (modified) (4 diffs)
-
Debug.php (added)
-
Users.php (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Phergie/Event/Handler/AdminCommand.php
r16 r17 5 5 */ 6 6 require_once 'Phergie/Event/Handler.php'; 7 8 /** 9 * @see Phergie_Event_Handler_Users 10 */ 11 require_once 'Phergie/Event/Handler/Users.php'; 7 12 8 13 /** … … 29 34 { 30 35 protected $_admins = array(); 36 protected $_adminOps = array(); 31 37 32 38 public function isAdmin(Phergie_Event_Request $event, $__class__ = __CLASS__) 33 39 { 34 40 $class = substr($__class__, 22); 35 if ( $this->_admins[$class] === null) {41 if (!isset($this->_admins[$class])) { 36 42 $this->initialize($class); 37 43 } 38 44 $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 } 39 49 // Try to match mask against admin masks 40 50 foreach ($this->_admins[$class] as $admin) { … … 48 58 protected function initialize($class) 49 59 { 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 50 72 $ini = $this->getIni($class.'.admins'); 51 if (empty($ini))73 if ($ini===null) { 52 74 $ini = $this->getIni('AdminCommand.admins'); 75 } 53 76 $admins = explode(',', $ini); 54 $this->_admins = array();55 77 foreach ($admins as $admin) { 56 78 // Find out which chars are present in the config mask and exclude them from the regex match … … 70 92 ); 71 93 // 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); 73 95 } 74 96 }