home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / calendar / accept.php next >
Encoding:
PHP Script  |  2004-03-08  |  5.1 KB  |  172 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.  
  13.  
  14. require("../../Group-Office.php");
  15.  
  16. require($GO_CONFIG->class_path."calendar.class.inc");
  17. $cal = new calendar();
  18. require($GO_LANGUAGE->get_language_file('calendar'));
  19.  
  20. if ($_SERVER['REQUEST_METHOD'] == "POST")
  21. {
  22.     if (isset($_POST['calendars']))
  23.     {
  24.         $cal->set_event_status($_REQUEST['event_id'], '1', $_POST['email']);
  25.         while($calendar_id = array_shift($_POST['calendars']))
  26.         {
  27.             if (!$cal->event_is_subscribed($_POST['event_id'], $calendar_id))
  28.             {
  29.                 if ($cal->subscribe_event($_POST['event_id'], $calendar_id))
  30.                 {
  31.                     if (!$cal->set_event_status($_POST['event_id'], '1', $_POST['email']))
  32.                     {
  33.                         $error = true;
  34.                     }
  35.                 }else
  36.                 {
  37.                     $error = true;
  38.                 }
  39.             }
  40.         }
  41.         require($GO_THEME->theme_path.'header.inc');
  42.         echo '<table border="0" cellpadding="10" cellspacing="0"><tr><td><h1>'.$sc_accept_title.'</h1>';
  43.         echo $sc_accept_confirm;
  44.  
  45.         if (isset($error))
  46.             echo '<p class="Error">'.$strSaveError.'</p>';
  47.  
  48.         echo '</td></tr></table>';
  49.         require($GO_THEME->theme_path.'footer.inc');
  50.         exit();
  51.     }else
  52.     {
  53.         $feedback = $sc_select_calendar_please;
  54.     }
  55. }
  56.  
  57.  
  58. $event = $cal->get_event($_REQUEST['event_id']);
  59. if ($event && $_REQUEST['email'] != '')
  60. {
  61.     if ($_REQUEST['member'] == "true")
  62.     {
  63.         $GO_SECURITY->authenticate(false);
  64.         $module = $GO_MODULES->get_module('calendar');
  65.         if ($GO_SECURITY->has_permission($GO_SECURITY->user_id, $module['acl_read']) || $GO_SECURITY->has_permission($GO_SECURITY->user_id, $module['acl_write']))
  66.         {
  67.             require($GO_THEME->theme_path.'header.inc');
  68.  
  69.             echo '<table border="0" cellpadding="10" cellspacing="0"><tr><td><h1>'.$sc_accept_title.'</h1></td></tr><tr><td>';
  70.  
  71.             if (isset($feedback))
  72.             {
  73.                 echo '<p class="Error">'.$feedback.'</p>';
  74.             }
  75.             if (!$GO_SECURITY->has_permission($GO_SECURITY->user_id, $event["acl_read"]) && !$GO_SECURITY->has_permission($GO_SECURITY->user_id, $event["acl_write"]))
  76.             {
  77.                 $GO_SECURITY->add_user_to_acl($GO_SECURITY->user_id, $event["acl_read"]);
  78.             }
  79.  
  80.             $calendar_count = $cal->get_subscribed($GO_SECURITY->user_id);
  81.             $calendar_id = isset($_REQUEST['calendar_id']) ? $_REQUEST['calendar_id'] : 0;
  82.  
  83.             if($calendar_count > 1)
  84.             {
  85.                 echo $sc_select_calendar.': ';
  86.                 echo '<form name="accept" method="post" action="'.$_SERVER['PHP_SELF'].'">';
  87.                 echo '<input type="hidden" name="email" value="'.$_REQUEST['email'].'" />';
  88.                 echo '<input type="hidden" name="event_id" value="'.$_REQUEST['event_id'].'" />';
  89.                 echo '<input type="hidden" name="member" value="'.$_REQUEST['member'].'" />';
  90.                 echo '<table border="0">';
  91.  
  92.                 while ($cal->next_record())
  93.                 {
  94.                     if ($GO_SECURITY->has_permission($GO_SECURITY->user_id, $cal->f('acl_write')))
  95.                     {
  96.                         $calendars_check = (isset($_POST['calendars']) && in_array($cal->f('id'), $_POST['calendars'])) ? 'checked' : '';
  97.                         echo '<tr><td><input type="checkbox" name="calendars[]" value="'.$cal->f('id').'" '.$calendars_check.'  /></td><td>'.$cal->f('name').'</td></tr>';
  98.                     }
  99.                 }
  100.                 echo '</table>';
  101.                 $button = new button($cmdOk, "javascript:document.forms[0].submit();");
  102.                 echo '</form>';
  103.             }else
  104.             {
  105.                 if ($calendar_count == 1)
  106.                 {
  107.                     $cal->next_record();
  108.                     $calendar_id = $cal->f('id');
  109.                     if ($calendar_id > 0)
  110.                     {
  111.                         if (!$cal->event_is_subscribed($_REQUEST['event_id'], $calendar_id))
  112.                         {
  113.                             if ($cal->subscribe_event($_REQUEST['event_id'], $calendar_id))
  114.                             {
  115.                                 if ($cal->set_event_status($_REQUEST['event_id'], '1', $_REQUEST['email']))
  116.                                 {
  117.                                     echo $sc_accept_confirm;
  118.                                 }else
  119.                                 {
  120.                                     echo $strSaveError;
  121.                                 }
  122.                             }else
  123.                             {
  124.                                 echo $strSaveError;
  125.                             }
  126.                         }else
  127.                         {
  128.                             if ($cal->set_event_status($_REQUEST['event_id'], '1', $_REQUEST['email']))
  129.                             {
  130.                                 echo $sc_accept_confirm;
  131.                             }else
  132.                             {
  133.                                 echo $strSaveError;
  134.                             }
  135.                         }
  136.                     }
  137.                 }else
  138.                 {
  139.                     echo $sc_no_calendars;
  140.                 }
  141.             }
  142.         }else
  143.         {
  144.             require($GO_THEME->theme_path.'header.inc');
  145.             echo '<table border="0"  cellspacing="0"><tr><td><h1>'.$sc_accept_title.'</h1>';
  146.             if ($cal->set_event_status($event_id,'1', $email))
  147.             {
  148.                 echo $sc_accept_confirm;
  149.             }
  150.         }
  151.     }else
  152.     {
  153.         require($GO_THEME->theme_path.'header.inc');
  154.         echo '<table border="0"  cellspacing="0"><tr><td><h1>'.$sc_accept_title.'</h1>';
  155.         if ($cal->set_event_status($_REQUEST['event_id'],'1', $_REQUEST['email']))
  156.         {
  157.             echo $sc_accept_confirm;
  158.         }
  159.     }
  160. }else
  161. {
  162.     require($GO_THEME->theme_path.'header.inc');
  163.  
  164.     echo '<table border="0" cellspacing="0"><tr><td class="Error"><h1>'.$sc_accept_title.'</h1>';
  165.  
  166.     echo $sc_bad_event;
  167. }
  168.  
  169. echo '</td></tr></table>';
  170. require($GO_THEME->theme_path.'footer.inc');
  171. ?>
  172.