/** * Delete all information about file * * @param Zend_Db_Table_Row $unit * @param Zend_Db_Table_Row $file */ function deleteFile($unit, $file) { $mediaManager = new RM_Media_Unit_Manager($unit); $mediaManager->deleteImageFiles($file->filename); $model = new RM_UnitMediaFileTypes(); $unitTypeFiles = $model->getByFile($file); foreach ($unitTypeFiles as $typeFile) { $typeFile->delete(); } return $file->delete(); }
/** * This method is for classification media file */ function classificationmediaJsonAction() { $unitID = $this->_getParam('unit_id', null); if ($unitID == null) { return array('data' => array('success' => false, 'error' => $this->_translate->_('Admin.Unit.Media', 'UnitIDNotSpecified'))); } $unitModel = new RM_Units(); $unit = $unitModel->find($unitID)->current(); if ($unit == null) { return array('data' => array('success' => false, 'error' => $this->_translate->_('Admin.Unit.Media', 'WrongUnitID'))); } $info = $this->_getParam('info', null); if ($info == null) { return array('data' => array('success' => false, 'error' => $this->_translate->_('Admin.Unit.Media', 'TypeInformationNotSpecified'))); } $fileTypeModel = new RM_UnitMediaFileTypes(); $infoObject = Zend_Json::decode($info); $result = $fileTypeModel->changeOrder($unit, $infoObject); if ($result) { return array('data' => array('success' => true)); } else { return array('data' => array('success' => false)); } }
protected function _copyMediaData(RM_Unit_Row $original, RM_Unit_Row $copy) { $unitMediaFilesModel = new RM_UnitMediaFiles(); $unitMediaFiles = $unitMediaFilesModel->get($original); $unitMediaFileTypesModel = new RM_UnitMediaFileTypes(); foreach ($unitMediaFiles as $unitMediaFile) { $copyMediaFileData = $unitMediaFile->toArray(); unset($copyMediaFileData['id']); $copyMediaFileData['unit_id'] = $copy->getId(); $copyMediaFile = $unitMediaFilesModel->createRow($copyMediaFileData); $copyMediaFileID = $copyMediaFile->save(); $unitMediaFileTypes = $unitMediaFileTypesModel->getByFile($unitMediaFile); foreach ($unitMediaFileTypes as $unitMediaFileType) { $copyUnitMediaFileTypeData = $unitMediaFileType->toArray(); unset($copyUnitMediaFileTypeData['id']); $copyUnitMediaFileTypeData['file_id'] = $copyMediaFileID; $copyUnitMediaFileType = $unitMediaFileTypesModel->createRow($copyUnitMediaFileTypeData); $copyUnitMediaFileType->save(); } } return true; }