From: hickert Date: Thu, 1 Jul 2010 14:16:34 +0000 (+0000) Subject: Updated class plugin and its callHook method. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=72528950e1a5aa06d0dd88c393e43060a59ca311;p=gosa.git Updated class plugin and its callHook method. -Added ability to receive returnVar and returnCode, additionally fixed error messages git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18907 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_plugin.inc b/gosa-core/include/class_plugin.inc index 9bef3cb81..436aee0da 100644 --- a/gosa-core/include/class_plugin.inc +++ b/gosa-core/include/class_plugin.inc @@ -1530,7 +1530,7 @@ class plugin * Replaces placeholder by class values of this plugin instance. * @param Allows to a add special replacements. */ - static function callHook($plugin, $cmd, $addAttrs= array()) + static function callHook($plugin, $cmd, $addAttrs= array(), &$returnOutput = array(), &$returnCode = NULL) { global $config; $command = $config->configRegistry->getPropertyValue(get_class($plugin),$cmd); @@ -1581,14 +1581,22 @@ class plugin } if (check_command($command)){ + @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__,$command,"Execute"); - exec($command,$arr); - if(is_array($arr)){ + exec($command, $arr, $returnCode); + $returnOutput = $arr; + + if($returnCode != 0){ + $str = implode("\n",$arr); + @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Execution failed code: ".$returnCode); + $message= msgPool::cmdexecfailed($cmd,$command, get_class($plugin)); + msg_dialog::display(_("Error"), $message, ERROR_DIALOG); + }elseif(is_array($arr)){ $str = implode("\n",$arr); @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, $command, "Result: ".$str); } } else { - $message= msgPool::cmdnotfound("POSTCREATE", get_class($plugin)); + $message= msgPool::cmdinvalid($cmd,$command, get_class($plugin)); msg_dialog::display(_("Error"), $message, ERROR_DIALOG); } }