Commit 8f7071c2028d00b81e9ff2cf13507f5b7562a658

Authored by Paul Barrett
2 parents b5393a6e 7f0a8d06

Merge branch 'edge' of github.com:ktgit/knowledgetree into edge

webservice/clienttools/jsonWrapper.php
@@ -91,6 +91,7 @@ class jsonWrapper{ @@ -91,6 +91,7 @@ class jsonWrapper{
91 public $jsonArray=array(); 91 public $jsonArray=array();
92 92
93 public function __construct($content=NULL){ 93 public function __construct($content=NULL){
  94 + $content=stripslashes($content);
94 $this->raw=$content; 95 $this->raw=$content;
95 $content=@json_decode($content,true); 96 $content=@json_decode($content,true);
96 if(!is_array($content))throw new jsonContentException('Invalid JSON input',jsonContentException::INPUT_ERROR); 97 if(!is_array($content))throw new jsonContentException('Invalid JSON input',jsonContentException::INPUT_ERROR);
webservice/clienttools/services/0.2/kt.php
@@ -855,7 +855,7 @@ class kt extends client_service { @@ -855,7 +855,7 @@ class kt extends client_service {
855 855
856 856
857 private function update_document_metadata($session_id, $document_id, $metadata, $application, $sysdata=null){ 857 private function update_document_metadata($session_id, $document_id, $metadata, $application, $sysdata=null){
858 - $this->addDebug('','entered update_document_metadata'); 858 + $this->addDebug('update_document_metadata','entered update_document_metadata');
859 $kt=&$this->KT; 859 $kt=&$this->KT;
860 $responseType='kt_document_detail'; 860 $responseType='kt_document_detail';
861 861
@@ -923,27 +923,44 @@ class kt extends client_service { @@ -923,27 +923,44 @@ class kt extends client_service {
923 923
924 public function update_metadata($arr){ 924 public function update_metadata($arr){
925 $metadata=array(); 925 $metadata=array();
926 - $packed=@json_decode($arr['metadata']); 926 + $meta=$arr['metadata'];
927 927
928 $this->addDebug('','Entered add_document_with_metadata'); 928 $this->addDebug('','Entered add_document_with_metadata');
  929 + $this->addDebug('metadata received',$meta);
929 930
930 $special=array(); 931 $special=array();
931 -  
932 - foreach($packed as $key=>$val) {  
933 - if(substr($val->name,0,2) != '__') {  
934 - if(!is_array($metadata[$val->fieldset])) {  
935 - $metadata[$val->fieldset]['fieldset']=$val->fieldset;  
936 - $metadata[$val->fieldset]['fields']=array();  
937 - }  
938 - $metadata[$val->fieldset]['fields'][]=array(  
939 - 'name'=>$val->name,  
940 - 'value'=>$val->value  
941 - ); 932 +// foreach($apacked as $packed){
  933 +// foreach($packed as $key=>$val) {
  934 +// if(substr($val->name,0,2) != '__') {
  935 +// if(!is_array($metadata[$val->fieldset])) {
  936 +// $metadata[$val->fieldset]['fieldset']=$val->fieldset;
  937 +// $metadata[$val->fieldset]['fields']=array();
  938 +// }
  939 +// $metadata[$val->fieldset]['fields'][]=array(
  940 +// 'name'=>$val->name,
  941 +// 'value'=>$val->value
  942 +// );
  943 +// }else{
  944 +// $special[$val->name]=$val->value;
  945 +// }
  946 +// }
  947 +// }
  948 +
  949 + foreach($meta as $item){
  950 + $isSpecial=substr($item['name'],0,2)=='__';
  951 + if($isSpecial){
  952 + $special[$item['name']]=$item['value'];
942 }else{ 953 }else{
943 - $special[$val->name]=$val->value;  
944 - } 954 + $fieldSet=$item['fieldset'];
  955 + unset($item['fieldset']);
  956 + $metadata[$fieldSet]['fieldset']=$fieldSet;
  957 + $metadata[$fieldSet]['fields'][]=$item;
  958 + }
945 } 959 }
946 - 960 +
  961 +
  962 + $this->addDebug('after processing',array('metadata'=>$metadata,'special'=>$special));
  963 +
947 $document_id=$arr['document_id']; 964 $document_id=$arr['document_id'];
948 965
949 $update_result=$this->update_document_metadata($arr['session_id'], $document_id, $metadata, $arr['application'], array()); 966 $update_result=$this->update_document_metadata($arr['session_id'], $document_id, $metadata, $arr['application'], array());
webservice/clienttools/standardservices/system.php
@@ -21,6 +21,10 @@ class system extends client_service{ @@ -21,6 +21,10 @@ class system extends client_service{
21 $this->setResponse($ret); 21 $this->setResponse($ret);
22 return true; 22 return true;
23 } 23 }
  24 +
  25 + public function jsondecode($params){
  26 + $this->setResponse(@json_decode(trim($params['code'])));
  27 + }
24 } 28 }
25 29
26 ?> 30 ?>
27 \ No newline at end of file 31 \ No newline at end of file