Example #1
0
 public function getNode($guid)
 {
     $modelCatalogFolder = new Pandamp_Modules_Dms_Catalog_Model_CatalogFolder();
     $rowset = $modelCatalogFolder->fetchRow("catalogGuid='" . $guid . "'");
     if ($rowset) {
         return $rowset->folderGuid;
     } else {
         return '';
     }
 }
Example #2
0
 public function copyFolderContent($currentFolderGuid, $newCatalogGuid)
 {
     $tblCatalogFolder = new Pandamp_Modules_Dms_Catalog_Model_CatalogFolder();
     $rowset = $tblCatalogFolder->fetchAll("folderGuid = '{$currentFolderGuid}'");
     if (count($rowset) > 0) {
         foreach ($rowset as $row) {
             $newContent = $tblCatalogFolder->createRow();
             $newContent->folderGuid = $newCatalogGuid;
             $newContent->catalogGuid = $row->catalogGuid;
             $newContent->save();
         }
     }
 }
 function emailAction()
 {
     $folderGuid = $this->_getParam('folderGuid') ? $this->_getParam('folderGuid') : '';
     $tblCatalogFolder = new Pandamp_Modules_Dms_Catalog_Model_CatalogFolder();
     $rowsetCatalogFolder = $tblCatalogFolder->fetchRow("folderGuid='" . $folderGuid . "'");
     if (isset($rowsetCatalogFolder)) {
         $catalogGuid = $rowsetCatalogFolder->catalogGuid;
     } else {
         $catalogGuid = '';
     }
     $gen = new Pandamp_Form_Helper_EmailConfirmGenerator();
     $aRender = $gen->generateFormAdd($catalogGuid, $folderGuid);
     $this->view->aRenderedAttributes = $aRender;
 }
Example #4
0
 public function removeFromFolder($catalogGuid, $folderGuid)
 {
     $tblCatalogFolder = new Pandamp_Modules_Dms_Catalog_Model_CatalogFolder();
     $rowset = $tblCatalogFolder->fetchAll("catalogGuid='{$catalogGuid}'");
     if (count($rowset) > 1) {
         try {
             $tblCatalogFolder->delete("catalogGuid='{$catalogGuid}' AND folderGuid='{$folderGuid}'");
         } catch (Exception $e) {
             throw new Zend_Exception($e->getMessage());
         }
     } else {
         throw new Zend_Exception("Can not remove from the only FOLDER.");
     }
 }
 function saveAction()
 {
     $response = array();
     $request = $this->getRequest();
     $tblCatalog = new Pandamp_Modules_Dms_Catalog_Model_Catalog();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $userName = $auth->getIdentity()->username;
     }
     $gman = new Pandamp_Core_Guid();
     $catalogGuid = $request->getParam('guid') ? $request->getParam('guid') : $gman->generateGuid();
     $folderGuid = $request->getParam('folderGuid') ? $request->getParam('folderGuid') : '';
     //if not empty, there are 2 possibilities
     $where = $tblCatalog->getAdapter()->quoteInto('guid=?', $catalogGuid);
     if ($tblCatalog->fetchRow($where)) {
         $rowCatalog = $tblCatalog->find($catalogGuid)->current();
         $rowCatalog->shortTitle = $request->getParam('shortTitle');
         $rowCatalog->publishedDate = $request->getParam('publishedDate');
         $rowCatalog->expiredDate = $request->getParam('expiredDate');
         $rowCatalog->modifiedBy = $userName;
         $rowCatalog->modifiedDate = date("Y-m-d h:i:s");
         $rowCatalog->status = $request->getParam('status');
     } else {
         $rowCatalog = $tblCatalog->fetchNew();
         $rowCatalog->shortTitle = $request->getParam('shortTitle');
         $rowCatalog->profileGuid = $request->getParam('profileGuid');
         $rowCatalog->publishedDate = $request->getParam('publishedDate');
         $rowCatalog->expiredDate = $request->getParam('expiredDate');
         $rowCatalog->createdBy = $userName;
         $rowCatalog->modifiedBy = $userName;
         $rowCatalog->createdDate = date("Y-m-d h:i:s");
         $rowCatalog->modifiedDate = date("Y-m-d h:i:s");
         $rowCatalog->deletedDate = '0000-00-00 00:00:00';
         $rowCatalog->status = $request->getParam('status');
     }
     $catalogGuid = $rowCatalog->save();
     $tableProfileAttribute = new Pandamp_Modules_Dms_Profile_Model_ProfileAttribute();
     $profileGuid = $rowCatalog->profileGuid;
     $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', $profileGuid);
     $rowsetProfileAttribute = $tableProfileAttribute->fetchAll($where, 'viewOrder ASC');
     $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute();
     foreach ($rowsetProfileAttribute as $rowProfileAttribute) {
         if ($rowsetCatalogAttribute->findByAttributeGuid($rowProfileAttribute->attributeGuid)) {
             $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid($rowProfileAttribute->attributeGuid);
         } else {
             $tblCatalogAttribute = new Pandamp_Modules_Dms_Catalog_Model_CatalogAttribute();
             $rowCatalogAttribute = $tblCatalogAttribute->fetchNew();
             $rowCatalogAttribute->catalogGuid = $catalogGuid;
             $rowCatalogAttribute->attributeGuid = $rowProfileAttribute->attributeGuid;
         }
         $rowCatalogAttribute->value = $request->getParam($rowProfileAttribute->attributeGuid);
         $rowCatalogAttribute->save();
     }
     //save to table CatalogFolder only if folderGuid is not empty
     if (!empty($folderGuid)) {
         $tblCatalogFolder = new Pandamp_Modules_Dms_Catalog_Model_CatalogFolder();
         $rowsetCatalogFolder = $tblCatalogFolder->find($catalogGuid, $folderGuid);
         if (count($rowsetCatalogFolder) <= 0) {
             $rowCatalogFolder = $tblCatalogFolder->createRow(array('catalogGuid' => '', 'folderGuid' => ''));
             $rowCatalogFolder->catalogGuid = $catalogGuid;
             $rowCatalogFolder->folderGuid = $folderGuid;
             $rowCatalogFolder->save();
         }
     }
     $response['success'] = true;
     echo Zend_Json::encode($response);
 }
