Exemplo n.º 1
1
 protected function _postDelete()
 {
     //find related docs and delete them
     $tblRelatedItem = new App_Model_Db_Table_RelatedItem();
     $rowsetRelatedDocs = $tblRelatedItem->fetchAll("relatedGuid='{$this->guid}' AND relateAs IN ('RELATED_FILE','RELATED_IMAGE','RELATED_VIDEO')");
     if (count($rowsetRelatedDocs)) {
         foreach ($rowsetRelatedDocs as $rowRelatedDoc) {
             $tblCatalog = new App_Model_Db_Table_Catalog();
             $rowCatalog = $tblCatalog->find($rowRelatedDoc->itemGuid)->current();
             if ($rowCatalog) {
                 $rowCatalog->delete();
             }
         }
     }
     $registry = Zend_Registry::getInstance();
     $config = $registry->get(Pandamp_Keys::REGISTRY_APP_OBJECT);
     $cdn = $config->getOption('cdn');
     if ($this->profileGuid == 'kutu_doc') {
         //get parentGuid
         $tblRelatedItem = new App_Model_Db_Table_RelatedItem();
         $rowsetRelatedItem = $tblRelatedItem->fetchAll("itemGuid='{$this->guid}' AND relateAs IN ('RELATED_FILE','RELATED_IMAGE','RELATED_VIDEO')");
         if (count($rowsetRelatedItem)) {
             foreach ($rowsetRelatedItem as $rowRelatedItem) {
                 //must delete the physical files
                 $rowsetCatAtt = $this->findDependentRowsetCatalogAttribute();
                 $systemname = $rowsetCatAtt->findByAttributeGuid('docSystemName')->value;
                 $parentGuid = $rowRelatedItem->relatedGuid;
                 $sDir1 = $cdn['static']['dir']['files'] . DIRECTORY_SEPARATOR . $systemname;
                 $sDir2 = $cdn['static']['dir']['files'] . DIRECTORY_SEPARATOR . $parentGuid . DIRECTORY_SEPARATOR . $systemname;
                 //$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;
                 if (file_exists($sDir1)) {
                     //delete file
                     unlink($sDir1);
                 } else {
                     if (file_exists($sDir2)) {
                         //delete file
                         unlink($sDir2);
                     }
                 }
             }
         }
     }
     //delete from table CatalogAttribute
     $tblCatalogAttribute = new App_Model_Db_Table_CatalogAttribute();
     $tblCatalogAttribute->delete("catalogGuid='{$this->guid}'");
     //delete catalogGuid from table CatalogFolder
     $tblCatalogFolder = new App_Model_Db_Table_CatalogFolder();
     $tblCatalogFolder->delete("catalogGuid='{$this->guid}'");
     //delete guid from table AssetSetting
     $tblAssetSetting = new App_Model_Db_Table_AssetSetting();
     $tblAssetSetting->delete("guid='{$this->guid}'");
     //delete from table relatedItem
     $tblRelatedItem = new App_Model_Db_Table_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 = $cdn['static']['dir']['files'] . DIRECTORY_SEPARATOR . $this->guid;
     //$sDir = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR.$this->guid;
     try {
         if (is_dir($sDir)) {
             rmdir($sDir);
         }
     } catch (Exception $e) {
     }
     $sDir = $cdn['static']['dir']['images'];
     //$sDir = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'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) {
     }
 }
Exemplo n.º 2
1
 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 App_Model_Db_Table_RelatedItem();
     $rowsetRelatedDocs = $tblRelatedItem->fetchAll("relatedGuid='{$this->relatedGuid}' AND relateAs IN ('RELATED_FILE','RELATED_IMAGE','RELATED_VIDEO')");
     if (count($rowsetRelatedDocs)) {
         foreach ($rowsetRelatedDocs as $rowRelatedDoc) {
             $systemname = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowRelatedDoc->itemGuid, 'docSystemName');
             $parentGuid = $rowRelatedDoc->relatedGuid;
             $sDir1 = $cdn['static']['dir']['images'] . DIRECTORY_SEPARATOR . $systemname;
             $sDir2 = $cdn['static']['dir']['images'] . DIRECTORY_SEPARATOR . $parentGuid . DIRECTORY_SEPARATOR . $systemname;
             //$sDir1 = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$systemname;
             //$sDir2 = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$parentGuid.DIRECTORY_SEPARATOR.$systemname;
             if (file_exists($sDir1)) {
                 unlink($sDir1);
             } else {
                 if (file_exists($sDir2)) {
                     unlink($sDir2);
                 }
             }
             $systemname = $rowRelatedDoc->itemGuid;
             $parentGuid = $rowRelatedDoc->relatedGuid;
             $sDir = $cdn['static']['dir']['images'];
             $sDir2 = $cdn['static']['dir']['images'] . DIRECTORY_SEPARATOR . $parentGuid;
             //$sDir = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'images';
             //$sDir2 = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$parentGuid;
             if (file_exists($sDir . "/" . $systemname . ".gif")) {
                 unlink($sDir . "/" . $systemname . ".gif");
             }
             if (file_exists($sDir . "/tn_" . $systemname . ".gif")) {
                 unlink($sDir . "/tn_" . $systemname . ".gif");
             }
             if (file_exists($sDir . "/" . $systemname . ".jpg")) {
                 unlink($sDir . "/" . $systemname . ".jpg");
             }
             if (file_exists($sDir . "/tn_" . $systemname . ".jpg")) {
                 unlink($sDir . "/tn_" . $systemname . ".jpg");
             }
             if (file_exists($sDir . "/" . $systemname . ".jpeg")) {
                 unlink($sDir . "/" . $systemname . ".jpeg");
             }
             if (file_exists($sDir . "/tn_" . $systemname . ".jpeg")) {
                 unlink($sDir . "/tn_" . $systemname . ".jpeg");
             }
             if (file_exists($sDir . "/" . $systemname . ".png")) {
                 unlink($sDir . "/" . $systemname . ".png");
             }
             if (file_exists($sDir . "/tn_" . $systemname . ".png")) {
                 unlink($sDir . "/tn_" . $systemname . ".png");
             }
             if (file_exists($sDir2 . "/" . $systemname . ".gif")) {
                 unlink($sDir2 . "/" . $systemname . ".gif");
             }
             if (file_exists($sDir2 . "/tn_" . $systemname . ".gif")) {
                 unlink($sDir2 . "/tn_" . $systemname . ".gif");
             }
             if (file_exists($sDir2 . "/" . $systemname . ".jpg")) {
                 unlink($sDir2 . "/" . $systemname . ".jpg");
             }
             if (file_exists($sDir2 . "/tn_" . $systemname . ".jpg")) {
                 unlink($sDir2 . "/tn_" . $systemname . ".jpg");
             }
             if (file_exists($sDir2 . "/" . $systemname . ".jpeg")) {
                 unlink($sDir2 . "/" . $systemname . ".jpeg");
             }
             if (file_exists($sDir2 . "/tn_" . $systemname . ".jpeg")) {
                 unlink($sDir2 . "/tn_" . $systemname . ".jpeg");
             }
             if (file_exists($sDir2 . "/" . $systemname . ".png")) {
                 unlink($sDir2 . "/" . $systemname . ".png");
             }
             if (file_exists($sDir2 . "/tn_" . $systemname . ".png")) {
                 unlink($sDir2 . "/tn_" . $systemname . ".png");
             }
             $tblCatalog = new App_Model_Db_Table_Catalog();
             $rowCatalog = $tblCatalog->find($rowRelatedDoc->itemGuid)->current();
             $rowCatalog->delete();
         }
     }
 }
