public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/functions.php
/**
 * Updates the database to generate a certificate entry. If a certificate already exists for the user/course ID,
 * then no new entry is created.
 *
 * @since 1.0.0
 *
 * @param integer $userID The ID of the user that the certificate is being generated for.
 * @param integer $courseID The ID of the associated course.
 */
Updates the database to generate a certificate entry. If a certificate already exists for the user/course ID,
then no new entry is created.



@param integer $userID The ID of the user that the certificate is being generated for.
@param integer $courseID The ID of the associated course.
Updates the database to generate a certificate entry . If a certificate already exists for the user / course ID then no new entry is created . @param integer $userID The ID of the user that the certificate is being generated for . @param integer $courseID The ID of the associated course .
function WPCW_certificate_generateCertificateEntry( $userID, $courseID ) {
	if ( ! $userID || ! $courseID ) {
		return;
	}
	global $wpdb, $wpcwdb;
	$wpdb->show_errors();
	if ( $certificateDetails = doesRecordExistAlready( $wpcwdb->certificates, array( 'cert_user_id', 'cert_course_id' ), array( $userID, $courseID ) ) ) {
		return $certificateDetails;
	}
	$data                    = array();
	$data['cert_user_id']    = $userID;
	$data['cert_course_id']  = $courseID;
	$data['cert_generated']  = current_time( 'mysql' );
	$data['cert_access_key'] = md5( serialize( $data ) ); 
	$SQL = arrayToSQLInsert( $wpcwdb->certificates, $data );
	$wpdb->query( $SQL );
	return getRecordDetails( $wpcwdb->certificates, array( 'cert_user_id', 'cert_course_id' ), array( $userID, $courseID ) );
}
function WPCW_certificate_generateCertificateEntry ( $ userID , $ courseID ) { if ( ! $ userID || ! $ courseID ) { return ; } global $ wpdb , $ wpcwdb ; $ wpdb -> show_errors ( ) ; if ( $ certificateDetails = doesRecordExistAlready ( $ wpcwdb -> certificates , array ( 'cert_user_id' , 'cert_course_id' ) , array ( $ userID , $ courseID ) ) ) { return $ certificateDetails ; } $ data = array ( ) ; $ data [ 'cert_user_id' ] = $ userID ; $ data [ 'cert_course_id' ] = $ courseID ; $ data [ 'cert_generated' ] = current_time ( 'mysql' ) ; $ data [ 'cert_access_key' ] = md5 ( serialize ( $ data ) ) ; $ SQL = arrayToSQLInsert ( $ wpcwdb -> certificates , $ data ) ; $ wpdb -> query ( $ SQL ) ; return getRecordDetails ( $ wpcwdb -> certificates , array ( 'cert_user_id' , 'cert_course_id' ) , array ( $ userID , $ courseID ) ) ; }
Updates the database to generate a certificate entry.
Updates the database to generate a certificate entry .
// Already have a record for this certificate. // Create anonymous entry to allow users to access a certificate when they've completed a course.  Means that certificates // stay existing even if units are added to a course. // Unique key based on data we've just added // Return details of the added certificate