Changeset 4154 in subversion


Ignore:
Timestamp:
Oct 29, 2010 4:42:28 AM (3 years ago)
Author:
alec
Message:
  • Plugin API: add possibility to disable plugin in AJAX mode, 'noajax' property
  • Plugin API: add possibility to disable plugin in framed mode, 'noframe' property
Location:
trunk/roundcubemail
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r4152 r4154  
    5555- Plugin API: added 'contact_form' hook 
    5656- Add SORT=DISPLAY support (RFC 5957) 
     57- Plugin API: add possibility to disable plugin in AJAX mode, 'noajax' property 
     58- Plugin API: add possibility to disable plugin in framed mode, 'noframe' property 
    5759 
    5860RELEASE 0.4.2 
  • trunk/roundcubemail/program/include/rcube_plugin.php

    r4091 r4154  
    2727abstract class rcube_plugin 
    2828{ 
     29  /** 
     30   * Class name of the plugin instance 
     31   * 
     32   * @var string 
     33   */ 
    2934  public $ID; 
    3035 
    3136  /** 
    32    * Holds an istance of Plugin API 
     37   * Instance of Plugin API 
    3338   * 
    3439   * @var rcube_plugin_api 
    3540   */ 
    3641  public $api; 
     42 
     43  /** 
     44   * Regular expression defining task(s) to bind with  
     45   * 
     46   * @var string 
     47   */ 
    3748  public $task; 
     49 
     50  /** 
     51   * Disables plugin in AJAX requests 
     52   * 
     53   * @var boolean 
     54   */ 
     55  public $noajax = false; 
     56 
     57  /** 
     58   * Disables plugin in framed mode 
     59   * 
     60   * @var boolean 
     61   */ 
     62  public $noframe = false; 
     63 
    3864  protected $home; 
    3965  protected $urlbase; 
    4066  private $mytask; 
     67 
    4168 
    4269  /** 
  • trunk/roundcubemail/program/include/rcube_plugin_api.php

    r4091 r4154  
    123123        if (class_exists($plugin_name, false)) { 
    124124          $plugin = new $plugin_name($this); 
    125           // check inheritance and task specification 
    126           if (is_subclass_of($plugin, 'rcube_plugin') && (!$plugin->task || preg_match('/^('.$plugin->task.')$/i', $rcmail->task))) { 
    127             $plugin->init(); 
    128             $this->plugins[] = $plugin; 
     125          // check inheritance... 
     126          if (is_subclass_of($plugin, 'rcube_plugin')) { 
     127            // ... task, request type and framed mode 
     128            if ((!$plugin->task || preg_match('/^('.$plugin->task.')$/i', $rcmail->task)) 
     129                && (!$plugin->noajax || is_a($this->output, 'rcube_template')) 
     130                && (!$plugin->noframe || empty($_REQUEST['_framed'])) 
     131            ) { 
     132              $plugin->init(); 
     133              $this->plugins[] = $plugin; 
     134            } 
    129135          } 
    130136        } 
     
    257263    else if (strpos($action, 'plugin.') !== 0) 
    258264      $action = 'plugin.'.$action; 
    259      
     265 
    260266    // can register action only if it's not taken or registered by myself 
    261267    if (!isset($this->actionmap[$action]) || $this->actionmap[$action] == $owner) { 
Note: See TracChangeset for help on using the changeset viewer.