home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / calendar / delete_event.php < prev    next >
PHP Script  |  2004-03-08  |  4KB  |  138 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. $task = isset($_POST['task']) ? $_POST['task'] : '';
  22. $return_to = isset($_REQUEST['return_to']) ? $_REQUEST['return_to'] : $_SERVER['HTTP_REFERER'];
  23.  
  24. $calendar_id = isset($_REQUEST['calendar_id']) ? $_REQUEST['calendar_id'] : $cal->get_default_calendar($GO_SECURITY->user_id);
  25. $event_id = isset($_REQUEST['event_id']) ? $_REQUEST['event_id'] : 0;
  26. $calendar = $cal->get_calendar($calendar_id);
  27. $event = $cal->get_event($_REQUEST['event_id']);
  28. if ($calendar && $event)
  29. {
  30.     $calendar['write_permission'] = $GO_SECURITY->has_permission($GO_SECURITY->user_id, $calendar['acl_write']);
  31.     $event['write_permission'] = $GO_SECURITY->has_permission($GO_SECURITY->user_id, $event['acl_write']);
  32. }else
  33. {
  34.     exit($strDataError);
  35. }
  36.  
  37. switch($task)
  38. {
  39.     case 'delete':
  40.     if ($event['write_permission'])
  41.     {
  42.         $cal->delete_event($event_id);
  43.     }
  44.     /*$return_to_url = $GO_MODULES->url;
  45.     if ($return_to_url = parse_url($return_to))
  46.     {
  47.         parse_str($return_to_url['query'], $query_str);
  48.         if (isset($query_str['return_to']))
  49.         {
  50.             $return_to = $query_str['return_to'];
  51.         }
  52.     }*/
  53.  
  54.     header('Location: '.$return_to);
  55.     exit();
  56.     break;
  57.  
  58.     case 'unsubscribe':
  59.         if ($calendar['write_permission'])
  60.         {
  61.             if ($cal->get_event_subscribtions($event_id) < 2)
  62.             {
  63.                 if($cal->delete_event($event_id))
  64.                 {
  65.                     $GO_SECURITY->delete_acl($event['acl_read']);
  66.                     $GO_SECURITY->delete_acl($event['acl_write']);
  67.                 }
  68.  
  69.             }else
  70.             {
  71.                 $cal->unsubscribe_event($event_id, $calendar_id);
  72.             }
  73.         }
  74.         /*$return_to_url = $GO_MODULES->url;
  75.         if ($return_to_url = parse_url($return_to))
  76.         {
  77.             if (isset($return_to_url['query']))
  78.             {
  79.                 parse_str($return_to_url['query'], $query_str);
  80.                 if (isset($query_str['return_to']))
  81.                 {
  82.                     $return_to = $query_str['return_to'];
  83.                 }
  84.             }
  85.         }*/
  86.  
  87.         header('Location: '.$return_to);
  88.         exit();
  89.     break;
  90.  
  91. }
  92.  
  93. require($GO_THEME->theme_path.'header.inc');
  94. ?>
  95. <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  96. <input type="hidden" name="event_id" value="<?php echo $event_id; ?>" />
  97. <input type="hidden" name="calendar_id" value="<?php echo $calendar_id; ?>" />
  98. <input type="hidden" name="return_to" value="<?php echo $return_to; ?>" />
  99. <input type="hidden" name="task" value="<?php echo $task; ?>" />
  100.  
  101. <table border="0" cellpadding="2">
  102. <tr>
  103.     <td>
  104.     <table border="0" cellpadding="4">
  105.     <tr>
  106.         <td><img src="<?php echo $GO_THEME->images['questionmark']; ?>" border="0" /></td><td align="center"><h2><?php echo $sc_delete_event; ?></h2></td>
  107.     </tr>
  108.     </table>
  109.     </td>
  110. </tr>
  111. <tr>
  112.     <td><?php echo $sc_delete_pre." '".$event['name']."' ".$sc_delete_suf; ?></td>
  113. </tr>
  114. <tr>
  115.     <td>
  116.     <br />
  117.     <?php
  118.     if ($calendar['write_permission'])
  119.     {
  120.         $button = new button($sc_from_calendar,"javascript:document.forms[0].task.value='unsubscribe';document.forms[0].submit();");
  121.         echo '  ';
  122.     }
  123.     if ($event['write_permission'])
  124.     {
  125.         $button = new button($sc_enitrely,"javascript:document.forms[0].task.value='delete';document.forms[0].submit();");
  126.  
  127.     }
  128.     echo '  ';
  129.     $button = new button($cmdCancel,"javascript:document.location='".$return_to."';");
  130.     ?>
  131.     </td>
  132. </tr>
  133. </table>
  134. </form>
  135. <?php
  136.  
  137. require($GO_THEME->theme_path.'footer.inc');
  138. ?>