public/wordpress/wp-content/plugins/wp-courseware/includes/legacy/classes/dripfeed.php
/**
		 * Add an item to the queue to notify the user when it becomes available.
		 *
		 * @param Integer $unitID The ID of the unit to add to the queue.
		 * @param Integer $userID The ID of the user that's going to be notified.
		 * @param Integer $unlockDate The date as a timestamp, of when the user should be notified that the unit is available.
		 *
		 */
Add an item to the queue to notify the user when it becomes available.
@param Integer $unitID The ID of the unit to add to the queue.
@param Integer $userID The ID of the user that's going to be notified.
@param Integer $unlockDate The date as a timestamp, of when the user should be notified that the unit is available.
Add an item to the queue to notify the user when it becomes available . @param Integer $unitID The ID of the unit to add to the queue . @param Integer $userID The ID of the user that ' s going to be notified . @param Integer $unlockDate The date as a timestamp of when the user should be notified that the unit is available .
public static function addQueueItem( $unitID, $userID, $unlockDate ) {
			global $wpdb, $wpcwdb;
			$wpdb->show_errors();
			$triggerDateAsMySQL = date( 'Y-m-d H:i:s', $unlockDate );
			$parentData   = WPCW_units_getAssociatedParentData( $unitID );
			$unitCourseID = $parentData->parent_course_id;
			do_action( 'wpcw_dripfeed_before_add_queue_item', $unitID, $userID, $unlockDate, $triggerDateAsMySQL, $unitCourseID, $parentData );
			if ( $existingQueueItem = $wpdb->get_row( $wpdb->prepare(
				"SELECT *
				 FROM $wpcwdb->queue_dripfeed
				 WHERE queue_unit_id = %d
				 AND queue_user_id = %d",
				$unitID,
				$userID
			) ) ) {
				do_action( 'wpcw_dripfeed_existing_queue_item', $existingQueueItem, $unitID, $userID, $unlockDate, $triggerDateAsMySQL, $unitCourseID, $parentData );
				if ( $existingQueueItem->queue_trigger_date != $triggerDateAsMySQL ) {
					$wpdb->query( $wpdb->prepare(
						"UPDATE $wpcwdb->queue_dripfeed
					   	 SET queue_trigger_date = %s, queue_enqueued_date = %s, queue_course_id = %d 
					   	 WHERE queue_id = %d",
						$triggerDateAsMySQL,
						current_time( 'mysql' ),
						$unitCourseID,
						$existingQueueItem->queue_id
					) );
				}
			} 
			else {
				do_action( 'wpcw_dripfeed_new_queue_item', $unitID, $userID, $unlockDate, $triggerDateAsMySQL, $unitCourseID, $parentData );
				$wpdb->query( $wpdb->prepare(
					"INSERT INTO $wpcwdb->queue_dripfeed (queue_unit_id, queue_course_id, queue_user_id, queue_trigger_date, queue_enqueued_date)
					 VALUES (%d, %d, %d, %s, %s)",
					$unitID,
					$unitCourseID,
					$userID,
					$triggerDateAsMySQL,
					current_time( 'mysql' )
				) );
			}
			do_action( 'wpcw_dripfeed_after_add_queue_item', $unitID, $userID, $unlockDate, $triggerDateAsMySQL, $unitCourseID, $parentData );
		}