Example #6
0
 function moveToCatalogAction()
 {
     $selitem = $this->_getParam('selitem') ? $this->_getParam('selitem') : '';
     $targetGuid = $this->_getParam('targetGuid') ? $this->_getParam('targetGuid') : '';
     $currentGuid = $this->_getParam('folderGuid') ? $this->_getParam('folderGuid') : '';
     $tblCatalogFolder = new Pandamp_Modules_Dms_Catalog_Model_CatalogFolder();
     $rowset = $tblCatalogFolder->find($selitem, $currentGuid)->current();
     $rowset->folderGuid = $targetGuid;
     try {
         $rowset->save();
         $this->view->success = true;
         $this->view->message = 'Move to Catalog Success';
     } catch (Exception $e) {
         $this->view->success = false;
         $this->view->error = $e->getMessage();
     }
 }
 public function getsearcharticleAction()
 {
     $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();
     $query = $query . ' profile:article';
     $a['query'] = $query;
     $indexingEngine = Pandamp_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 Pandamp_Modules_Dms_Catalog_Model_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->shortTitle)) {
                     $a['catalogs'][$ii]['subTitle'] = '';
                 } else {
                     $a['catalogs'][$ii]['subTitle'] = $row->shortTitle;
                 }
                 if ($row->profile == 'kutu_doc') {
                     $tblRelatedItem = new Pandamp_Modules_Dms_Catalog_Model_RelatedItem();
                     $rowsetRelatedItem = $tblRelatedItem->fetchRow("itemGuid='{$row->id}' AND relateAs='RELATED_FILE'");
                     if ($rowsetRelatedItem) {
                         $parentGuid = $rowsetRelatedItem->relatedGuid;
                     } else {
                         $parentGuid = '';
                     }
                 } else {
                     $tblCatalogFolder = new Pandamp_Modules_Dms_Catalog_Model_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);
 }
