public function documentAction()
 {
     $r = $this->getRequest();
     $guid = $r->getParam('g');
     $this->view->catalogGuid = $guid;
     Zend_Loader::loadClass('Kutu_Core_Orm_Table_RelatedItem');
     $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
     $where = "relatedGuid='{$guid}' AND relateAs='RELATED_FILE'";
     $rowsetRelatedItem = $tblRelatedItem->fetchAll($where);
     $this->view->rowsetRelatedItem = $rowsetRelatedItem;
 }
Ejemplo n.º 2
0
 public function relateTo($relatedGuid, $as = 'RELATED_ITEM', $valRelation = 0)
 {
     $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
     if (empty($this->guid)) {
         throw new Zend_Exception('Can not relate to empty GUID');
     }
     if (empty($relatedGuid)) {
         throw new Zend_Exception('Can not relate to empty related GUID');
     }
     $rowsetRelatedItem = $tblRelatedItem->find($this->guid, $relatedGuid, $as);
     if (count($rowsetRelatedItem) > 0) {
         $row = $rowsetRelatedItem->current();
         $row->valueIntRelation = $valRelation;
     } else {
         $row = $tblRelatedItem->createNew();
         $row->itemGuid = $this->guid;
         $row->relatedGuid = $relatedGuid;
         $row->relateAs = $as;
         $row->valueIntRelation = $valRelation;
     }
     $row->save();
 }
Ejemplo n.º 3
0
 private function _extractText_ZendDb($guid, $systemName, $fileName, $mimeType)
 {
     //$c = $this->_registry->get('config');
     $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
     $rowset = $tblRelatedItem->fetchAll("itemGuid='{$guid}' AND relateAs='RELATED_FILE'");
     if (count($rowset)) {
         $row = $rowset->current();
         $parentCatalogGuid = $row->relatedGuid;
         if (!empty($systemName)) {
             $fileName = $systemName;
         }
         $sDir1 = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $fileName;
         $sDir2 = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $parentCatalogGuid . DIRECTORY_SEPARATOR . $fileName;
         $sDir = '';
         if (file_exists($sDir1)) {
             $sDir = $sDir1;
         } else {
             if (file_exists($sDir2)) {
                 $sDir = $sDir2;
             }
         }
         if (!empty($sDir)) {
             $outpath = $sDir . '.txt';
             switch ($mimeType) {
                 case 'application/pdf':
                     $pdfExtractor = $this->_pdfExtractor;
                     system("{$pdfExtractor} " . $sDir . ' ' . $outpath, $ret);
                     if ($ret == 0) {
                         $value = file_get_contents($outpath);
                         unlink($outpath);
                         //echo 'content PDF: '. $sDir.' ' . strlen($value);
                         if (strlen($value) > 20) {
                             return $this->clean_string_input($value);
                         } else {
                             //echo 'content file kosong';
                             return '';
                         }
                     }
                     if ($ret == 127) {
                         //print "Could not find pdftotext tool.";
                         return '';
                     }
                     if ($ret == 1) {
                         //print "Could not find pdf file.";
                         return '';
                     }
                     break;
                 case 'text/html':
                 case 'text/plain':
                     $docHtml = Zend_Search_Lucene_Document_Html::loadHTMLFile($sDir);
                     return $docHtml->getFieldValue('body');
                     break;
                 case 'application/x-javascript':
                 case 'application/octet-stream':
                 case 'application/msword':
                     if (strpos(strtolower($fileName), '.doc')) {
                         $extractor = $this->_wordExtractor;
                         system("{$extractor} -m cp850.txt " . $sDir . ' > ' . $outpath, $ret);
                         if ($ret == 0) {
                             $value = file_get_contents($outpath);
                             unlink($outpath);
                             //echo $value;
                             return $value;
                         }
                         if ($ret == 127) {
                             //print "Could not find pdftotext tool.";
                             return '';
                         }
                         if ($ret == 1) {
                             //print "Could not find pdf file.";
                             return '';
                         }
                     } else {
                         return '';
                     }
                     break;
                 default:
                     return '';
                     break;
             }
         }
     }
     return '';
 }