public static function addQueueItem ( $ unitID , $ userID , $ unlockDate ) { global $ wpdb , $ wpcwdb ; $ wpdb -> show_errors ( ) ; $ triggerDateAsMySQL = date ( 'Y-m-d H:i:s' , $ unlockDate ) ; $ parentData = WPCW_units_getAssociatedParentData ( $ unitID ) ; $ unitCourseID = $ parentData -> parent_course_id ; do_action ( 'wpcw_dripfeed_before_add_queue_item' , $ unitID , $ userID , $ unlockDate , $ triggerDateAsMySQL , $ unitCourseID , $ parentData ) ; if ( $ existingQueueItem = $ wpdb -> get_row ( $ wpdb -> prepare ( " SELECT *
				 FROM  $ wpcwdb -> queue_dripfeed 
				 WHERE queue_unit_id = %d
				 AND queue_user_id = %d " , $ unitID , $ userID ) ) ) { do_action ( 'wpcw_dripfeed_existing_queue_item' , $ existingQueueItem , $ unitID , $ userID , $ unlockDate , $ triggerDateAsMySQL , $ unitCourseID , $ parentData ) ; if ( $ existingQueueItem -> queue_trigger_date != $ triggerDateAsMySQL ) { $ wpdb -> query ( $ wpdb -> prepare ( " UPDATE  $ wpcwdb -> queue_dripfeed 
					   	 SET queue_trigger_date = %s, queue_enqueued_date = %s, queue_course_id = %d 
					   	 WHERE queue_id = %d " , $ triggerDateAsMySQL , current_time ( 'mysql' ) , $ unitCourseID , $ existingQueueItem -> queue_id ) ) ; } } else { do_action ( 'wpcw_dripfeed_new_queue_item' , $ unitID , $ userID , $ unlockDate , $ triggerDateAsMySQL , $ unitCourseID , $ parentData ) ; $ wpdb -> query ( $ wpdb -> prepare ( " INSERT INTO  $ wpcwdb -> queue_dripfeed  (queue_unit_id, queue_course_id, queue_user_id, queue_trigger_date, queue_enqueued_date)
					 VALUES (%d, %d, %d, %s, %s) " , $ unitID , $ unitCourseID , $ userID , $ triggerDateAsMySQL , current_time ( 'mysql' ) ) ) ; } do_action ( 'wpcw_dripfeed_after_add_queue_item' , $ unitID , $ userID , $ unlockDate , $ triggerDateAsMySQL , $ unitCourseID , $ parentData ) ; }
Add an item to the queue to notify the user when it becomes available.
Add an item to the queue to notify the user when it becomes available .
// Need date as MySQL date for comparison or insertion below // Need the course ID - going to assume this is valid, otherwise it wouldn't get triggered // in the first place. /**
			 * Action: Dripfeed Before Add Queue Item.
			 *
			 * @since 4.4.0
			 *
			 * @param int $unitID The unit id.
			 * @param int $userID The user id.
			 * @param string $unlockDate The unlock date.
			 * @param string $triggerDateAsMySQL The unlock dat as mysql.
			 * @param int $unitCourseID The unit course id.
			 * @param object $parentData The unit parent data.
			 */ // Check if the queue item already exists for this unit/user. If we find it, // then we need to update the unlock date (if it's different). // ### 1 - Yep, got an existing queue item /**
				 * Action: Dripfeed Existing Queue Item
				 *
				 * @since 4.4.0
				 *
				 * @param object $existingQueueItem The existing queue item.
				 * @param int $unitID The unit id.
				 * @param int $userID The user id.
				 * @param string $unlockDate The unlock date.
				 * @param string $triggerDateAsMySQL The unlock dat as mysql.
				 * @param int $unitCourseID The unit course id.
				 * @param object $parentData The unit parent data.
				 */ // Do a simple string match on the trigger date. If no match, then just // update database with the new date. // Update the trigger date. // ### 2 - No entry for this user or unit, so add one. /**
				 * Action: Dripfeed New Queue Item
				 *
				 * @since 4.4.0
				 *
				 * @param object $existingQueueItem The existing queue item.
				 * @param int $unitID The unit id.
				 * @param int $userID The user id.
				 * @param string $unlockDate The unlock date.
				 * @param string $triggerDateAsMySQL The unlock dat as mysql.
				 * @param int $unitCourseID The unit course id.
				 * @param object $parentData The unit parent data.
				 */ /**
			 * Action: Dripfeed After Add Queue Item.
			 *
			 * @since 4.4.0
			 *
			 * @param int $unitID The unit id.
			 * @param int $userID The user id.
			 * @param string $unlockDate The unlock date.
			 * @param string $triggerDateAsMySQL The unlock dat as mysql.
			 * @param int $unitCourseID The unit course id.
			 * @param object $parentData The unit parent data.
			 */