public function newAction() { $this->view->message = "Nothing is saved"; $req = $this->getRequest(); $item = $req->getParam('guid'); $relatedItem = $req->getParam('relatedGuid'); $as = $req->getParam('relateAs'); Zend_Loader::loadClass('Kutu_Core_Orm_Table_Catalog'); $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); if (empty($relatedItem)) { $this->view->message = "No relatedGuid specified!"; } //check if $guid is an array if (is_array($item)) { foreach ($item as $guid) { echo "<br>" . $guid; $rowCatalog = $tblCatalog->find($guid)->current(); echo $rowCatalog->guid; $rowCatalog->relateTo($relatedItem, $as); } } else { $rowCatalog = $tblCatalog->find($item)->current(); $rowCatalog->relateTo($relatedItem, $as); $this->view->message = "Data was successfully saved"; } }
public function detailsAction() { $this->_helper->layout()->setLayout('layout-iht'); $r = $this->getRequest(); $catalogGuid = $r->getParam('guid'); $this->view->catalogGuid = $catalogGuid; $folderGuid = $r->getParam('node'); $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowCatalog = $tblCatalog->find($catalogGuid)->current(); $rowsetAttribute = $rowCatalog->findDependentRowsetCatalogAttribute(); $rowTitle = $rowsetAttribute->findByAttributeGuid('fixedTitle'); $this->view->catalogTitle = $rowTitle->value; $rowSubTitle = $rowsetAttribute->findByAttributeGuid('fixedSubTitle'); $this->view->catalogSubTitle = $rowSubTitle->value; $modDir = $this->getFrontController()->getModuleDirectory(); require_once $modDir . '/components/Dms/Catalog/DetailsViewer.php'; $w = new Dms_Catalog_DetailsViewer($catalogGuid, 'root'); $this->view->widget1 = $w; if (empty($folderGuid)) { $rowsetFolder = $rowCatalog->findManyToManyRowset('Kutu_Core_Orm_Table_Folder', 'Kutu_Core_Orm_Table_CatalogFolder'); if (count($rowsetFolder) > 0) { $rowFolder = $rowsetFolder->current(); $folderGuid = $rowFolder->guid; } } require_once $modDir . '/components/Dms/FolderBreadcrumbs.php'; $w2 = new Dms_FolderBreadcrumbs($folderGuid); $this->view->widget2 = $w2; }
static function find($catalogGuid) { $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowsetCatalog = $tblCatalog->find($catalogGuid); if ($rowsetCatalog->count()) { return new Kutu_Core_Model_Catalog($rowsetCatalog->current()); } else { return false; } }
public function getPrice($catalogGuid) { $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowset = $tblCatalog->find($catalogGuid); if (count($rowset)) { $row = $rowset->current(); return $row->price; } else { return 0; } }
function generateFormAnswer($catalogGuid) { $aRenderedAttributes = array(); $aBaseAttributes = array(); $tableCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowsetCatalog = $tableCatalog->find($catalogGuid); $rowCatalog = $rowsetCatalog->current(); $tableProfileAttribute = new Kutu_Core_Orm_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('Kutu_Core_Orm_Table_Attribute'); if (isset($rowCatalogAttribute->value)) { $attributeValue = $rowCatalogAttribute->value; } else { $attributeValue = ''; } if (isset($rowCatalogAttribute->guid)) { $catalogAttributeGuid = $rowCatalogAttribute->guid; } else { $guidMan = new Kutu_Core_Guid(); $catalogAttributeGuid = $guidMan->generateGuid(); } $attributeRenderer = new Kutu_Form_Attribute_Renderer($rowAttribute->guid, $attributeValue, $rowAttribute->type, null, 'clinic', 'clinic_category'); $aRenderedAttributes[$rowAttribute->guid]['description'] = $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}'>"; // $aBaseAttributes['shortTitle']['description'] = 'shortTitle'; // $aBaseAttributes['shortTitle']['form'] = "<textarea name='shortTitle' id='shortTitle' rows='1'' cols='50'>$rowCatalog->shortTitle</textarea>"; $aBaseAttributes['profileGuid']['description'] = ''; $aBaseAttributes['profileGuid']['form'] = "<input type='hidden' name='profileGuid' id='profileGuid' value='{$rowCatalog->profileGuid}'>"; $aBaseAttributes['profileGuid']['description'] = 'Sender'; $aBaseAttributes['profileGuid']['form'] = "{$rowCatalog->createdBy}"; // $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="'.KUTU_ROOT_URL.'/mix_lib/extjs/resources/images/default/custom/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="'.KUTU_ROOT_URL.'/mix_lib/extjs/resources/images/default/custom/img.gif" width="16" height="16" border="0" alt="Pick a date"></a>'; // $aBaseAttributes['expiredDate']['description'] = 'Expired Date'; // $aBaseAttributes['expiredDate']['form'] = $n; $aBaseAttributes['status']['description'] = ''; $aBaseAttributes['status']['form'] = "<input type='hidden' name='status' id='status' value='{$rowCatalog->status}'>"; $aReturn = array(); $aReturn['baseForm'] = $aBaseAttributes; $aReturn['attributeForm'] = $aRenderedAttributes; return $aReturn; }
public function GetCatalogDocSize($catalogGuid) { $tblCatalog = new Kutu_Core_Orm_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; }
public function GetCatalogDocType($catalogGuid) { $tblCatalog = new Kutu_Core_Orm_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)); } else { $docType = ''; } return $docType; }
public function GetCatalogDownloadTitle($catalogGuid) { $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowsetCatalog = $tblCatalog->find($catalogGuid); if (count($rowsetCatalog)) { $rowCatalog = $rowsetCatalog->current(); $rowsetCatAtt = $rowCatalog->findDependentRowsetCatalogAttribute(); $oriName = $rowsetCatAtt->findByAttributeGuid('docOriginalName')->value; } else { $oriName = 'No-Title'; } return $oriName; }
public function genericAction() { $r = $this->getRequest(); $guid = $r->getParam('g'); $this->view->catalogGuid = $guid; $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowCatalog = $tblCatalog->find($guid)->current(); $this->view->row = $rowCatalog; $rowsetFolder = $rowCatalog->findManyToManyRowset('Kutu_Core_Orm_Table_Folder', 'Kutu_Core_Orm_Table_CatalogFolder'); if (count($rowsetFolder) > 0) { $rowFolder = $rowsetFolder->current(); $folderGuid = $rowFolder->guid; $this->view->folderGuid = $folderGuid; $this->view->folderTitle = $rowFolder->title; } }
public function indexCatalog($guid, $mode = "NORMAL") { $solr =& $this->_solr; $tbl = new Kutu_Core_Orm_Table_Catalog(); $rowset = $tbl->find($guid); if (count($rowset)) { $row = $rowset->current(); if ($row->profileGuid != 'kutu_doc') { $documents = array(); $documents[] = $this->_createSolrDocument($row, $mode); try { $solr->addDocuments($documents); $solr->commit(); } catch (Exception $e) { throw new Zend_Exception($e->getMessage()); //echo $e->getMessage(); } } } }
public function indexCatalog($guid) { $solr =& $this->_solr; $tbl = new Kutu_Core_Orm_Table_Catalog(); $rowset = $tbl->find($guid); if (count($rowset)) { $row = $rowset->current(); $log = new Kutu_Log(); $hTitle = new Kutu_View_Helper_GetCatalogTitle(); $log->info("indexing:" . $hTitle->getCatalogTitle($row->guid)); $documents = array(); $documents[] = $this->_createSolrDocument($row); try { $solr->addDocuments($documents); $solr->commit(); } catch (Exception $e) { $log->err($e->getMessage()); throw new Zend_Exception($e->getMessage()); } } }
public function forceDelete($folderGuid) { Zend_Loader::loadClass('Kutu_Core_Orm_Table_Folder'); $tblFolder = new Kutu_Core_Orm_Table_Folder(); $rowSet = $tblFolder->fetchChildren($folderGuid); $row1 = $tblFolder->find($folderGuid)->current(); foreach ($rowSet as $row) { $this->forceDelete($row->guid); } echo $row1->title . ' '; $rowsetCatalogFolder = $row1->findDependentRowsetCatalogFolder(); $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $bpmCatalog = new Kutu_Core_Bpm_Catalog(); if (count($rowsetCatalogFolder)) { foreach ($rowsetCatalogFolder as $rowCatalogFolder) { $rowCatalog = $tblCatalog->find($rowCatalogFolder->catalogGuid)->current(); echo $rowCatalog->guid . '<br>'; $bpmCatalog->delete($rowCatalog->guid); } $this->delete($row1->guid); } else { $this->delete($row1->guid); } }
function generateFormEdit($catalogGuid) { $today = date('Y-m-d H:i:s'); Zend_Loader::loadClass('Kutu_Form_Attribute_Renderer'); Zend_Loader::loadClass('Kutu_Core_Orm_Table_ProfileAttribute'); Zend_Loader::loadClass('Kutu_Core_Orm_Table_Catalog'); $aRenderedAttributes = array(); $aBaseAttributes = array(); $tableCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowsetCatalog = $tableCatalog->find($catalogGuid); $rowCatalog = $rowsetCatalog->current(); $tableProfileAttribute = new Kutu_Core_Orm_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('Kutu_Core_Orm_Table_Attribute'); if (isset($rowCatalogAttribute->value)) { $attributeValue = $rowCatalogAttribute->value; } else { $attributeValue = ''; } if (isset($rowCatalogAttribute->guid)) { $catalogAttributeGuid = $rowCatalogAttribute->guid; } else { Zend_Loader::loadClass('Kutu_Core_Guid'); $guidMan = new Kutu_Core_Guid(); $catalogAttributeGuid = $guidMan->generateGuid(); } if (isset($rowAttribute)) { $attributeRenderer = new Kutu_Form_Attribute_Renderer($rowAttribute->guid, $attributeValue, $rowAttribute->type, null, $rowCatalog->profileGuid); $aRenderedAttributes[$rowAttribute->guid]['description'] = $rowAttribute->description; $aRenderedAttributes[$rowAttribute->guid]['form'] = $attributeRenderer->render(); } $i++; } $aBaseAttributes['guid']['description'] = 'Guid'; $aBaseAttributes['guid']['form'] = $rowCatalog->guid . "<input type='hidden' name='guid' id='guid' value='{$rowCatalog->guid}'>"; //$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'>";*/ //$aBaseAttributes['publishedDate']['description'] = 'Published Date'; //$aBaseAttributes['publishedDate']['form'] = "<input type='text' name='publishedDate' id='publishedDate' value='$rowCatalog->publishedDate'>"; //$aBaseAttributes['expiredDate']['description'] = 'Expired Date'; //$aBaseAttributes['expiredDate']['form'] = "<input type='text' name='expiredDate' id='expiredDate' value='$rowCatalog->expiredDate'>"; $aBaseAttributes['createdBy']['description'] = 'Created By'; $aBaseAttributes['createdBy']['form'] = $rowCatalog->createdBy; //"<input type='text' name='createdBy' id='createdBy' value='$rowCatalog->createdBy'>"; $aBaseAttributes['modifiedBy']['description'] = 'Modified By'; $aBaseAttributes['modifiedBy']['form'] = $rowCatalog->modifiedBy; //"<input type='text' name='modifiedBy' id='modifiedBy' value='$rowCatalog->modifiedBy'>"; $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 (in USD)'; $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 Kutu_Form_Attribute_Renderer('status', $rowCatalog->status, 101); $aBaseAttributes['status']['form'] = $attributeRenderer->render(); $aReturn = array(); $aReturn['baseForm'] = $aBaseAttributes; $aReturn['attributeForm'] = $aRenderedAttributes; return $aReturn; }
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'; } }
public function indexAction() { //$this->view->render( $r = $this->getRequest(); $folderLegalDb = "lgs4a0ee4ab533b4"; $guid = $r->getParam('g'); if (empty($guid)) { $this->_forward('home', "pages", 'sitenlrp', $r->getParams()); return true; } if ($guid == 'search') { $this->_forward('search', "pages", 'sitenlrp', $r->getParams()); return true; } $tblFolder = new Kutu_Core_Orm_Table_Folder(); $rowset = $tblFolder->find($guid); if (count($rowset)) { $row = $rowset->current(); $json = new Zend_Json(); if (empty($row->cmsParams)) { //check if folder is child of folderLegalDb if (strpos($row->path, $folderLegalDb) === false) { $aParam = array('heading' => 1); $aParam = array_merge($aParam, $r->getParams()); $this->_forward('list', "pages", 'sitenlrp', $aParam); } else { $this->_redirect(KUTU_ROOT_URL . '/dms/' . $row->guid); } return true; //die(); } else { $aData = $json->decode($row->cmsParams); if (!empty($aData['a']) && !empty($aData['c']) && !empty($aData['m'])) { $aData['p'] = array_merge($aData['p'], $r->getParams()); $this->_forward($aData['a'], $aData['c'], $aData['m'], $aData['p']); return true; } else { $aData['p'] = array_merge($aData['p'], $r->getParams()); //check if folder is child of folderLegalDb if (strpos($row->path, $folderLegalDb) === false) { $this->_forward('list', "pages", 'sitenlrp', $aData['p']); } else { $this->_redirect(KUTU_ROOT_URL . '/dms/' . $row->guid); } return true; } } } else { $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowset = $tblCatalog->find($guid); if (count($rowset)) { $row = $rowset->current(); //update number of downloads and number of views $bpm = new Kutu_Core_Bpm_Catalog(); //$bpm->updateNumberOfViews($row->guid); switch ($row->profileGuid) { case 'kutu_peraturan': case 'kutu_putusan': $this->_redirect(KUTU_ROOT_URL . '/dms/catalog/' . $guid); return true; } $rowsetFolder = $row->findManyToManyRowset('Kutu_Core_Orm_Table_Folder', 'Kutu_Core_Orm_Table_CatalogFolder'); if (count($rowsetFolder) > 0) { foreach ($rowsetFolder as $rowFolder) { //$rowFolder = $rowsetFolder->current(); $folderGuid = $rowFolder->guid; if (strpos($rowFolder->path, $folderLegalDb) !== false) { //do nothing } else { $aParams = $r->getParams(); $aParams['node'] = $folderGuid; //Should forward to specific controller based on catalog's profileGuid $this->_forward('generic', "pages_details", 'sitenlrp', $aParams); return true; } } $this->_redirect(KUTU_ROOT_URL . '/dms/catalog/' . $guid . '/node/' . $folderGuid); } else { $this->_redirect(KUTU_ROOT_URL . '/dms/catalog/' . $guid . '/node/' . $folderGuid); } } else { } } }
public function indexCatalog($catalogGuid) { $index = $this->_index; $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowsetCatalog = $tblCatalog->find($catalogGuid); if (count($rowsetCatalog)) { //check if guid exist in index, then delete $term = new Zend_Search_Lucene_Index_Term($catalogGuid, 'guid'); $docIds = $index->termDocs($term); foreach ($docIds as $id) { $doc = $index->getDocument($id); $index->delete($id); } $rowCatalog = $rowsetCatalog->current(); $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::Keyword('guid', $rowCatalog->guid)); //fill parentGuid with catalogGuid if it's kutu_doc if ($rowCatalog->profileGuid == 'kutu_doc') { $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem(); $rowset = $tblRelatedItem->fetchAll("itemGuid='{$rowCatalog->guid}' AND relateAs='RELATED_FILE'"); if (count($rowset)) { $row = $rowset->current(); $parentCatalogGuid = $row->relatedGuid; $doc->addField(Zend_Search_Lucene_Field::Keyword('parentGuid', $parentCatalogGuid)); } } else { $doc->addField(Zend_Search_Lucene_Field::Keyword('parentGuid', $rowCatalog->guid)); } $doc->addField(Zend_Search_Lucene_Field::Text('profile', $rowCatalog->profileGuid)); $doc->addField(Zend_Search_Lucene_Field::Keyword('publishedDate', $this->_filterDateTime($rowCatalog->publishedDate))); $doc->addField(Zend_Search_Lucene_Field::Keyword('expiredDate', $this->_filterDateTime($rowCatalog->expiredDate))); $doc->addField(Zend_Search_Lucene_Field::Keyword('createdBy', $rowCatalog->createdBy)); $doc->addField(Zend_Search_Lucene_Field::Keyword('modifiedBy', $rowCatalog->modifiedBy)); $doc->addField(Zend_Search_Lucene_Field::Keyword('createdDate', $this->_filterDateTime($rowCatalog->createdDate))); $doc->addField(Zend_Search_Lucene_Field::Keyword('modifiedDate', $this->_filterDateTime($rowCatalog->modifiedDate))); $doc->addField(Zend_Search_Lucene_Field::Keyword('status', $rowCatalog->status)); if ($rowCatalog->profileGuid == 'kutu_doc') { $doc->addField(Zend_Search_Lucene_Field::Keyword('objectType', 'file')); } else { $doc->addField(Zend_Search_Lucene_Field::Keyword('objectType', 'catalog')); } $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute(); if (count($rowsetCatalogAttribute)) { foreach ($rowsetCatalogAttribute as $rowCatalogAttribute) { switch ($rowCatalogAttribute->attributeGuid) { case 'fixedTitle': case 'title': $doc->addField(Zend_Search_Lucene_Field::Text('title', $rowCatalogAttribute->value)); break; case 'fixedSubTitle': case 'subTitle': $doc->addField(Zend_Search_Lucene_Field::Text('subtitle', $rowCatalogAttribute->value)); break; case 'fixedContent': case 'content': $docHtml = Zend_Search_Lucene_Document_Html::loadHTML($rowCatalogAttribute->value); $cleanedText = $docHtml->getFieldValue('body'); $doc->addField(Zend_Search_Lucene_Field::UnStored('content', $cleanedText)); break; case 'fixedKeywords': case 'keywords': $doc->addField(Zend_Search_Lucene_Field::UnStored('keywords', $rowCatalogAttribute->value)); break; case 'fixedDescription': case 'description': $doc->addField(Zend_Search_Lucene_Field::Text('description', $rowCatalogAttribute->value)); break; case 'ptsKetua': $doc->addField(Zend_Search_Lucene_Field::Text('judge', $rowCatalogAttribute->value)); break; case 'prtNomor': case 'fixedNomor': case 'fixedNumber': case 'nomor': case 'ptsNomor': $doc->addField(Zend_Search_Lucene_Field::UnStored('number', $rowCatalogAttribute->value)); break; case 'prtTahun': case 'fixedTahun': case 'fixedYear': case 'tahun': case 'ptsTahun': $doc->addField(Zend_Search_Lucene_Field::UnStored('year', $rowCatalogAttribute->value)); break; default: //check if attribute is a datetime field $tblAttribute = new Kutu_Core_Orm_Table_Attribute(); $rowAttribute = $tblAttribute->find($rowCatalogAttribute->attributeGuid)->current(); if ($rowAttribute->type == 4) { $doc->addField(Zend_Search_Lucene_Field::UnStored(strtolower($rowCatalogAttribute->attributeGuid), $this->_filterDateTime($rowCatalogAttribute->value))); } else { if ($rowAttribute->type == 2) { $docHtml = Zend_Search_Lucene_Document_Html::loadHTML($rowCatalogAttribute->value); $cleanedText = $docHtml->getFieldValue('body'); $doc->addField(Zend_Search_Lucene_Field::UnStored(strtolower($rowCatalogAttribute->attributeGuid), $cleanedText)); } else { $doc->addField(Zend_Search_Lucene_Field::UnStored(strtolower($rowCatalogAttribute->attributeGuid), $rowCatalogAttribute->value)); } } break; } } //if profile=kutu_doc, extract text from its file and put it in content field if ($rowCatalog->profileGuid == 'kutu_doc') { $row = $rowsetCatalogAttribute->findByAttributeGuid('docSystemName'); $systemName = $row->value; $row = $rowsetCatalogAttribute->findByAttributeGuid('docMimeType'); $mimeType = $row->value; $extactedText = $this->_extractText($rowCatalog->guid, $systemName, $mimeType); $doc->addField(Zend_Search_Lucene_Field::UnStored('content', $extactedText)); } } // if catalog is a kutu_doc, and if field content empty (this means // file can't be read, text can't be extracted, or file empty), do not index if ($rowCatalog->profileGuid == 'kutu_doc') { $tmpS = $doc->getFieldValue('content'); if (!empty($tmpS)) { $index->addDocument($doc); } else { } } else { $index->addDocument($doc); } } else { // do nothing } }
protected function _postDelete() { //find related docs and delete them $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem(); $rowsetRelatedDocs = $tblRelatedItem->fetchAll("relatedGuid='{$this->guid}' AND relateAs='RELATED_FILE'"); if (count($rowsetRelatedDocs)) { foreach ($rowsetRelatedDocs as $rowRelatedDoc) { $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowCatalog = $tblCatalog->find($rowRelatedDoc->itemGuid)->current(); $rowCatalog->delete(); } } if ($this->profileGuid == 'kutu_doc') { //get parentGuid $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem(); $rowsetRelatedItem = $tblRelatedItem->fetchAll("itemGuid='{$this->guid}' AND relateAs='RELATED_FILE'"); if (count($rowsetRelatedItem)) { foreach ($rowsetRelatedItem as $rowRelatedItem) { //must delete the physical files $rowsetCatAtt = $this->findDependentRowsetCatalogAttribute(); $systemname = $rowsetCatAtt->findByAttributeGuid('docSystemName')->value; $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)) { //delete file unlink($sDir1); } else { if (file_exists($sDir2)) { //delete file unlink($sDir2); } } } } } //delete from table CatalogAttribute $tblCatalogAttribute = new Kutu_Core_Orm_Table_CatalogAttribute(); $tblCatalogAttribute->delete("catalogGuid='{$this->guid}'"); //delete catalogGuid from table CatalogFolder $tblCatalogFolder = new Kutu_Core_Orm_Table_CatalogFolder(); $tblCatalogFolder->delete("catalogGuid='{$this->guid}'"); //delete guid from table AssetSetting $tblAssetSetting = new Kutu_Core_Orm_Table_AssetSetting(); $tblAssetSetting->delete("guid='{$this->guid}'"); //delete from table relatedItem $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem(); $tblRelatedItem->delete("itemGuid='{$this->guid}'"); $tblRelatedItem->delete("relatedGuid='{$this->guid}'"); //delete from lucene index //check if guid exist in index, then delete // $indexEngine = new Kutu_Search_Index_Engine(); // $indexEngine->deleteCatalogFromIndex($this->guid); $registry = Zend_Registry::getInstance(); $conf = $registry->get('config'); $indexingEngine = Kutu_Search::manager(); try { $hits = $indexingEngine->deleteCatalogFromIndex($this->guid); } catch (Exception $e) { } /* $tblTmpIndex = new Kutu_Core_Orm_Table_TmpIndex(); $rowTmpIndex = $tblTmpIndex->fetchNew(); $rowTmpIndex->catalogGuid = $this->guid; $rowTmpIndex->status = 'delete'; $rowTmpIndex->save(); */ $tblTmpIndex = new Kutu_Core_Orm_Table_TmpIndex(); $tblTmpIndex->delete("catalogGuid='{$this->guid}'"); //delete physical catalog folder from uploads/files/[catalogGuid] $sDir = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $this->guid; try { if (is_dir($sDir)) { rmdir($sDir); } } catch (Exception $e) { } $sDir = KUTU_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) { } //delete from ACL }
function viewerAction() { $catalogGuid = $this->_getParam('guid') ? $this->_getParam('guid') : ''; $node = $this->_getParam('node') ? $this->_getParam('node') : ''; $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); if (!empty($catalogGuid)) { $rowCatalog = $tblCatalog->find($catalogGuid)->current(); if ($rowCatalog) { $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute(); $tableProfileAttribute = new Kutu_Core_Orm_Table_ProfileAttribute(); $profileGuid = $rowCatalog->profileGuid; $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', $profileGuid); $rowsetProfileAttribute = $tableProfileAttribute->fetchAll($where, 'viewOrder ASC'); $aAttribute = array(); $i = 0; $tblAttribute = new Kutu_Core_Orm_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->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>"; } } } } }
function isAllowed($username, $itemGuid, $action, $section = 'content') { if ($this->checkAcl("site", 'all', 'user', $username, false, false)) { return true; } if ($section == 'content') { if ($this->checkAcl("dms", 'all', 'user', $username, false, false)) { return true; } switch ($action) { case 'create': if ($this->checkAcl("dms", 'createCatalog', 'user', $username, false, false)) { return true; } case 'read': if ($this->checkAcl("dms", 'readCatalog', 'user', $username, false, false) || $acl->checkAcl("dms", 'updateCatalog', 'user', $username, false, false)) { return true; } case 'update': if ($this->checkAcl("dms", 'updateCatalog', 'user', $username, false, false)) { return true; } case 'delete': if ($this->checkAcl("dms", 'deleteCatalog', '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 Kutu_Core_Orm_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('Kutu_Core_Orm_Table_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 Kutu_Core_Orm_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; }
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 }
function generateFormAdd($catalogGuid, $folderGuid = null) { $aRenderedAttributes = array(); $aBaseAttributes = array(); $tableCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowsetCatalog = $tableCatalog->find($catalogGuid); $rowCatalog = $rowsetCatalog->current(); if (!isset($rowCatalog)) { $tableProfileAttribute = new Kutu_Core_Orm_Table_ProfileAttribute(); $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', 'setting'); $rows = $tableProfileAttribute->fetchAll($where, 'viewOrder ASC'); $i = 0; foreach ($rows as $row) { $rowset = $row->findParentRow('Kutu_Core_Orm_Table_Attribute'); $attributeRenderer = new Kutu_Form_Attribute_Renderer($rowset->guid, null, $rowset->type, null); $aRenderedAttributes[$rowset->guid]['description'] = $rowset->description; $aRenderedAttributes[$rowset->guid]['form'] = $attributeRenderer->render(); $i++; } $aBaseAttributes['profileGuid']['description'] = ''; $aBaseAttributes['profileGuid']['form'] = "<input type='hidden' name='profileGuid' id='profileGuid' value='setting'>"; $aBaseAttributes['folderGuid']['description'] = ''; $aBaseAttributes['folderGuid']['form'] = "<input type='hidden' name='folderGuid' id='folderGuid' value='{$folderGuid}'>"; $aBaseAttributes['status']['description'] = ''; $aBaseAttributes['status']['form'] = "<input type='hidden' name='status' id='status' value='1'>"; } else { $tableProfileAttributes = new Kutu_Core_Orm_Table_ProfileAttribute(); $where = $tableProfileAttributes->getAdapter()->quoteInto('profileGuid=?', $rowCatalog->profileGuid); $rowsetProfileAttributes = $tableProfileAttributes->fetchAll($where, array('viewOrder ASC')); $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute(); $i = 0; foreach ($rowsetProfileAttributes as $row) { $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid($row->attributeGuid); $rowAttribute = $row->findParentRow('Kutu_Core_Orm_Table_Attribute'); if (isset($rowCatalogAttribute->value)) { $attributeValue = $rowCatalogAttribute->value; } else { $attributeValue = ''; } if (isset($rowCatalogAttribute->guid)) { $catalogAttributeGuid = $rowCatalogAttribute->guid; } else { $guidMan = new Kutu_Core_Guid(); $catalogAttributeGuid = $guidMan->generateGuid(); } $attributeRenderer = new Kutu_Form_Attribute_Renderer($rowAttribute->guid, $attributeValue, $rowAttribute->type, null); $aRenderedAttributes[$rowAttribute->guid]['description'] = $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}'>"; $aBaseAttributes['profileGuid']['description'] = ''; $aBaseAttributes['profileGuid']['form'] = "<input type='hidden' name='profileGuid' id='profileGuid' value='{$rowCatalog->profileGuid}'>"; $aBaseAttributes['status']['description'] = ''; $aBaseAttributes['status']['form'] = "<input type='hidden' name='status' id='status' value='1'>"; } $aReturn = array(); $aReturn['baseForm'] = $aBaseAttributes; $aReturn['attributeForm'] = $aRenderedAttributes; return $aReturn; }
function getMailContent($title) { // table Folder $tblFolder = new Kutu_Core_Orm_Table_Folder(); $where = $tblFolder->getAdapter()->quoteInto("title=?", $title); $rowFolder = $tblFolder->fetchRow($where); // table CatalogFolder $tblCatalogFolder = new Kutu_Core_Orm_Table_CatalogFolder(); $find = $tblCatalogFolder->getAdapter()->quoteInto("folderGuid=?", $rowFolder->guid); $rowCatFolder = $tblCatalogFolder->fetchRow($find); if (isset($rowCatFolder)) { $catalogGuid = $rowCatFolder->catalogGuid; } else { $catalogGuid = ''; } // table Catalog $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowCatalog = $tblCatalog->find($catalogGuid)->current(); // table ProfileAttribute $tblProfileAttributes = new Kutu_Core_Orm_Table_ProfileAttribute(); $search = $tblProfileAttributes->getAdapter()->quoteInto("profileGuid=?", $rowCatalog->profileGuid); $rowsetProfileAttributes = $tblProfileAttributes->fetchAll($search, array('viewOrder ASC')); $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute(); $i = 0; foreach ($rowsetProfileAttributes as $row) { $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid($row->attributeGuid); $rowAttribute = $row->findParentRow('Kutu_Core_Orm_Table_Attribute'); if (isset($rowCatalogAttribute->value)) { $attributeValue = $rowCatalogAttribute->value; } else { $attributeValue = ''; } $mailcontent = $attributeValue; $i++; } return $mailcontent; }
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'; } }
public function alterdateAction() { $urlReferer = $_SERVER['HTTP_REFERER']; $r = $this->getRequest(); $guid = $r->getParam('guid'); $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowset = $tblCatalog->find($guid); if (count($rowset)) { $row = $rowset->current(); $this->view->row = $row; $this->view->guid = $row->guid; $this->view->catalogTitle = Kutu_Core_Util::getCatalogAttributeValue($row->guid, 'fixedTitle'); if ($r->isPost()) { $sessHistory = new Zend_Session_Namespace('BROWSER_HISTORY'); $urlReferer = $sessHistory->urlReferer; $createdDate = $r->getParam('createdDate'); $modifiedDate = $r->getParam('modifiedDate'); $bpm = new Kutu_Core_Bpm_Catalog(); $bpm->alterDate($r->getParams()); $this->view->message = "Date has been altered."; } else { } } $sessHistory = new Zend_Session_Namespace('BROWSER_HISTORY'); $sessHistory->urlReferer = $urlReferer; $this->view->urlReferer = $sessHistory->urlReferer; }
public function view() { $this->view->addHelperPath(KUTU_ROOT_DIR . '/lib/Kutu/View/Helper', 'Kutu_View_Helper'); $catalogGuid = $this->catalogGuid ? $this->catalogGuid : ''; $node = $this->folderGuid ? $this->folderGuid : 'root'; Zend_Loader::loadClass('Kutu_Core_Orm_Table_Catalog'); $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); if (!empty($catalogGuid)) { $rowCatalog = $tblCatalog->find($catalogGuid)->current(); $rowsetCatalogAttribute = $rowCatalog->findDependentRowsetCatalogAttribute(); Zend_Loader::loadClass('Kutu_Core_Orm_Table_ProfileAttribute'); $tableProfileAttribute = new Kutu_Core_Orm_Table_ProfileAttribute(); $profileGuid = $rowCatalog->profileGuid; $where = $tableProfileAttribute->getAdapter()->quoteInto('profileGuid=?', $profileGuid); $rowsetProfileAttribute = $tableProfileAttribute->fetchAll($where, 'viewOrder ASC'); $aAttribute = array(); $i = 0; Zend_Loader::loadClass('Kutu_Core_Orm_Table_Attribute'); $tblAttribute = new Kutu_Core_Orm_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->catalogGuid = $catalogGuid; $rowCatalogAttribute = $rowsetCatalogAttribute->findByAttributeGuid('fixedExpired'); //set your year, month, daym hour, minute, second you want to cuntdown to, Change the numbers beetwen " and " 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"; //set what is going to happen than $event = "My birthday"; //don't change anything below unless you know what you are doing $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; //echo 'sisa hari: ' . $cuntdowndays; 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 "<script>alert('Dokumen perjanjian ini akan berakhir masa berlakunya dalam ".round($cuntdowndays)." hari.');</script>"; echo "<br><strong>Dokumen perjanjian ini akan berakhir masa berlakunya dalam " . round($cuntdowndays) . " hari.</strong>"; } } }
public function getFolders($catalogGuid) { Zend_Loader::loadClass('Kutu_Core_Orm_Table_Catalog'); $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowCatalog = $tblCatalog->find($catalogGuid)->current(); $rowsetFolder = $rowCatalog->findManyToManyRowset('Kutu_Core_Orm_Table_Folder', 'Kutu_Core_Orm_Table_CatalogFolder'); return $rowsetFolder; }
static function getCatalogAuthor($guid) { $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowset = $tblCatalog->find($guid)->current(); if ($rowset) { return $rowset->createdBy; } }
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"); } } }*/ }
protected function _postDelete() { //find related docs and delete them $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem(); $rowsetRelatedDocs = $tblRelatedItem->fetchAll("relatedGuid='{$this->guid}' AND relateAs='RELATED_FILE'"); if (count($rowsetRelatedDocs)) { foreach ($rowsetRelatedDocs as $rowRelatedDoc) { $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowCatalog = $tblCatalog->find($rowRelatedDoc->itemGuid)->current(); $rowCatalog->delete(); } } if ($this->profileGuid == 'kutu_doc') { //get parentGuid $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem(); $rowsetRelatedItem = $tblRelatedItem->fetchAll("itemGuid='{$this->guid}' AND relateAs='RELATED_FILE'"); if (count($rowsetRelatedItem)) { foreach ($rowsetRelatedItem as $rowRelatedItem) { //must delete the physical files $rowsetCatAtt = $this->findDependentRowsetCatalogAttribute(); $systemname = $rowsetCatAtt->findByAttributeGuid('docSystemName')->value; $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)) { //delete file unlink($sDir1); } else { if (file_exists($sDir2)) { //delete file unlink($sDir2); } } } } } //delete from table CatalogAttribute $tblCatalogAttribute = new Kutu_Core_Orm_Table_CatalogAttribute(); $tblCatalogAttribute->delete("catalogGuid='{$this->guid}'"); //delete catalogGuid from table CatalogFolder $tblCatalogFolder = new Kutu_Core_Orm_Table_CatalogFolder(); $tblCatalogFolder->delete("catalogGuid='{$this->guid}'"); //delete guid from table AssetSetting $tblAssetSetting = new Kutu_Core_Orm_Table_AssetSetting(); $tblAssetSetting->delete("guid='{$this->guid}'"); //delete from table relatedItem $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem(); $tblRelatedItem->delete("itemGuid='{$this->guid}'"); $tblRelatedItem->delete("relatedGuid='{$this->guid}'"); //delete physical catalog folder from uploads/files/[catalogGuid] $sDir = KUTU_ROOT_DIR . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $this->guid; try { if (is_dir($sDir)) { rmdir($sDir); } } catch (Exception $e) { } //delete from index try { $indexingEngine = Kutu_Search::manager(); $indexingEngine->deleteCatalogFromIndex($this->guid); } catch (Exception $e) { } //delete from ACL }
public function indexAction() { $r = $this->getRequest(); $folderLegalDb = "lgs4a0ee4ab533b4"; switch ($r->getParam('m')) { case 'list': if ($r->getParam('f')) { $folderGuid = $r->getParam('f'); $tblFolder = new Kutu_Core_Orm_Table_Folder(); $row = $tblFolder->find($folderGuid)->current(); if (strpos($row->path, $folderLegalDb) !== false) { //$this->_forward('list', "pages", 'site', $r->getParams); $this->_redirect(KUTU_ROOT_URL . '/dms/' . $folderGuid); } } $this->_forward('list', "pages", 'site2', $r->getParams()); break; case 'home': $this->_forward('home', "pages", 'site2', $r->getParams()); break; default: $guid = $r->getParam('g'); if (!empty($guid)) { $tblCatalog = new Kutu_Core_Orm_Table_Catalog(); $rowset = $tblCatalog->find($guid); if (count($rowset)) { $row = $rowset->current(); switch ($row->profileGuid) { case 'kutu_peraturan': case 'kutu_putusan': $this->_redirect(KUTU_ROOT_URL . '/dms/catalog/' . $guid); return true; } $rowsetFolder = $row->findManyToManyRowset('Kutu_Core_Orm_Table_Folder', 'Kutu_Core_Orm_Table_CatalogFolder'); if (count($rowsetFolder) > 0) { foreach ($rowsetFolder as $rowFolder) { //$rowFolder = $rowsetFolder->current(); $folderGuid = $rowFolder->guid; if (strpos($rowFolder->path, $folderLegalDb) !== false) { //$this->_forward('list', "pages", 'site', $r->getParams); //$this->_redirect(KUTU_ROOT_URL.'/dms/catalog/'.$guid.'/node/'.$folderGuid); } else { $this->_forward('details', "pages", 'site2', $r->getParams()); return true; } } $this->_redirect(KUTU_ROOT_URL . '/dms/catalog/' . $guid . '/node/' . $folderGuid); } else { $this->_redirect(KUTU_ROOT_URL . '/dms/catalog/' . $guid . '/node/' . $folderGuid); } } else { $tblFolder = new Kutu_Core_Orm_Table_Folder(); $rowset = $tblFolder->find($guid); if (count($rowset)) { $row = $rowset->current(); if (strpos($row->path, $folderLegalDb) !== false) { //$this->_forward('list', "pages", 'site', $r->getParams); $this->_redirect(KUTU_ROOT_URL . '/dms/' . $guid); } else { $aData = $r->getParams(); $aData['f'] = $guid; $this->_forward('list', "pages", 'site2', $aData); break; } } } } } }