Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

eznotificationschedule.php
Go to the documentation of this file.
1 <?php
17 class eZNotificationSchedule
18 {
19 static function setDateForItem( $item, $settings )
20 {
21 if ( !is_array( $settings ) )
22 return false;
23
24 $dayNum = isset( $settings['day'] ) ? $settings['day'] : false;
25 $hour = $settings['hour'];
26 $currentDate = getdate();
27 $hoursDiff = $hour - $currentDate['hours'];
28
29 switch ( $settings['frequency'] )
30 {
31 case 'day':
32 {
33 if ( $hoursDiff <= 0 )
34 {
35 $hoursDiff += 24;
36 }
37
38 $secondsDiff = 3600 * $hoursDiff
39 - $currentDate['seconds']
40 - 60 * $currentDate['minutes'];
41 } break;
42
43 case 'week':
44 {
45 $daysDiff = $dayNum - $currentDate['wday'];
46 if ( $daysDiff < 0 or
47 ( $daysDiff == 0 and $hoursDiff <= 0 ) )
48 {
49 $daysDiff += 7;
50 }
51
52 $secondsDiff = 3600 * ( $daysDiff * 24 + $hoursDiff )
53 - $currentDate['seconds']
54 - 60 * $currentDate['minutes'];
55 } break;
56
57 case 'month':
58 {
59 // If the daynum the user has chosen is larger than the number of days in this month,
60 // then reduce it to the number of days in this month.
61 $daysInMonth = intval( date( 't', mktime( 0, 0, 0, $currentDate['mon'], 1, $currentDate['year'] ) ) );
62 if ( $dayNum > $daysInMonth )
63 {
64 $dayNum = $daysInMonth;
65 }
66
67 $daysDiff = $dayNum - $currentDate['mday'];
68 if ( $daysDiff < 0 or
69 ( $daysDiff == 0 and $hoursDiff <= 0 ) )
70 {
71 $daysDiff += $daysInMonth;
72 }
73
74 $secondsDiff = 3600 * ( $daysDiff * 24 + $hoursDiff )
75 - $currentDate['seconds']
76 - 60 * $currentDate['minutes'];
77 } break;
78 }
79
80 $sendDate = time() + $secondsDiff;
81 eZDebugSetting::writeDebug( 'kernel-notification', getdate( $sendDate ), "item date" );
82 $item->setAttribute( 'send_date', $sendDate );
83 return $sendDate;
84 }
85 }
86
87 ?>
eZDebugSetting\writeDebug
static writeDebug( $conditionName, $string, $label="")
Definition: ezdebugsetting.php:127
eZNotificationSchedule
The class eZNotificationSchedule does.
Definition: eznotificationschedule.php:18
eZNotificationSchedule\setDateForItem
static setDateForItem( $item, $settings)
Definition: eznotificationschedule.php:19
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.