Exemplo n.º 3
0
 public function getLocation($catalogGuid)
 {
     $catalogDb = new App_Model_Db_Table_Catalog();
     $catalogs = $catalogDb->find($catalogGuid)->current();
     $folders = $catalogs->findManyToManyRowset('App_Model_Db_Table_Folder', 'App_Model_Db_Table_CatalogFolder');
     if ($folders) {
         return $folders;
     }
     return;
 }
Exemplo n.º 4
0
 public function viewFolderAction()
 {
     $catalogGuid = $this->_getParam('guid') ? $this->_getParam('guid') : '';
     $tblCatalog = new App_Model_Db_Table_Catalog();
     $rowCatalog = $tblCatalog->find($catalogGuid)->current();
     if ($rowCatalog) {
         $rowsetFolder = $rowCatalog->findManyToManyRowset('App_Model_Db_Table_Folder', 'App_Model_Db_Table_CatalogFolder');
         $this->view->rowsetFolder = $rowsetFolder;
         $this->view->catalogGuid = $catalogGuid;
     }
 }
Exemplo n.º 5
0
 public function GetCatalogDocSize($catalogGuid)
 {
     $tblCatalog = new App_Model_Db_Table_Catalog();
     $rowsetCatalog = $tblCatalog->find($catalogGuid);
     if (count($rowsetCatalog)) {
         $rowCatalog = $rowsetCatalog->current();
         $rowsetCatAtt = $rowCatalog->findDependentRowsetCatalogAttribute();
         $docSize = $this->bytesToString($rowsetCatAtt->findByAttributeGuid('docSize')->value);
     } else {
         $docSize = '0kB';
     }
     return $docSize;
 }
Exemplo n.º 6
0
 public function GetCatalogDocType($catalogGuid, $relatedGuid = NULL)
 {
     $tblCatalog = new App_Model_Db_Table_Catalog();
     $rowsetCatalog = $tblCatalog->find($catalogGuid);
     if (count($rowsetCatalog)) {
         $rowCatalog = $rowsetCatalog->current();
         $rowsetCatAtt = $rowCatalog->findDependentRowsetCatalogAttribute();
         $docType = $this->imageDocumentType($this->dl_file($rowsetCatAtt->findByAttributeGuid('docOriginalName')->value), $catalogGuid, $relatedGuid);
     } else {
         $docType = '';
     }
     return $docType;
 }
Exemplo n.º 7
0
 public function indexCatalog($guid)
 {
     $solr =& $this->_solr;
     $tbl = new App_Model_Db_Table_Catalog();
     $rowset = $tbl->find($guid);
     if (count($rowset)) {
         $row = $rowset->current();
         $documents = array();
         $documents[] = $this->_createSolrDocument($row);
         try {
             $solr->addDocuments($documents);
             $solr->commit();
         } catch (Exception $e) {
             throw new Zend_Exception($e->getMessage());
         }
     }
 }
Exemplo n.º 8
0
 public function forceDelete($folderGuid)
 {
     $tblFolder = new App_Model_Db_Table_Folder();
     $rowSet = $tblFolder->fetchChildren($folderGuid);
     $row1 = $tblFolder->find($folderGuid)->current();
     foreach ($rowSet as $row) {
         $this->forceDelete($row->guid);
     }
     $rowsetCatalogFolder = $row1->findDependentRowsetCatalogFolder();
     $tblCatalog = new App_Model_Db_Table_Catalog();
     $bpmCatalog = new Pandamp_Core_Hol_Catalog();
     if (count($rowsetCatalogFolder)) {
         foreach ($rowsetCatalogFolder as $rowCatalogFolder) {
             $rowCatalog = $tblCatalog->find($rowCatalogFolder->catalogGuid)->current();
             if ($rowCatalog) {
                 $bpmCatalog->delete($rowCatalog->guid);
             }
         }
         $this->delete($row1->guid);
     } else {
         $this->delete($row1->guid);
     }
 }
Exemplo n.º 9
0
 function newAction()
 {
     $this->_helper->layout->disableLayout();
     $aResult = array();
     $req = $this->getRequest();
     $item = $req->getParam('guid');
     $relatedItem = $req->getParam('relatedGuid');
     $as = $req->getParam('relateAs');
     $tblCatalog = new App_Model_Db_Table_Catalog();
     if (empty($relatedItem)) {
         $aResult['isError'] = true;
         $aResult['msg'] = 'No relatedGuid specified!';
     }
     if (is_array($item)) {
         $item = implode(',', $item);
         $item = explode(',', $item);
         foreach ($item as $guid) {
             $rowCatalog = $tblCatalog->find($guid)->current();
             $rowCatalog->relateTo($relatedItem, $as);
             $aResult['isError'] = false;
             $aResult['msg'] = 'Adding Multi Relation Success';
             $aResult['relateAs'] = $as;
             $aResult['relatedGuid'] = $relatedItem;
             $aResult['itemGuid'] = $guid;
         }
     } else {
         $rowCatalog = $tblCatalog->find($item)->current();
         $rowCatalog->relateTo($relatedItem, $as);
         $aResult['isError'] = false;
         $aResult['msg'] = 'Adding Relation Success';
         $aResult['relateAs'] = $as;
         $aResult['relatedGuid'] = $relatedItem;
         $aResult['itemGuid'] = $item;
     }
     echo Zend_Json::encode($aResult);
 }
