/** * Get all secondary files * @return array of secondary files that is being used in this->content. */ function getAllSecondaryFiles() { global $db; $secondary_files = array(); include_once TR_INCLUDE_PATH . 'classes/DAO/SecondaryResourcesDAO.class.php'; $secondaryResourcesDAO = new SecondaryResourcesDAO(); $rows = $secondaryResourcesDAO->getByContent($this->cid); // $sql = "SELECT DISTINCT secondary_resource FROM ".TABLE_PREFIX."primary_resources a LEFT JOIN ".TABLE_PREFIX."secondary_resources s // ON a.primary_resource_id = s.primary_resource_id WHERE content_id=".$this->cid; // $result = mysql_query ($sql); if (is_array($rows)) { foreach ($rows as $row) { if (!empty($row['secondary_resource'])) { $secondary_files[] = $row['secondary_resource']; } } } return $secondary_files; }
} else { if (!@unlink($current_path . $pathext . $filename)) { $msg->addError('FILE_NOT_DELETED'); $result = false; break; } } } if ($result) { // delete according definition of primary resources and alternatives for adapted content $filename = '../' . $pathext . $filename; // 1. delete secondary resources types $secondaryResourcesTypesDAO = new SecondaryResourcesTypesDAO(); $secondaryResourcesTypesDAO->DeleteByResourceName($filename); // 2. delete secondary resources $secondaryResourcesDAO = new SecondaryResourcesDAO(); $secondaryResourcesDAO->DeleteByResourceName($filename); // 3. delete primary resources types $primaryResourcesTypesDAO = new PrimaryResourcesTypesDAO(); $primaryResourcesTypesDAO->DeleteByResourceName($filename); // 4. delete primary resources $primaryResourcesDAO = new PrimaryResourcesDAO(); $primaryResourcesDAO->DeleteByResourceName($filename); $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY'); } } /* delete directory */ if (isset($_POST['listofdirs'])) { $checkbox = explode(',', $_POST['listofdirs']); $count = count($checkbox); $result = true;
function setSecondaryResource($primary_resource_id, $file_name, $lang) { include_once TR_INCLUDE_PATH . 'classes/DAO/SecondaryResourcesDAO.class.php'; $secondaryResourcesDAO = new SecondaryResourcesDAO(); if ($secondaryResourcesDAO->Create($primary_resource_id, $file_name, $lang)) { return mysql_insert_id(); } return false; }