/** * This function save the last content_id accessed by current user on a course into db and set $_SESSION['s_cid'] * @access: public * @param: $content_id * @return: save $content_id, the last visited one of the current user, into db and session */ public static function saveLastCid($content_id) { global $_course_id; if (!$content_id || !isset($_SESSION['user_id'])) { return; } include_once TR_INCLUDE_PATH . 'classes/DAO/UserCoursesDAO.class.php'; $userCoursesDAO = new UserCoursesDAO(); if ($userCoursesDAO->isExist($_SESSION['user_id'], $_course_id)) { $userCoursesDAO->UpdateLastCid($_SESSION['user_id'], $_course_id, $content_id); $_SESSION['s_cid'] = $content_id; } }
function deleteContent($content_id) { global $_current_user, $_course_id; if (!isset($_current_user) || !$_current_user->isAuthor($this->course_id)) { 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)) ) { if (!($row = $this->getContentPage($content_id))) { 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) { if ($info['content_id'] > 0) { $this->deleteContentRecursive($info['content_id']); } } } $this->contentDAO->Delete($content_id); /* 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={$_course_id}"; $this->contentDAO->execute($sql); // unset last-visited content id require_once TR_INCLUDE_PATH . 'classes/DAO/UserCoursesDAO.class.php'; $userCoursesDAO = new UserCoursesDAO(); $userCoursesDAO->UpdateLastCid($_SESSION['user_id'], $_course_id, 0); unset($_SESSION['s_cid']); unset($_SESSION['from_cid']); /* 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(TR_INCLUDE_PATH.'classes/A4a/A4a.class.php'); // $a4a = new A4a($content_id); // $a4a->deleteA4a(); /* 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; }