Exemplo n.º 10
0
 function viewerClinic80Action()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $dateDiff = new Pandamp_Lib_DateDiff();
     $author = $this->_getParam('folderGuid') ? $this->_getParam('folderGuid') : '';
     $start = $this->_getParam('start') ? $this->_getParam('start') : 0;
     $limit = $this->_getParam('limit') ? $this->_getParam('limit') : 10;
     $a = array();
     $tblCatalog = new App_Model_Db_Table_Catalog();
     $tblCatalogAttribute = new App_Model_Db_Table_CatalogAttribute();
     $clinic = $tblCatalogAttribute->fetchAll("value='" . $author . "'", '', $limit, $start);
     $clinic1 = $tblCatalogAttribute->fetchAll("value='" . $author . "'");
     $a['folderGuid'] = $author;
     $a['totalCount'] = count($clinic1);
     $ii = 0;
     if ($clinic) {
         $value_clinic = array();
         foreach ($clinic as $c) {
             $value_clinic[] = $c->catalogGuid;
         }
         //			$value_clinic = $tblCatalog->implode_with_keys(", ", $value_clinic, "'");
         echo '<pre>';
         print_r($value_clinic);
         echo '</pre>';
         die;
         if (isset($value_clinic)) {
             $rowset = $tblCatalog->fetchAll("guid IN({$value_clinic}) AND status=99", "publishedDate desc");
             foreach ($rowset as $row) {
                 $arraypictureformat = array("jpg", "jpeg", "gif");
                 $txt_allowedformat = implode('; ', $arraypictureformat);
                 $registry = Zend_Registry::getInstance();
                 $config = $registry->get(Pandamp_Keys::REGISTRY_APP_OBJECT);
                 $cdn = $config->getOption('cdn');
                 $sDir = $cdn['static']['dir']['photo'];
                 $sDir2 = $cdn['static']['url']['photo'] . '/';
                 $smg = $cdn['static']['images'];
                 $modelUser = App_Model_Show_User::show()->getUserByName($row->createdBy);
                 $x = 0;
                 foreach ($arraypictureformat as $key => $val) {
                     if (is_file($sDir . "/" . $modelUser['kopel'] . "." . $val)) {
                         $myphoto = $sDir . "/" . $modelUser['kopel'] . "." . $val;
                         $myext = $val;
                         $x = 1;
                         break;
                     }
                 }
                 if ($x == 1) {
                     $myphotosize = getimagesize($myphoto);
                     $dis = "";
                     if (isset($myext) && is_file($sDir . "/" . $modelUser['kopel'] . "." . $myext)) {
                         $txt_existence = "<img src=\"" . $sDir2 . $modelUser['kopel'] . "." . $myext . "\" class=\"avatar\" width=\"38\" height=\"38\" />";
                     }
                 } else {
                     $txt_existence = "<img src=\"" . $smg . "/gravatar-140.png\" width=\"38\" height=\"38\" class=\"avatar\" border=\"0\" />";
                 }
                 $rowsetCatalogAttribute = $row->findDependentRowsetCatalogAttribute();
                 $rowCatalogTitle = $rowsetCatalogAttribute->findByAttributeGuid('fixedCommentTitle');
                 $rowCatalogQuestion = $rowsetCatalogAttribute->findByAttributeGuid('fixedCommentQuestion');
                 $rowCatalogSelectCat = $rowsetCatalogAttribute->findByAttributeGuid('fixedKategoriKlinik');
                 $author = $rowsetCatalogAttribute->findByAttributeGuid('fixedSelectNama');
                 $source = $rowsetCatalogAttribute->findByAttributeGuid('fixedSelectMitra');
                 /* Get Category from profile clinic_category */
                 $findCategory = $tblCatalog->find($rowCatalogSelectCat->value)->current();
                 $rowCategory = $findCategory->findDependentRowsetCatalogAttribute();
                 $category = $rowCategory->findByAttributeGuid('fixedTitle');
                 $a['index'][$ii]['title'] = $rowCatalogTitle->value;
                 $a['index'][$ii]['question'] = $rowCatalogQuestion->value;
                 $a['index'][$ii]['secat'] = $rowCatalogSelectCat->value;
                 $a['index'][$ii]['category'] = $category->value;
                 $a['index'][$ii]['guid'] = $row->guid;
                 $a['index'][$ii]['createdBy'] = $row->createdBy;
                 $a['index'][$ii]['author'] = isset($author->value) ? $author->value : '';
                 if (isset($source->value)) {
                     $findSource = $tblCatalog->find($source->value)->current();
                     $rowSource = $findCategory->findDependentRowsetCatalogAttribute();
                     $sc = $rowSource->findByAttributeGuid('fixedTitle');
                     $a['index'][$ii]['source'] = $sc->value;
                     $a['index'][$ii]['sid'] = $source->value;
                 } else {
                     $a['index'][$ii]['source'] = '';
                     $a['index'][$ii]['sid'] = '';
                 }
                 $a['index'][$ii]['publishedDate'] = $dateDiff->ago(strftime('%Y-%m-%d %H:%M:%S', strtotime($row->publishedDate)));
                 $a['index'][$ii]['existence'] = '<div style="float:left;padding:2px;margin: 1px 10px 10px 0px;"><a href="">' . $txt_existence . '</a></div>';
                 $ii++;
             }
         }
     }
     echo Zend_Json::encode($a);
 }
