[ Index ]
 

Code source de Claroline 188

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/claroline/inc/lib/icalendar/ -> class.iCalEvent.inc.php (source)

   1  <?php // $Id: class.iCalEvent.inc.php,v 1.4 2006/10/16 07:55:02 moosh Exp $
   2  if ( count( get_included_files() ) == 1 ) die( '---' );
   3  //+----------------------------------------------------------------------+
   4  //| WAMP (XP-SP1/1.3.24/4.0.12/4.3.0)                                    |
   5  //+----------------------------------------------------------------------+
   6  //| Copyright (c) 1992-2003 Michael Wimmer                               |
   7  //+----------------------------------------------------------------------+
   8  //| I don't have the time to read through all the licences to find out   |
   9  //| what the exactly say. But it's simple. It's free for non commercial  |
  10  //| projects, but as soon as you make money with it, i want my share :-) |
  11  //| (License : Free for non-commercial use)                              |
  12  //+----------------------------------------------------------------------+
  13  //| Authors: Michael Wimmer <flaimo@gmx.net>                             |
  14  //+----------------------------------------------------------------------+
  15  //
  16  // $Id: class.iCalEvent.inc.php,v 1.4 2006/10/16 07:55:02 moosh Exp $
  17  
  18  /**
  19  * @package iCalendar Everything to generate simple iCal files
  20  */
  21  /**
  22  * We need the base class
  23  */
  24  include_once  'class.iCalBase.inc.php';
  25  /**
  26  * We need the child class
  27  */
  28  include_once  'class.iCalAlarm.inc.php';
  29  
  30  /**
  31  * Container for a single event
  32  *
  33  * Last Change: 2003-03-29
  34  * Tested with WAMP (XP-SP1/1.3.24/4.0.4/4.3.0)
  35  *
  36  * @desc Container for a single event
  37  * @access private
  38  * @author Michael Wimmer <flaimo 'at' gmx 'dot' net>
  39  * @copyright Michael Wimmer
  40  * @link http://www.flaimo.com/
  41  * @package iCalendar
  42  * @version 1.032
  43  */
  44  class iCalEvent extends iCalBase {
  45  
  46      /*-------------------*/
  47      /* V A R I A B L E S */
  48      /*-------------------*/
  49  
  50      /**#@+
  51      * @access private
  52      */
  53      /**
  54      * Timestamp of the start date
  55      *
  56      * @desc Timestamp of the start date
  57      * @var int
  58      */
  59      var $startdate_ts;
  60  
  61      /**
  62      * Timestamp of the end date
  63      *
  64      * @desc Timestamp of the end date
  65      * @var int
  66      */
  67      var $enddate_ts;
  68  
  69      /**
  70      * OPAQUE (1) or TRANSPARENT (1)
  71      *
  72      * @desc OPAQUE (1) or TRANSPARENT (1)
  73      * @var int
  74      */
  75      var $transp = 0;
  76  
  77      /**
  78      * start date in iCal format
  79      *
  80      * @desc start date in iCal format
  81      * @var string
  82      */
  83      var $startdate;
  84  
  85      /**
  86      * end date in iCal format
  87      *
  88      * @desc end date in iCal format
  89      * @var string
  90      */
  91      var $enddate;
  92  
  93      /**
  94      * Automaticaly created: md5 value of the start date + end date
  95      *
  96      * @desc Automaticaly created: md5 value of the start date + end date
  97      * @var string
  98      */
  99      var $uid;
 100  
 101      /**
 102      * '' = never, integer < 4 numbers = number of times, integer >= 4 = timestamp
 103      *
 104      * @desc '' = never, integer < 4 numbers = number of times, integer >= 4 = timestamp
 105      * @var mixed
 106      */
 107      var $rec_end;
 108  
 109      /**
 110      * If alarm is set, holds alarm object
 111      *
 112      * @desc If alarm is set, holds alarm object
 113      * @var object
 114      */
 115      var $alarm;
 116      /**#@-*/
 117  
 118      /*-----------------------*/
 119      /* C O N S T R U C T O R */
 120      /*-----------------------*/
 121  
 122      /**#@+
 123      * @access private
 124      * @return void
 125      */
 126      /**
 127      * Constructor
 128      *
 129      * Only job is to set all the variablesnames
 130      *
 131      * @desc Constructor
 132      * @param array $organizer  The organizer - use array('Name', 'name@domain.com')
 133      * @param int $start  Start time for the event (timestamp; if you want an allday event the startdate has to start at 00:00:00)
 134      * @param int $end  Start time for the event (timestamp or write 'allday' for an allday event)
 135      * @param string $location  Location
 136      * @param int $transp  Transparancy (0 = OPAQUE | 1 = TRANSPARENT)
 137      * @param array $categories  Array with Strings (example: array('Freetime','Party'))
 138      * @param string $description  Description
 139      * @param string $summary  Title for the event
 140      * @param int $class  (0 = PRIVATE | 1 = PUBLIC | 2 = CONFIDENTIAL)
 141      * @param array $attendees  key = attendee name, value = e-mail, second value = role of the attendee [0 = CHAIR | 1 = REQ | 2 = OPT | 3 =NON] (example: array('Michi' => 'flaimo@gmx.net,1'); )
 142      * @param int $prio  riority = 0–9
 143      * @param int $frequency  frequency: 0 = once, secoundly – yearly = 1–7
 144      * @param mixed $rec_end  recurrency end: ('' = forever | integer = number of times | timestring = explicit date)
 145      * @param int $interval  Interval for frequency (every 2,3,4 weeks…)
 146      * @param string $days  Array with the number of the days the event accures (example: array(0,1,5) = Sunday, Monday, Friday
 147      * @param string $weekstart  Startday of the Week ( 0 = Sunday - 6 = Saturday)
 148      * @param string $exept_dates  exeption dates: Array with timestamps of dates that should not be includes in the recurring event
 149      * @param array $alarm  Array with all the alarm information, "''" for no alarm
 150      * @param int $status  Status of the event (0 = TENTATIVE, 1 = CONFIRMED, 2 = CANCELLED)
 151      * @param string $url  optional URL for that event
 152      * @param string $language  Language of the strings used in the event (iso code)
 153      * @param string $uid  Optional UID for the event
 154      * @uses iCalBase::setLanguage()
 155      * @uses iCalBase::setOrganizer()
 156      * @uses setStartDate()
 157      * @uses setEndDate()
 158      * @uses iCalBase::setLocation()
 159      * @uses setTransp()
 160      * @uses iCalBase::setSequence()
 161      * @uses iCalBase::setCategories()
 162      * @uses iCalBase::setDescription()
 163      * @uses iCalBase::setSummary()
 164      * @uses iCalBase::setPriority()
 165      * @uses iCalBase::setClass()
 166      * @uses setUID()
 167      * @uses iCalBase::setAttendees()
 168      * @uses iCalBase::setFrequency()
 169      * @uses setRecEnd()
 170      * @uses iCalBase::setInterval()
 171      * @uses iCalBase::setDays()
 172      * @uses iCalBase::setWeekStart()
 173      * @uses iCalBase::setExeptDates()
 174      * @uses iCalBase::setStatus()
 175      * @uses setAlarm()
 176      * @uses iCalBase::setURL()
 177      * @uses setUID()
 178      */
 179  	function iCalEvent($organizer, $start, $end, $location, $transp, $categories,
 180                         $description, $summary, $class, $attendees, $prio, $frequency,
 181                         $rec_end, $interval, $days, $weekstart, $exept_dates,
 182                         $alarm, $status, $url, $language, $uid) {
 183          parent::iCalBase();
 184          parent::setLanguage($language);
 185          parent::setOrganizer($organizer);
 186          $this->setStartDate($start);
 187          $this->setEndDate($end);
 188          parent::setLocation($location);
 189          $this->setTransp($transp);
 190          parent::setSequence(0);
 191          parent::setCategories($categories);
 192          parent::setDescription($description);
 193          parent::setSummary($summary);
 194          parent::setPriority($prio);
 195          parent::setClass($class);
 196          parent::setAttendees($attendees);
 197          parent::setFrequency($frequency);
 198          $this->setRecEnd($rec_end);
 199          parent::setInterval($interval);
 200          parent::setDays($days);
 201          parent::setWeekStart($weekstart);
 202          parent::setExeptDates($exept_dates);
 203          parent::setStatus($status);
 204          $this->setAlarm($alarm);
 205          parent::setURL($url);
 206          $this->setUID($uid);
 207      } // end constructor
 208  
 209      /*-------------------*/
 210      /* F U N C T I O N S */
 211      /*-------------------*/
 212  
 213      /**
 214      * Sets the end for a recurring event (0 = never ending,
 215      * integer < 4 numbers = number of times, integer >= 4 enddate)
 216      *
 217      * @desc Get $rec_end variable
 218      * @param int $freq
 219      * @see getRecEnd()
 220      * @see $rec_end
 221      * @since 1.010 - 2002-10-26
 222      */
 223  	function setRecEnd($freq = '') {
 224          if (strlen(trim($freq)) < 1) {
 225              $this->rec_end = 0;
 226          } elseif (is_int($freq) && strlen(trim($freq)) < 4) {
 227              $this->rec_end = $freq;
 228          } else {
 229              $this->rec_end = (string) gmdate('Ymd\THi00\Z',$freq);
 230          } // end if
 231      } // end function
 232  
 233      /**
 234      * Set $startdate_ts variable
 235      *
 236      * @desc Set $startdate_ts variable
 237      * @param int $timestamp
 238      * @see getStartDateTS()
 239      * @see $startdate_ts
 240      */
 241  	function setStartDateTS($timestamp = 0) {
 242          if (is_int($timestamp) && $timestamp > 0) {
 243              $this->startdate_ts = (int) $timestamp;
 244          } else {
 245              $this->startdate_ts = (int) ((isset($this->enddate_ts) && is_numeric($this->enddate_ts) && $this->enddate_ts > 0) ? ($this->enddate_ts - 3600) : time());
 246          } // end if
 247      } // end function
 248  
 249      /**
 250      * Set $enddate_ts variable
 251      *
 252      * @desc Set $enddate_ts variable
 253      * @param int $timestamp
 254      * @see getEndDateTS()
 255      * @see  $enddate_ts
 256      */
 257  	function setEndDateTS($timestamp = 0) {
 258          if (is_int($timestamp) && $timestamp > 0) {
 259              $this->enddate_ts = (int) $timestamp;
 260          } else {
 261              $this->enddate_ts = (int) ((isset($this->startdate_ts) && is_numeric($this->startdate_ts) && $this->startdate_ts > 0) ? ($this->startdate_ts + 3600) : (time() + 3600));
 262          } // end if
 263      } // end function
 264  
 265      /**
 266      * Set $startdate variable
 267      *
 268      * @desc Set $startdate variable
 269      * @param int $timestamp
 270      * @see getStartDate()
 271      * @see $startdate
 272      */
 273  	function setStartDate($timestamp = 0) {
 274          $this->setStartDateTS($timestamp);
 275          if (date('H:i:s', $this->startdate_ts) == '00:00:00') {
 276              $this->startdate = (string) gmdate('Ymd',$this->startdate_ts);
 277          } else {
 278              $this->startdate = (string) gmdate('Ymd\THi00\Z',$this->startdate_ts);
 279          } // end if
 280      } // end function
 281  
 282      /**
 283      * Set $enddate variable
 284      *
 285      * @desc Set $enddate variable
 286      * @param (mixed) $timestamp or 'allday'
 287      * @see getEndDate()
 288      * @see $enddate
 289      * @uses setEndDateTS()
 290      */
 291  	function setEndDate($timestamp = 0) {
 292          if (is_int($timestamp)) {
 293              $this->setEndDateTS($timestamp);
 294              $this->enddate = (string) gmdate('Ymd\THi00\Z',$this->enddate_ts);
 295          } else {
 296              $this->enddate = (string) '';
 297          } // end if
 298  
 299      } // end function
 300  
 301      /**
 302      * Set $transp variable
 303      *
 304      * @desc Set $transp variable
 305      * @param int $int  0|1
 306      * @see getTransp()
 307      * @see $transp
 308      */
 309  	function setTransp($int = 0) {
 310          $this->transp = (int) $int;
 311      } // end function
 312  
 313      /**
 314      * Set $uid variable
 315      *
 316      * @desc Set $uid variable
 317      * @param int $uid
 318      * @see getUID()
 319      * @see $uid
 320      */
 321  	function setUID($uid = 0) {
 322          if (strlen(trim($uid)) > 0) {
 323              $this->uid = (string) $uid;
 324          } else {
 325              $rawid = (string) $this->startdate . 'plus' .  $this->enddate;
 326              $this->uid = (string) md5($rawid);
 327          }
 328      } // end function
 329  
 330      /**
 331      * Set $alarm object
 332      *
 333      * @desc Set $attendees variable
 334      * @param (array) $attendees
 335      * @see getAttendees()
 336      * @see $attendees
 337      * @since 1.001 - 2002-10-10
 338      */
 339  	function setAlarm($alarm = '') {
 340          if (is_array($alarm)) {
 341              $this->alarm = (object) new iCalAlarm($alarm[0], $alarm[1],
 342                                                    $alarm[2], $alarm[3], $alarm[4],
 343                                                    $alarm[5], $alarm[6], $this->lang);
 344          } // end if
 345      } // end function
 346      /**#@-*/
 347  
 348      /**#@+
 349      * @access public
 350      */
 351      /**
 352      * Get $rec_end variable
 353      *
 354      * @desc Get $rec_end variable
 355      * @return (mixed) $rec_end
 356      * @see setRecEnd()
 357      * @see $rec_end
 358      * @since 1.010 - 2002-10-26
 359      */
 360      function &getRecEnd() {
 361          return $this->rec_end;
 362      } // end function
 363  
 364      /**
 365      * Get $startdate_ts variable
 366      *
 367      * @desc Get $startdate_ts variable
 368      * @return (int) $startdate_ts
 369      * @see setStartDateTS()
 370      * @see $startdate_ts
 371      */
 372      function &getStartDateTS() {
 373          $ret = (int) $this->startdate_ts;
 374          return $ret;
 375      } // end function
 376  
 377      /**
 378      * Get $enddate_ts variable
 379      *
 380      * @desc Get $enddate_ts variable
 381      * @return (int) $enddate_ts
 382      * @see setEndDateTS()
 383      * @see $enddate_ts
 384      */
 385      function &getEndDateTS() {
 386          $ret = (int) $this->enddate_ts;
 387          return $ret;
 388      } // end function
 389  
 390      /**
 391      * Get $startdate variable
 392      *
 393      * @desc Get $startdate variable
 394      * @return (int) $startdate
 395      * @see setStartDate()
 396      * @see $startdate
 397      */
 398      function &getStartDate() {
 399          $ret = (string) $this->startdate;
 400          return $ret;
 401      } // end function
 402  
 403      /**
 404      * Get $enddate variable
 405      *
 406      * @desc Get $enddate variable
 407      * @return string $enddate
 408      * @see setEndDate()
 409      * @see $enddate
 410      */
 411      function &getEndDate() {
 412          $ret = (string) $this->enddate;
 413          return $ret;
 414      } // end function
 415  
 416      /**
 417      * Get $transp variable
 418      *
 419      * @desc Get $transp variable
 420      * @return (int) $transp
 421      * @see setTransp()
 422      * @see $transp
 423      */
 424      function &getTransp() {
 425          $transps = (array) array('OPAQUE','TRANSPARENT');
 426          $ret = (string) ((array_key_exists($this->transp, $transps)) ? $transps[$this->transp] : $transps[0]);
 427          return $ret;
 428      } // end function
 429  
 430      /**
 431      * Get $uid variable
 432      *
 433      * @desc Get $uid variable
 434      * @return string $uid
 435      * @see setUID()
 436      * @see $uid
 437      */
 438      function &getUID() {
 439          $ret = (string) $this->uid;
 440          return $ret;
 441      } // end function
 442  
 443      /**
 444      * Get $alarm object
 445      *
 446      * @desc Get $attendees variable
 447      * @return string $attendees
 448      * @see setAttendees()
 449      * @see $attendees
 450      * @since 1.001 - 2002-10-10
 451      */
 452      function &getAlarm() {
 453          $ret = ((is_object($this->alarm)) ? $this->alarm : FALSE);
 454          return $ret;
 455      } // end function
 456      /**#@-*/
 457  } // end class iCalEvent
 458  ?>


Généré le : Thu Nov 29 14:38:42 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics