function JLMS_deleteDropBox($course_id, $option) { global $my, $JLMS_DB, $Itemid; $usertype = JLMS_GetUserType($my->id, $course_id); if ($course_id && $usertype == 1) { $cid = mosGetParam($_REQUEST, 'cid', array(0)); if (is_array($cid) && count($cid) > 0) { $cids = implode(',', $cid); $query = "SELECT distinct file_id FROM #__lms_dropbox WHERE id IN ({$cids}) AND course_id = '" . $course_id . "'"; $JLMS_DB->SetQuery($query); $files = $JLMS_DB->LoadResultArray(); if (count($files)) { $query = "DELETE FROM #__lms_dropbox WHERE id IN ({$cids}) AND course_id = '" . $course_id . "'"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); $files_del = JLMS_checkFiles($course_id, $files); if (count($files_del)) { JLMS_deleteFiles($files_del); } } } } elseif ($course_id && $usertype == 2) { $cid = mosGetParam($_REQUEST, 'cid', array(0)); if (is_array($cid) && count($cid) > 0) { $cids = implode(',', $cid); $query = "SELECT distinct file_id FROM #__lms_dropbox WHERE id IN ({$cids}) AND course_id = '" . $course_id . "' AND owner_id = '" . $my->id . "'"; $JLMS_DB->SetQuery($query); $files = $JLMS_DB->LoadResultArray(); if (count($files)) { $query = "DELETE FROM #__lms_dropbox WHERE id IN ({$cids}) AND course_id = '" . $course_id . "' AND owner_id = '" . $my->id . "'"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); $files_del = JLMS_checkFiles($course_id, $files); if (count($files_del)) { JLMS_deleteFiles($files_del); } } } } JLMSRedirect(sefRelToAbs("index.php?option={$option}&Itemid={$Itemid}&task=dropbox&id={$course_id}")); }
function JLMS_DelOp_deleteCourseStudents($course_id, $group_id, &$del_ids) { global $JLMS_DB; $del_ids_str = implode(',', $del_ids); //modified by TPETb //canceled group_id check $query = "DELETE FROM #__lms_users_in_groups WHERE course_id = '" . $course_id . "' AND user_id IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); $query = "DELETE FROM #__lms_certificate_users WHERE course_id = '" . $course_id . "' AND user_id IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); $query = "DELETE FROM #__lms_chat_history WHERE course_id = '" . $course_id . "' AND user_id IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); $query = "DELETE FROM #__lms_chat_users WHERE course_id = '" . $course_id . "' AND user_id IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); $query = "SELECT distinct file_id FROM #__lms_dropbox WHERE course_id = '" . $course_id . "' AND ( owner_id IN ({$del_ids_str}) OR recv_id IN ({$del_ids_str}) )"; $JLMS_DB->SetQuery($query); $del_files = $JLMS_DB->LoadResultArray(); $query = "DELETE FROM #__lms_dropbox WHERE course_id = '" . $course_id . "' AND ( owner_id IN ({$del_ids_str}) OR recv_id IN ({$del_ids_str}) )"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); $files_del = JLMS_checkFiles($course_id, $del_files); if (count($files_del)) { JLMS_deleteFiles($files_del); } $query = "DELETE FROM #__lms_gradebook WHERE course_id = '" . $course_id . "' AND user_id IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); $query = "DELETE FROM #__lms_homework_results WHERE course_id = '" . $course_id . "' AND user_id IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); $query = "SELECT id FROM #__lms_learn_path_results WHERE course_id = '" . $course_id . "' AND user_id IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $lp_res_ids = $JLMS_DB->LoadResultArray(); $query = "DELETE FROM #__lms_learn_path_grades WHERE course_id = '" . $course_id . "' AND user_id IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); if (count($lp_res_ids)) { $lpr_str = implode(',', $lp_res_ids); $query = "DELETE FROM #__lms_learn_path_results WHERE id IN ({$lpr_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); $query = "DELETE FROM #__lms_learn_path_step_results WHERE result_id IN ({$lpr_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); // 18.08.2007 (deleting of lp quiz results) $query = "DELETE FROM #__lms_learn_path_step_quiz_results WHERE result_id IN ({$lpr_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); } //delete QUIZ results $query = "DELETE FROM #__lms_quiz_results WHERE course_id = '" . $course_id . "' AND user_id IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); $query = "SELECT c_id FROM #__lms_quiz_t_quiz WHERE course_id = '" . $course_id . "'"; $JLMS_DB->SetQuery($query); $q_ids = $JLMS_DB->LoadResultArray(); if (count($q_ids)) { $q_str = implode(',', $q_ids); $query = "SELECT c_id FROM #__lms_quiz_r_student_quiz WHERE c_quiz_id IN ({$q_str}) AND c_student_id IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $rsq_ids = $JLMS_DB->LoadResultArray(); if (count($rsq_ids)) { $rsq_str = implode(',', $rsq_ids); $query = "SELECT c_id FROM #__lms_quiz_r_student_question WHERE c_stu_quiz_id IN ( {$rsq_str} )"; $JLMS_DB->SetQuery($query); $rsqq_ids = $JLMS_DB->LoadResultArray(); if (count($rsqq_ids)) { $stu_cids = implode(',', $rsqq_ids); $query = "DELETE FROM #__lms_quiz_r_student_blank WHERE c_sq_id IN ( {$stu_cids} )"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); $query = "DELETE FROM #__lms_quiz_r_student_choice WHERE c_sq_id IN ( {$stu_cids} )"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); $query = "DELETE FROM #__lms_quiz_r_student_hotspot WHERE c_sq_id IN ( {$stu_cids} )"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); $query = "DELETE FROM #__lms_quiz_r_student_matching WHERE c_sq_id IN ( {$stu_cids} )"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); $query = "DELETE FROM #__lms_quiz_r_student_survey WHERE c_sq_id IN ( {$stu_cids} )"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); $query = "DELETE FROM #__lms_quiz_r_student_question WHERE c_id IN ( {$stu_cids} )"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); } $query = "DELETE FROM #__lms_quiz_r_student_quiz WHERE c_id IN ( {$rsq_str} )"; $JLMS_DB->setQuery($query); $JLMS_DB->query(); } } // end of QUIZ //delete SCORMs tracking $query = "SELECT id FROM #__lms_scorm_packages WHERE course_id = '" . $course_id . "'"; $JLMS_DB->SetQuery($query); $sc_ids = $JLMS_DB->LoadResultArray(); //old scorms (before JoomlaLMS 1.0.5) if (count($sc_ids)) { $sc_str = implode(',', $sc_ids); $query = "DELETE FROM #__lms_scorm_sco WHERE content_id IN ({$sc_str}) AND user_id IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); } //new scorms $query = "SELECT id FROM #__lms_n_scorm WHERE course_id = '" . $course_id . "'"; $JLMS_DB->SetQuery($query); $scn_ids = $JLMS_DB->LoadResultArray(); if (count($scn_ids)) { $scn_str = implode(',', $scn_ids); $query = "DELETE FROM #__lms_n_scorm_scoes_track WHERE scormid IN ({$scn_str}) AND userid IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); } //end of SCORMs part //delete TRACKING records $query = "DELETE FROM #__lms_track_chat WHERE course_id = '" . $course_id . "' AND user_id IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); $query = "DELETE FROM #__lms_track_hits WHERE course_id = '" . $course_id . "' AND user_id IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); $query = "DELETE FROM #__lms_track_learnpath_stats WHERE course_id = '" . $course_id . "' AND user_id IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); $query = "SELECT id FROM #__lms_documents WHERE course_id = '" . $course_id . "'"; $JLMS_DB->SetQuery($query); $doc_ids = $JLMS_DB->LoadResultArray(); if (count($doc_ids)) { $d_str = implode(',', $doc_ids); $query = "DELETE FROM #__lms_track_downloads WHERE doc_id IN ({$d_str}) AND user_id IN ({$del_ids_str})"; $JLMS_DB->SetQuery($query); $JLMS_DB->query(); } }