Exemplo n.º 11
0
 function generateFormEdit($catalogGuid)
 {
     $zl = Zend_Registry::get("Zend_Locale");
     $today = date('Y-m-d H:i:s');
     $aRenderedAttributes = array();
     $aBaseAttributes = array();
     $tableCatalog = new App_Model_Db_Table_Catalog();
     $rowsetCatalog = $tableCatalog->find($catalogGuid);
     $rowCatalog = $rowsetCatalog->current();
     $tableProfileAttribute = new App_Model_Db_Table_ProfileAttribute();
     $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', $rowCatalog->profileGuid);
     $rowsetProfileAttribute = $tableProfileAttribute->fetchAll($where, array('viewOrder ASC'));
     $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute();
     $i = 0;
     foreach ($rowsetProfileAttribute as $row) {
         $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid($row->attributeGuid);
         $rowAttribute = $row->findParentRow('App_Model_Db_Table_Attribute');
         if (isset($rowCatalogAttribute->value)) {
             $attributeValue = $rowCatalogAttribute->value;
         } else {
             $attributeValue = '';
         }
         if (isset($rowCatalogAttribute->guid)) {
             $catalogAttributeGuid = $rowCatalogAttribute->guid;
         } else {
             $guidMan = new Pandamp_Core_Guid();
             $catalogAttributeGuid = $guidMan->generateGuid();
         }
         if (isset($rowAttribute)) {
             $desc = $rowAttribute->description == 'Category' ? 'Kategori Klinik' : $rowAttribute->description;
             if ($zl->getLanguage() == 'en') {
                 $attributeRenderer = new Pandamp_Form_Attribute_Renderer($rowAttribute->guid, $attributeValue, $rowAttribute->type, null, $rowCatalog->profileGuid, $desc, 'clinic_partner');
             } else {
                 $attributeRenderer = new Pandamp_Form_Attribute_Renderer($rowAttribute->guid, $attributeValue, $rowAttribute->type, null, $rowCatalog->profileGuid, $desc, 'partner');
             }
             //$aRenderedAttributes[$rowAttribute->guid]['description'] = ($rowAttribute->description == 'Category')? 'Kategori Klinik' : $rowAttribute->description;
             $aRenderedAttributes[$rowAttribute->guid]['form'] = $attributeRenderer->render();
         }
         $i++;
     }
     $aBaseAttributes['guid']['description'] = '';
     $aBaseAttributes['guid']['form'] = "<input type='hidden' name='guid' id='guid' value='{$rowCatalog->guid}'>";
     $checked = $rowCatalog->sticky == 1 ? 'checked="checked"' : '';
     $aBaseAttributes['stickyCategory']['form'] = "<input type=\"checkbox\" name=\"stickyCategory\" value=\"1\" {$checked} />&nbsp;<b>Set this article sticky</b>";
     $aBaseAttributes['stickyCategory']['description'] = "";
     $aBaseAttributes['shortTitle']['description'] = 'shortTitle';
     $aBaseAttributes['shortTitle']['form'] = "<textarea name='shortTitle' id='shortTitle' rows='1'' cols='50'>{$rowCatalog->shortTitle}</textarea>";
     $aBaseAttributes['profileGuid']['description'] = 'Profile';
     $aBaseAttributes['profileGuid']['form'] = $rowCatalog->profileGuid . "<input type='hidden' name='profileGuid' id='profileGuid' value='{$rowCatalog->profileGuid}'>";
     //TO DO: I don't think we should put category/folder input here in cataloginputgenerator.
     /*$aBaseAttributes['folderGuid']['description'] = 'Category';
     		$aBaseAttributes['folderGuid']['form'] = $folderGuid."<input type='hidden' name='folderGuid' id='folderGuid' value='$folderGuid'>";*/
     $registry = Zend_Registry::getInstance();
     $config = $registry->get(Pandamp_Keys::REGISTRY_APP_OBJECT);
     $cdn = $config->getOption('cdn');
     $s = '<input type="Text" id="publishedDate" maxlength="25" size="25" name="publishedDate" value="' . $rowCatalog->publishedDate . '"><a href="javascript:NewCal(\'publishedDate\',\'yyyymmdd\',true,24)"><img src="' . $cdn['static']['images'] . '/img.gif" width="16" height="16" border="0" alt="Pick a date"></a>';
     $aBaseAttributes['publishedDate']['description'] = 'Published Date';
     $aBaseAttributes['publishedDate']['form'] = $s;
     $n = '<input type="Text" id="expiredDate" maxlength="25" size="25" name="expiredDate" value="' . $rowCatalog->expiredDate . '"><a href="javascript:NewCal(\'expiredDate\',\'yyyymmdd\',true,24)"><img src="' . $cdn['static']['images'] . '/img.gif" width="16" height="16" border="0" alt="Pick a date"></a>';
     $aBaseAttributes['expiredDate']['description'] = 'Expired Date';
     $aBaseAttributes['expiredDate']['form'] = $n;
     /*
     $aBaseAttributes['publishedDate']['description'] = '';
     $aBaseAttributes['publishedDate']['form'] = "<input type='hidden' name='publishedDate' id='publishedDate' value='$rowCatalog->publishedDate'>";
     $aBaseAttributes['expiredDate']['description'] = '';
     $aBaseAttributes['expiredDate']['form'] = "<input type='hidden' name='expiredDate' id='expiredDate' value='$rowCatalog->expiredDate'>";
     */
     $aBaseAttributes['createdDate']['description'] = 'Created on';
     $aBaseAttributes['createdDate']['form'] = $rowCatalog->createdDate . "<input type='hidden' name='createdDate' id='createdDate' value='{$rowCatalog->createdDate}'>";
     $aBaseAttributes['modifiedDate']['description'] = 'Last Modified on';
     $aBaseAttributes['modifiedDate']['form'] = $rowCatalog->modifiedDate . "<input type='hidden' name='modifiedDate' id='modifiedDate' value='{$today}'>";
     $aBaseAttributes['deletedDate']['description'] = 'Deleted on';
     $aBaseAttributes['deletedDate']['form'] = $rowCatalog->deletedDate . "<input type='hidden' name='deletedDate' id='deletedDate' value='{$rowCatalog->deletedDate}'>";
     $aBaseAttributes['status']['description'] = 'Status';
     $aBaseAttributes['price']['description'] = 'Price';
     $aBaseAttributes['price']['form'] = "<input type='text' name='price' id='price' value='{$rowCatalog->price}'>";
     require_once CONFIG_PATH . '/master-status.php';
     $statusConfig = MasterStatus::getPublishingStatus();
     //$aBaseAttributes['status']['form'] = $statusConfig[$rowCatalog->status]."<input type='hidden' name='status' id='status' value='$rowCatalog->status'>";
     $attributeRenderer = new Pandamp_Form_Attribute_Renderer('status', $rowCatalog->status, 101);
     $aBaseAttributes['status']['form'] = $attributeRenderer->render();
     $aReturn = array();
     $aReturn['baseForm'] = $aBaseAttributes;
     $aReturn['attributeForm'] = $aRenderedAttributes;
     return $aReturn;
 }
Exemplo n.º 12
0
 function viewerAction()
 {
     $catalogGuid = $this->_getParam('guid') ? $this->_getParam('guid') : '';
     $node = $this->_getParam('node') ? $this->_getParam('node') : '';
     $npts = $this->_getParam('npts') ? $this->_getParam('npts') : '';
     $nprt = $this->_getParam('nprt') ? $this->_getParam('nprt') : '';
     $tblCatalog = new App_Model_Db_Table_Catalog();
     if (!empty($catalogGuid)) {
         $rowCatalog = $tblCatalog->find($catalogGuid)->current();
         if ($rowCatalog) {
             $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute();
             $tableProfileAttribute = new App_Model_Db_Table_ProfileAttribute();
             $profileGuid = $rowCatalog->profileGuid;
             $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', $profileGuid);
             $rowsetProfileAttribute = $tableProfileAttribute->fetchAll($where, 'viewOrder ASC');
             $aAttribute = array();
             $i = 0;
             $tblAttribute = new App_Model_Db_Table_Attribute();
             foreach ($rowsetProfileAttribute as $rowProfileAttribute) {
                 if ($rowsetCatalogAttribute->findByAttributeGuid($rowProfileAttribute->attributeGuid)) {
                     $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid($rowProfileAttribute->attributeGuid);
                     $rowsetAttribute = $tblAttribute->find($rowCatalogAttribute->attributeGuid);
                     if (count($rowsetAttribute)) {
                         $rowAttribute = $rowsetAttribute->current();
                         $aAttribute[$i]['name'] = $rowAttribute->name;
                     } else {
                         $aAttribute[$i]['name'] = '';
                     }
                     $aAttribute[$i]['value'] = $rowCatalogAttribute->value;
                 } else {
                 }
                 $i++;
             }
             $this->view->aAttribute = $aAttribute;
             $this->view->rowCatalog = $rowCatalog;
             $this->view->rowsetCatalogAttribute = $rowsetCatalogAttribute;
             $this->view->node = $node;
             $this->view->npts = $npts;
             $this->view->nprt = $nprt;
             $this->view->catalogGuid = $catalogGuid;
             $this->view->profileGuid = $profileGuid;
             $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid('fixedExpired');
             if (!empty($rowCatalogAttribute->value)) {
                 $tDate = $rowCatalogAttribute->value;
                 $aDate = explode('-', $tDate);
                 $year = $aDate[0];
                 $month = $aDate[1];
                 $day = $aDate[2];
                 $hour = "00";
                 $minute = "00";
                 $second = "00";
                 $event = "My birthday";
                 $time = mktime($hour, $minute, $second, $month, $day, $year);
                 $timecurrent = date('U');
                 $cuntdowntime = $time - $timecurrent;
                 $cuntdownminutes = $cuntdowntime / 60;
                 $cuntdownhours = $cuntdowntime / 3600;
                 $cuntdowndays = $cuntdownhours / 24;
                 $cuntdownmonths = $cuntdowndays / 30;
                 $cuntdownyears = $cuntdowndays / 365;
                 if ($cuntdowndays < 0) {
                     echo "<script>alert('Dokumen perjanjian ini telah berakhir masa berlakunya.');</script>";
                     echo "<br><strong>Dokumen perjanjian ini telah berakhir masa berlakunya.</strong>";
                 } else {
                     echo "<br><strong>Dokumen perjanjian ini akan berakhir masa berlakunya dalam " . round($cuntdowndays) . " hari.</strong>";
                 }
             }
         }
     }
 }
