| 13 | | public function onDoDisable($plugin) |
|---|
| 14 | | { |
|---|
| 15 | | if (($instance = $this->getPlugin($plugin)) && $instance != $this) { |
|---|
| 16 | | $instance->enabled = false; |
|---|
| 17 | | $this->doPrivmsg($this->event->getSource(), 'Disabled '.$plugin.'.'); |
|---|
| 18 | | } else { |
|---|
| 19 | | $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' is not loaded.'); |
|---|
| 20 | | } |
|---|
| 21 | | } |
|---|
| | 13 | public function onDoDisable($plugin) |
|---|
| | 14 | { |
|---|
| | 15 | // Check to see if the admin is a hostmask admin only and not an op |
|---|
| | 16 | if ($this->fromAdmin(false)) { |
|---|
| | 17 | if (($instance = $this->getPlugin($plugin)) && $instance != $this) { |
|---|
| | 18 | $instance->enabled = false; |
|---|
| | 19 | $this->doPrivmsg($this->event->getSource(), 'Disabled '.$plugin.'.'); |
|---|
| | 20 | } else { |
|---|
| | 21 | $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' is not loaded.'); |
|---|
| | 22 | } |
|---|
| | 23 | } |
|---|
| | 24 | } |
|---|
| 23 | | public function onDoEnable($plugin) |
|---|
| 24 | | { |
|---|
| 25 | | // Plugin is loaded already |
|---|
| 26 | | if ($instance = $this->getPlugin($plugin)) { |
|---|
| 27 | | // Already enabled |
|---|
| 28 | | if ($instance->enabled) { |
|---|
| 29 | | $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' was already enabled.'); |
|---|
| 30 | | // Not yet enabled, enable |
|---|
| 31 | | } else { |
|---|
| 32 | | $instance->enabled = true; |
|---|
| 33 | | $this->doPrivmsg($this->event->getSource(), 'Enabled '.$plugin.'.'); |
|---|
| 34 | | } |
|---|
| 35 | | // Plugin was not loaded, try to see if we can load it |
|---|
| 36 | | } else { |
|---|
| 37 | | // Build loaded plugin list to pass to the checkDependencies method |
|---|
| 38 | | $iterator = new DirectoryIterator(PHERGIE_DIR . '/Phergie/Plugin'); |
|---|
| 39 | | $plugins = array(); |
|---|
| | 26 | public function onDoEnable($plugin) |
|---|
| | 27 | { |
|---|
| | 28 | // Check to see if the admin is a hostmask admin only and not an op |
|---|
| | 29 | if ($this->fromAdmin(false)) { |
|---|
| | 30 | // Plugin is loaded already |
|---|
| | 31 | if ($instance = $this->getPlugin($plugin)) { |
|---|
| | 32 | // Already enabled |
|---|
| | 33 | if ($instance->enabled) { |
|---|
| | 34 | $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' was already enabled.'); |
|---|
| | 35 | // Not yet enabled, enable |
|---|
| | 36 | } else { |
|---|
| | 37 | $instance->enabled = true; |
|---|
| | 38 | $this->doPrivmsg($this->event->getSource(), 'Enabled '.$plugin.'.'); |
|---|
| | 39 | } |
|---|
| | 40 | // Plugin was not loaded, try to see if we can load it |
|---|
| | 41 | } else { |
|---|
| | 42 | // Build loaded plugin list to pass to the checkDependencies method |
|---|
| | 43 | $iterator = new DirectoryIterator(PHERGIE_DIR . '/Phergie/Plugin'); |
|---|
| | 44 | $plugins = array(); |
|---|
| 41 | | foreach ($iterator as $entry) { |
|---|
| 42 | | if ($iterator->isFile()) { |
|---|
| 43 | | $plugins[] = basename((string) $entry, '.php'); |
|---|
| | 46 | foreach ($iterator as $entry) { |
|---|
| | 47 | if ($iterator->isFile()) { |
|---|
| | 48 | $plugins[] = basename((string) $entry, '.php'); |
|---|
| | 49 | } |
|---|
| | 50 | |
|---|
| | 51 | if ($iterator->isFile() && strtolower((string) $entry) == strtolower($plugin).'.php') { |
|---|
| | 52 | $target = (string) $entry; |
|---|
| | 53 | } |
|---|
| 46 | | if ($iterator->isFile() && strtolower((string) $entry) == strtolower($plugin).'.php') { |
|---|
| 47 | | $target = (string) $entry; |
|---|
| | 56 | foreach ($plugins as $k=>$p) { |
|---|
| | 57 | if(!($this->getPlugin($p) instanceof Phergie_Plugin_Abstract_Base)) { |
|---|
| | 58 | unset($plugins[$k]); |
|---|
| | 59 | } |
|---|
| | 60 | } |
|---|
| | 61 | |
|---|
| | 62 | // Plugin file was found, check if it can be loaded |
|---|
| | 63 | if (isset($target)) { |
|---|
| | 64 | require_once PHERGIE_DIR.'/Phergie/Plugin/'.$target; |
|---|
| | 65 | $class = 'Phergie_Plugin_'.substr($target, 0, -4); |
|---|
| | 66 | if (call_user_func(array($class, 'checkDependencies'), $this->client, $plugins)) { |
|---|
| | 67 | $instance = new $class($this->client); |
|---|
| | 68 | $this->client->addPlugin($instance); |
|---|
| | 69 | $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' loaded.'); |
|---|
| | 70 | } else { |
|---|
| | 71 | $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' can not be loaded, missing dependencies.'); |
|---|
| | 72 | } |
|---|
| | 73 | // Plugin file not found |
|---|
| | 74 | } else { |
|---|
| | 75 | $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' not found, could not enable.'); |
|---|
| 57 | | // Plugin file was found, check if it can be loaded |
|---|
| 58 | | if (isset($target)) { |
|---|
| 59 | | require_once PHERGIE_DIR.'/Phergie/Plugin/'.$target; |
|---|
| 60 | | $class = 'Phergie_Plugin_'.substr($target, 0, -4); |
|---|
| 61 | | if (call_user_func(array($class, 'checkDependencies'), $this->client, $plugins)) { |
|---|
| 62 | | $instance = new $class($this->client); |
|---|
| 63 | | $this->client->addPlugin($instance); |
|---|
| 64 | | $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' loaded.'); |
|---|
| 65 | | } else { |
|---|
| 66 | | $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' can not be loaded, missing dependencies.'); |
|---|
| 67 | | } |
|---|
| 68 | | // Plugin file not found |
|---|
| 69 | | } else { |
|---|
| 70 | | $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' not found, could not enable.'); |
|---|
| 71 | | } |
|---|
| 72 | | } |
|---|
| 73 | | } |
|---|
| 74 | | |
|---|
| 75 | | public function onDoMute($plugin) |
|---|
| 76 | | { |
|---|
| 77 | | if ($instance = $this->getPlugin($plugin)) { |
|---|
| 78 | | $instance->muted = true; |
|---|
| 79 | | $this->doPrivmsg($this->event->getSource(), 'Muted '.$plugin.'.'); |
|---|
| 80 | | } else { |
|---|
| 81 | | $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' not found, could not mute.'); |
|---|
| 82 | | } |
|---|
| 83 | | } |
|---|
| 84 | | |
|---|
| 85 | | public function onDoUnmute($plugin) |
|---|
| 86 | | { |
|---|
| 87 | | if ($instance = $this->getPlugin($plugin)) { |
|---|
| 88 | | $instance->muted = false; |
|---|
| 89 | | $this->doPrivmsg($this->event->getSource(), 'Unmuted '.$plugin.'.'); |
|---|
| 90 | | } else { |
|---|
| 91 | | $this->doPrivmsg($this->event->getSource(), 'Plugin '.$plugin.' not found, could not unmute.'); |
|---|
| 92 | | } |
|---|
| 93 | | } |
|---|
| | 91 | public function onDoUnmute($plugin) |
|---|
| | 92 | { |
|---|
| | 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 | } |
|---|
| | 99 | } |
|---|