[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/kernel/classes/notification/ -> eznotificationschedule.php (source)

   1  <?php
   2  //
   3  // Definition of eZNotificationSchedule class
   4  //
   5  // Created on: <16-May-2003 15:22:43 sp>
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  /*! \file eznotificationschedule.php
  30  */
  31  
  32  /*!
  33    \class eZNotificationSchedule eznotificationschedule.php
  34    \brief The class eZNotificationSchedule does
  35  
  36  */
  37  include_once ( "lib/ezlocale/classes/ezdate.php" );
  38  
  39  
  40  class eZNotificationSchedule
  41  {
  42      /*!
  43       Constructor
  44      */
  45      function eZNotificationSchedule()
  46      {
  47      }
  48  
  49      function setDateForItem( &$item, $settings )
  50      {
  51          if ( !is_array( $settings ) )
  52              return false;
  53  
  54          $dayNum = isset( $settings['day'] ) ? $settings['day'] : false;
  55          $hour = $settings['hour'];
  56          $currentDate = getdate();
  57          $hoursDiff = $hour - $currentDate['hours'];
  58  
  59          switch ( $settings['frequency'] )
  60          {
  61              case 'day':
  62              {
  63                  if ( $hoursDiff <= 0 )
  64                  {
  65                      $hoursDiff += 24;
  66                  }
  67  
  68                  $secondsDiff = 3600 * $hoursDiff
  69                       - $currentDate['seconds']
  70                       - 60 * $currentDate['minutes'];
  71              } break;
  72  
  73              case 'week':
  74              {
  75                  $daysDiff = $dayNum - $currentDate['wday'];
  76                  if ( $daysDiff < 0 or
  77                       ( $daysDiff == 0 and $hoursDiff <= 0 ) )
  78                  {
  79                      $daysDiff += 7;
  80                  }
  81  
  82                  $secondsDiff = 3600 * ( $daysDiff * 24 + $hoursDiff )
  83                       - $currentDate['seconds']
  84                       - 60 * $currentDate['minutes'];
  85              } break;
  86  
  87              case 'month':
  88              {
  89                  // If the daynum the user has chosen is larger than the number of days in this month,
  90                  // then reduce it to the number of days in this month.
  91                  $daysInMonth = intval( date( 't', mktime( 0, 0, 0, $currentDate['mon'], 1, $currentDate['year'] ) ) );
  92                  if ( $dayNum > $daysInMonth )
  93                  {
  94                      $dayNum = $daysInMonth;
  95                  }
  96  
  97                  $daysDiff = $dayNum - $currentDate['mday'];
  98                  if ( $daysDiff < 0 or
  99                       ( $daysDiff == 0 and $hoursDiff <= 0 ) )
 100                  {
 101                      $daysDiff += $daysInMonth;
 102                  }
 103  
 104                  $secondsDiff = 3600 * ( $daysDiff * 24 + $hoursDiff )
 105                       - $currentDate['seconds']
 106                       - 60 * $currentDate['minutes'];
 107              } break;
 108          }
 109  
 110          $sendDate = mktime() + $secondsDiff;
 111          eZDebugSetting::writeDebug( 'kernel-notification', getdate( $sendDate ), "item date"  );
 112          $item->setAttribute( 'send_date', $sendDate );
 113          return $sendDate;
 114      }
 115  }
 116  
 117  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7