]> git.mxchange.org Git - mailer.git/blobdiff - inc/filter/holiday_filter.php
Renamed templates + added some filters for mail order
[mailer.git] / inc / filter / holiday_filter.php
index ce44eecebed8b8fcb44d2421af561de18c060d71..488ef9421d357e232b9e98e5fab0f8a5659e070e 100644 (file)
@@ -58,5 +58,77 @@ function FILTER_HOLIDAY_USER_EXCLUSION_SQL ($sql) {
        return $sql;
 }
 
+// Filter to check for user's holiday
+function FILTER_CHECK_USER_HOLIDAY ($filterData) {
+       // Is the id number set and valid?
+       if ((isset($filterData['userid'])) && (isValidId($filterData['userid']))) {
+               // Check for his holiday status
+               $result_holiday = sqlQueryEscaped("SELECT
+       `id`
+FROM
+       `{?_MYSQL_PREFIX?}_user_holidays`
+WHERE
+       `userid`=%s AND
+       `holiday_start` < UNIX_TIMESTAMP() AND
+       `holiday_end` > UNIX_TIMESTAMP()
+LIMIT 1",
+                       array($filterData['userid']), __FILE__, __LINE__);
+
+               // Entry found?
+               if (sqlNumRows($result_holiday) == 1) {
+                       // Exclude user who are in holiday
+                       $filterData['userid'] = NULL;
+               } // END - if
+
+               // Free memory
+               sqlFreeResult($result_holiday);
+       } // END - if
+
+       // Return data for next filter
+       return $filterData;
+}
+
+// Filter to check if holiday is activated
+function FILTER_PRE_USERID_HOLIDAY_CHECK ($filterData) {
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
+       // Is it still fine?
+       if ((isValidId($filterData['userid'])) && ($filterData['pre_okay'] === TRUE)) {
+               // Check user's holiday status
+               $result_holiday = sqlQueryEscaped("SELECT
+       COUNT(`d`.`userid`) AS `cnt`
+FROM
+       `{?_MYSQL_PREFIX?}_user_data` AS `d`
+LEFT JOIN
+       `{?_MYSQL_PREFIX?}_user_holidays` AS `h`
+ON
+       `d`.`userid`=`h`.`userid`
+WHERE
+       `d`.`userid`=%s AND
+       `d`.`receive_mails` > 0 AND
+       `d`.`status`='CONFIRMED' AND
+       `d`.`holiday_active`='Y' AND
+       `h`.`holiday_start` < UNIX_TIMESTAMP() AND
+       `h`.`holiday_end` > UNIX_TIMESTAMP()
+LIMIT 1",
+                       array(
+                               bigintval($filterData['userid'])
+                       ), __FILE__, __LINE__
+               );
+
+               // Fetch entry
+               list($count) = sqlFetchRow($result_holiday);
+
+               // Free memory
+               sqlFreeResult($result_holiday);
+
+               // Is holiday is active?
+               $filterData['pre_check'] = ($count == 0);
+       } // END - if
+
+       // Return filter data to next filter
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
+       return $filterData;
+}
+
 // [EOF]
 ?>