Ejemplo n.º 4
0
 public function sampleAction()
 {
     $req = $this->getRequest();
     //$this->view->message = "We detected that you don't have yet access to this resource. If you believe you have one, please contact our support. Thank you.";
     $catalogGuid = $req->getParam('guid');
     $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
     $rowsetCatalog = $tblCatalog->find($catalogGuid);
     $this->_helper->layout()->disableLayout();
     if (count($rowsetCatalog)) {
         $rowCatalog = $rowsetCatalog->current();
         $rowsetCatAtt = $rowCatalog->findDependentRowsetCatalogAttribute();
         $contentType = $rowsetCatAtt->findByAttributeGuid('docMimeType')->value;
         $systemname = $rowsetCatAtt->findByAttributeGuid('docSystemName')->value;
         $filename = $rowsetCatAtt->findByAttributeGuid('docOriginalName')->value;
         $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
         $rowsetRelatedItem = $tblRelatedItem->fetchAll("itemGuid='{$catalogGuid}' AND relateAs='RELATED_FILE'");
         $flagFileFound = false;
         foreach ($rowsetRelatedItem as $rowRelatedItem) {
             if (!$flagFileFound) {
                 $parentGuid = $rowRelatedItem->relatedGuid;
                 $sDir1 = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $systemname;
                 $sDir2 = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $parentGuid . DIRECTORY_SEPARATOR . $systemname;
                 if (file_exists($sDir1)) {
                     $flagFileFound = true;
                     if (trim($contentType) == 'application/pdf') {
                         $this->_generatePdfSamplePage($sDir1);
                     } else {
                         echo 'NO SAMPLE PAGE';
                     }
                 } else {
                     if (file_exists($sDir2)) {
                         $flagFileFound = true;
                         if (trim($contentType) == 'application/pdf') {
                             $this->_generatePdfSamplePage($sDir2);
                         } else {
                             echo 'NO SAMPLE PAGE';
                         }
                     } else {
                         echo 'No FILE';
                         $flagFileFound = false;
                     }
                 }
             }
         }
     } else {
         echo 'NO FILE';
     }
 }
Ejemplo n.º 5
0
 function _traverseHistory($catalogGuid, $aData)
 {
     $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
     $sGuid = '';
     $where = "relatedGuid='{$catalogGuid}' AND relateAs='RELATED_HISTORY'";
     $rowsetRelatedItem = $tblRelatedItem->fetchAll($where);
     foreach ($rowsetRelatedItem as $rowRelatedItem) {
         if (!isset($aData[$catalogGuid]['right'])) {
             //echo 'right: '.$rowRelatedItem->itemGuid . '|';
             $sGuid .= $catalogGuid . '|';
             $aData[$catalogGuid]['right'] = $catalogGuid;
             $sGuid .= $this->_traverseHistory($rowRelatedItem->itemGuid, $aData) . '|';
         }
     }
     $where2 = "itemGuid='{$catalogGuid}' AND relateAs='RELATED_HISTORY'";
     $rowsetRelatedItem = $tblRelatedItem->fetchAll($where2);
     foreach ($rowsetRelatedItem as $rowRelatedItem) {
         if (!isset($aData[$catalogGuid]['left'])) {
             //echo 'left: '.$rowRelatedItem->relatedGuid . '|';
             $sGuid .= $catalogGuid . '|';
             $aData[$catalogGuid]['left]'] = $catalogGuid;
             $sGuid .= $this->_traverseHistory($rowRelatedItem->relatedGuid, $aData) . '|';
         }
     }
     return $sGuid;
 }
