Changeset 05a631a in github
- Timestamp:
- Jun 3, 2010 2:40:06 AM (3 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- bb8721aa
- Parents:
- ae8a2a55
- Files:
-
- 3 edited
-
index.php (modified) (1 diff)
-
program/include/rcube_plugin.php (modified) (3 diffs)
-
program/include/rcube_plugin_api.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
index.php
r3544558 r05a631a 243 243 $stepfile = !empty($action_map[$RCMAIL->task][$RCMAIL->action]) ? 244 244 $action_map[$RCMAIL->task][$RCMAIL->action] : strtr($RCMAIL->action, '-', '_') . '.inc'; 245 245 246 246 // execute a plugin action 247 if (preg_match('/^plugin\./', $RCMAIL->action)) { 247 if ($RCMAIL->plugins->is_plugin_task($RCMAIL->task)) { 248 $RCMAIL->plugins->exec_action($RCMAIL->task.'.'.$RCMAIL->action); 249 break; 250 } 251 else if (preg_match('/^plugin\./', $RCMAIL->action)) { 248 252 $RCMAIL->plugins->exec_action($RCMAIL->action); 249 253 break; -
program/include/rcube_plugin.php
rd062dbe r05a631a 32 32 protected $home; 33 33 protected $urlbase; 34 private $mytask; 34 35 35 36 /** … … 135 136 public function register_task($task) 136 137 { 137 if ($task != asciiwords($task)) { 138 raise_error(array('code' => 526, 'type' => 'php', 139 'file' => __FILE__, 'line' => __LINE__, 140 'message' => "Invalid task name: $task. Only characters [a-z0-9_.-] are allowed"), true, false); 141 } 142 else if (in_array(rcmail::$main_tasks, $task)) { 143 raise_error(array('code' => 526, 'type' => 'php', 144 'file' => __FILE__, 'line' => __LINE__, 145 'message' => "Cannot register taks $task; already taken by another plugin or the application itself"), true, false); 146 } 147 else { 148 rcmail::$main_tasks[] = $task; 149 } 138 if ($this->api->register_task($task, $this->ID)) 139 $this->mytask = $task; 150 140 } 151 141 … … 160 150 public function register_action($action, $callback) 161 151 { 162 $this->api->register_action($action, $this->ID, $callback );152 $this->api->register_action($action, $this->ID, $callback, $this->mytask); 163 153 } 164 154 -
program/include/rcube_plugin_api.php
rd062dbe r05a631a 35 35 public $handlers = array(); 36 36 private $plugins = array(); 37 private $tasks = array(); 37 38 private $actions = array(); 38 39 private $actionmap = array(); … … 207 208 * @param string Plugin name that registers this action 208 209 * @param mixed Callback: string with global function name or array($obj, 'methodname') 209 */ 210 public function register_action($action, $owner, $callback) 210 * @param string Task name registered by this plugin 211 */ 212 public function register_action($action, $owner, $callback, $task = null) 211 213 { 212 214 // check action name 213 if (strpos($action, 'plugin.') !== 0) 215 if ($task) 216 $action = $task.'.'.$action; 217 else if (strpos($action, 'plugin.') !== 0) 214 218 $action = 'plugin.'.$action; 215 219 … … 273 277 274 278 /** 279 * Register this plugin to be responsible for a specific task 280 * 281 * @param string Task name (only characters [a-z0-9_.-] are allowed) 282 * @param string Plugin name that registers this action 283 */ 284 public function register_task($task, $owner) 285 { 286 if ($task != asciiwords($task)) { 287 raise_error(array('code' => 526, 'type' => 'php', 288 'file' => __FILE__, 'line' => __LINE__, 289 'message' => "Invalid task name: $task. Only characters [a-z0-9_.-] are allowed"), true, false); 290 } 291 else if (in_array($task, rcmail::$main_tasks)) { 292 raise_error(array('code' => 526, 'type' => 'php', 293 'file' => __FILE__, 'line' => __LINE__, 294 'message' => "Cannot register taks $task; already taken by another plugin or the application itself"), true, false); 295 } 296 else { 297 $this->tasks[$task] = $owner; 298 rcmail::$main_tasks[] = $task; 299 return true; 300 } 301 302 return false; 303 } 304 305 306 /** 307 * Checks whether the given task is registered by a plugin 308 * 309 * @return boolean True if registered, otherwise false 310 */ 311 public function is_plugin_task($task) 312 { 313 return $this->tasks[$task] ? true : false; 314 } 315 316 317 /** 275 318 * Check if a plugin hook is currently processing. 276 319 * Mainly used to prevent loops and recursion.
Note: See TracChangeset
for help on using the changeset viewer.
