function content_delete($course) { require(AT_INCLUDE_PATH.'../mods/_core/imsafa/classes/A4a.class.php'); global $db; // related_content + content: $sql = "SELECT content_id FROM ".TABLE_PREFIX."content WHERE course_id=$course"; $result = mysql_query($sql, $db); while ($row = mysql_fetch_array($result)) { $sql = "DELETE FROM ".TABLE_PREFIX."related_content WHERE content_id=$row[0]"; $result2 = mysql_query($sql, $db); $sql3 = "DELETE FROM ".TABLE_PREFIX."member_track WHERE content_id=$row[0]"; $result3 = mysql_query($sql3, $db); $sql = "DELETE FROM ".TABLE_PREFIX."content_tests_assoc WHERE content_id=$row[0]"; $result4 = mysql_query($sql, $db); // Delete all AccessForAll contents $a4a = new A4a($row[0]); $a4a->deleteA4a(); } $sql = "DELETE FROM ".TABLE_PREFIX."content WHERE course_id=$course"; $result = mysql_query($sql,$db); $sql = "OPTIMIZE TABLE ".TABLE_PREFIX."content"; $result = @mysql_query($sql, $db); }
function content_delete($course) { require AT_INCLUDE_PATH . '../mods/_core/imsafa/classes/A4a.class.php'; // related_content + content: $sql = "SELECT content_id FROM %scontent WHERE course_id=%d"; $rows_content = queryDB($sql, array(TABLE_PREFIX, $course)); foreach ($rows_content as $row) { $sql = "DELETE FROM %srelated_content WHERE content_id=%d"; $result2 = queryDB($sql, array(TABLE_PREFIX, $row['0'])); $sql3 = "DELETE FROM %smember_track WHERE content_id=%d"; $result3 = queryDB($sql3, array(TABLE_PREFIX, $row['0'])); $sql = "DELETE FROM %scontent_tests_assoc WHERE content_id=%d"; $result4 = queryDB($sql, array(TABLE_PREFIX, $row['0'])); // Delete all AccessForAll contents $a4a = new A4a($row[0]); $a4a->deleteA4a(); } $sql = "DELETE FROM %scontent WHERE course_id=%d"; $result = queryDB($sql, array(TABLE_PREFIX, $course)); $sql = "OPTIMIZE TABLE %scontent"; $result = queryDB($sql, array(TABLE_PREFIX)); }
/** * Get information for this content * @return the xml content */ function getAlternative() { $resources = parent::getPrimaryResources(); foreach ($resources as $rid => $prop) { $resources_types = parent::getPrimaryResourcesTypes($rid); if (empty($resources_types)) { //if there are no resource types, then don't use it. continue; } $temp = array(); $secondary_array = array(); foreach ($resources_types as $rtid) { $sec_resources['secondary_resources'] = parent::getSecondaryResources($rid); //determine secondary resource type foreach ($sec_resources['secondary_resources'] as $sec_id => $sec_resource) { $current_sec_file = $sec_resource['resource']; $secondary_array['secondary_resources'][] = $current_sec_file; //add to secondary file array if it's not there if (!isset($this->original_files[$current_sec_file]) || empty($this->original_files[$current_sec_file])) { //TODO merge these values i think $this->original_files[$current_sec_file] = $sec_resource; $this->original_files[$current_sec_file]['resource_type'][$prop['resource']][] = parent::getSecondaryResourcesTypes($sec_id); } else { $this->original_files[$current_sec_file]['resource_type'][$prop['resource']][] = parent::getSecondaryResourcesTypes($sec_id); } //add this primary file ref, and the resources type to the secondary file $this->original_files[$current_sec_file]['primary_resources'][$prop['resource']] = $rtid; // $this->original_files[$current_sec_file]['primary_resources'][$prop['resource']]['language_code'] = $sec_resource['language_code']; } } $res_type['resource_type'] = $rtid; //could be 1+ $temp = array_merge($prop, $res_type, $secondary_array); if (isset($this->original_files[$temp['resource']])) { //use the existing temp array values, but merge in the secondary_array $temp = array_merge($this->original_files[$temp['resource']], $secondary_array); } if (!empty($temp)) { $this->original_files[$temp['resource']] = $temp; } } return $this->original_files; }
function populate_a4a($cid, $content, $formatting) { global $db, $my_files, $content_base_href, $contentManager; // Defining alternatives is only available for content type "html". // But don't clean up the a4a tables at other content types in case the user needs them back at html. if ($formatting != 1) { return; } include_once AT_INCLUDE_PATH . '../mods/_core/imsafa/classes/A4a.class.php'; include_once AT_INCLUDE_PATH . 'classes/XML/XML_HTMLSax/XML_HTMLSax.php'; /* for XML_HTMLSax */ include_once AT_INCLUDE_PATH . 'classes/ContentOutputParser.class.php'; /* for parser */ // initialize content_base_href; used in format_content if (!isset($content_base_href)) { $result = $contentManager->getContentPage($cid); // return if the cid is not found foreach ($result as $content_row) { if (count($content_row) < 1) { return; } else { $content_base_href = $content_row["content_path"] . '/'; } } } $body = format_content($content, $formatting, array()); $handler = new ContentOutputParser(); $parser = new XML_HTMLSax(); $parser->set_object($handler); $parser->set_element_handler('openHandler', 'closeHandler'); $my_files = array(); $parser->parse($body); $my_files = array_unique($my_files); foreach ($my_files as $file) { /* filter out full urls */ $url_parts = @parse_url($file); // file should be relative to content if (substr($file, 0, 1) == '/') { continue; } // The URL of the movie from youtube.com has been converted above in embed_media(). // For example: http://www.youtube.com/watch?v=a0ryB0m0MiM is converted to // http://www.youtube.com/v/a0ryB0m0MiM to make it playable. This creates the problem // that the parsed-out url (http://www.youtube.com/v/a0ryB0m0MiM) does not match with // the URL saved in content table (http://www.youtube.com/watch?v=a0ryB0m0MiM). // The code below is to convert the URL back to original. $file = convert_youtube_playURL_to_watchURL($file); $resources[] = convert_amp($file); // converts & to & } $a4a = new A4a($cid); $db_primary_resources = $a4a->getPrimaryResources(); // clean up the removed resources foreach ($db_primary_resources as $primary_rid => $db_resource) { //if this file from our table is not found in the $resource, then it's not used. if (count($resources) == 0 || !in_array($db_resource['resource'], $resources)) { $a4a->deletePrimaryResource($primary_rid); } } if (count($resources) == 0) { return; } // insert the new resources foreach ($resources as $primary_resource) { if (!$a4a->getPrimaryResourceByName($primary_resource)) { $a4a->setPrimaryResource($cid, $primary_resource, $_SESSION['lang']); } } }
function deleteContent($content_id) { if (!authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) { return false; } /* check if exists */ $sql = "SELECT ordering, content_parent_id FROM " . TABLE_PREFIX . "content WHERE content_id={$content_id} AND course_id={$_SESSION['course_id']}"; $result = mysql_query($sql, $this->db); if (!($row = @mysql_fetch_assoc($result))) { return false; } $ordering = $row['ordering']; $content_parent_id = $row['content_parent_id']; /* check if this content has sub content */ $children = $this->_menu[$content_id]; if (is_array($children) && count($children) > 0) { /* delete its children recursively first*/ foreach ($children as $x => $info) { $this->deleteContentRecursive($info['content_id']); } } /* delete this content page */ $sql = "DELETE FROM " . TABLE_PREFIX . "content WHERE content_id={$content_id} AND course_id={$_SESSION['course_id']}"; $result = mysql_query($sql, $this->db); /* delete this content from member tracking page */ $sql = "DELETE FROM " . TABLE_PREFIX . "member_track WHERE content_id={$content_id} AND course_id={$_SESSION['course_id']}"; $result = mysql_query($sql, $this->db); $sql = "DELETE FROM " . TABLE_PREFIX . "related_content WHERE content_id={$content_id} OR related_content_id={$content_id}"; $result = mysql_query($sql, $this->db); /* delete the content tests association */ $sql = "DELETE FROM " . TABLE_PREFIX . "content_tests_assoc WHERE content_id={$content_id}"; $result = mysql_query($sql, $this->db); /* delete the content forum association */ $sql = "DELETE FROM " . TABLE_PREFIX . "content_forums_assoc WHERE content_id={$content_id}"; $result = mysql_query($sql, $this->db); /* Delete all AccessForAll contents */ require_once AT_INCLUDE_PATH . '../mods/_core/imsafa/classes/A4a.class.php'; $a4a = new A4a($content_id); $a4a->deleteA4a(); /* re-order the rest of the content */ $sql = "UPDATE " . TABLE_PREFIX . "content SET ordering=ordering-1 WHERE ordering>={$ordering} AND content_parent_id={$content_parent_id} AND course_id={$_SESSION['course_id']}"; $result = mysql_query($sql, $this->db); /* end moving block */ /* remove the "resume" to this page, b/c it was deleted */ $sql = "UPDATE " . TABLE_PREFIX . "course_enrollment SET last_cid=0 WHERE course_id={$_SESSION['course_id']} AND last_cid={$content_id}"; $result = mysql_query($sql, $this->db); return true; }
function A4aImport($cid) { parent::A4a($cid); //call its parent }
/** * Delete content * @access public * @param content ID * @return true, if successful * false and add error into global var $msg, if unsuccessful * @author Cindy Qi Li */ public function Delete($contentID) { global $msg; require_once TR_INCLUDE_PATH . 'classes/A4a/A4a.class.php'; $a4a = new A4a($contentID); $a4a->deleteA4a(); // delete the content tests association include_once TR_INCLUDE_PATH . 'classes/DAO/ContentTestsAssocDAO.class.php'; $contentTestsAssocDAO = new ContentTestsAssocDAO(); $contentTestsAssocDAO->DeleteByContentID($contentID); // delete the content forums association include_once TR_INCLUDE_PATH . 'classes/DAO/ContentForumsAssocDAO.class.php'; $contentForumsAssocDAO = new ContentForumsAssocDAO(); $contentForumsAssocDAO->DeleteByContentID($contentID); $sql = "DELETE FROM " . TABLE_PREFIX . "content WHERE content_id = " . $contentID; if ($this->execute($sql)) { // update the courses.modified_date to the current timestamp include_once TR_INCLUDE_PATH . 'classes/DAO/CoursesDAO.class.php'; $coursesDAO = new CoursesDAO(); $coursesDAO->updateModifiedDate($contentID, "content_id"); return true; } else { $msg->addError('DB_NOT_UPDATED'); return false; } }
if (!$found_alternative) { echo ' <div id="' . $pid . '_' . $alternative_type . '">' . "\n"; echo ' <input type="button" value="' . _AT('add') . '" title="' . _AT('new_window') . '" onclick="ATutor.poptastic(\'' . AT_BASE_HREF . 'mods/_core/file_manager/index.php?framed=1' . SEP . 'popup=1' . SEP . 'cp=' . $content_row['content_path'] . SEP . 'cid=' . $content_id . SEP . 'pid=' . $pid . SEP . 'a_type=' . $alternative_type . '\');return false;" />' . "\n"; echo ' </div>' . "\n"; } echo ' </td>' . "\n"; } // Main program if ($_POST['formatting'] != 1) { $msg->addFeedback('NO_A4A_FOR_PLAIN_TEXT'); $msg->printAll(); } else { global $db, $content_row, $stripslashes; populate_a4a($cid, $stripslashes($_POST['body_text']), $_POST['formatting']); include_once AT_INCLUDE_PATH . '../mods/_core/imsafa/classes/A4a.class.php'; $a4a = new A4a($cid); $primary_resources = $a4a->getPrimaryResources(); if (count($primary_resources) == 0) { $msg->addFeedback('NO_RESOURCES'); $msg->printAll(); } else { $is_post_indicator_set = false; // get all resource types $sql = "SELECT * FROM %sresource_types"; $rows_resource_types = queryDB($sql, array(TABLE_PREFIX)); echo '<table class="data" rules="all">' . "\n"; echo ' <thead>' . "\n"; echo ' <tr>' . "\n"; echo ' <th rowspan="2" id="header1">' . _AT('original_resource') . '</th>' . "\n"; echo ' <th rowspan="2" id="header2">' . _AT('resource_type') . '</th>' . "\n"; echo ' <th colspan="4">' . _AT('alternatives') . '</th>' . "\n";