public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/classes/dripfeed.php
/**
		 * Function called when a users enrollment date as been updated, so ensure that the
		 * notification dates are correct.
		 *
		 * @param Integer $userID The ID of the user that has been updated.
		 * @param Integer $courseID The ID of the course that's been updated for this user.
		 */
Function called when a users enrollment date as been updated, so ensure that the
notification dates are correct.

@param Integer $userID The ID of the user that has been updated.
@param Integer $courseID The ID of the course that's been updated for this user.
Function called when a users enrollment date as been updated so ensure that the notification dates are correct . @param Integer $userID The ID of the user that has been updated . @param Integer $courseID The ID of the course that ' s been updated for this user .
public static function updateQueueItems_updateNotifications_forCourse( $userID, $courseID ) {
			global $wpdb, $wpcwdb;
			$wpdb->show_errors();
			$queueItems = $wpdb->get_results( $wpdb->prepare( "
				SELECT *
				FROM $wpcwdb->queue_dripfeed
				WHERE queue_user_id = %d
				  AND queue_course_id = %d
				", $userID, $courseID ) );
			if ( empty( $queueItems ) ) {
				return;
			}
			foreach ( $queueItems as $singleItem ) {
				$unitMetaData = WPCW_units_getUnitMetaData( $singleItem->queue_unit_id );
				switch ( $unitMetaData->unit_drip_type ) {
					case 'drip_interval':
						$enrolmentDate = WPCW_users_getCourseEnrolmentDate( $singleItem->queue_user_id, $singleItem->queue_course_id );
						$newTargetDate = $unitMetaData->unit_drip_interval + $enrolmentDate;
						$wpdb->query( $wpdb->prepare( "
							UPDATE $wpcwdb->queue_dripfeed
							   SET queue_trigger_date = %s
							WHERE queue_id = %d
							", date( 'Y-m-d H:i:s', $newTargetDate ), $singleItem->queue_id ) );
						break;
					default:
						break;
				}
			} 
		}
public static function updateQueueItems_updateNotifications_forCourse ( $ userID , $ courseID ) { global $ wpdb , $ wpcwdb ; $ wpdb -> show_errors ( ) ; $ queueItems = $ wpdb -> get_results ( $ wpdb -> prepare ( " 
				SELECT *
				FROM  $ wpcwdb -> queue_dripfeed 
				WHERE queue_user_id = %d
				  AND queue_course_id = %d
				 " , $ userID , $ courseID ) ) ; if ( empty ( $ queueItems ) ) { return ; } foreach ( $ queueItems as $ singleItem ) { $ unitMetaData = WPCW_units_getUnitMetaData ( $ singleItem -> queue_unit_id ) ; switch ( $ unitMetaData -> unit_drip_type ) { case 'drip_interval' : $ enrolmentDate = WPCW_users_getCourseEnrolmentDate ( $ singleItem -> queue_user_id , $ singleItem -> queue_course_id ) ; $ newTargetDate = $ unitMetaData -> unit_drip_interval + $ enrolmentDate ; $ wpdb -> query ( $ wpdb -> prepare ( " 
							UPDATE  $ wpcwdb -> queue_dripfeed 
							   SET queue_trigger_date = %s
							WHERE queue_id = %d
							 " , date ( 'Y-m-d H:i:s' , $ newTargetDate ) , $ singleItem -> queue_id ) ) ; break ; default : break ; } } }
Function called when a users enrollment date as been updated, so ensure that the
 notification dates are correct.
Function called when a users enrollment date as been updated so ensure that the notification dates are correct .
// See if we have any items in the queue that need updating. // #### 1 - We need the meta data for this unit to calculate the dates. // #### 2 - Now we need to see we we're expecting to happen. // We've got to calculate the interval for this user, for each item. // Fetch the enrolement date for this user to use in our calculation. // Add the interval type, which is stored in seconds. // Now update this queue item to the new date. Assume that if the date has been set backwards, // we still notify the user, because they'll want to know that they can access the unit. Any old // queue items will always get triggered. // Either we've got a specific date to set to. No action needed, it's an absolute date. // or we've not got a drip type to worry about. //case 'drip_specific': //case '': // end foreach