public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/functions.php
/**
 * Function to get a list of the courses for use in a select list.
 *
 * @since 1.0.0
 *
 * @param string  $addBlank If set, use this string as the blank option at the top of the list.
 * @param integer $excludeCourseId If set, it will exclude the course id from the list.
 *
 * @return array The list of courses as an array of (courseID => Course name).
 */
Function to get a list of the courses for use in a select list.

@param string  $addBlank If set, use this string as the blank option at the top of the list.
@param integer $excludeCourseId If set, it will exclude the course id from the list.

@return array The list of courses as an array of (courseID => Course name).
Function to get a list of the courses for use in a select list . @param string $addBlank If set use this string as the blank option at the top of the list . @param integer $excludeCourseId If set it will exclude the course id from the list . @return array The list of courses as an array of ( courseID = > Course name ) .
function WPCW_courses_getCourseList( $addBlank = false, $excludeCourseId = false ) {
	$list = array();
	if ( $addBlank ) {
		$list[] = $addBlank;
	}
	global $wpcwdb, $wpdb;
	$current_user_id = get_current_user_id();
	$wpdb->show_errors();
	$SQL_WHERE = false;
	if ( ! user_can( $current_user_id, 'manage_wpcw_settings' ) ) {
		$SQL_WHERE = $wpdb->prepare( 'WHERE course_author = %d', $current_user_id );
	}
	$SQL = "SELECT *
			FROM $wpcwdb->courses
			$SQL_WHERE
			ORDER BY course_title
			";
	$items = $wpdb->get_results( $SQL );
	if ( count( $items ) < 1 ) {
		return $list;
	}
	foreach ( $items as $item ) {
		$list[ $item->course_id ] = $item->course_title;
	}
	if ( $excludeCourseId !== false ) {
		unset( $list[ $excludeCourseId ] );
	}
	return $list;
}
function WPCW_courses_getCourseList ( $ addBlank = false , $ excludeCourseId = false ) { $ list = array ( ) ; if ( $ addBlank ) { $ list [ ] = $ addBlank ; } global $ wpcwdb , $ wpdb ; $ current_user_id = get_current_user_id ( ) ; $ wpdb -> show_errors ( ) ; $ SQL_WHERE = false ; if ( ! user_can ( $ current_user_id , 'manage_wpcw_settings' ) ) { $ SQL_WHERE = $ wpdb -> prepare ( 'WHERE course_author = %d' , $ current_user_id ) ; } $ SQL = " SELECT *
			FROM  $ wpcwdb -> courses $ SQL_WHERE 
			ORDER BY course_title
			 " ; $ items = $ wpdb -> get_results ( $ SQL ) ; if ( count ( $ items ) < 1 ) { return $ list ; } foreach ( $ items as $ item ) { $ list [ $ item -> course_id ] = $ item -> course_title ; } if ( $ excludeCourseId !== false ) { unset ( $ list [ $ excludeCourseId ] ) ; } return $ list ; }
Function to get a list of the courses for use in a select list.
Function to get a list of the courses for use in a select list .