Ejemplo n.º 6
0
 public function addTranslation($itemGuid, $relatedGuid)
 {
     $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
     //check apakah relatedGuid adalah seorang parent atau child
     $rowsetRelatedItem = $tblRelatedItem->fetchAll("relatedGuid='{$relatedGuid}' AND relateAs='RELATED_TRANSLATION'");
     if (count($rowsetRelatedItem)) {
         //do nothing
     }
     $rowsetRelatedItem = $tblRelatedItem->fetchAll("itemGuid='{$relatedGuid}' AND relateAs='RELATED_TRANSLATION'");
     if (count($rowsetRelatedItem)) {
         $relatedGuid = $rowsetRelatedItem->current()->relatedGuid;
     }
     //check if $itemGuid adalah parent atau child
     $rowsetRelatedItem = $tblRelatedItem->fetchAll("relatedGuid='{$itemGuid}' AND relateAs='RELATED_TRANSLATION'");
     if (count($rowsetRelatedItem)) {
         //check apakah sudah ada
         $rs1 = $tblRelatedItem->find($this->itemGuid, $relatedGuid, "RELATED_TRANSLATION");
         if (count($rs1)) {
         } else {
             $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
             $rowset = $tblCatalog->find($itemGuid);
             if (count($rowset)) {
                 $row = $rowset->current();
                 $row->relateTo($relatedGuid, "RELATED_TRANSLATION");
             }
         }
         //get all children and set its current relatedGuid to the new relatedGuid
         foreach ($rowsetRelatedItem as $row) {
             $row->relatedGuid = $relatedGuid;
             $row->save();
         }
     } else {
         //check apakah itemGuid adalah child
         $rs1 = $tblRelatedItem->fetchAll("itemGuid='{$itemGuid}' AND relateAs='RELATED_TRANSLATION'");
         if (count($rs1)) {
             //update bapaknya dan anak dari bapaknya
             $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
             $rowset = $tblCatalog->find($rs1->current()->relatedGuid);
             if (count($rowset)) {
                 $row = $rowset->current();
                 $row->relateTo($relatedGuid, "RELATED_TRANSLATION");
             }
             $bapak = $rs1->current()->relatedGuid;
             $rs2 = $tblRelatedItem->fetchAll("relatedGuid='{$bapak}' AND relateAs='RELATED_TRANSLATION'");
             if (count($rs2)) {
                 foreach ($rs2 as $row) {
                     $row->relatedGuid = $relatedGuid;
                     $row->save();
                 }
             }
         }
     }
     /*$rowsetRelatedItem = $tblRelatedItem->find($this->itemGuid, $relatedGuid, "RELATED_TRANSLATION");
     		if(count($rowsetRelatedItem))
     		{
     			
     		}
     		else
     		{
     			$rowsetRelatedItem = $tblRelatedItem->find($relatedGuid, $this->itemGuid, "RELATED_TRANSLATION");
     			if(count($rowsetRelatedItem))
     			{
     				
     			}
     			else
     			{
     				$tblCatalog = new Kutu_Core_Orm_Table_Catalog();
     				$rowset = $tblCatalog->find($itemGuid);
     				if(count($rowset))
     				{
     					$row = $rowset->current();
     					$row->relateTo($relatedGuid, "RELATED_TRANSLATION");
     				}
     			}
     		}*/
 }
Ejemplo n.º 7
0
 public function jCartIsItemSellable($catalogGuid)
 {
     //apakah pernah dibeli
     $auth = Zend_Auth::getInstance();
     $hasBought = false;
     if ($auth->hasIdentity()) {
         $bpm = new Kutu_Core_Bpm_Catalog();
         $hasBought = $bpm->isBoughtByUser($catalogGuid, $auth->getIdentity()->guid);
     }
     if ($hasBought) {
         $aReturn['isError'] = true;
         $aReturn['message'] = 'You have bought this Item before. Please check your account.';
         $aReturn['code'] = 1;
         return $aReturn;
     }
     // if status=draft then return false
     $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
     $rowCatalog = $tblCatalog->find($catalogGuid)->current();
     if ($rowCatalog) {
         if ($rowCatalog->status != 99) {
             $aReturn['isError'] = true;
             $aReturn['message'] = 'This item is not ready to be bought yet.';
             $aReturn['code'] = 1;
             return $aReturn;
         }
         // if price <= 0 then return false
         if ($rowCatalog->price <= 0) {
             $aReturn['isError'] = true;
             $aReturn['message'] = 'This item is for FREE.';
             $aReturn['code'] = 2;
             return $aReturn;
         }
         $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
         $where = "relatedGuid='{$catalogGuid}' AND relateAs='RELATED_FILE'";
         $rowsetRelatedItem = $tblRelatedItem->fetchAll($where);
         if (count($rowsetRelatedItem) > 0) {
             //check if the physical FILE is available in uploads directory.
             $flagFileFound = true;
             foreach ($rowsetRelatedItem as $rowRelatedItem) {
                 $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
                 $rowsetCatalogFile = $tblCatalog->find($rowRelatedItem->itemGuid);
                 $rowCatalogFile = $rowsetCatalogFile->current();
                 $rowsetCatAtt = $rowCatalogFile->findDependentRowsetCatalogAttribute();
                 $contentType = $rowsetCatAtt->findByAttributeGuid('docMimeType')->value;
                 $systemname = $rowsetCatAtt->findByAttributeGuid('docSystemName')->value;
                 $filename = $rowsetCatAtt->findByAttributeGuid('docOriginalName')->value;
                 if (true) {
                     $parentGuid = $rowRelatedItem->relatedGuid;
                     $sDir1 = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $systemname;
                     $sDir2 = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $parentGuid . DIRECTORY_SEPARATOR . $systemname;
                     if (file_exists($sDir1)) {
                         //$flagFileFound = true;
                     } else {
                         if (file_exists($sDir2)) {
                             //$flagFileFound = true;
                         } else {
                             $flagFileFound = false;
                         }
                     }
                 }
             }
             if ($flagFileFound) {
                 $aReturn['isError'] = false;
                 $aReturn['message'] = 'This item is SELLABLE.';
                 $aReturn['code'] = 99;
                 return $aReturn;
             } else {
                 $aReturn['isError'] = true;
                 $aReturn['message'] = 'We are Sorry. The document(s) you are requesting is still under review. Please check back later.';
                 $aReturn['code'] = 5;
                 return $aReturn;
             }
         } else {
             $aReturn['isError'] = true;
             $aReturn['message'] = 'We are Sorry. The document(s) you are requesting is still being prepared. Please check back later.';
             $aReturn['code'] = 5;
             return $aReturn;
         }
     } else {
         $aReturn['isError'] = true;
         $aReturn['message'] = 'Can not find your selected item(s).';
         $aReturn['code'] = 10;
         return $aReturn;
     }
     //if ada record related document, but tidak ada dokumen fisik, then return false
     // if tidak ada record related document (blm ada dokumen/file diupload), then return false
     // if pernah dibeli user sebelumnya, then return false
 }
