[ PHPXref.com ] [ Generated: Sun Jul 20 16:48:44 2008 ] [ Chaussette 1.0 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> export_ical.php (source)

   1  <?php
   2  include_once  "include.php";
   3  
   4  $user = User :: GetInstance($_SESSION["user"]);
   5  extract($_GET);
   6  extract($_POST);
   7  
   8  if ($action == 1) {
   9      $sql = new DBconnection();
  10      if (!isset ($groups) || $groups == null || !isset ($groups[0]) || $groups[0] == null || $groups[0] == "null" || $groups[0] == "0" || $groups[0] == 'undefined') {
  11          $groups[0] = $user->getLogin();
  12          $vars = array (1 => $user->getId());
  13          $result = $sql->query("events_for_a_user", $vars);
  14      } else {
  15          $vars = array (1 => $user->getId(), 2 => $group);
  16          $result = $sql->query("events_for_a_group", $vars);
  17      }
  18      $sql->close();
  19      header("Content-Type: application/octet-stream");
  20      header('Content-Disposition: attachment; filename="'."export_ical_".$groups[0].".ics".'"');
  21      header('Pragma: no-cache');
  22      header('Cache-Control: no-cache');
  23  
  24      header("Content-Type: text/x-vcalendar");
  25      echo "BEGIN:VCALENDAR\n";
  26      echo "VERSION:1.0\n";
  27      echo "X-WR-CALNAME:".$groups[0]."\n";
  28  
  29      for (; $row = $result->fetchRow();) {
  30          $start_time_hour = split(" ", $row[5]);
  31          $tmp_start_time_day = split("-", $start_time_hour[0]);
  32          $tmp_start_time_hour = split(":", $start_time_hour[1]);
  33          $end_time_hour = split(" ", $row[6]);
  34          $tmp_end_time_day = split("-", $end_time_hour[0]);
  35          $tmp_end_time_hour = split(":", $end_time_hour[1]);
  36          echo "BEGIN:VEVENT"."\n";
  37          echo "DTSTART:".$tmp_start_time_day[0].$tmp_start_time_day[1].$tmp_start_time_day[2]."T".$tmp_start_time_hour[0].$tmp_start_time_hour[1]."00"."\n";
  38          echo "UID:".$row[0]."\n";
  39          echo "SUMMARY:".$row[4]."\n";
  40          echo "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:".$row[7]."\n";
  41          echo "LOCATION:"."\n";
  42          echo "DTEND:".$tmp_end_time_day[0].$tmp_end_time_day[1].$tmp_end_time_day[2]."T".$tmp_end_time_hour[0].$tmp_end_time_hour[1]."00"."\n";
  43          echo "END:VEVENT"."\n";
  44      }
  45      echo "END:VCALENDAR"."\n";
  46  } else {
  47  
  48      $smarty = new My_Smarty();
  49      $sql = new DBconnection();
  50      $vars = array ($user->getId(),);
  51      $smarty->assign('groups', $sql->getAssoc("all_groups_for_a_user", $vars));
  52      $sql->close();
  53  
  54      $smarty->assign('selected_groups', $group);
  55      $smarty->assign('group', translate("group_assign_export_ical"));
  56  
  57      $smarty->assign("close", translate("Quitter"));
  58      $smarty->assign("ical_title", translate("export"));
  59      $smarty->assign("my_export", translate("my_export"));
  60  
  61      $smarty->display('export_ical.tpl');
  62  }
  63  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]