Example #8
0
 function viewFolderNavigationAction()
 {
     $browserUrl = ROOT_URL . '/pusatdata/view/node';
     $folderGuid = $this->_getParam('node') ? $this->_getParam('node') : 'root';
     $tblFolder = new Pandamp_Modules_Dms_Folder_Model_Folder();
     $aPath = array();
     if ($folderGuid == 'root') {
         $aPath[0]['title'] = 'Root';
         $aPath[0]['url'] = $browserUrl;
     } else {
         $rowFolder = $tblFolder->find($folderGuid)->current();
         if (!isset($rowFolder)) {
             $tblCatalogFolder = new Pandamp_Modules_Dms_Catalog_Model_CatalogFolder();
             $rowsetCatalogFolder = $tblCatalogFolder->fetchRow("catalogGuid='{$folderGuid}'");
             if ($rowsetCatalogFolder) {
                 $rowFolder = $tblFolder->find($rowsetCatalogFolder->folderGuid)->current();
             }
         }
         if (!empty($rowFolder->path)) {
             $aFolderGuid = explode("/", $rowFolder->path);
             $sPath = 'root >';
             $aPath[0]['title'] = 'Root';
             $aPath[0]['url'] = $browserUrl;
             $i = 1;
             if (count($aFolderGuid)) {
                 $sPath1 = '';
                 foreach ($aFolderGuid as $guid) {
                     if (!empty($guid)) {
                         $rowFolder1 = $tblFolder->find($guid)->current();
                         $sPath1 .= $rowFolder1->title . ' > ';
                         $aPath[$i]['title'] = $rowFolder1->title . ' > ';
                         $aPath[$i]['url'] = $browserUrl . '/' . $rowFolder1->guid;
                         $i++;
                     }
                 }
                 $aPath[$i]['title'] = $rowFolder->title;
                 $aPath[$i]['url'] = $browserUrl . '/' . $rowFolder->guid;
             }
         } else {
             $aPath[0]['title'] = 'Root';
             $aPath[0]['url'] = $browserUrl;
             $aPath[1]['title'] = $rowFolder->title;
             $aPath[1]['url'] = $browserUrl . '/' . $rowFolder->guid;
         }
     }
     $this->view->aPath = $aPath;
 }