Ejemplo n.º 8
0
 public function downloadAction()
 {
     $this->_helper->layout()->disableLayout();
     //$this->view->addHelperPath(KUTU_ROOT_DIR.'/mix_lib/Kutu/View/Helper', 'Kutu_View_Helper');
     $req = $this->getRequest();
     $catalogGuid = $req->getParam('guid');
     $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
     $rowsetCatalog = $tblCatalog->find($catalogGuid);
     if (count($rowsetCatalog)) {
         $rowCatalog = $rowsetCatalog->current();
         $rowsetCatAtt = $rowCatalog->findDependentRowsetCatalogAttribute();
         $contentType = $rowsetCatAtt->findByAttributeGuid('docMimeType')->value;
         $systemname = $rowsetCatAtt->findByAttributeGuid('docSystemName')->value;
         $filename = $rowsetCatAtt->findByAttributeGuid('docOriginalName')->value;
         $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
         $rowsetRelatedItem = $tblRelatedItem->fetchAll("itemGuid='{$catalogGuid}' AND relateAs='RELATED_FILE'");
         $flagFileFound = false;
         foreach ($rowsetRelatedItem as $rowRelatedItem) {
             if (!$flagFileFound) {
                 $parentGuid = $rowRelatedItem->relatedGuid;
                 $sDir1 = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $systemname;
                 $sDir2 = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $parentGuid . DIRECTORY_SEPARATOR . $systemname;
                 if (file_exists($sDir1)) {
                     $flagFileFound = true;
                     header("Content-type: {$contentType}");
                     header("Content-Disposition: attachment; filename={$filename}");
                     @readfile($sDir1);
                 } else {
                     if (file_exists($sDir2)) {
                         $flagFileFound = true;
                         header("Content-type: {$contentType}");
                         header("Content-Disposition: attachment; filename={$filename}");
                         @readfile($sDir2);
                     } else {
                         echo 'No FILE';
                         $flagFileFound = false;
                     }
                 }
             }
         }
     } else {
         echo 'NO FILE';
     }
 }
Ejemplo n.º 9
0
 public function delete($catalogGuid)
 {
     $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
     $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
     $rowset = $tblCatalog->find($catalogGuid);
     if (count($rowset)) {
         $row = $rowset->current();
         $profileGuid = $row->profileGuid;
         if ($row->profileGuid == 'kutu_doc') {
             $rowRelatedItem = $tblRelatedItem->fetchRow("itemGuid='{$row->guid}' AND relateAs='RELATED_FILE'");
         }
         $row->delete();
         //if deleted catalog is kutu_doc then re-index its parentGuid
         if ($profileGuid == 'kutu_doc') {
             $indexingEngine = Kutu_Search::manager();
             $indexingEngine->indexCatalog($rowRelatedItem->relatedGuid);
         }
     }
 }
