From 75969686c23575e61f306ae4502f132968848096 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Mon, 10 Aug 2009 17:32:44 -0400
Subject: [PATCH] Added 'message_compose' hook

---
 program/include/main.inc |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/program/include/main.inc b/program/include/main.inc
index 9401e28..ce27b75 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -545,7 +545,7 @@
  * @return string   Field value or NULL if not available
  */
 function get_input_value($fname, $source, $allow_html=FALSE, $charset=NULL)
-  {
+{
   global $OUTPUT;
   $value = NULL;
   
@@ -582,7 +582,26 @@
     return rcube_charset_convert($value, $OUTPUT->get_charset(), $charset);
   else
     return $value;
+}
+
+/**
+ * Convert array of request parameters (prefixed with _)
+ * to a regular array with non-prefixed keys.
+ *
+ * @param  int   Source to get value from (GPC)
+ * @return array Hash array with all request parameters
+ */
+function request2param($mode = RCUBE_INPUT_GPC)
+{
+  $out = array();
+  $src = $mode == RCUBE_INPUT_GET ? $_GET : ($mode == RCUBE_INPUT_POST ? $_POST : $_REQUEST);
+  foreach ($src as $key => $value) {
+    $fname = $key[0] == '_' ? substr($key, 1) : $key;
+    $out[$fname] = get_input_value($key, $mode);
   }
+  
+  return $out;
+}
 
 /**
  * Remove all non-ascii and non-word chars
@@ -958,8 +977,11 @@
   {
   $args = func_get_args();
 
-  if (class_exists('rcmail', false))
-    rcmail::get_instance()->plugins->exec_hook('console', $args);
+  if (class_exists('rcmail', false)) {
+    $rcmail = rcmail::get_instance();
+    if (is_object($rcmail->plugins))
+      $rcmail->plugins->exec_hook('console', $args);
+  }
 
   $msg = array();
   foreach ($args as $arg)

--
Gitblit v1.9.1