Commit 5f57588f1a44f1e75fb563e0fb7cca0db4325c82

Authored by Mark Holtzhausen
1 parent 7d58f620

Created client_service::bool to force boolean values

Fixed KTE-49 - Checkin major version / minor version
webservice/clienttools/client_service.php
... ... @@ -67,6 +67,16 @@ class client_service{
67 67 return true;
68 68 }
69 69  
  70 + /**
  71 + * Forces parameter to boolean.
  72 + * $isTrue array contains a list of values that are recognized as 'true' values in boolean
  73 + */
  74 + protected function bool($var=NULL){
  75 + $isTrue=Array('true','0','yes');
  76 + if(is_bool($var))return $var;
  77 + return (in_array(strtolower(trim((string)$var)),$isTrue));
  78 + }
  79 +
70 80 }
71 81  
72 82 ?>
73 83 \ No newline at end of file
... ...
webservice/clienttools/services/0.9/kt.php
... ... @@ -532,10 +532,9 @@ class kt extends client_service {
532 532 $filename = $params ['filename'];
533 533 $reason = $params ['reason'];
534 534 $tempfilename = $params ['tempfilename'];
535   - $major_update = $params ['major_update'];
  535 + $major_update = $this->bool($params); //Force value into boolean container.
536 536 $application = $this->AuthInfo ['appType'];
537 537  
538   - $this->addDebug ( 'Checkin', "checkin_document('$session_id',$document_id,'$filename','$reason','$tempfilename', '$application', $major_update)" );
539 538 $kt = &$this->KT;
540 539  
541 540 // we need to add some security to ensure that people don't frig the checkin process to access restricted files.
... ... @@ -552,6 +551,7 @@ class kt extends client_service {
552 551 }
553 552  
554 553 // checkin
  554 + $this->logInfo('kt.checkin_document','Parameter Inspector',$major_update);
555 555 $result = $document->checkin ( $filename, $reason, $tempfilename, $major_update );
556 556 if (PEAR::isError ( $result )) {
557 557 $this->setResponse ( array ('status_code' => 14 ) );
... ... @@ -578,6 +578,7 @@ class kt extends client_service {
578 578 $metadata = array ();
579 579 $packed = $arr ['metadata'];
580 580  
  581 + //TODO: $meta is undefined - please revise
581 582 foreach ( $meta as $item ) {
582 583 $fieldSet = $item ['fieldset'];
583 584 unset ( $item ['fieldset'] );
... ... @@ -604,7 +605,7 @@ class kt extends client_service {
604 605  
605 606 $document = &$folder->add_document ( $arr ['title'], $arr ['filename'], $arr ['documenttype'], $arr ['tempfilename'] );
606 607 if (PEAR::isError ( $document )) {
607   - $this->addError ( "Could not add Document [title:{$title},filename:{$filename},documenttype:{$documenttype},tempfilename:{$tempfilename}]" );
  608 + $this->addError ( "Could not add Document [title:{$arr['title']},filename:{$arr['filename']},documenttype:{$arr['documenttype']},tempfilename:{$arr['tempfilename']}]" );
608 609 $this->setResponse ( array ('status_code' => 1, 'message' => 'Could not add Document' ) );
609 610 return false;
610 611 }
... ...