home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / admin / edit_calendar.inc < prev    next >
Encoding:
Text File  |  2003-03-16  |  2.1 KB  |  75 lines

  1. <?php
  2. /********************************************************
  3.     include/edit_calendar.inc
  4.     
  5.     (C)Copyright 2003 Ryo Chijiiwa <Ryo@IlohaMail.org>
  6.  
  7.     This file is part of IlohaMail, and released under GPL.
  8.     See COPYING, or http://www.fsf.org/copyleft/gpl.html
  9.     
  10.     PURPOSE:
  11.         Handle calendar item edits and deletes
  12.  
  13. ********************************************************/
  14.  
  15. include_once("../conf/db_conf.php");
  16. include_once("../include/idba.$DB_TYPE.inc");
  17. include_once("../include/array2sql.inc");
  18.  
  19. $db = new idba_obj;
  20. if (!$db->connect()){
  21.     echo "DB connection failed.";
  22.     exit;
  23. }
  24.  
  25. if (isset($edit_cal)){
  26.     $error = "";
  27.     
  28.     $beginDate = formatCalDate($start_month, $start_day, $start_year);
  29.     if (!$beginDate) $error .= "Invalid beginning date\n";
  30.     $endDate = formatCalDate($end_month, $end_day, $end_year);
  31.     if (!$endDate) $error .= "Invalid ending date\n";
  32.     
  33.     $beginTime = ($start_hour * 100) + $start_minute;
  34.     $endTime = ($end_hour * 100) + $end_minute;
  35.     
  36.     $pattern = "";
  37.     if (count($repeat_d)>0){
  38.         $pattern = "d:";
  39.         while (list($k,$d) = each($repeat_d)) $pattern .= "$k,";
  40.     }
  41.     if (count($repeat_w)>0){
  42.         $pattern .= " ";
  43.         while (list($k,$d) = each($repeat_w)) $pattern .= "w$k,";        
  44.     }else if (count($repeat_d)>0){
  45.         $pattern .= " w:all";
  46.     }
  47.     if ($repeat_monthly) $pattern .= " m:".substr($beginDate, 6);
  48.     if ($repeat_yearly) $pattern .= " y:".substr($beginDate, 4);
  49.     
  50.     $data["userID"] = $session_dataID;
  51.     $data["title"] = $title;
  52.     $data["place"] = $place;
  53.     $data["description"] = $description;
  54.     $data["participants"] = $participants;
  55.     $data["beginTime"] = $beginTime;
  56.     $data["endTime"] = $endTime;
  57.     $data["beginDate"] = $beginDate;
  58.     $data["endDate"] = $endDate;
  59.     $data["pattern"] = $pattern;
  60.     $data["color"] = $color;
  61.     
  62.     //echo implode(",",$data);
  63.     
  64.     $sql = Array2SQL($DB_CALENDAR_TABLE, $data, ($edit > 0 ? "UPDATE":"INSERT"));
  65.     if ($edit>0) $sql.= " WHERE id=$edit and userID=$session_dataID";
  66.     
  67.     $backend_result = $db->query($sql);
  68.     
  69.     $date = $beginDate;
  70. }else if (isset($delete_cal)){
  71.     $backend_query = "DELETE FROM $DB_CALENDAR_TABLE WHERE userID='$session_dataID' and id='$edit'";;
  72.     $backend_result = $db->query($backend_query);    
  73. }
  74.  
  75. ?>