Пример #1
0
 /**
  * Checkin Document //TODO: Find out how upload works
  * params contains:
  * 		document_id
  * 		filename
  * 		reason
  * 		tempfilename
  *
  * @param array $params
  */
 function checkin_document($params)
 {
     $session_id = $this->AuthInfo['session'];
     $document_id = $params['document_id'];
     $filename = $params['filename'];
     $reason = $params['reason'];
     $tempfilename = $params['tempfilename'];
     $application = $this->AuthInfo['appType'];
     $this->addDebug('Checkin', "checkin_document('{$session_id}',{$document_id},'{$filename}','{$reason}','{$tempfilename}', '{$application}')");
     $kt =& $this->KT;
     // we need to add some security to ensure that people don't frig the checkin process to access restricted files.
     // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome.
     $upload_manager = new KTUploadManager();
     if (!$upload_manager->is_valid_temporary_file($tempfilename)) {
         $this->setResponse(array('status_code' => 12));
         return;
     }
     $document =& $kt->get_document_by_id($document_id);
     if (PEAR::isError($document)) {
         $this->setResponse(array('status_code' => 13));
     }
     // checkin
     $result = $document->checkin($filename, $reason, $tempfilename, false);
     if (PEAR::isError($result)) {
         $this->setResponse(array('status_code' => 14));
     }
     // get status after checkin
     //$this->response= $this->get_document_detail($session_id, $document_id);
     $detail = $document->get_detail();
     $detail['status_code'] = 0;
     $detail['message'] = '';
     $this->setResponse($detail);
 }
Пример #2
0
 /**
  * Does a document checkin.
  *
  * @author KnowledgeTree Team
  * @access public
  * @param int $folder_id
  * @param string $title
  * @param string $filename
  * @param string $documenttype
  * @param string $tempfilename
  * @return kt_document_detail. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_FOLDER, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS
  */
 public function checkin_document($document_id, $filename, $reason, $tempfilename, $major_update, $sig_username = '', $sig_password = '')
 {
     $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, 'ktcore.transactions.check_in');
     if ($response['status_code'] == 1) {
         return $response;
     }
     // we need to add some security to ensure that people don't frig the checkin process to access restricted files.
     // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome.
     $upload_manager = new KTUploadManager();
     if (!$upload_manager->is_valid_temporary_file($tempfilename)) {
         $response['status_code'] = 1;
         $response['message'] = 'Invalid temporary file';
         return $response;
     }
     $document =& $this->get_document_by_id($document_id);
     if (PEAR::isError($document)) {
         $response['status_code'] = 1;
         $response['message'] = $document->getMessage();
         return $response;
     }
     // checkin
     $result = $document->checkin($filename, $reason, $tempfilename, $major_update);
     if (PEAR::isError($result)) {
         $response['status_code'] = 1;
         $response['message'] = $result->getMessage();
         return $response;
     }
     // get status after checkin
     return $this->get_document_detail($document_id);
 }
Пример #3
0
 /**
  * Does a document checkin.
  *
  * @param string $session_id
  * @param int $folder_id
  * @param string $title
  * @param string $filename
  * @param string $documenttype
  * @param string $tempfilename
  * @return kt_document_detail. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_FOLDER, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS
  */
 function checkin_document($session_id, $document_id, $filename, $reason, $tempfilename, $major_update)
 {
     $this->debug("checkin_document('{$session_id}',{$document_id},'{$filename}','{$reason}','{$tempfilename}',{$major_update})");
     $kt =& $this->get_ktapi($session_id);
     if (is_array($kt)) {
         return new SOAP_Value('return', "{urn:{$this->namespace}}kt_document_detail", $kt);
     }
     $response = KTWebService::_status(KTWS_ERR_INVALID_DOCUMENT);
     // we need to add some security to ensure that people don't frig the checkin process to access restricted files.
     // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome.
     $upload_manager = new KTUploadManager();
     if (!$upload_manager->is_valid_temporary_file($tempfilename)) {
         $response['message'] = 'Invalid temporary file';
         $this->debug("checkin_document - {$upload_manager->temp_dir} != {$tempdir}", $session_id);
         return new SOAP_Value('return', "{urn:{$this->namespace}}kt_document_detail", $response);
     }
     $document =& $kt->get_document_by_id($document_id);
     if (PEAR::isError($document)) {
         $response['message'] = $document->getMessage();
         $this->debug("checkin_document - cannot get documentid {$document_id} - " . $document->getMessage(), $session_id);
         return new SOAP_Value('return', "{urn:{$this->namespace}}kt_document_detail", $response);
     }
     // checkin
     $result = $document->checkin($filename, $reason, $tempfilename, $major_update);
     if (PEAR::isError($result)) {
         $response['message'] = $result->getMessage();
         $this->debug("checkin_document - cannot checkin - " . $result->getMessage(), $session_id);
         return new SOAP_Value('return', "{urn:{$this->namespace}}kt_document_detail", $response);
     }
     // get status after checkin
     return $this->get_document_detail($session_id, $document_id);
 }
Пример #4
0
 function add_document_params($params)
 {
     $folder_id = $params['folder_id'];
     $title = $params['title'];
     $filename = $params['filename'];
     $documenttype = $params['documenttype'];
     $tempfilename = $params['tempfilename'];
     $application = $params['application'];
     $this->addDebug('', 'Entered add_document');
     $kt =& $this->KT;
     $upload_manager = new KTUploadManager();
     if (!$upload_manager->is_valid_temporary_file($tempfilename)) {
         $this->addError('Temporary File Not Valid');
         $this->setResponse(array('status_code' => 1));
         return false;
     }
     $this->addDebug('', 'Exited is_valid_temporary file');
     $folder =& $kt->get_folder_by_id($folder_id);
     if (PEAR::isError($folder)) {
         $this->addError('Could not find Folder ' . $folder_id);
         $this->setResponse(array('status_code' => 1));
         return false;
     }
     $this->addDebug('', 'Exited get_folder_by_id');
     $document =& $folder->add_document($title, $filename, $documenttype, $tempfilename);
     if (PEAR::isError($document)) {
         $this->addError("Could add Document [title:{$title},filename:{$filename},documenttype:{$documenttype},tempfilename:{$tempfilename}]");
         $this->setResponse(array('status_code' => 1));
         return false;
     }
     $this->addDebug('', 'Exited folder add_document');
     $detail = $document->get_detail();
     $detail['status_code'] = 0;
     $detail['message'] = '';
     $this->setResponse($detail);
 }