public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/functions.php
/**
 * Handle a modified module.
 *
 * Used to ensure that all modules have a valid module number.
 *
 * @since 1.0.0
 *
 * @param integer $courseID The ID of the course that looks after the module that's been created or edited.
 */
Handle a modified module.
Used to ensure that all modules have a valid module number.



@param integer $courseID The ID of the course that looks after the module that's been created or edited.
Handle a modified module . Used to ensure that all modules have a valid module number . @param integer $courseID The ID of the course that looks after the module that ' s been created or edited .
function WPCW_actions_modules_modulesModified( $courseID ) {
	global $wpdb, $wpcwdb;
	$wpdb->show_errors();
	$modules = $wpdb->get_results( $wpdb->prepare( "
		SELECT *
		FROM $wpcwdb->modules
		WHERE parent_course_id = %d
		ORDER BY module_order ASC
	", $courseID ) );
	if ( ! $modules ) {
		return;
	}
	$moduleOrderCount = 0;
	foreach ( $modules as $module ) {
		$moduleOrderCount ++;
		$SQL = $wpdb->prepare( "
			UPDATE $wpcwdb->modules
			   SET module_order = %d, module_number = %d
			WHERE module_id = %d
		", $moduleOrderCount, $moduleOrderCount, $module->module_id );
		$wpdb->query( $SQL );
	}
}
function WPCW_actions_modules_modulesModified ( $ courseID ) { global $ wpdb , $ wpcwdb ; $ wpdb -> show_errors ( ) ; $ modules = $ wpdb -> get_results ( $ wpdb -> prepare ( " 
		SELECT *
		FROM  $ wpcwdb -> modules 
		WHERE parent_course_id = %d
		ORDER BY module_order ASC
	 " , $ courseID ) ) ; if ( ! $ modules ) { return ; } $ moduleOrderCount = 0 ; foreach ( $ modules as $ module ) { $ moduleOrderCount ++ ; $ SQL = $ wpdb -> prepare ( " 
			UPDATE  $ wpcwdb -> modules 
			   SET module_order = %d, module_number = %d
			WHERE module_id = %d
		 " , $ moduleOrderCount , $ moduleOrderCount , $ module -> module_id ) ; $ wpdb -> query ( $ SQL ) ; } }
Handle a modified module.
Handle a modified module .
// Nothing to do // Update module list with new ordering