From 60bab946cd1e3436fd789f56707a5137d20a86f1 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 28 Jul 2010 14:27:50 +0000 Subject: [PATCH] -Updated jsonRPC calls - use ssl certs -Adde pre_events git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19190 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_configRegistry.inc | 6 ++++ gosa-core/include/class_jsonRPC.inc | 1 + gosa-core/include/class_plugin.inc | 34 ++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/gosa-core/include/class_configRegistry.inc b/gosa-core/include/class_configRegistry.inc index 9809788ef..ee68d2ed4 100644 --- a/gosa-core/include/class_configRegistry.inc +++ b/gosa-core/include/class_configRegistry.inc @@ -415,6 +415,12 @@ class configRegistry{ $this->register($cname, $data); $data = array('name' => 'postmodify','type' => 'command'); $this->register($cname, $data); + $data = array('name' => 'precreate','type' => 'command'); + $this->register($cname, $data); + $data = array('name' => 'preremove','type' => 'command'); + $this->register($cname, $data); + $data = array('name' => 'premodify','type' => 'command'); + $this->register($cname, $data); $data = array('name' => 'check', 'type' => 'command'); $this->register($cname, $data); diff --git a/gosa-core/include/class_jsonRPC.inc b/gosa-core/include/class_jsonRPC.inc index f0032365a..d9084f61c 100644 --- a/gosa-core/include/class_jsonRPC.inc +++ b/gosa-core/include/class_jsonRPC.inc @@ -34,6 +34,7 @@ class jsonRPC { curl_setopt($this->curlHandler, CURLOPT_COOKIEFILE, 'cookiefile.txt'); curl_setopt($this->curlHandler, CURLOPT_POST , TRUE); curl_setopt($this->curlHandler, CURLOPT_RETURNTRANSFER , TRUE); + curl_setopt($this->curlHandler, CURLOPT_SSL_VERIFYPEER, TRUE); curl_setopt($this->curlHandler, CURLOPT_HTTPHEADER , array('Content-Type: application/json')); // Try to login diff --git a/gosa-core/include/class_plugin.inc b/gosa-core/include/class_plugin.inc index bb5d80135..4660c375c 100644 --- a/gosa-core/include/class_plugin.inc +++ b/gosa-core/include/class_plugin.inc @@ -319,6 +319,9 @@ class plugin /* $ldap->modify($this->attrs); */ + if($this->initially_was_account){ + $this->handle_pre_events('remove'); + } } @@ -398,6 +401,37 @@ class plugin /* Handle tagging */ $this->tag_attrs($this->attrs); + + if($this->is_new){ + $this->handle_pre_events('add'); + }else{ + $this->handle_pre_events('modify'); + } + } + + + /*! \brief Forward command execution requests + * to the hook execution method. + */ + function handle_pre_events($mode, $addAttrs= array()) + { + if(!in_array($mode, array('add','remove','modify'))){ + trigger_error(sprintf("Invalid pre event type given %s! Valid types are [add,modify,remove].", $mode)); + return; + } + switch ($mode){ + case "add": + plugin::callHook($this,"PRECREATE", $addAttrs); + break; + + case "modify": + plugin::callHook($this,"PREMODIFY", $addAttrs); + break; + + case "remove": + plugin::callHook($this,"PREREMOVE", $addAttrs); + break; + } } -- 2.30.2