public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/classes/dripfeed.php
/**
		 * Method called when a unit has been updated, so we need to adjust the notification times in the queue.
		 *
		 * @param Integer $unitID The ID of the unit that has been updated.
		 */
Method called when a unit has been updated, so we need to adjust the notification times in the queue.
@param Integer $unitID The ID of the unit that has been updated.
Method called when a unit has been updated so we need to adjust the notification times in the queue . @param Integer $unitID The ID of the unit that has been updated .
public static function updateQueueItems_unitUpdated( $unitID ) {
			global $wpdb, $wpcwdb;
			$wpdb->show_errors();
			$queueItems = $wpdb->get_results( $wpdb->prepare( "
				SELECT *
				FROM $wpcwdb->queue_dripfeed
				WHERE queue_unit_id = %d
				", $unitID ) );
			if ( ! empty( $queueItems ) ) {
				$unitMetaData = WPCW_units_getUnitMetaData( $unitID );
				switch ( $unitMetaData->unit_drip_type ) {
					case 'drip_specific':
						$wpdb->query( $wpdb->prepare( "
						UPDATE $wpcwdb->queue_dripfeed
						   SET queue_trigger_date = %s
						WHERE queue_unit_id = %d
						", $unitMetaData->unit_drip_date, $unitID ) );
						break;
					case 'drip_interval':
						foreach ( $queueItems as $singleItem ) {
							$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:
						$wpdb->query( $wpdb->prepare( "
						UPDATE $wpcwdb->queue_dripfeed
						   SET queue_trigger_date = %s
						WHERE queue_unit_id = %d
						", date( 'Y-m-d H:i:s', strtotime( '+15 minutes' ) ), $unitID ) );
						break;
				}
			}
		}
public static function updateQueueItems_unitUpdated ( $ unitID ) { global $ wpdb , $ wpcwdb ; $ wpdb -> show_errors ( ) ; $ queueItems = $ wpdb -> get_results ( $ wpdb -> prepare ( " 
				SELECT *
				FROM  $ wpcwdb -> queue_dripfeed 
				WHERE queue_unit_id = %d
				 " , $ unitID ) ) ; if ( ! empty ( $ queueItems ) ) { $ unitMetaData = WPCW_units_getUnitMetaData ( $ unitID ) ; switch ( $ unitMetaData -> unit_drip_type ) { case 'drip_specific' : $ wpdb -> query ( $ wpdb -> prepare ( " 
						UPDATE  $ wpcwdb -> queue_dripfeed 
						   SET queue_trigger_date = %s
						WHERE queue_unit_id = %d
						 " , $ unitMetaData -> unit_drip_date , $ unitID ) ) ; break ; case 'drip_interval' : foreach ( $ queueItems as $ singleItem ) { $ 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 : $ wpdb -> query ( $ wpdb -> prepare ( " 
						UPDATE  $ wpcwdb -> queue_dripfeed 
						   SET queue_trigger_date = %s
						WHERE queue_unit_id = %d
						 " , date ( 'Y-m-d H:i:s' , strtotime ( '+15 minutes' ) ) , $ unitID ) ) ; break ; } } }
Method called when a unit has been updated, so we need to adjust the notification times in the queue.
Method called when a unit has been updated so we need to adjust the notification times in the queue .
// See if we have any items in the queue that need updating. // Right, we've got some items to update, we had better get the dates on these updated. // #### 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 a specific date to set to. So set all items to this date. // We've got to calculate the interval for each user. // Calculate the new date 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. // No drip-feeding is needed now. Set the time to 15 minutes from now. // As they're expecting to be notified when the unit is accessible.