Ejemplo n.º 10
0
 public function getsearchAction()
 {
     $this->_helper->layout()->disableLayout();
     $r = $this->getRequest();
     $query = $r->getParam('query') ? $r->getParam('query') : '';
     $start = $r->getParam('start') ? $r->getParam('start') : 0;
     $limit = $r->getParam('limit') ? $r->getParam('limit') : 20;
     $orderBy = $r->getParam('orderBy') ? $r->getParam('sortBy') : 'regulationOrder';
     $sortOrder = $r->getParam('sortOrder') ? $r->getParam('sortOrder') : ' asc';
     $a = array();
     $a['query'] = $query;
     $indexingEngine = Kutu_Search::manager();
     $hits = $indexingEngine->find($query, $start, $limit);
     $num = $hits->response->numFound;
     $solrNumFound = count($hits->response->docs);
     $ii = 0;
     if ($solrNumFound == 0) {
         $a['catalogs'][0]['guid'] = 'XXX';
         $a['catalogs'][0]['title'] = "No Data";
         $a['catalogs'][0]['subTitle'] = "";
         $a['catalogs'][0]['createdDate'] = '';
         $a['catalogs'][0]['modifiedDate'] = '';
     } else {
         if ($solrNumFound > $limit) {
             $numRowset = $limit;
         } else {
             $numRowset = $solrNumFound;
         }
         for ($ii = 0; $ii < $numRowset; $ii++) {
             $row = $hits->response->docs[$ii];
             if (!empty($row)) {
                 if ($row->profile == 'kutu_doc') {
                     $title = 'File : ' . $row->title;
                     $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
                     $rowset = $tblRelatedItem->fetchRow("itemGuid='{$row->id}'");
                     if ($rowset) {
                         $guid = $rowset->relatedGuid;
                     } else {
                         $guid = $row->id;
                     }
                 } else {
                     $title = $row->title;
                     $guid = $row->id;
                 }
                 $a['catalogs'][$ii]['title'] = $title;
                 $a['catalogs'][$ii]['guid'] = $guid;
                 if (!isset($row->subTitle)) {
                     $a['catalogs'][$ii]['subTitle'] = '';
                 } else {
                     $a['catalogs'][$ii]['subTitle'] = $row->subTitle;
                 }
                 if ($row->profile == 'kutu_doc') {
                     $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
                     $rowsetRelatedItem = $tblRelatedItem->fetchRow("itemGuid='{$row->id}' AND relateAs='RELATED_FILE'");
                     if ($rowsetRelatedItem) {
                         $parentGuid = $rowsetRelatedItem->relatedGuid;
                     } else {
                         $parentGuid = '';
                     }
                 } else {
                     $tblCatalogFolder = new Kutu_Core_Orm_Table_CatalogFolder();
                     $rowsetCatalogFolder = $tblCatalogFolder->fetchRow("catalogGuid='{$row->id}'");
                     if ($rowsetCatalogFolder) {
                         $parentGuid = $rowsetCatalogFolder->folderGuid;
                     } else {
                         $parentGuid = '';
                     }
                 }
                 $a['catalogs'][$ii]['folderGuid'] = $parentGuid;
                 $a['catalogs'][$ii]['createdDate'] = $row->createdDate;
                 $a['catalogs'][$ii]['modifiedDate'] = $row->modifiedDate;
             }
         }
     }
     echo Zend_Json::encode($a);
 }