Exemplo n.º 13
0
 function downloadFileAction()
 {
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $catalogGuid = $this->_getParam('guid');
     $parentGuid = $this->_getParam('parent');
     $tblCatalog = new App_Model_Db_Table_Catalog();
     $rowsetCatalog = $tblCatalog->find($catalogGuid);
     if (count($rowsetCatalog)) {
         $auth = Zend_Auth::getInstance();
         if ($auth->hasIdentity()) {
             $identity = $auth->getIdentity();
             $guidUser = $identity->kopel;
         }
         $tblAsetSetting = new App_Model_Db_Table_AssetSetting();
         $rowAset = $tblAsetSetting->find($catalogGuid)->current();
         if ($rowAset) {
             $rowAset->valueInt = $rowAset->valueInt + 1;
         } else {
             $rowAset = $tblAsetSetting->fetchNew();
             $rowAset->guid = $catalogGuid;
             $rowAset->application = "kutu_doc";
             $rowAset->part = isset($guidUser) ? $guidUser : '';
             $rowAset->valueType = gethostbyaddr($_SERVER['REMOTE_ADDR']);
             $rowAset->valueInt = 1;
         }
         $rowAset->save();
         $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 App_Model_Db_Table_RelatedItem();
         $rowsetRelatedItem = $tblRelatedItem->fetchAll("itemGuid='{$catalogGuid}' AND relateAs='RELATED_FILE'");
         $registry = Zend_Registry::getInstance();
         $config = $registry->get(Pandamp_Keys::REGISTRY_APP_OBJECT);
         $cdn = $config->getOption('cdn');
         $flagFileFound = false;
         foreach ($rowsetRelatedItem as $rowRelatedItem) {
             if (!$flagFileFound) {
                 $parentGuid = $rowRelatedItem->relatedGuid;
                 $sDir1 = $cdn['static']['dir']['files'] . "/" . $systemname;
                 $sDir2 = $cdn['static']['dir']['files'] . "/" . $parentGuid . "/" . $systemname;
                 $sDir3 = $cdn['static']['dir']['files'] . "/" . $oname;
                 $sDir4 = $cdn['static']['dir']['files'] . "/" . $parentGuid . "/" . $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->_redirect(ROOT_URL . '/' . $this->_zl->getLanguage() . '/dms/browser/forbidden');
                 }
             }
         }
     } else {
         $flagFileFound = false;
         $this->_redirect(ROOT_URL . '/' . $this->_zl->getLanguage() . '/dms/browser/forbidden');
     }
 }
Exemplo n.º 14
0
 function isAllowed($username, $itemGuid, $action, $section = 'content')
 {
     if ($this->checkAcl("action", 'all', 'user', $username, 'content', 'all-access')) {
         return true;
     }
     if ($section == 'content') {
         //			if($this->checkAcl("dms",'all','user', $username, false,false))
         //				return true;
         /**
          * TODO
          */
         switch ($action) {
             case 'create':
                 if ($this->checkAcl("action", 'create', 'user', $username, false, false)) {
                     return true;
                 }
             case 'read':
                 if ($this->checkAcl("action", 'read', 'user', $username, false, false) || $this->checkAcl("action", 'update', 'user', $username, false, false)) {
                     return true;
                 }
             case 'update':
                 if ($this->checkAcl("action", 'update', 'user', $username, false, false)) {
                     return true;
                 }
             case 'delete':
                 if ($this->checkAcl("action", 'delete', 'user', $username, false, false)) {
                     return true;
                 }
         }
         //			if ($this->checkAcl('action', $action, 'user', $username, 'admin', 'content'))
         //				return true;
         //check if itemGuid exist in table KutuCatalog
         $tblCatalog = new App_Model_Db_Table_Catalog();
         $rowset = $tblCatalog->find($itemGuid);
         if (count($rowset) > 0) {
             $row = $rowset->current();
             if ($row->profileGuid != 'kutu_folder') {
                 //if user was the creator of the item, allow everything
                 if ($row->createdBy == $username) {
                     return true;
                 }
                 $aAclId = $this->searchAcl('action', false, false, false, false, 'content', $itemGuid);
                 if (count($aAclId) > 0) {
                     return $this->checkAcl('action', $action, 'user', $username, 'content', $itemGuid);
                 } else {
                     //check permission of the folder which this catalog belongs to
                     $rowset1 = $row->findDependentRowset('Pandamp_Modules_Dms_Catalog_Model_CatalogFolder');
                     $flagFolderPermission = false;
                     foreach ($rowset1 as $row1) {
                         if ($this->_traverseFolderPermission($username, $row1->folderGuid, $action)) {
                             $flagFolderPermission = true;
                         }
                     }
                     return $flagFolderPermission;
                 }
             }
         }
         //check if itemGuid exist in table KutuFolder
         $tblFolder = new App_Model_Db_Table_Folder();
         $rowset = $tblFolder->find($itemGuid);
         if (count($rowset) > 0) {
             return $this->_traverseFolderPermission($username, $itemGuid, $action);
         }
     }
     //check at section
     $aAclId = $this->searchAcl('action', false, false, false, false, $section, $itemGuid);
     if (count($aAclId) > 0) {
         return $this->checkAcl('action', $action, 'user', $username, $section, $itemGuid);
     }
     //check at feature section
     /*$aAclId = $this->searchAcl('action', false, false, false, false, 'feature', $itemGuid);
     		if(count($aAclId)>0)
     		{
     			return $this->checkAcl('action', $action, 'user', $username, 'feature', $itemGuid);
     		}*/
     return false;
 }
Exemplo n.º 15
0
 /**
  * categoryClinicPullDown
  * @return category clinic
  */
 static function categoryClinicPullDown($cat = '')
 {
     $tblCatalog = new App_Model_Db_Table_Catalog();
     $rowset = $tblCatalog->fetchAll("profileGuid='kategoriklinik'", 'createdDate DESC');
     $category = "<select name=\"category\">\n";
     if ($cat) {
         $rowCategory = $tblCatalog->find($cat)->current();
         $title = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($cat, 'fixedTitle');
         $category .= "<option value='{$rowCategory->guid}' selected>{$title}</option>";
         $category .= "<option value=''>---Semua Kategori---</option>";
     } else {
         $category .= "<option value='' selected>---Semua Kategori---</option>";
     }
     foreach ($rowset as $row) {
         $attributeTitle = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($row->guid, 'fixedTitle');
         if ($cat && $row->guid == $rowCategory->guid) {
             continue;
         } else {
             $category .= "<option value='{$row->guid}'>{$attributeTitle}</option>";
         }
     }
     $category .= "</select>\n\n";
     return $category;
 }
