public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/admin/functions.php
/**
 * Creates the column columns of data.
 *
 * @since 1.0.0
 *
 * @param string  $colContent The content of the column.
 * @param string  $column_name The name of the column we're changing.
 * @param integer $user_id The ID of the user we're rendering.
 *
 * @return string The formatted HTML code for the table.
 */
Creates the column columns of data.

@param string  $colContent The content of the column.
@param string  $column_name The name of the column we're changing.
@param integer $user_id The ID of the user we're rendering.

@return string The formatted HTML code for the table.
Creates the column columns of data . @param string $colContent The content of the column . @param string $column_name The name of the column we ' re changing . @param integer $user_id The ID of the user we ' re rendering . @return string The formatted HTML code for the table .
function WPCW_users_addCustomColumnContent( $colContent, $column_name, $user_id ) {
	switch ( $column_name ) {
		case 'wpcw_col_user_details':
			global $wp_roles;
			$userDetails = get_userdata( $user_id );
			$roleName = false;
			if ( ! empty( $userDetails->roles ) ) {
				$roleNameId = $userDetails->roles[0];
				$roleName   = $wp_roles->roles[ $roleNameId ]['name'];
			}
			$colContent = sprintf( '<span class="wpcw_col_cell_name">%s</span>', $userDetails->data->display_name );
			$colContent .= sprintf( '<span class="wpcw_col_cell_email"><a href="mailto:%s" target="_blank">%s</a></span>', $userDetails->data->user_email, $userDetails->data->user_email );
			$colContent .= sprintf( '<span class="wpcw_col_cell_role">%s</span>', ucwords( $roleName ) );
			break;
		case 'wpcw_col_training_courses':
			$courseData = WPCW_users_getUserCourseListAdmin( $user_id );
			if ( $courseData ) {
				foreach ( $courseData as $courseDataItem ) {
					$colContent .= WPCW_stats_convertPercentageToBar( $courseDataItem->course_progress, $courseDataItem->course_title );
				}
			} 
			else {
				$colContent = __( 'No associated courses', 'wp-courseware' );
			}
			break;
		case 'wpcw_col_training_courses_access':
			$colContent = sprintf( '<span><a href="%s&user_id=%d" class="button-primary">%s</a></span>',
				admin_url( 'admin.php?page=WPCW_showPage_UserProgess' ),
				$user_id,
				__( 'View Detailed Progress', 'wp-courseware' )
			);
			$colContent .= sprintf( '<span><a href="%s&user_id=%d" class="button-secondary">%s</a></span>',
				admin_url( 'admin.php?page=WPCW_showPage_UserCourseAccess' ),
				$user_id,
				__( 'Update Course Access Permissions', 'wp-courseware' )
			);
			$courseData   = WPCW_users_getUserCourseListAdmin( $user_id );
			$courseIDList = array();
			if ( ! empty( $courseData ) ) {
				foreach ( $courseData as $courseDetails ) {
					$courseIDList[] = $courseDetails->course_id;
				}
			}
			$colContent .= '<span>';
			$colContent .= '<form method="get">';
			$colContent .= sprintf( '<input type="hidden" name="wpcw_users_single" value="%d" >', $user_id );
			$colContent .= WPCW_courses_getCourseResetDropdown(
				'wpcw_user_progress_reset_point_single',
				$courseIDList,
				__( 'No associated courses.', 'wp-courseware' ),
				__( 'Reset this user to beginning of...', 'wp-courseware' ),
				'',
				'wpcw_user_progress_reset_select wpcw_user_progress_reset_point_single'
			);
			$colContent .= '</form>';
			$colContent .= '</span>';
			break;
	}
	return $colContent;
}
function WPCW_users_addCustomColumnContent ( $ colContent , $ column_name , $ user_id ) { switch ( $ column_name ) { case 'wpcw_col_user_details' : global $ wp_roles ; $ userDetails = get_userdata ( $ user_id ) ; $ roleName = false ; if ( ! empty ( $ userDetails -> roles ) ) { $ roleNameId = $ userDetails -> roles [ 0 ] ; $ roleName = $ wp_roles -> roles [ $ roleNameId ] [ 'name' ] ; } $ colContent = sprintf ( '<span class="wpcw_col_cell_name">%s</span>' , $ userDetails -> data -> display_name ) ; $ colContent .= sprintf ( '<span class="wpcw_col_cell_email"><a href="mailto:%s" target="_blank">%s</a></span>' , $ userDetails -> data -> user_email , $ userDetails -> data -> user_email ) ; $ colContent .= sprintf ( '<span class="wpcw_col_cell_role">%s</span>' , ucwords ( $ roleName ) ) ; break ; case 'wpcw_col_training_courses' : $ courseData = WPCW_users_getUserCourseListAdmin ( $ user_id ) ; if ( $ courseData ) { foreach ( $ courseData as $ courseDataItem ) { $ colContent .= WPCW_stats_convertPercentageToBar ( $ courseDataItem -> course_progress , $ courseDataItem -> course_title ) ; } } else { $ colContent = __ ( 'No associated courses' , 'wp-courseware' ) ; } break ; case 'wpcw_col_training_courses_access' : $ colContent = sprintf ( '<span><a href="%s&user_id=%d" class="button-primary">%s</a></span>' , admin_url ( 'admin.php?page=WPCW_showPage_UserProgess' ) , $ user_id , __ ( 'View Detailed Progress' , 'wp-courseware' ) ) ; $ colContent .= sprintf ( '<span><a href="%s&user_id=%d" class="button-secondary">%s</a></span>' , admin_url ( 'admin.php?page=WPCW_showPage_UserCourseAccess' ) , $ user_id , __ ( 'Update Course Access Permissions' , 'wp-courseware' ) ) ; $ courseData = WPCW_users_getUserCourseListAdmin ( $ user_id ) ; $ courseIDList = array ( ) ; if ( ! empty ( $ courseData ) ) { foreach ( $ courseData as $ courseDetails ) { $ courseIDList [ ] = $ courseDetails -> course_id ; } } $ colContent .= '<span>' ; $ colContent .= '<form method="get">' ; $ colContent .= sprintf ( '<input type="hidden" name="wpcw_users_single" value="%d" >' , $ user_id ) ; $ colContent .= WPCW_courses_getCourseResetDropdown ( 'wpcw_user_progress_reset_point_single' , $ courseIDList , __ ( 'No associated courses.' , 'wp-courseware' ) , __ ( 'Reset this user to beginning of...' , 'wp-courseware' ) , '' , 'wpcw_user_progress_reset_select wpcw_user_progress_reset_point_single' ) ; $ colContent .= '</form>' ; $ colContent .= '</span>' ; break ; } return $ colContent ; }
Creates the column columns of data.
Creates the column columns of data .
// Basically condense user details. // Format nice details of name, email and role to save space. // Ensure role is valid and it exists. // The training course statuses. // Got some associated courses, so render progress. // No courses // Links to change user access for courses. // View the full progress of the user. // Allow the user progress to be reset // Construct a simple list of IDs that we can use for filtering. // Construct the mini form for resetting the user progress. // Using this method of the user ID automaticallyed added the first user to any bulk action, which is clearly a bug. // So the field had to be renamed. //$colContent .= sprintf('<input type="hidden" name="users[]" value="%d" >', $user_id); // The dropdown for this.