Ejemplo n.º 11
0
 function downloadFileAction()
 {
     $catalogGuid = $this->_getParam('guid');
     $parentGuid = $this->_getParam('parent');
     $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
     $rowsetCatalog = $tblCatalog->find($catalogGuid);
     if (count($rowsetCatalog)) {
         $rowCatalog = $rowsetCatalog->current();
         $rowsetCatAtt = $rowCatalog->findDependentRowsetCatalogAttribute();
         $contentType = $rowsetCatAtt->findByAttributeGuid('docMimeType')->value;
         $filename = $systemname = $rowsetCatAtt->findByAttributeGuid('docSystemName')->value;
         $oriName = $oname = $rowsetCatAtt->findByAttributeGuid('docOriginalName')->value;
         $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
         $rowsetRelatedItem = $tblRelatedItem->fetchAll("itemGuid='{$catalogGuid}' AND relateAs='RELATED_FILE'");
         $flagFileFound = false;
         foreach ($rowsetRelatedItem as $rowRelatedItem) {
             if (!$flagFileFound) {
                 $parentGuid = $rowRelatedItem->relatedGuid;
                 $sDir1 = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $systemname;
                 $sDir2 = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $parentGuid . DIRECTORY_SEPARATOR . $systemname;
                 $sDir3 = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $oname;
                 $sDir4 = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $parentGuid . DIRECTORY_SEPARATOR . $oname;
                 if (file_exists($sDir1)) {
                     $flagFileFound = true;
                     header("Content-type: {$contentType}");
                     header("Content-Disposition: attachment; filename={$oriName}");
                     @readfile($sDir1);
                     die;
                 } else {
                     if (file_exists($sDir2)) {
                         $flagFileFound = true;
                         header("Content-type: {$contentType}");
                         header("Content-Disposition: attachment; filename={$oriName}");
                         @readfile($sDir2);
                         die;
                     }
                 }
                 if (file_exists($sDir3)) {
                     $flagFileFound = true;
                     header("Content-type: {$contentType}");
                     header("Content-Disposition: attachment; filename={$oriName}");
                     @readfile($sDir3);
                     die;
                 }
                 if (file_exists($sDir4)) {
                     $flagFileFound = true;
                     header("Content-type: {$contentType}");
                     header("Content-Disposition: attachment; filename={$oriName}");
                     @readfile($sDir4);
                     die;
                 } else {
                     $flagFileFound = false;
                     $this->_forward('forbidden', 'browser');
                 }
             }
         }
     } else {
         $flagFileFound = false;
         $this->_forward('forbidden', 'browser');
     }
 }
