home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / calendar / show_event.php < prev   
Encoding:
PHP Script  |  2004-03-08  |  11.1 KB  |  383 lines

  1. <?php
  2. /*
  3. Copyright Intermesh 2003
  4. Author: Merijn Schering <mschering@intermesh.nl>
  5. Version: 1.0 Release date: 08 July 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12. require("../../Group-Office.php");
  13. $GO_SECURITY->authenticate();
  14. $GO_MODULES->authenticate('calendar');
  15.  
  16. require($GO_LANGUAGE->get_language_file('calendar'));
  17.  
  18. require($GO_CONFIG->class_path.'calendar.class.inc');
  19. $cal = new calendar();
  20.  
  21.  
  22. //get the local times
  23. $local_time = get_time();
  24. $year = isset($_REQUEST['year']) ? $_REQUEST['year'] : date("Y", $local_time);
  25. $month = isset($_REQUEST['month']) ? $_REQUEST['month'] : date("m", $local_time);
  26. $day = isset($_REQUEST['day']) ? $_REQUEST['day'] : date("j", $local_time);
  27. $hour = isset($_REQUEST['hour']) ? $_REQUEST['hour'] : date("H", $local_time);
  28. $min = isset($_REQUEST['min']) ? $_REQUEST['min'] : date("i", $local_time);
  29.  
  30. $task = isset($_POST['task']) ? $_POST['task'] : '';
  31. $return_to = isset($_REQUEST['return_to']) ? $_REQUEST['return_to'] : $_SERVER['HTTP_REFERER'];
  32.  
  33. $calendar_id = isset($_REQUEST['calendar_id']) ? $_REQUEST['calendar_id'] : $cal->get_default_calendar($GO_SECURITY->user_id);
  34. $event_id = isset($_REQUEST['event_id']) ? $_REQUEST['event_id'] : 0;
  35.  
  36. if (isset($status))
  37. {
  38.     $cal->set_event_status($event_id, $status, $_SESSION['GO_SESSION']['email']);
  39. }
  40.  
  41.  
  42. $event = $cal->get_event($event_id);
  43.  
  44. if ($calendar = $cal->get_calendar($calendar_id))
  45. {
  46.     $calendar['write_permission'] = $GO_SECURITY->has_permission($GO_SECURITY->user_id, $calendar['acl_write']);
  47. }else
  48. {
  49.     exit($strDataError);
  50. }
  51.  
  52. require($GO_THEME->theme_path.'header.inc');
  53.  
  54. echo '<form name="event" method="post" action="'.$_SERVER['PHP_SELF'].'">';
  55. echo '<input type="hidden" name="calendar_id" value="'.$calendar_id.'" />';
  56. echo '<input type="hidden" name="event_id" value="'.$event_id.'" />';
  57. echo '<input type="hidden" name="task" value="" />';
  58. echo '<input type="hidden" name="return_to" value="'.$return_to.'" />';
  59. ?>
  60. <table border="0" cellpadding="10">
  61. <tr>
  62.     <td valign="top">
  63.     <table border="0">
  64.     <tr>
  65.         <td><?php echo $strName; ?>:</td>
  66.         <td><?php echo $event['name']; ?></td>
  67.     </tr>
  68.     <tr>
  69.         <td><?php echo $strOwner; ?>:</td>
  70.         <td><?php echo show_profile($event['user_id'], '', 'normal'); ?></td>
  71.     </tr>
  72.  
  73.     <?php
  74.     if ($event['contact_id'] > 0)
  75.     {
  76.         echo '<tr><td>'.$sc_client.':</td>';
  77.         echo '<td>'.show_contact($event['contact_id'], '', rawurlencode($_SERVER['REQUEST_URI'])).'</td></tr>';
  78.     }
  79.     if ($event['description'] != '')
  80.     {
  81.         echo '<tr><td valign="top">'.$strDescription.':</td>';
  82.         echo '<td>'.text_to_html($event['description']).'</td></tr>';
  83.     }
  84.  
  85.     if ($event['location'] != '')
  86.     {
  87.         echo '<tr><td>'.$sc_location.':</td>';
  88.         echo '<td>'.$event['location'].'</td></tr>';
  89.     }
  90.  
  91.     echo '<tr><td>'.$sc_type.':</td>';
  92.     echo '<td>'.$sc_types[$event['repeat_type']].'</td></tr>';
  93.  
  94.     //don't calculate timezone offset for all day events
  95.     $timezone_offset = ($event['all_day_event'] == '0') ? ($_SESSION['GO_SESSION']['timezone']*3600) : 0;
  96.  
  97.     if ($event['all_day_event'] == '1')
  98.     {
  99.         $event_time_format = $_SESSION['GO_SESSION']['date_format'];
  100.     }else
  101.     {
  102.         $event_time_format = $_SESSION['GO_SESSION']['date_format'].' '.$_SESSION['GO_SESSION']['time_format'];
  103.     }
  104.  
  105.     switch($event['repeat_type'])
  106.     {
  107.         case REPEAT_NONE:
  108.             echo '<tr><td>'.$sc_start_at.':</td><td>'.date($event_time_format, $event['start_time']+$timezone_offset).'</td></tr>';
  109.             echo '<tr><td>'.$sc_end_at.':</td><td>'.date($event_time_format, $event['end_time']+$timezone_offset).'</td></tr>';
  110.         break;
  111.  
  112.         case REPEAT_WEEKLY:
  113.             if ($event['all_day_event'] == '0')
  114.             {
  115.                 echo '<tr><td>'.$sc_start_at.':</td><td>'.date($_SESSION['GO_SESSION']['time_format'], $event['start_time']+$timezone_offset).'</td></tr>';
  116.                 echo '<tr><td>'.$sc_end_at.':</td><td>'.date($_SESSION['GO_SESSION']['time_format'], $event['end_time']+$timezone_offset).'</td></tr>';
  117.             }
  118.  
  119.             echo '<tr><td>'.$sc_at_days.':</td><td>';
  120.  
  121.             $local_start_hour = date('H',$event['start_time']-$timezone_offset) + ($timezone_offset/3600);
  122.             if ($local_start_hour > 23)
  123.             {
  124.                 $local_start_hour = $local_start_hour - 24;
  125.                 $shift_day = 1;
  126.             }elseif($local_start_hour < 0)
  127.             {
  128.                 $local_start_hour = 24 + $local_start_hour;
  129.                 $shift_day = -1;
  130.             }else
  131.             {
  132.                 $shift_day = 0;
  133.             }
  134.  
  135.             if ($event['sun'] == 1)
  136.             {
  137.                 $event['days'][] = $full_days[0+$shift_day];
  138.             }
  139.             if ($event['mon'] == 1)
  140.             {
  141.                 $event['days'][] = $full_days[1+$shift_day];
  142.             }
  143.  
  144.             if ($event['tue'] == 1)
  145.             {
  146.                 $event['days'][] = $full_days[2+$shift_day];
  147.             }
  148.  
  149.             if ($event['wed'] == 1)
  150.             {
  151.                 $event['days'][] = $full_days[3+$shift_day];
  152.             }
  153.  
  154.             if ($event['thu'] == 1)
  155.             {
  156.                 $event['days'][] = $full_days[4+$shift_day];
  157.             }
  158.  
  159.             if ($event['fri'] == 1)
  160.             {
  161.                 $event['days'][] = $full_days[5+$shift_day];
  162.             }
  163.  
  164.             if ($event['sat'] == 1)
  165.             {
  166.                 $event['days'][] = $full_days[6]+$shift_day;
  167.             }
  168.             echo implode(', ', $event['days']);
  169.             echo '</td></tr>';
  170.             echo '<tr><td>'.$sc_cycle_end.':</td><td>';
  171.             if ($event['repeat_forever'] == 1)
  172.             {
  173.                 echo $sc_noend;
  174.             }else
  175.             {
  176.                 echo date($_SESSION['GO_SESSION']['date_format'].' '.$_SESSION['GO_SESSION']['time_format'], $event['repeat_end_time']);
  177.             }
  178.             echo '</td></tr>';
  179.  
  180.         break;
  181.  
  182.         case REPEAT_DAILY:
  183.             if ($event['all_day_event'] == '0')
  184.             {
  185.                 echo '<tr><td>'.$sc_start_at.':</td><td>'.date($_SESSION['GO_SESSION']['time_format'], $event['start_time']+$timezone_offset).'</td></tr>';
  186.                 echo '<tr><td>'.$sc_end_at.':</td><td>'.date($_SESSION['GO_SESSION']['time_format'], $event['end_time']+$timezone_offset).'</td></tr>';
  187.             }
  188.             echo '<tr><td>'.$sc_cycle_end.':</td><td>';
  189.             if ($event['repeat_forever'] == 1)
  190.             {
  191.                 echo $sc_noend;
  192.             }else
  193.             {
  194.                 echo date($_SESSION['GO_SESSION']['date_format'].' '.$_SESSION['GO_SESSION']['time_format'], $event['repeat_end_time']);
  195.             }
  196.             echo '</td></tr>';
  197.         break;
  198.  
  199.         case REPEAT_MONTH_DATE:
  200.             $event['start_day'] = date('j', $event['start_time']);
  201.             $event['start_hour'] = date('G', $event['start_time']);
  202.             $event['start_min'] = date('i', $event['start_time']);
  203.  
  204.             $start_time = mktime($event['start_hour'], $event['start_min'], 0, $month, $event['start_day'], $year);
  205.             $end_time = $event['start_time'] + $event['end_time'] - $event['start_time'];
  206.  
  207.             echo '<tr><td>'.$sc_start_at.':</td><td>'.date($event_time_format, $start_time+$timezone_offset).'</td></tr>';
  208.             echo '<tr><td>'.$sc_end_at.':</td><td>'.date($event_time_format, $end_time+$timezone_offset).'</td></tr>';
  209.             echo '<tr><td>'.$sc_cycle_end.':</td><td>';
  210.             if ($event['repeat_forever'] == 1)
  211.             {
  212.                 echo $sc_noend;
  213.             }else
  214.             {
  215.                 echo date($_SESSION['GO_SESSION']['date_format'].' '.$_SESSION['GO_SESSION']['time_format'], $event['repeat_end_time']);
  216.             }
  217.             echo '</td></tr>';
  218.         break;
  219.  
  220.         case REPEAT_MONTH_DAY:
  221.             if ($event['all_day_event'] == '0')
  222.             {
  223.                 echo '<tr><td>'.$sc_start_at.':</td><td>'.date($_SESSION['GO_SESSION']['time_format'], $event['start_time']+$timezone_offset).'</td></tr>';
  224.                 echo '<tr><td>'.$sc_end_at.':</td><td>'.date($_SESSION['GO_SESSION']['time_format'], $event['end_time']+$timezone_offset).'</td></tr>';
  225.             }
  226.  
  227.             echo '<tr><td>'.$sc_at_days.':</td><td>';
  228.  
  229.             $local_start_hour = date('H',$event['start_time']-$timezone_offset) + ($timezone_offset/3600);
  230.             if ($local_start_hour > 23)
  231.             {
  232.                 $local_start_hour = $local_start_hour - 24;
  233.                 $shift_day = 1;
  234.             }elseif($local_start_hour < 0)
  235.             {
  236.                 $local_start_hour = 24 + $local_start_hour;
  237.                 $shift_day = -1;
  238.             }else
  239.             {
  240.                 $shift_day = 0;
  241.             }
  242.  
  243.             if ($event['sun'] == 1)
  244.             {
  245.                 $event['days'][] = $full_days[0+$shift_day];
  246.             }
  247.             if ($event['mon'] == 1)
  248.             {
  249.                 $event['days'][] = $full_days[1+$shift_day];
  250.             }
  251.  
  252.             if ($event['tue'] == 1)
  253.             {
  254.                 $event['days'][] = $full_days[2+$shift_day];
  255.             }
  256.  
  257.             if ($event['wed'] == 1)
  258.             {
  259.                 $event['days'][] = $full_days[3+$shift_day];
  260.             }
  261.  
  262.             if ($event['thu'] == 1)
  263.             {
  264.                 $event['days'][] = $full_days[4+$shift_day];
  265.             }
  266.  
  267.             if ($event['fri'] == 1)
  268.             {
  269.                 $event['days'][] = $full_days[5+$shift_day];
  270.             }
  271.  
  272.             if ($event['sat'] == 1)
  273.             {
  274.                 $event['days'][] = $full_days[6]+$shift_day;
  275.             }
  276.             echo $month_times[$event['month_time']-1].' ';
  277.             echo implode(', ', $event['days']);
  278.             echo '</td></tr>';
  279.             echo '<tr><td>'.$sc_cycle_end.':</td><td>';
  280.             if ($event['repeat_forever'] == 1)
  281.             {
  282.                 echo $sc_noend;
  283.             }else
  284.             {
  285.                 echo date($_SESSION['GO_SESSION']['date_format'].' '.$_SESSION['GO_SESSION']['time_format'], $event['repeat_end_time']);
  286.             }
  287.             echo '</td></tr>';
  288.  
  289.         break;
  290.  
  291.         case REPEAT_YEARLY;
  292.  
  293.             $event['start_month'] = date('m', $event['start_time']);
  294.             $event['start_day'] = date('j', $event['start_time']);
  295.             $event['start_hour'] = date('G', $event['start_time']);
  296.             $event['start_min'] = date('i', $event['start_time']);
  297.  
  298.  
  299.             $start_time = mktime($event['start_hour'], $event['start_min'], 0, $event['start_month'], $event['start_day'], $year);
  300.             $end_time = $event['start_time'] + $event['end_time'] - $event['start_time'];
  301.  
  302.             echo '<tr><td>'.$sc_start_at.':</td><td>'.date($event_time_format, $start_time+$timezone_offset).'</td></tr>';
  303.             echo '<tr><td>'.$sc_end_at.':</td><td>'.date($event_time_format, $end_time+$timezone_offset).'</td></tr>';
  304.             echo '<tr><td>'.$sc_cycle_end.':</td><td>';
  305.             if ($event['repeat_forever'] == 1)
  306.             {
  307.                 echo $sc_noend;
  308.             }else
  309.             {
  310.                 echo date($_SESSION['GO_SESSION']['date_format'].' '.$_SESSION['GO_SESSION']['time_format'], $event['repeat_end_time']);
  311.             }
  312.             echo '</td></tr>';
  313.         break;
  314.     }
  315.  
  316.     echo '<tr><td colspan="2"><br />';
  317.     $button = new button($cmdClose, "javascript:document.location= '".$return_to."'");
  318.     echo '</td></tr>';
  319.     ?>
  320.     </table>
  321.     </td>
  322.     <td valign="top">
  323.     <?php
  324.     if ($cal->get_participants($event_id))
  325.     {
  326.         echo '<input type="hidden" name="status" />';
  327.         echo '<table border="0">';
  328.         echo '<tr><td><h3>'.$strName.'</td>';
  329.         echo '<td><h3>'.$strEmail.'</td>';
  330.         echo '<td><h3>'.$sc_status.'</td></tr>';
  331.  
  332.         while ($cal->next_record())
  333.         {
  334.             echo '<tr><td nowrap>'.show_profile_by_email($cal->f('email'), $cal->f('name')).' </td>';
  335.             echo '<td nowrap>'.mail_to($cal->f('email')).' </td><td>';
  336.             switch($cal->f('status'))
  337.             {
  338.                 case '0':
  339.                     echo $sc_not_responded;
  340.                 break;
  341.  
  342.                 case '1':
  343.                     echo $sc_accepted;
  344.                 break;
  345.  
  346.                 case '2':
  347.                     echo $sc_declined;
  348.                 break;
  349.  
  350.             }
  351.             echo '</td></tr>';
  352.         }
  353.         echo '</table>';
  354.         $status = $cal->get_event_status($event_id, $_SESSION['GO_SESSION']['email']);
  355.         if($status !== false)
  356.         {
  357.             echo '<br />';
  358.             switch ($status)
  359.             {
  360.                 case '0';
  361.                     $button = new button($sc_accept, "javascript:document.location='".$_SERVER['REQUEST_URI']."&status=1'");
  362.                     echo '  ';
  363.                     $button = new button($sc_decline, "javascript:document.location='".$_SERVER['REQUEST_URI']."&status=2'");
  364.                 break;
  365.  
  366.                 case '1';
  367.                     $button = new button($sc_decline, "javascript:document.location='".$_SERVER['REQUEST_URI']."&status=2'");
  368.                 break;
  369.  
  370.                 case '2';
  371.                     $button = new button($sc_accept, "javascript:document.location='".$_SERVER['REQUEST_URI']."&status=1'");
  372.                 break;
  373.             }
  374.         }
  375.     }
  376.     ?>
  377.     </td>
  378. </tr>
  379. </table>
  380. <?php
  381. require($GO_THEME->theme_path.'footer.inc');
  382. ?>
  383.