Example #1
0
    $msg->addFeedback('EXPORT_CANCELLED');
    header('Location: ../index.php');
    exit;
}
$zipfile = new zipfile();
$zipfile->create_dir('resources/');
/* get all the content */
$content = array();
$paths = array();
$top_content_parent_id = 0;
$handler = new ContentOutputParser();
$parser = new XML_HTMLSax();
$parser->set_object($handler);
$parser->set_element_handler('openHandler', 'closeHandler');
$contentDAO = new ContentDAO();
$rows = $contentDAO->getContentByCourseID($course_id);
//if (authenticate(TR_PRIV_CONTENT, TR_PRIV_RETURN)) {
//	$sql = "SELECT *, UNIX_TIMESTAMP(last_modified) AS u_ts FROM ".TABLE_PREFIX."content WHERE course_id=$course_id ORDER BY content_parent_id, ordering";
//} else {
//	$sql = "SELECT *, UNIX_TIMESTAMP(last_modified) AS u_ts FROM ".TABLE_PREFIX."content WHERE course_id=$course_id ORDER BY content_parent_id, ordering";
//}
//$result = mysql_query($sql, $db);
//$cid = $_REQUEST['cid'];  //takes care of some system which lost the REQUEST[cid]
//while ($row = mysql_fetch_assoc($result)) {
//	if (authenticate(TR_PRIV_CONTENT, TR_PRIV_RETURN) || $contentManager->isReleased($row['content_id']) === TRUE) {
if (is_array($rows)) {
    foreach ($rows as $row) {
        $content[$row['content_parent_id']][] = $row;
        if ($cid == $row['content_id']) {
            $top_content = $row;
            $top_content_parent_id = $row['content_parent_id'];
Example #2
0
 /**
  * Delete course
  * @access  public
  * @param   course ID
  * @return  true, if successful
  *          false and add error into global var $msg, if unsuccessful
  * @author  Cindy Qi Li
  */
 public function Delete($courseID)
 {
     require_once TR_INCLUDE_PATH . 'classes/FileUtility.class.php';
     require_once TR_INCLUDE_PATH . 'classes/DAO/ContentDAO.class.php';
     require_once TR_INCLUDE_PATH . 'classes/DAO/ForumsCoursesDAO.class.php';
     $contentDAO = new ContentDAO();
     $forumsCoursesDAO = new ForumsCoursesDAO();
     unset($_SESSION['s_cid']);
     // delete course content dir
     $content_dir = TR_CONTENT_DIR . $courseID . '/';
     FileUtility::clr_dir($content_dir);
     // delete tests and tests related data
     $sql = "DELETE FROM " . TABLE_PREFIX . "content_tests_assoc\n\t\t         WHERE content_id in (SELECT content_id FROM " . TABLE_PREFIX . "content WHERE course_id = " . $courseID . ")";
     $this->execute($sql);
     $sql = "DELETE FROM " . TABLE_PREFIX . "tests_questions_categories WHERE course_id = " . $courseID;
     $this->execute($sql);
     $sql = "DELETE FROM " . TABLE_PREFIX . "tests_questions_assoc \n\t\t         WHERE test_id in (SELECT test_id FROM " . TABLE_PREFIX . "tests WHERE course_id = " . $courseID . ")";
     $this->execute($sql);
     $sql = "DELETE FROM " . TABLE_PREFIX . "tests_questions WHERE course_id = " . $courseID;
     $this->execute($sql);
     $sql = "DELETE FROM " . TABLE_PREFIX . "tests WHERE course_id = " . $courseID;
     $this->execute($sql);
     // delete forums that are associated with this course
     $forumsCoursesDAO->DeleteByCourseID($courseID);
     // loop thru content to delete using ContentDAO->Delete(), which deletes a4a objects as well
     $content_rows = $contentDAO->getContentByCourseID($courseID);
     if (is_array($content_rows)) {
         foreach ($content_rows as $content) {
             $contentDAO->Delete($content['content_id']);
         }
     }
     $sql = "DELETE FROM " . TABLE_PREFIX . "content WHERE course_id = " . $courseID;
     $this->execute($sql);
     // delete user <-> course association
     $sql = "DELETE FROM " . TABLE_PREFIX . "user_courses WHERE course_id = " . $courseID;
     $this->execute($sql);
     // delete the course
     $sql = "DELETE FROM " . TABLE_PREFIX . "courses WHERE course_id = " . $courseID;
     return $this->execute($sql);
 }