Assembla home | Assembla project page
 

Changeset 153

Show
Ignore:
Timestamp:
03/09/08 19:05:45 (9 months ago)
Author:
Slynderdale
Message:

Made mute work per channel and globally instead of just globally. By default, mute <plugin> will mute that plugin for that channel while hostmask admins can specify globally or a certain channel by going mute <plugin> <global|channel>. This requires r142 for the hostmask admin check.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Plugin/Abstract/Base.php

    r147 r153  
    6969     * Flag indicating whether or not the plugin is muted and can output events 
    7070     * 
    71      * @var bool 
     71     * @var array 
    7272     */ 
    73     public $muted = false
     73    public $muted = array()
    7474 
    7575    /** 
     
    505505    public function __call($method, $arguments) 
    506506    { 
    507         if ($this->muted && substr($method, 0, 2) === 'do') { // Silence output calls if the plugin is muted 
     507        // Silence output calls if the plugin is muted for that source or globally 
     508        $source = trim($arguments[0]); 
     509        if (($source && $this->muted[$source] || $this->muted['global']) && substr($method, 0, 2) === 'do') { 
    508510                return false; 
    509511        } 
  • trunk/Phergie/Plugin/Toggle.php

    r142 r153  
    7979        } 
    8080 
    81         public function onDoMute($plugin
     81        public function onDoMute($plugin, $target=''
    8282        { 
    83                 if ($instance = $this->getPlugin($plugin)) { 
    84                         $instance->muted = true; 
    85                         $this->doPrivmsg($this->event->getSource(), 'Muted '.$plugin.'.'); 
    86                 } else { 
    87                         $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' not found, could not mute.'); 
    88                 } 
     83                $target = trim((!empty($target) && $this->fromAdmin(false)) ? $target : $this->event->getSource()); 
     84                if (!empty($target)) { 
     85                if ($instance = $this->getPlugin($plugin)) { 
     86                        $instance->muted[$target] = true; 
     87                        $this->doPrivmsg($this->event->getSource(), 'Muted '.$plugin.' for '.$target.'.'); 
     88                } else { 
     89                        $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' not found, could not mute.'); 
     90                } 
     91            } 
    8992        } 
    9093 
    91         public function onDoUnmute($plugin
     94        public function onDoUnmute($plugin, $target=''
    9295        { 
    93                 if ($instance = $this->getPlugin($plugin)) { 
    94                         $instance->muted = false; 
    95                         $this->doPrivmsg($this->event->getSource(), 'Unmuted '.$plugin.'.'); 
    96                 } else { 
    97                         $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' not found, could not unmute.'); 
    98                 } 
     96                $target = trim((!empty($target) && $this->fromAdmin(false)) ? $target : $this->event->getSource()); 
     97                if (!empty($target)) { 
     98                    if ($instance = $this->getPlugin($plugin)) { 
     99                        $instance->muted[$target] = false; 
     100                        $this->doPrivmsg($this->event->getSource(), 'Unmuted '.$plugin.' for '.$target.'.'); 
     101                } else { 
     102                        $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' not found, could not unmute.'); 
     103                    } 
     104            } 
    99105        } 
    100106}