Ejemplo n.º 12
0
 public function otherAction()
 {
     $catalogGuid = $this->_getParam('guid') ? $this->_getParam('guid') : '';
     $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
     $where = "relatedGuid='{$catalogGuid}' AND relateAs='RELATED_OTHER'";
     $rowsetRelatedItem = $tblRelatedItem->fetchAll($where);
     $this->view->rowsetRelatedItem = $rowsetRelatedItem;
 }
 private function _createDocs($sourceCatalogId, $guidPrefix = 'lgsimpfl')
 {
     // get all related documents
     $tblCatalog = new Kutu_Core_Orm_Table_Catalog();
     $tblCatalogAttribute = new Kutu_Core_Orm_Table_CatalogAttribute();
     $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem();
     $this->_dbSource->setFetchMode(Zend_Db::FETCH_OBJ);
     $rowsetDocItem = $this->_dbSource->fetchAll("SELECT * from tblDms_DocItem A  \n\t\t\t\tWHERE A.CatalogID = {$sourceCatalogId}");
     foreach ($rowsetDocItem as $rowDocItem) {
         $rowsetCatalog = $tblCatalog->find($guidPrefix . $rowDocItem->DocItemID);
         if (count($rowsetCatalog) == 0) {
             $rowCatalog = $tblCatalog->fetchNew();
             $rowCatalog->guid = $guidPrefix . $rowDocItem->DocItemID;
             echo "KITI: " . $rowCatalog->guid;
             $sFileAsli = str_replace(array('_', '.'), '-', $rowDocItem->DocFileAsli);
             $rowCatalog->shortTitle = $sFileAsli;
             $rowCatalog->profileGuid = "kutu_doc";
             $rowCatalog->createdBy = $rowDocItem->DocCreator;
             $rowCatalog->modifiedBy = $rowDocItem->DocModifier;
             $rowCatalog->createdDate = $rowDocItem->DocCreated;
             $rowCatalog->modifiedDate = $rowDocItem->DocModified;
             $rowCatalog->save();
             $rowExp = $this->_dbSource->fetchRow("Select * from tblDms_Exp_Seq where DocItemID={$rowDocItem->DocItemID} AND DocumentID={$rowDocItem->CatalogID}");
             //	untuk catalogAttributenya tambahan agar isinya fixedTitle,dsb itu
             // fixedTitle
             $rowCatalogAttribute = $tblCatalogAttribute->fetchNew();
             $rowCatalogAttribute->catalogGuid = $guidPrefix . $rowDocItem->DocItemID;
             $rowCatalogAttribute->attributeGuid = 'fixedTitle';
             if (empty($rowExp->Friendlyname)) {
                 $rowCatalogAttribute->value = $rowDocItem->DocFileAsli;
             } else {
                 $rowCatalogAttribute->value = $rowExp->Friendlyname;
             }
             $rowCatalogAttribute->save();
             // fixedKeywords
             $rowCatalogAttribute = $tblCatalogAttribute->fetchNew();
             $rowCatalogAttribute->catalogGuid = $guidPrefix . $rowDocItem->DocItemID;
             $rowCatalogAttribute->attributeGuid = 'fixedKeywords';
             $rowCatalogAttribute->value = "";
             $rowCatalogAttribute->save();
             // fixedDescription
             $rowCatalogAttribute = $tblCatalogAttribute->fetchNew();
             $rowCatalogAttribute->catalogGuid = $guidPrefix . $rowDocItem->DocItemID;
             $rowCatalogAttribute->attributeGuid = 'fixedDescription';
             $rowCatalogAttribute->value = "";
             $rowCatalogAttribute->save();
             // fixedLanguage
             $rowCatalogAttribute = $tblCatalogAttribute->fetchNew();
             $rowCatalogAttribute->catalogGuid = $guidPrefix . $rowDocItem->DocItemID;
             $rowCatalogAttribute->attributeGuid = 'fixedLanguage';
             $rowCatalogAttribute->value = "en";
             $rowCatalogAttribute->save();
             // docCategoryGuid
             $rowCatalogAttribute = $tblCatalogAttribute->fetchNew();
             $rowCatalogAttribute->catalogGuid = $guidPrefix . $rowDocItem->DocItemID;
             $rowCatalogAttribute->attributeGuid = 'docCategoryGuid';
             $rowCatalogAttribute->value = "";
             $rowCatalogAttribute->save();
             // docSystemName
             $rowCatalogAttribute = $tblCatalogAttribute->fetchNew();
             $rowCatalogAttribute->catalogGuid = $guidPrefix . $rowDocItem->DocItemID;
             $rowCatalogAttribute->attributeGuid = 'docSystemName';
             $rowCatalogAttribute->value = $rowDocItem->DocFileName;
             $rowCatalogAttribute->save();
             // docOriginalName
             $rowCatalogAttribute = $tblCatalogAttribute->fetchNew();
             $rowCatalogAttribute->catalogGuid = $guidPrefix . $rowDocItem->DocItemID;
             $rowCatalogAttribute->attributeGuid = 'docOriginalName';
             $rowCatalogAttribute->value = $rowDocItem->DocFileAsli;
             $rowCatalogAttribute->save();
             // docSize
             $rowCatalogAttribute = $tblCatalogAttribute->fetchNew();
             $rowCatalogAttribute->catalogGuid = $guidPrefix . $rowDocItem->DocItemID;
             $rowCatalogAttribute->attributeGuid = 'docSize';
             $rowCatalogAttribute->value = $rowDocItem->DocSize;
             $rowCatalogAttribute->save();
             // docMimeType
             $rowCatalogAttribute = $tblCatalogAttribute->fetchNew();
             $rowCatalogAttribute->catalogGuid = $guidPrefix . $rowDocItem->DocItemID;
             $rowCatalogAttribute->attributeGuid = 'docMimeType';
             $rowCatalogAttribute->value = $rowDocItem->DocType;
             $rowCatalogAttribute->save();
         } else {
             echo 'Data tidak disimpan';
         }
         // related the file/document as RELATED_FILE
         $rowsetRelatedItem = $tblRelatedItem->find($guidPrefix . $rowDocItem->DocItemID, 'lgsimpdms' . $rowDocItem->CatalogID, "RELATED_FILE");
         if (count($rowsetRelatedItem) == 0) {
             $rowRelation = $tblRelatedItem->createNew();
             $rowRelation->itemGuid = $guidPrefix . $rowDocItem->DocItemID;
             $rowRelation->relatedGuid = 'lgsimpdms' . $rowDocItem->CatalogID;
             $rowRelation->relateAs = "RELATED_FILE";
             if (isset($rowExp->Sequence)) {
                 $rowRelation->valueIntRelation = $rowExp->Sequence;
             }
             $rowRelation->save();
             //echo "<font color=blue>Record ke = ".$r." dari itemGuid = fl".$row->DocItemID." - ".$row->CatalogID." relasi file di-saved</font><br>";
         }
     }
 }