/[drupal]/contributions/modules/rsvp/rsvp_dateconnector.module
ViewVC logotype

Diff of /contributions/modules/rsvp/rsvp_dateconnector.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2.2.10, Wed Oct 14 06:11:20 2009 UTC revision 1.2.2.11, Thu Nov 5 22:36:47 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: rsvp_dateconnector.module,v 1.2.2.9 2009/06/17 19:10:25 ulf1 Exp $  // $Id: rsvp_dateconnector.module,v 1.2.2.10 2009/10/14 06:11:20 ulf1 Exp $
3    
4    
5  class RsvpDateConnectorImpl extends RsvpConnectorImpl {  class RsvpDateConnectorImpl extends RsvpConnectorImpl {
# Line 29  class RsvpDateConnectorImpl extends Rsvp Line 29  class RsvpDateConnectorImpl extends Rsvp
29    
30    
31    //returns startdate as is to use it as hash    //returns startdate as is to use it as hash
32    function get_startdate($node, $field, $pos) {    function get_startdateAsHash($node, $field, $pos) {
33    
34      $date_value = $node->{$field['field_name']}[$pos]['value'];      $date_value = $node->{$field['field_name']}[$pos]['value'];
35      return $date_value;      return $date_value;
36  /*    }
37    
38      //returns startdate as is to use it as hash
39      function get_startdateAsUTC($node, $field, $pos) {
40    
41        $date_value = $this->get_startdateAsHash($node, $field, $pos);
42    
43      $db_tz = $this->_get_dbtimezone($node, $field, $pos);      $db_tz = $this->_get_dbtimezone($node, $field, $pos);
44    
45      // Create a date object      // Create a date object
# Line 44  class RsvpDateConnectorImpl extends Rsvp Line 50  class RsvpDateConnectorImpl extends Rsvp
50      $date_utc = date_format($date, 'U');      $date_utc = date_format($date, 'U');
51    
52      return $date_utc;      return $date_utc;
 */  
   }  
53    
54      }
55    
56    
57    //returns startdate as string in local timezone    //returns startdate as string in local timezone
58    function get_startdateAsString($node, $field, $pos) {    function get_startdateAsString($node, $field, $pos) {
# Line 54  class RsvpDateConnectorImpl extends Rsvp Line 60  class RsvpDateConnectorImpl extends Rsvp
60    }    }
61    
62    //returns enddate in utc form    //returns enddate in utc form
63    function get_enddate($node, $field, $pos) {    function get_enddateAsUTC($node, $field, $pos) {
64    
65      //if no "toDate" is set, return the "StartDate" of the event instead.      if ($this->has_enddate($node, $field, $pos) == true)
66      if (!isset($node->{$field['field_name']}[$pos]['value2']))      {
       $date_value = $this->get_startdate($node, $field, $pos);  
     else  
67        $date_value = $node->{$field['field_name']}[$pos]['value2'];        $date_value = $node->{$field['field_name']}[$pos]['value2'];
68    
69      $db_tz = $this->_get_dbtimezone($node, $field, $pos);        $db_tz = $this->_get_dbtimezone($node, $field, $pos);
70    
71      // Create a date object        // Create a date object
72      $date = date_make_date($date_value, $db_tz, $field['type']);        $date = date_make_date($date_value, $db_tz, $field['type']);
73      // Make sure the date object is going to print UTC values.        // Make sure the date object is going to print UTC values.
74      date_timezone_set($date, timezone_open('UTC'));        date_timezone_set($date, timezone_open('UTC'));
75    
76      $date_utc = date_format($date, 'U');        $date_utc = date_format($date, 'U');
77    
78      return $date_utc;        return $date_utc;
79        }
80        else {
81          return null;
82        }
83      }
84    
85      //returns if event has a valid enddate
86      function has_enddate($node, $field, $pos) {
87        return isset($node->{$field['field_name']}[$pos]['value2']);
88    }    }
89    
90    //returns the position for a particular hash, or -1 if invalid hash    //returns the position for a particular hash, or -1 if invalid hash
# Line 80  class RsvpDateConnectorImpl extends Rsvp Line 93  class RsvpDateConnectorImpl extends Rsvp
93      $count = $this->get_datecount($node, $field);      $count = $this->get_datecount($node, $field);
94    
95      for ($i = 0; $i < $count; $i++) {      for ($i = 0; $i < $count; $i++) {
96        $unixdate = $this->get_startdate($node, $field, $i);        $unixdate = $this->get_startdateAsHash($node, $field, $i);
97        if ($unixdate == $hash) {        if ($unixdate == $hash) {
98          return $i;          return $i;
99        }        }
# Line 144  class RsvpDateConnectorImpl extends Rsvp Line 157  class RsvpDateConnectorImpl extends Rsvp
157      }      }
158      $date_out = date_format_date($date, 'custom', $format);      $date_out = date_format_date($date, 'custom', $format);
159    
160      if ($include_to_date) {      if ($include_to_date && $this->has_enddate($node, $field, $pos)) {
161        if (isset($node->{$field['field_name']})) {        if (isset($node->{$field['field_name']})) {
162          $date_value = $node->{$field['field_name']}[$pos]['value2'];          $date_value = $node->{$field['field_name']}[$pos]['value2'];
163        }        }

Legend:
Removed from v.1.2.2.10  
changed lines
  Added in v.1.2.2.11

  ViewVC Help
Powered by ViewVC 1.1.2