Example #9
0
 protected function _postDelete()
 {
     $registry = Zend_Registry::getInstance();
     $config = $registry->get(Pandamp_Keys::REGISTRY_APP_OBJECT);
     $cdn = $config->getOption('cdn');
     //find related docs and delete them
     $tblRelatedItem = new Pandamp_Modules_Dms_Catalog_Model_RelatedItem();
     $rowsetRelatedDocs = $tblRelatedItem->fetchAll("relatedGuid='{$this->guid}' AND relateAs IN ('RELATED_FILE','RELATED_IMAGE')");
     if (count($rowsetRelatedDocs)) {
         foreach ($rowsetRelatedDocs as $rowRelatedDoc) {
             $tblCatalog = new Pandamp_Modules_Dms_Catalog_Model_Catalog();
             $rowCatalog = $tblCatalog->find($rowRelatedDoc->itemGuid)->current();
             $rowCatalog->delete();
         }
     }
     if ($this->profileGuid == 'kutu_doc') {
         //get parentGuid
         $tblRelatedItem = new Pandamp_Modules_Dms_Catalog_Model_RelatedItem();
         $rowsetRelatedItem = $tblRelatedItem->fetchAll("itemGuid='{$this->guid}' AND relateAs IN ('RELATED_FILE','RELATED_IMAGE')");
         if (count($rowsetRelatedItem)) {
             foreach ($rowsetRelatedItem as $rowRelatedItem) {
                 //must delete the physical files
                 $rowsetCatAtt = $this->findDependentRowsetCatalogAttribute();
                 $systemname = $rowsetCatAtt->findByAttributeGuid('docSystemName')->value;
                 $parentGuid = $rowRelatedItem->relatedGuid;
                 //$sDir1 = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR.$systemname;
                 //$sDir2 = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR.$parentGuid.DIRECTORY_SEPARATOR.$systemname;
                 $sDir1 = $cdn['static']['dir']['files'] . "/" . $systemname;
                 $sDir2 = $cdn['static']['dir']['files'] . "/" . $parentGuid . "/" . $systemname;
                 $sDir1_Remote = $cdn['remote']['dir']['files'] . "/" . $systemname;
                 $sDir2_Remote = $cdn['remote']['dir']['files'] . "/" . $parentGuid . "/" . $systemname;
                 if (file_exists($sDir1)) {
                     // delete file
                     unlink($sDir1);
                     // check remote file
                     if (file_exists($sDir1_Remote)) {
                         $this->remoteDeleteFile($sDir1_Remote);
                     }
                 } else {
                     if (file_exists($sDir2)) {
                         //delete file
                         unlink($sDir2);
                         // check remote file
                         if (file_exists($sDir2_Remote)) {
                             $this->remoteDeleteFile($sDir2_Remote);
                         }
                     }
                 }
                 $img1 = $cdn['static']['dir']['images'] . "/" . $systemname;
                 $img2 = $cdn['static']['dir']['images'] . "/" . $parentGuid . "/" . $systemname;
                 $img1_Remote = $cdn['remote']['dir']['images'] . "/" . $systemname;
                 $img2_Remote = $cdn['remote']['dir']['images'] . "/" . $parentGuid . "/" . $systemname;
                 if (file_exists($img1)) {
                     // delete file
                     unlink($img1);
                     // check remote file
                     if (file_exists($img1_Remote)) {
                         $this->remoteDeleteFile($img1_Remote);
                     }
                 } else {
                     if (file_exists($img2)) {
                         //delete file
                         unlink($img2);
                         // check remote file
                         if (file_exists($img2_Remote)) {
                             $this->remoteDeleteFile($img2_Remote);
                         }
                     }
                 }
             }
         }
     }
     //delete from table CatalogAttribute
     $tblCatalogAttribute = new Pandamp_Modules_Dms_Catalog_Model_CatalogAttribute();
     $tblCatalogAttribute->delete("catalogGuid='{$this->guid}'");
     //delete catalogGuid from table CatalogFolder
     $tblCatalogFolder = new Pandamp_Modules_Dms_Catalog_Model_CatalogFolder();
     $tblCatalogFolder->delete("catalogGuid='{$this->guid}'");
     //delete guid from table AssetSetting
     $tblAssetSetting = new Pandamp_Modules_Dms_Catalog_Model_AssetSetting();
     $tblAssetSetting->delete("guid='{$this->guid}'");
     //delete from table relatedItem
     $tblRelatedItem = new Pandamp_Modules_Dms_Catalog_Model_RelatedItem();
     $tblRelatedItem->delete("itemGuid='{$this->guid}'");
     $tblRelatedItem->delete("relatedGuid='{$this->guid}'");
     $indexingEngine = Pandamp_Search::manager();
     try {
         $hits = $indexingEngine->deleteCatalogFromIndex($this->guid);
     } catch (Exception $e) {
     }
     //delete physical catalog folder from uploads/files/[catalogGuid]
     //$sDir = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR.$this->guid;
     $sDir = $cdn['static']['dir']['files'] . "/" . $this->guid;
     $sDir_Remote = $cdn['remote']['dir']['files'] . "/" . $this->guid;
     try {
         if (is_dir($sDir)) {
             rmdir($sDir);
             // check remote is_dir
             if (is_dir($sDir_Remote)) {
                 $this->remoteRemoveDir($sDir_Remote);
             }
         }
     } catch (Exception $e) {
     }
     //$sDir = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'images';
     $sDir = $cdn['static']['dir']['images'];
     try {
         if (file_exists($sDir . "/" . $this->guid . ".gif")) {
             unlink($sDir . "/" . $this->guid . ".gif");
         }
         if (file_exists($sDir . "/tn_" . $this->guid . ".gif")) {
             unlink($sDir . "/tn_" . $this->guid . ".gif");
         }
         if (file_exists($sDir . "/" . $this->guid . ".jpg")) {
             unlink($sDir . "/" . $this->guid . ".jpg");
         }
         if (file_exists($sDir . "/tn_" . $this->guid . ".jpg")) {
             unlink($sDir . "/tn_" . $this->guid . ".jpg");
         }
         if (file_exists($sDir . "/" . $this->guid . ".jpeg")) {
             unlink($sDir . "/" . $this->guid . ".jpeg");
         }
         if (file_exists($sDir . "/tn_" . $this->guid . ".jpeg")) {
             unlink($sDir . "/tn_" . $this->guid . ".jpeg");
         }
         if (file_exists($sDir . "/" . $this->guid . ".png")) {
             unlink($sDir . "/" . $this->guid . ".png");
         }
         if (file_exists($sDir . "/tn_" . $this->guid . ".png")) {
             unlink($sDir . "/tn_" . $this->guid . ".png");
         }
     } catch (Exception $e) {
     }
     $sDir = $cdn['remote']['dir']['images'];
     try {
         if (file_exists($sDir . "/" . $this->guid . ".gif")) {
             $this->remoteDeleteFile($sDir . "/" . $this->guid . ".gif");
         }
         if (file_exists($sDir . "/tn_" . $this->guid . ".gif")) {
             $this->remoteDeleteFile($sDir . "/tn_" . $this->guid . ".gif");
         }
         if (file_exists($sDir . "/" . $this->guid . ".jpg")) {
             $this->remoteDeleteFile($sDir . "/" . $this->guid . ".jpg");
         }
         if (file_exists($sDir . "/tn_" . $this->guid . ".jpg")) {
             $this->remoteDeleteFile($sDir . "/tn_" . $this->guid . ".jpg");
         }
         if (file_exists($sDir . "/" . $this->guid . ".jpeg")) {
             $this->remoteDeleteFile($sDir . "/" . $this->guid . ".jpeg");
         }
         if (file_exists($sDir . "/tn_" . $this->guid . ".jpeg")) {
             $this->remoteDeleteFile($sDir . "/tn_" . $this->guid . ".jpeg");
         }
         if (file_exists($sDir . "/" . $this->guid . ".png")) {
             $this->remoteDeleteFile($sDir . "/" . $this->guid . ".png");
         }
         if (file_exists($sDir . "/tn_" . $this->guid . ".png")) {
             $this->remoteDeleteFile($sDir . "/tn_" . $this->guid . ".png");
         }
     } catch (Exception $e) {
     }
 }
