From 1d786c86bf81bfd8250035e8d22791deb77d3f31 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 18 Jan 2010 14:05:11 -0500
Subject: [PATCH] - fixed svn keywords

---
 program/include/rcube_plugin_api.php |   40 ++++++++++++++++++++++++++++++----------
 1 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/program/include/rcube_plugin_api.php b/program/include/rcube_plugin_api.php
index c23b1e6..3a8ae52 100644
--- a/program/include/rcube_plugin_api.php
+++ b/program/include/rcube_plugin_api.php
@@ -15,7 +15,7 @@
  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
  +-----------------------------------------------------------------------+
 
- $Id: $
+ $Id$
 
 */
 
@@ -39,7 +39,8 @@
   private $objectsmap = array();
   private $template_contents = array();
   
-  private  $required_plugins = array('filesystem_attachments');
+  private $required_plugins = array('filesystem_attachments');
+  private $active_hook = false;
 
   /**
    * This implements the 'singleton' design pattern
@@ -61,8 +62,7 @@
    */
   private function __construct()
   {
-    $rcmail = rcmail::get_instance();
-    $this->dir = realpath($rcmail->config->get('plugins_dir'));
+    $this->dir = INSTALL_PATH . $this->url;
   }
   
   
@@ -90,7 +90,7 @@
         if (class_exists($plugin_name, false)) {
           $plugin = new $plugin_name($this);
           // check inheritance and task specification
-          if (is_subclass_of($plugin, 'rcube_plugin') && (!$plugin->task || $plugin->task == $rcmail->task)) {
+          if (is_subclass_of($plugin, 'rcube_plugin') && (!$plugin->task || preg_match('/('.$plugin->task.')/i', $rcmail->task))) {
             $plugin->init();
             $this->plugins[] = $plugin;
           }
@@ -118,15 +118,17 @@
       if (!$loaded) {
         $fn = $plugins_dir->path . DIRECTORY_SEPARATOR . $plugin_name . DIRECTORY_SEPARATOR . $plugin_name . '.php';
         if (file_exists($fn)) {
-          include($fn);
+          include_once($fn);
           
           if (class_exists($plugin_name, false)) {
             $plugin = new $plugin_name($this);
             // check inheritance
             if (is_subclass_of($plugin, 'rcube_plugin')) {
-              $plugin->init();
-              $this->plugins[] = $plugin;
-              $loaded = true;
+	      if (!$plugin->task || preg_match('/('.$plugin->task.')/i', $rcmail->task)) {
+                $plugin->init();
+                $this->plugins[] = $plugin;
+              }
+	      $loaded = true;
             }
           }
         }
@@ -179,7 +181,11 @@
    */
   public function exec_hook($hook, $args = array())
   {
+    if (!is_array($args))
+      $args = array('arg' => $args);
+
     $args += array('abort' => false);
+    $this->active_hook = $hook;
     
     foreach ((array)$this->handlers[$hook] as $callback) {
       $ret = call_user_func($callback, $args);
@@ -190,6 +196,7 @@
         break;
     }
     
+    $this->active_hook = false;
     return $args;
   }
 
@@ -258,6 +265,19 @@
     }
   }
   
+  
+  /**
+   * Check if a plugin hook is currently processing.
+   * Mainly used to prevent loops and recursion.
+   *
+   * @param string Hook to check (optional)
+   * @return boolean True if any/the given hook is currently processed, otherwise false
+   */
+  public function is_processing($hook = null)
+  {
+    return $this->active_hook && (!$hook || $this->active_hook == $hook);
+  }
+  
   /**
    * Include a plugin script file in the current HTML page
    */
@@ -294,7 +314,7 @@
   private function template_container_hook($attrib)
   {
     $container = $attrib['name'];
-    return array('content' => $this->template_contents[$container]);
+    return array('content' => $attrib['content'] . $this->template_contents[$container]);
   }
   
   /**

--
Gitblit v1.9.1