コード例 #1
0
 /**
  * Gets a data stream of files by claim reference number
  *
  * Collates all uploaded files into a zip file on the server. Also makes md5
  * hash of zip file so that, once transferred, data integrity can be tested
  * at the consumer end.
  *
  * Subsequently the zip file is deleted.
  *
  * @param int $refNo rent guarantee claim reference number
  * @return array data
  */
 public function getFileByRefNo($refNo)
 {
     $claimMan = new Manager_Insurance_RentGuaranteeClaim_Claim();
     $files = $claimMan->getSupportingDocumentsByReferenceNumber($refNo);
     if (count($files) == 0) {
         return array('item' => sprintf('Error - No files registered for CRN %s', $refNo), 'hash' => False);
     }
     // Setup paths and file location
     $base_path = APPLICATION_PATH . '/../private/uploads/';
     $zip_path = $base_path . 'rentguaranteeclaims/zips/';
     // Check for file path sanity
     if (!file_exists($zip_path)) {
         return array('item' => sprintf('Error - file path <%s> does not exist', $zip_path), 'hash' => False);
     }
     // Create archive
     $zip = new ZipArchive();
     $archive = sprintf($zip_path . 'files_%s.zip', $refNo);
     // Create archive
     if ($zip->open($archive, ZIPARCHIVE::CREATE) !== TRUE) {
         return array('item' => sprintf('Error - cannot create <%s>', $archive), 'hash' => False);
     }
     // Add the files
     foreach ($files as $file) {
         $zip->addFile($base_path . $file->fullPath, array_pop(explode('/', $file->fullPath)));
     }
     $zip->close();
     $md5 = md5_file($archive);
     // Read the zip
     $fh = fopen($archive, 'r');
     $zipData = fread($fh, filesize($archive));
     // Clean up
     fclose($fh);
     unlink($archive);
     // Return the data to the caller
     return array('data' => base64_encode($zipData), 'hash' => $md5);
 }
コード例 #2
0
 public function continueAction()
 {
     if ($this->getRequest()->isPost()) {
         // Sanitise ref_num
         $filters = array('*' => array('StringTrim', 'HtmlEntities', 'StripTags'));
         $validators = array('*' => array('allowEmpty' => true));
         $input['referenceNumber'] = $this->_request->getParam('ref_num');
         $validate = new Zend_Filter_Input($filters, $validators, $input);
         Zend_Debug::dump($input['referenceNumber']);
         $referenceNumber = $validate->getEscaped('referenceNumber');
         $pageSession = new Zend_Session_Namespace('online_claims');
         $pageSession->ClaimReferenceNumber = $referenceNumber;
         /*
         We are always going to go back to step1 for claims when continuing but we have to set the session variables up
         to know how far into the process we got. Otherwise this crap f*cking Sword code doesn't bother
         populating any of the forms with data already saved.
         
         I hate this - so much it gives me headache just thinking about it…
         */
         //Claim Manager
         $claimManager = new Manager_Insurance_RentGuaranteeClaim_Claim();
         //Identify the Step
         $pageSession->completed[1] = true;
         $pageSession->identifier[1] = true;
         $claimData = $claimManager->getClaim($referenceNumber, $this->_agentSchemeNumber);
         if ($claimData->getTenancyStartDate() != "") {
             $step = 2;
             $pageSession->completed[2] = true;
             $pageSession->identifier[2] = true;
         }
         $rentPayments = $claimManager->getRentPaymentsByReferenceNumber($referenceNumber);
         if (count($rentPayments) > 0) {
             $step = 3;
             $pageSession->completed[3] = true;
             $pageSession->identifier[3] = true;
         }
         $supportingDocs = $claimManager->getSupportingDocumentsByReferenceNumber($referenceNumber);
         if (count($supportingDocs) > 0) {
             $step = 4;
             $pageSession->completed[4] = true;
             $pageSession->identifier[4] = true;
         }
         $this->_helper->redirector->gotoUrl('rentguaranteeclaims/step1');
     }
 }