public function copyFolderContent($currentFolderGuid, $newCatalogGuid) { $tblCatalogFolder = new Kutu_Core_Orm_Table_CatalogFolder(); $rowset = $tblCatalogFolder->fetchAll("folderGuid = '{$currentFolderGuid}'"); if (count($rowset) > 0) { foreach ($rowset as $row) { $newContent = $tblCatalogFolder->createRow(); $newContent->folderGuid = $newCatalogGuid; $newContent->catalogGuid = $row->catalogGuid; $newContent->save(); } } }
public function moveToFolder($sourceFolder, $targetFolder) { $tblCatalogFolder = new Kutu_Core_Orm_Table_CatalogFolder(); $this->copyToFolder($targetFolder); $tblCatalogFolder->delete("catalogGuid='{$this->guid}' AND folderGuid='{$sourceFolder}'"); }
function viewFolderNavigationDetailAction() { $browserUrl = KUTU_ROOT_URL . '/app/hold/browser/view/node'; $browserUrlP = KUTU_ROOT_URL . '/app/hold/browser/view/nprt'; $browserUrlT = KUTU_ROOT_URL . '/app/hold/browser/view/npts'; $folderGuid = $this->_getParam('node') ? $this->_getParam('node') : 'root'; // $wview = $this->_request->getParams('nprt');print_r($wview['node']); $tblFolder = new Kutu_Core_Orm_Table_Folder(); $aPath = array(); if ($folderGuid == 'root') { $aPath[0]['title'] = 'Root'; $aPath[0]['url'] = $browserUrl; } else { $rowFolder = $tblFolder->find($folderGuid)->current(); if (!isset($rowFolder)) { $tblCatalogFolder = new Kutu_Core_Orm_Table_CatalogFolder(); $rowsetCatalogFolder = $tblCatalogFolder->fetchRow("catalogGuid='{$folderGuid}'"); $rowFolder = $tblFolder->find($rowsetCatalogFolder->folderGuid)->current(); } if (!empty($rowFolder->path)) { $aFolderGuid = explode("/", $rowFolder->path); $sPath = 'root >'; $aPath[0]['title'] = 'Root'; $aPath[0]['url'] = $browserUrl; $i = 1; if (count($aFolderGuid)) { $sPath1 = ''; foreach ($aFolderGuid as $guid) { if (!empty($guid)) { $rowFolder1 = $tblFolder->find($guid)->current(); $sPath1 .= $rowFolder1->title . ' > '; $aPath[$i]['title'] = $rowFolder1->title; $rowFolder2 = $tblFolder->find($rowFolder1->guid)->current(); if ($rowFolder2->parentGuid == 'lt49714f3105801' || $rowFolder->parentGuid == $folderGuid) { if (in_array($rowFolder2->guid, array('658', '761', '971'))) { $aPath[$i]['url'] = $browserUrlP . '/' . $rowFolder1->guid; } elseif (in_array($rowFolder2->guid, array('137', '711'))) { $aPath[$i]['url'] = $browserUrlT . '/' . $rowFolder1->guid; } else { $aPath[$i]['url'] = $browserUrl . '/' . $rowFolder1->guid; } } else { if (in_array($rowFolder2->parentGuid, array('658', '761', '971'))) { $aPath[$i]['url'] = $browserUrlP . '/' . $rowFolder1->guid; } elseif (in_array($rowFolder2->parentGuid, array('137', '711'))) { $aPath[$i]['url'] = $browserUrlT . '/' . $rowFolder1->guid; } else { $aPath[$i]['url'] = $browserUrl . '/' . $rowFolder1->guid; } } $i++; } } $aPath[$i]['title'] = $rowFolder->title; // $aPath[$i]['url'] = $browserUrl.'/'.$rowFolder->guid; if ($aFolderGuid[0] == 'lt49714f3105801' || $aFolderGuid[0] == $folderGuid) { if (in_array($folderGuid, array('658', '761', '971'))) { $aPath[$i]['url'] = $browserUrlP . '/' . $rowFolder->guid; } elseif (in_array($folderGuid, array('137', '711'))) { $aPath[$i]['url'] = $browserUrlT . '/' . $rowFolder->guid; } else { $aPath[$i]['url'] = $browserUrl . '/' . $rowFolder->guid; } } else { if (in_array($aFolderGuid[0], array('658', '761', '971'))) { $aPath[$i]['url'] = $browserUrlP . '/' . $rowFolder->guid; } elseif (in_array($aFolderGuid[0], array('137', '711'))) { $aPath[$i]['url'] = $browserUrlT . '/' . $rowFolder->guid; } else { $aPath[$i]['url'] = $browserUrl . '/' . $rowFolder->guid; } } //print_r($aFolderGuid[0]); } } else { $aPath[0]['title'] = 'Root'; $aPath[0]['url'] = $browserUrl; $aPath[1]['title'] = $rowFolder->title; $aPath[1]['url'] = $browserUrl . '/' . $rowFolder->guid; } } $this->view->aPath = $aPath; }
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 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 removeFromFolder($catalogGuid, $folderGuid) { $tblCatalogFolder = new Kutu_Core_Orm_Table_CatalogFolder(); $rowset = $tblCatalogFolder->fetchAll("catalogGuid='{$catalogGuid}'"); if (count($rowset) > 1) { try { $tblCatalogFolder->delete("catalogGuid='{$catalogGuid}' AND folderGuid='{$folderGuid}'"); } catch (Exception $e) { throw new Zend_Exception($e->getMessage()); } } else { throw new Zend_Exception("Can not remove from the only FOLDER."); } }
public function getsearchAction() { $this->_helper->layout()->disableLayout(); $r = $this->getRequest(); $query = $r->getParam('query') ? $r->getParam('query') : ''; $start = $r->getParam('start') ? $r->getParam('start') : 0; $limit = $r->getParam('limit') ? $r->getParam('limit') : 20; $orderBy = $r->getParam('orderBy') ? $r->getParam('sortBy') : 'regulationOrder'; $sortOrder = $r->getParam('sortOrder') ? $r->getParam('sortOrder') : ' asc'; $a = array(); $a['query'] = $query; $indexingEngine = Kutu_Search::manager(); $hits = $indexingEngine->find($query, $start, $limit); $num = $hits->response->numFound; $solrNumFound = count($hits->response->docs); $ii = 0; if ($solrNumFound == 0) { $a['catalogs'][0]['guid'] = 'XXX'; $a['catalogs'][0]['title'] = "No Data"; $a['catalogs'][0]['subTitle'] = ""; $a['catalogs'][0]['createdDate'] = ''; $a['catalogs'][0]['modifiedDate'] = ''; } else { if ($solrNumFound > $limit) { $numRowset = $limit; } else { $numRowset = $solrNumFound; } for ($ii = 0; $ii < $numRowset; $ii++) { $row = $hits->response->docs[$ii]; if (!empty($row)) { if ($row->profile == 'kutu_doc') { $title = 'File : ' . $row->title; $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem(); $rowset = $tblRelatedItem->fetchRow("itemGuid='{$row->id}'"); if ($rowset) { $guid = $rowset->relatedGuid; } else { $guid = $row->id; } } else { $title = $row->title; $guid = $row->id; } $a['catalogs'][$ii]['title'] = $title; $a['catalogs'][$ii]['guid'] = $guid; if (!isset($row->subTitle)) { $a['catalogs'][$ii]['subTitle'] = ''; } else { $a['catalogs'][$ii]['subTitle'] = $row->subTitle; } if ($row->profile == 'kutu_doc') { $tblRelatedItem = new Kutu_Core_Orm_Table_RelatedItem(); $rowsetRelatedItem = $tblRelatedItem->fetchRow("itemGuid='{$row->id}' AND relateAs='RELATED_FILE'"); if ($rowsetRelatedItem) { $parentGuid = $rowsetRelatedItem->relatedGuid; } else { $parentGuid = ''; } } else { $tblCatalogFolder = new Kutu_Core_Orm_Table_CatalogFolder(); $rowsetCatalogFolder = $tblCatalogFolder->fetchRow("catalogGuid='{$row->id}'"); if ($rowsetCatalogFolder) { $parentGuid = $rowsetCatalogFolder->folderGuid; } else { $parentGuid = ''; } } $a['catalogs'][$ii]['folderGuid'] = $parentGuid; $a['catalogs'][$ii]['createdDate'] = $row->createdDate; $a['catalogs'][$ii]['modifiedDate'] = $row->modifiedDate; } } } echo Zend_Json::encode($a); }