public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/pages/page-course-dashboard.php
/**
 * Delete a module and disassociating of the units that it contains.
 *
 * @since 1.0.0
 *
 * @param object $moduleDetails The details of the module to delete.
 */
Delete a module and disassociating of the units that it contains.

@param object $moduleDetails The details of the module to delete.
Delete a module and disassociating of the units that it contains . @param object $moduleDetails The details of the module to delete .
function WPCW_modules_deleteModule( $moduleDetails ) {
	if ( ! $moduleDetails ) {
		return;
	}
	global $wpdb, $wpcwdb;
	$wpdb->show_errors();
	$unitList = WPCW_units_getListOfUnits( $moduleDetails->module_id );
	if ( $unitList ) {
		$SQL = $wpdb->prepare( "
			UPDATE $wpcwdb->units_meta
			   SET unit_order = 0, parent_module_id = 0, parent_course_id = 0, unit_number = 0
			WHERE parent_module_id = %d
		", $moduleDetails->module_id );
		foreach ( $unitList as $unitID => $unitObj ) {
			$wpdb->query( $SQL );
			update_post_meta( $unitID, 'wpcw_associated_module', 0 );
			$SQL = $wpdb->prepare( "DELETE FROM $wpcwdb->user_progress WHERE unit_id = %d", $unitID );
			$wpdb->query( $SQL );
			$SQL = $wpdb->prepare( "UPDATE $wpcwdb->quiz SET parent_unit_id = 0, parent_course_id = 0 WHERE parent_unit_id = %d", $unitID );
			$wpdb->query( $SQL );
		}
	}
	$wpdb->query( $SQL = $wpdb->prepare( "
				DELETE FROM $wpcwdb->modules
				WHERE module_id = %d
			", $moduleDetails->module_id ) );
	do_action( 'wpcw_modules_modified', $moduleDetails->parent_course_id );
	$courseDetails = WPCW_courses_getCourseDetails( $moduleDetails->parent_course_id );
	if ( $courseDetails ) {
		do_action( 'wpcw_course_details_updated', $courseDetails );
	}
	do_action( 'wpcw_module_deleted', $moduleDetails );
	return true;
}
function WPCW_modules_deleteModule ( $ moduleDetails ) { if ( ! $ moduleDetails ) { return ; } global $ wpdb , $ wpcwdb ; $ wpdb -> show_errors ( ) ; $ unitList = WPCW_units_getListOfUnits ( $ moduleDetails -> module_id ) ; if ( $ unitList ) { $ SQL = $ wpdb -> prepare ( " 
			UPDATE  $ wpcwdb -> units_meta 
			   SET unit_order = 0, parent_module_id = 0, parent_course_id = 0, unit_number = 0
			WHERE parent_module_id = %d
		 " , $ moduleDetails -> module_id ) ; foreach ( $ unitList as $ unitID => $ unitObj ) { $ wpdb -> query ( $ SQL ) ; update_post_meta ( $ unitID , 'wpcw_associated_module' , 0 ) ; $ SQL = $ wpdb -> prepare ( " DELETE FROM  $ wpcwdb -> user_progress  WHERE unit_id = %d " , $ unitID ) ; $ wpdb -> query ( $ SQL ) ; $ SQL = $ wpdb -> prepare ( " UPDATE  $ wpcwdb -> quiz  SET parent_unit_id = 0, parent_course_id = 0 WHERE parent_unit_id = %d " , $ unitID ) ; $ wpdb -> query ( $ SQL ) ; } } $ wpdb -> query ( $ SQL = $ wpdb -> prepare ( " 
				DELETE FROM  $ wpcwdb -> modules 
				WHERE module_id = %d
			 " , $ moduleDetails -> module_id ) ) ; do_action ( 'wpcw_modules_modified' , $ moduleDetails -> parent_course_id ) ; $ courseDetails = WPCW_courses_getCourseDetails ( $ moduleDetails -> parent_course_id ) ; if ( $ courseDetails ) { do_action ( 'wpcw_course_details_updated' , $ courseDetails ) ; } do_action ( 'wpcw_module_deleted' , $ moduleDetails ) ; return true ; }
Delete a module and disassociating of the units that it contains.
Delete a module and disassociating of the units that it contains .
// Remove association with all units for this module // Unassociate units from this module // Update database with new association and ordering. // Update post meta to remove associated module detail // Remove progress for this unit, since unit is now unassociated. // Quiz - Unconnect it from the quiz that it's associated with. // Perform module deletion here. // Modules have changed for this course, update numbering // Course has been updated, update the progress details // Trigger event that module has been deleted