Example #10
0
 public function searchAction()
 {
     $query = $this->_getParam('query');
     $category = $this->_getParam('qbox');
     $isrelate = $this->_getParam('isrelate');
     $start = $this->_getParam('start') ? $this->_getParam('start') : 0;
     $end = $this->_getParam('limit') ? $this->_getParam('limit') : 10;
     try {
         switch ($category) {
             case 1:
                 $query = $query . ' profile:article';
                 break;
             case 2:
                 $query = $query . ' profile:klinik';
                 break;
             case 3:
                 $query = $query . ' profile:(kutu_peraturan OR kutu_peraturan_kolonial OR kutu_rancangan_peraturan OR kutu_putusan)';
                 break;
             default:
                 $query = $query;
         }
         $indexingEngine = Pandamp_Search::manager();
         $hits = $indexingEngine->find($query, $start, $end);
         $a = array();
         $a['totalCount'] = $hits->response->numFound;
         $i = 0;
         if ($hits->response->numFound > 0) {
             foreach ($hits->response->docs as $hit) {
                 $a['search'][$i]['guid'] = $hit->id;
                 if ($hit->profile == 'kutu_doc') {
                     $title = 'File : ' . $hit->title;
                 } else {
                     $title = isset($hit->title) ? $hit->title : 'No-Title';
                 }
                 $a['search'][$i]['title'] = $title;
                 if (!isset($hit->subTitle)) {
                     $subTitle = '';
                 } else {
                     $subTitle = $hit->subTitle;
                 }
                 $a['search'][$i]['subtitle'] = $subTitle;
                 if ($hit->profile == 'kutu_doc') {
                     $tblRelatedItem = new Pandamp_Modules_Dms_Catalog_Model_RelatedItem();
                     $rowsetRelatedItem = $tblRelatedItem->fetchRow("itemGuid='{$hit->id}' AND relateAs='RELATED_FILE'");
                     if ($rowsetRelatedItem) {
                         $parentGuid = $rowsetRelatedItem->relatedGuid;
                     } else {
                         $parentGuid = '';
                     }
                 } else {
                     $tblCatalogFolder = new Pandamp_Modules_Dms_Catalog_Model_CatalogFolder();
                     $rowsetCatalogFolder = $tblCatalogFolder->fetchRow("catalogGuid='{$hit->id}'");
                     if ($rowsetCatalogFolder) {
                         $parentGuid = $rowsetCatalogFolder->folderGuid;
                     } else {
                         $parentGuid = '';
                     }
                 }
                 $a['search'][$i]['folderGuid'] = $parentGuid;
                 if ($isrelate) {
                     $a['search'][$i]['value'] = 'Select Relation';
                 }
                 $i++;
             }
         }
         if ($hits->response->numFound == 0) {
             $a['search'][0]['guid'] = 'XXX';
             $a['search'][0]['title'] = "No Data";
             $a['search'][0]['subtitle'] = "-";
         }
     } catch (Exception $e) {
         $a['search'][0]['guid'] = 'XXX';
         $a['search'][0]['title'] = "No Data";
         $a['search'][0]['subtitle'] = $e->getMessage();
     }
     echo Zend_Json::encode($a);
 }