diff --git a/webservice/clienttools/jsonWrapper.php b/webservice/clienttools/jsonWrapper.php index c025f35..db3c395 100644 --- a/webservice/clienttools/jsonWrapper.php +++ b/webservice/clienttools/jsonWrapper.php @@ -91,6 +91,7 @@ class jsonWrapper{ public $jsonArray=array(); public function __construct($content=NULL){ + $content=stripslashes($content); $this->raw=$content; $content=@json_decode($content,true); if(!is_array($content))throw new jsonContentException('Invalid JSON input',jsonContentException::INPUT_ERROR); diff --git a/webservice/clienttools/services/0.2/kt.php b/webservice/clienttools/services/0.2/kt.php index da76840..db7f273 100644 --- a/webservice/clienttools/services/0.2/kt.php +++ b/webservice/clienttools/services/0.2/kt.php @@ -855,7 +855,7 @@ class kt extends client_service { private function update_document_metadata($session_id, $document_id, $metadata, $application, $sysdata=null){ - $this->addDebug('','entered update_document_metadata'); + $this->addDebug('update_document_metadata','entered update_document_metadata'); $kt=&$this->KT; $responseType='kt_document_detail'; @@ -923,27 +923,44 @@ class kt extends client_service { public function update_metadata($arr){ $metadata=array(); - $packed=@json_decode($arr['metadata']); + $meta=$arr['metadata']; $this->addDebug('','Entered add_document_with_metadata'); + $this->addDebug('metadata received',$meta); $special=array(); - - foreach($packed as $key=>$val) { - if(substr($val->name,0,2) != '__') { - if(!is_array($metadata[$val->fieldset])) { - $metadata[$val->fieldset]['fieldset']=$val->fieldset; - $metadata[$val->fieldset]['fields']=array(); - } - $metadata[$val->fieldset]['fields'][]=array( - 'name'=>$val->name, - 'value'=>$val->value - ); +// foreach($apacked as $packed){ +// foreach($packed as $key=>$val) { +// if(substr($val->name,0,2) != '__') { +// if(!is_array($metadata[$val->fieldset])) { +// $metadata[$val->fieldset]['fieldset']=$val->fieldset; +// $metadata[$val->fieldset]['fields']=array(); +// } +// $metadata[$val->fieldset]['fields'][]=array( +// 'name'=>$val->name, +// 'value'=>$val->value +// ); +// }else{ +// $special[$val->name]=$val->value; +// } +// } +// } + + foreach($meta as $item){ + $isSpecial=substr($item['name'],0,2)=='__'; + if($isSpecial){ + $special[$item['name']]=$item['value']; }else{ - $special[$val->name]=$val->value; - } + $fieldSet=$item['fieldset']; + unset($item['fieldset']); + $metadata[$fieldSet]['fieldset']=$fieldSet; + $metadata[$fieldSet]['fields'][]=$item; + } } - + + + $this->addDebug('after processing',array('metadata'=>$metadata,'special'=>$special)); + $document_id=$arr['document_id']; $update_result=$this->update_document_metadata($arr['session_id'], $document_id, $metadata, $arr['application'], array()); diff --git a/webservice/clienttools/standardservices/system.php b/webservice/clienttools/standardservices/system.php index 17b4a01..9e6b891 100644 --- a/webservice/clienttools/standardservices/system.php +++ b/webservice/clienttools/standardservices/system.php @@ -21,6 +21,10 @@ class system extends client_service{ $this->setResponse($ret); return true; } + + public function jsondecode($params){ + $this->setResponse(@json_decode(trim($params['code']))); + } } ?> \ No newline at end of file