Exemplo n.º 16
0
 function downloadFileAction()
 {
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $catalogGuid = $this->_getParam('guid');
     $parentGuid = $this->_getParam('parent');
     $tblCatalog = new App_Model_Db_Table_Catalog();
     $rowsetCatalog = $tblCatalog->find($catalogGuid);
     if (count($rowsetCatalog)) {
         $auth = Zend_Auth::getInstance();
         //$sso = new Pandamp_Session_Remote();
         //$user = $sso->getInfo();
         if ($auth->hasIdentity()) {
             $guidUser = $auth->getIdentity()->guid;
         }
         $tblAsetSetting = new App_Model_Db_Table_AssetSetting();
         $rowAset = $tblAsetSetting->find($catalogGuid)->current();
         if ($rowAset) {
             $rowAset->valueInt = $rowAset->valueInt + 1;
         } else {
             $rowAset = $tblAsetSetting->fetchNew();
             $rowAset->guid = $catalogGuid;
             $rowAset->application = "kutu_doc";
             $rowAset->part = isset($guidUser) ? $guidUser : '';
             $rowAset->valueType = gethostbyaddr($_SERVER['REMOTE_ADDR']);
             $rowAset->valueInt = 1;
         }
         $rowAset->save();
         $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 App_Model_Db_Table_RelatedItem();
         $rowsetRelatedItem = $tblRelatedItem->fetchAll("itemGuid='{$catalogGuid}' AND relateAs='RELATED_FILE'");
         $flagFileFound = false;
         foreach ($rowsetRelatedItem as $rowRelatedItem) {
             if (!$flagFileFound) {
                 $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;
                 $sDir3 = ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $oname;
                 $sDir4 = 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', 'hold');
                 }
             }
         }
     } else {
         $flagFileFound = false;
         $this->_forward('forbidden', 'browser', 'hold');
     }
 }
Exemplo n.º 17
0
 function copyFolderAction()
 {
     $urlReferer = $_SERVER['HTTP_REFERER'];
     $r = $this->getRequest();
     $guid = explode(',', $r->getParam('guid'));
     if (is_array($guid)) {
         $sGuid = '';
         $sTitle = '';
         for ($i = 0; $i < count($guid); $i++) {
             $sGuid .= $guid[$i] . ';';
             $modelCatalog = App_Model_Show_Catalog::show()->getCatalogByGuid($guid[$i]);
             if ($modelCatalog['profileGuid'] == "klinik") {
                 $sTitle .= App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($guid[$i], "fixedCommentTitle") . ', ';
             } else {
                 $sTitle .= App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($guid[$i], "fixedTitle") . ', ';
             }
         }
         $guid = $sGuid;
     } else {
         $sTitle = '';
         if (!empty($guid)) {
             $modelCatalog = App_Model_Show_Catalog::show()->getCatalogByGuid($guid);
             if ($modelCatalog['profileGuid'] == "klinik") {
                 $sTitle .= App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($guid, "fixedCommentTitle") . ', ';
             } else {
                 $sTitle .= App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($guid, "fixedTitle");
             }
         }
     }
     $this->view->catalogTitle = $sTitle;
     $this->view->guid = $guid;
     $this->_helper->layout()->headerTitle = "Catalog Management: Copy to Folder";
     if ($r->isPost()) {
         $sessHistory = new Zend_Session_Namespace('BROWSER_HISTORY');
         $urlReferer = $sessHistory->urlReferer;
         $req = $this->getRequest();
         $targetNode = $req->getParam('targetNode');
         $queue = Zend_Registry::get(Bootstrap::NAME_ORDERQUEUE);
         $tblCatalog = new App_Model_Db_Table_Catalog();
         if (is_array($r->getParam('guid'))) {
             foreach ($r->getParam('guid') as $tmpGuid) {
                 $rowset = $tblCatalog->find($tmpGuid);
                 if (count($rowset)) {
                     $row = $rowset->current();
                     $row->copyToFolder($targetNode);
                     Zend_Registry::get('Zend_Log')->info('copy multiple article:' . $tmpGuid . ' to folderGuid:' . $targetNode . ' dari ip:' . Pandamp_Lib_Formater::getHttpRealIp() . ' oleh:' . $this->_user->kopel);
                     $queue->addJob('Pandamp_Job_Catalog', ['guid' => $tmpGuid, 'folderGuid' => $targetNode, 'ip' => Pandamp_Lib_Formater::getHttpRealIp(), 'kopel' => $this->_user->kopel, 'lang' => $this->view->getLanguage()], false);
                 }
             }
         } else {
             $g = $r->getParam('guid');
             $rowset = $tblCatalog->find($g);
             if (count($rowset)) {
                 $row = $rowset->current();
                 $row->copyToFolder($targetNode);
                 Zend_Registry::get('Zend_Log')->info('copy article:' . $g . ' to folderGuid:' . $targetNode . ' dari ip:' . Pandamp_Lib_Formater::getHttpRealIp() . ' oleh:' . $this->_user->kopel);
                 $queue->addJob('Pandamp_Job_Catalog', ['guid' => $g, 'folderGuid' => $targetNode, 'ip' => Pandamp_Lib_Formater::getHttpRealIp(), 'kopel' => $this->_user->kopel, 'lang' => $this->view->getLanguage()], false);
             }
         }
         $this->view->message = "Data was successfully saved.";
     }
     $sessHistory = new Zend_Session_Namespace('BROWSER_HISTORY');
     $sessHistory->urlReferer = $urlReferer;
     $this->view->urlReferer = $sessHistory->urlReferer;
 }
