[Svn] r4154 - in trunk/roundcubemail: . program/include

trac at roundcube.net trac at roundcube.net
Fri Oct 29 10:42:28 CEST 2010


Author: alec
Date: 2010-10-29 03:42:28 -0500 (Fri, 29 Oct 2010)
New Revision: 4154

Modified:
   trunk/roundcubemail/CHANGELOG
   trunk/roundcubemail/program/include/rcube_plugin.php
   trunk/roundcubemail/program/include/rcube_plugin_api.php
Log:
- Plugin API: add possibility to disable plugin in AJAX mode, 'noajax' property
- Plugin API: add possibility to disable plugin in framed mode, 'noframe' property


Modified: trunk/roundcubemail/CHANGELOG
===================================================================
--- trunk/roundcubemail/CHANGELOG	2010-10-28 16:35:49 UTC (rev 4153)
+++ trunk/roundcubemail/CHANGELOG	2010-10-29 08:42:28 UTC (rev 4154)
@@ -54,6 +54,8 @@
 - Fix handling of URLs with tilde (~) or semicolon (;) character (#1487087, #1487088)
 - Plugin API: added 'contact_form' hook
 - Add SORT=DISPLAY support (RFC 5957)
+- Plugin API: add possibility to disable plugin in AJAX mode, 'noajax' property
+- Plugin API: add possibility to disable plugin in framed mode, 'noframe' property
 
 RELEASE 0.4.2
 -------------

Modified: trunk/roundcubemail/program/include/rcube_plugin.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_plugin.php	2010-10-28 16:35:49 UTC (rev 4153)
+++ trunk/roundcubemail/program/include/rcube_plugin.php	2010-10-29 08:42:28 UTC (rev 4154)
@@ -26,19 +26,46 @@
  */
 abstract class rcube_plugin
 {
+  /**
+   * Class name of the plugin instance
+   *
+   * @var string
+   */
   public $ID;
 
   /**
-   * Holds an istance of Plugin API
+   * Instance of Plugin API
    *
    * @var rcube_plugin_api
    */
   public $api;
+
+  /**
+   * Regular expression defining task(s) to bind with 
+   *
+   * @var string
+   */
   public $task;
+
+  /**
+   * Disables plugin in AJAX requests
+   *
+   * @var boolean
+   */
+  public $noajax = false;
+
+  /**
+   * Disables plugin in framed mode
+   *
+   * @var boolean
+   */
+  public $noframe = false;
+
   protected $home;
   protected $urlbase;
   private $mytask;
 
+
   /**
    * Default constructor.
    *

Modified: trunk/roundcubemail/program/include/rcube_plugin_api.php
===================================================================
--- trunk/roundcubemail/program/include/rcube_plugin_api.php	2010-10-28 16:35:49 UTC (rev 4153)
+++ trunk/roundcubemail/program/include/rcube_plugin_api.php	2010-10-29 08:42:28 UTC (rev 4154)
@@ -122,10 +122,16 @@
         // instantiate class if exists
         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 || preg_match('/^('.$plugin->task.')$/i', $rcmail->task))) {
-            $plugin->init();
-            $this->plugins[] = $plugin;
+          // check inheritance...
+          if (is_subclass_of($plugin, 'rcube_plugin')) {
+            // ... task, request type and framed mode
+            if ((!$plugin->task || preg_match('/^('.$plugin->task.')$/i', $rcmail->task))
+                && (!$plugin->noajax || is_a($this->output, 'rcube_template'))
+                && (!$plugin->noframe || empty($_REQUEST['_framed']))
+            ) {
+              $plugin->init();
+              $this->plugins[] = $plugin;
+            }
           }
         }
         else {
@@ -256,7 +262,7 @@
       $action = $task.'.'.$action;
     else if (strpos($action, 'plugin.') !== 0)
       $action = 'plugin.'.$action;
-    
+
     // can register action only if it's not taken or registered by myself
     if (!isset($this->actionmap[$action]) || $this->actionmap[$action] == $owner) {
       $this->actions[$action] = $callback;

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list