Exemplo n.º 18
0
 function delete($itemGuid, $relatedGuid, $relateAs)
 {
     if (empty($relateAs)) {
         throw new Zend_Exception('relateAs can not be empty!');
     }
     $registry = Zend_Registry::getInstance();
     $config = $registry->get(Pandamp_Keys::REGISTRY_APP_OBJECT);
     $cdn = $config->getOption('cdn');
     $tblRelatedItem = new App_Model_Db_Table_RelatedItem();
     $rowsetRelatedDocs = $tblRelatedItem->fetchAll("itemGuid='{$itemGuid}' AND relatedGuid='{$relatedGuid}' AND relateAs='{$relateAs}'");
     if ($rowsetRelatedDocs) {
         foreach ($rowsetRelatedDocs as $rowRelatedDoc) {
             $systemname = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowRelatedDoc->itemGuid, 'docSystemName');
             $ext = pathinfo($systemname, PATHINFO_EXTENSION);
             $ext = strtolower($ext);
             $parentGuid = $rowRelatedDoc->relatedGuid;
             //$sDir1 = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR.$systemname;
             $sDir1 = $cdn['static']['dir']['files'] . DIRECTORY_SEPARATOR . $systemname;
             $sDir2 = $cdn['static']['dir']['files'] . DIRECTORY_SEPARATOR . $parentGuid . DIRECTORY_SEPARATOR . $systemname;
             //$sDir2 = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR.$parentGuid.DIRECTORY_SEPARATOR.$systemname;
             if (file_exists($sDir1)) {
                 unlink($sDir1);
             } else {
                 if (file_exists($sDir2)) {
                     unlink($sDir2);
                 }
             }
             $systemname = $rowRelatedDoc->itemGuid;
             $parentGuid = $rowRelatedDoc->relatedGuid;
             $sDir = $cdn['static']['dir']['images'];
             $sDir2 = $cdn['static']['dir']['images'] . DIRECTORY_SEPARATOR . $parentGuid;
             //$sDir = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'images';
             //$sDir2 = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.$parentGuid;
             if (file_exists($sDir . "/" . $systemname . '.' . $ext)) {
                 unlink($sDir . "/" . $systemname . '.' . $ext);
             }
             if (file_exists($sDir . "/tn_" . $systemname . '.' . $ext)) {
                 unlink($sDir . "/tn_" . $systemname . '.' . $ext);
             }
             if (file_exists($sDir2 . "/" . $systemname . '.' . $ext)) {
                 unlink($sDir2 . "/" . $systemname . '.' . $ext);
             }
             if (file_exists($sDir2 . "/tn_" . $systemname . '.' . $ext)) {
                 unlink($sDir2 . "/tn_" . $systemname . '.' . $ext);
             }
             $file = new Zend_Config_Ini(APPLICATION_PATH . '/configs/image.ini', 'size');
             $keys = array_keys($file->toArray());
             foreach ($keys as $key) {
                 if (file_exists($sDir2 . '/' . $key . '_' . $systemname . '.' . $ext)) {
                     unlink($sDir2 . '/' . $key . '_' . $systemname . '.' . $ext);
                 }
             }
             $tblCatalog = new App_Model_Db_Table_Catalog();
             $rowCatalog = $tblCatalog->find($rowRelatedDoc->itemGuid)->current();
             $rowCatalog->delete();
         }
     }
     if ($tblRelatedItem->delete("itemGuid='{$itemGuid}' AND relatedGuid='{$relatedGuid}' AND relateAs='{$relateAs}'")) {
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 19
0
 function detailProdukAction()
 {
     $this->_helper->layout->setLayout('layout-misc');
     $catalogGuid = $this->_getParam('guid') ? $this->_getParam('guid') : '';
     $tblCatalog = new App_Model_Db_Table_Catalog();
     $rowset = $tblCatalog->find($catalogGuid)->current();
     if ($catalogGuid) {
         $title = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset->guid, 'fixedTitle');
         $desc = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset->guid, 'fixedDescription');
         $content = App_Model_Show_CatalogAttribute::show()->getCatalogAttributeValue($rowset->guid, 'fixedContent');
         $this->view->title = $title;
         $this->view->desc = $desc;
         $this->view->content = $content;
     }
 }
Exemplo n.º 20
0
 public function jCartIsItemSellable($catalogGuid)
 {
     //apakah pernah dibeli
     $hasBought = false;
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $bpm = new Pandamp_Core_Hol_Catalog();
         $hasBought = $bpm->isBoughtByUser($catalogGuid, $auth->getIdentity()->kopel);
     }
     if ($hasBought) {
         $aReturn['isError'] = true;
         $aReturn['message'] = 'You have bought this Item before. Please check your account.';
         $aReturn['code'] = 1;
         return $aReturn;
     }
     Pandamp_Application::getResource('multidb');
     require_once ROOT_DIR . '/app/models/Db/Table/Catalog.php';
     require_once ROOT_DIR . '/app/models/Db/Table/Rowset/CatalogAttribute.php';
     require_once ROOT_DIR . '/app/models/Db/Table/Row/Catalog.php';
     // if status=draft then return false
     $tblCatalog = new App_Model_Db_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 Pandamp_Modules_Dms_Catalog_Model_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 Pandamp_Modules_Dms_Catalog_Model_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 = 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;
         
                     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
 }
Exemplo n.º 21
0
 public function uploadFile($aDataCatalog, $relatedGuid)
 {
     if ($aDataCatalog['profileGuid'] != 'kutu_doc') {
         throw new Zend_Exception('Profile does not match profile for FILE');
     }
     if (empty($relatedGuid)) {
         throw new Zend_Exception('No RELATED GUID specified!');
     }
     $registry = Zend_Registry::getInstance();
     $config = $registry->get(Pandamp_Keys::REGISTRY_APP_OBJECT);
     $cdn = $config->getOption('cdn');
     $id = 1 + ($aDataCatalog['id'] - 1);
     for ($x = 1; $x < $id; $x++) {
         $title = $aDataCatalog['fixedTitle' . $x] ? $aDataCatalog['fixedTitle' . $x] : '';
         $registry = Zend_Registry::getInstance();
         $files = $registry->get('files');
         if (isset($files['uploadedFile' . $x])) {
             $file = $files['uploadedFile' . $x];
             //$this->checkTitle($aDataCatalog['fixedTitle'.$x]);
         }
         $type = $aDataCatalog['fixedType' . $x] ? $aDataCatalog['fixedType' . $x] : '';
         if ($type == 'file') {
             $relatedType = 'RELATED_FILE';
         } elseif ($type == 'image') {
             $relatedType = 'RELATED_IMAGE';
             $this->checkSize($file['size'], $aDataCatalog['fixedTitle' . $x]);
         } elseif ($type == 'video') {
             $relatedType = 'RELATED_VIDEO';
         }
         $tblCatalog = new App_Model_Db_Table_Catalog();
         $gman = new Pandamp_Core_Guid();
         $catalogGuid = isset($aDataCatalog['guid']) && !empty($aDataCatalog['guid']) ? $aDataCatalog['guid'] : $gman->generateGuid();
         $folderGuid = isset($aDataCatalog['folderGuid']) && !empty($aDataCatalog['folderGuid']) ? $aDataCatalog['folderGuid'] : '';
         $where = $tblCatalog->getAdapter()->quoteInto('guid=?', $catalogGuid);
         if ($tblCatalog->fetchRow($where)) {
             $rowCatalog = $tblCatalog->find($catalogGuid)->current();
             $rowCatalog->shortTitle = isset($aDataCatalog['shortTitle']) ? $aDataCatalog['shortTitle'] : $rowCatalog->shortTitle;
             $rowCatalog->publishedDate = isset($aDataCatalog['publishedDate']) ? $aDataCatalog['publishedDate'] : $rowCatalog->publishedDate;
             $rowCatalog->expiredDate = isset($aDataCatalog['expiredDate']) ? $aDataCatalog['expiredDate'] : $rowCatalog->expiredDate;
             $rowCatalog->status = isset($aDataCatalog['status']) ? $aDataCatalog['status'] : $rowCatalog->status;
         } else {
             $rowCatalog = $tblCatalog->fetchNew();
             $rowCatalog->guid = $catalogGuid;
             $rowCatalog->shortTitle = isset($aDataCatalog['shortTitle']) ? $aDataCatalog['shortTitle'] : '';
             $rowCatalog->profileGuid = $aDataCatalog['profileGuid'];
             $rowCatalog->publishedDate = isset($aDataCatalog['publishedDate']) ? $aDataCatalog['publishedDate'] : '0000-00-00 00:00:00';
             $rowCatalog->expiredDate = isset($aDataCatalog['expiredDate']) ? $aDataCatalog['expiredDate'] : '0000-00-00 00:00:00';
             $rowCatalog->createdBy = isset($aDataCatalog['username']) ? $aDataCatalog['username'] : '';
             $rowCatalog->modifiedBy = $rowCatalog->createdBy;
             $rowCatalog->createdDate = date("Y-m-d h:i:s");
             $rowCatalog->modifiedDate = $rowCatalog->createdDate;
             $rowCatalog->deletedDate = '0000-00-00 00:00:00';
             $rowCatalog->status = isset($aDataCatalog['status']) ? $aDataCatalog['status'] : 0;
         }
         $catalogGuid = $rowCatalog->save();
         $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute();
         if (isset($files['uploadedFile' . $x])) {
             if (isset($files['uploadedFile' . $x]['name']) && !empty($files['uploadedFile' . $x]['name'])) {
                 $this->_updateCatalogAttribute($rowsetCatalogAttribute, $catalogGuid, 'docSystemName', strtoupper(str_replace(' ', '_', $file['name'])));
                 $this->_updateCatalogAttribute($rowsetCatalogAttribute, $catalogGuid, 'docOriginalName', strtoupper(str_replace(' ', '_', $file['name'])));
                 $this->_updateCatalogAttribute($rowsetCatalogAttribute, $catalogGuid, 'docSize', $file['size']);
                 $this->_updateCatalogAttribute($rowsetCatalogAttribute, $catalogGuid, 'docMimeType', $file['type']);
                 $this->_updateCatalogAttribute($rowsetCatalogAttribute, $catalogGuid, 'fixedTitle', $title);
                 $this->_updateCatalogAttribute($rowsetCatalogAttribute, $catalogGuid, 'docViewOrder', 0);
                 if ($type == 'file') {
                     //$sDir = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'files'.DIRECTORY_SEPARATOR.$relatedGuid;
                     $sDir = $cdn['static']['dir']['files'] . DIRECTORY_SEPARATOR . $relatedGuid;
                     if (is_dir($sDir)) {
                         move_uploaded_file($file['tmp_name'], $sDir . DIRECTORY_SEPARATOR . strtoupper(str_replace(' ', '_', $file['name'])));
                     } else {
                         if (mkdir($sDir)) {
                             move_uploaded_file($file['tmp_name'], $sDir . DIRECTORY_SEPARATOR . strtoupper(str_replace(' ', '_', $file['name'])));
                         } else {
                             move_uploaded_file($file['tmp_name'], $cdn['static']['dir']['files'] . DIRECTORY_SEPARATOR . strtoupper(str_replace(' ', '_', $file['name'])));
                         }
                     }
                 } elseif ($type == 'image') {
                     $sDir = $cdn['static']['dir']['images'];
                     //$sDir = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'images';
                     $file = $files['uploadedFile' . $x]['name'];
                     $ext = explode(".", $file);
                     $ext = strtolower(array_pop($ext));
                     if ($ext == "jpg" || $ext == "jpeg" || $ext == "gif" || $ext == "png") {
                         //$target_path = $sDir.DIRECTORY_SEPARATOR.$catalogGuid.".".$ext;
                         $thumb_mode = $sDir . DIRECTORY_SEPARATOR . $catalogGuid . "." . $ext;
                         $thumb = $sDir . DIRECTORY_SEPARATOR . $relatedGuid . DIRECTORY_SEPARATOR . $catalogGuid . "." . $ext;
                         $target_path = $sDir . DIRECTORY_SEPARATOR . $relatedGuid;
                         if (is_dir($target_path)) {
                             move_uploaded_file($files['uploadedFile' . $x]['tmp_name'], $target_path . DIRECTORY_SEPARATOR . $catalogGuid . "." . $ext);
                             //chmod($target_path,0644);
                             Pandamp_Lib_Formater::createthumb($thumb, $target_path . '/tn_' . $catalogGuid . "." . $ext, 275, 160);
                             // sebelumnya 130x130
                         } else {
                             if (mkdir($target_path)) {
                                 move_uploaded_file($files['uploadedFile' . $x]['tmp_name'], $target_path . DIRECTORY_SEPARATOR . $catalogGuid . "." . $ext);
                                 //chmod($target_path,0644);
                                 Pandamp_Lib_Formater::createthumb($thumb, $target_path . '/tn_' . $catalogGuid . "." . $ext, 275, 160);
                             } else {
                                 move_uploaded_file($files['uploadedFile' . $x]['tmp_name'], $sDir . DIRECTORY_SEPARATOR . $catalogGuid . "." . $ext);
                                 //chmod($target_path,0644);
                                 Pandamp_Lib_Formater::createthumb($thumb_mode, $sDir . '/tn_' . $catalogGuid . "." . $ext, 275, 160);
                             }
                         }
                     }
                 } elseif ($type == 'video') {
                     $sDir = $cdn['static']['dir']['video'] . DIRECTORY_SEPARATOR . $relatedGuid;
                     //$sDir = ROOT_DIR.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'video'.DIRECTORY_SEPARATOR.$relatedGuid;
                     if (is_dir($sDir)) {
                         move_uploaded_file($file['tmp_name'], $sDir . DIRECTORY_SEPARATOR . strtoupper(str_replace(' ', '_', $file['name'])));
                     } else {
                         if (mkdir($sDir)) {
                             move_uploaded_file($file['tmp_name'], $sDir . DIRECTORY_SEPARATOR . strtoupper(str_replace(' ', '_', $file['name'])));
                         } else {
                             move_uploaded_file($file['tmp_name'], $cdn['static']['dir']['video'] . DIRECTORY_SEPARATOR . strtoupper(str_replace(' ', '_', $file['name'])));
                         }
                     }
                 }
             }
         }
         $this->relateTo($catalogGuid, $relatedGuid, $relatedType);
         $indexingEngine = Pandamp_Search::manager();
         $indexingEngine->indexCatalog($catalogGuid);
         $registry = Zend_Registry::getInstance();
         $application = Zend_Registry::get(Pandamp_Keys::REGISTRY_APP_OBJECT);
         $res = $application->getOption('resources')['indexing']['solr']['write'];
         $esolr = new Pandamp_Search_Adapter_Esolr($res['host'], $res['port'], $res['dir4']);
         $esolr->indexCatalog($catalogGuid);
     }
 }