00001 <?PHP
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00037 class Webcal {
00038 var $localdb;
00039 var $heure = -1;
00040 var $duree = 0;
00041
00046 function
Webcal()
00047 {
00048 global $conf;
00049
00050 $this->localdb =
new Db($conf->webcal->db->type,
00051 $conf->webcal->db->host,
00052 $conf->webcal->db->user,
00053 $conf->webcal->db->pass,
00054 $conf->webcal->db->name);
00055 }
00056
00065 function
add($user, $date, $texte, $desc)
00066 {
00067
00068 $id = $this->
get_next_id();
00069
00070 $cal_id = $id;
00071 $cal_create_by = $user->webcal_login;
00072 $cal_date = strftime('%Y%m%d', $date);
00073 $cal_time = $this->heure;
00074 $cal_mod_date = strftime('%Y%m%d', time());
00075 $cal_mod_time = strftime('%H%M', time());
00076 $cal_duration = $this->duree;
00077 $cal_priority = 2;
00078 $cal_type =
"E";
00079 $cal_access =
"P";
00080 $cal_name = $texte;
00081 $cal_description = $desc;
00082
00083 $sql =
"INSERT INTO webcal_entry (cal_id, cal_create_by,cal_date,cal_time,cal_mod_date,
00084
cal_mod_time,cal_duration,cal_priority,cal_type, cal_access, cal_name,cal_description)";
00085
00086 $sql .=
" VALUES ($cal_id, '$cal_create_by', $cal_date, $cal_time,$cal_mod_date, $cal_mod_time,
00087
$cal_duration,$cal_priority,'$cal_type', '$cal_access', '$cal_name','$cal_description')";
00088
00089
if ( $this->localdb->query($sql) )
00090 {
00091
00092 $sql =
"INSERT INTO webcal_entry_user (cal_id, cal_login, cal_status)";
00093 $sql .=
" VALUES ($cal_id, '$cal_create_by', 'A')";
00094
00095
if ( $this->localdb->query($sql) )
00096 {
00097
00098 }
00099
else
00100 {
00101 $error = $this->localdb->error() . '<br>' .$sql;
00102 }
00103 }
00104
else
00105 {
00106 $error = $this->localdb->error() . '<br>' .$sql;
00107 }
00108
00109 $this->localdb->close();
00110 }
00111
00118 function
get_next_id()
00119 {
00120
00121 $sql =
"SELECT max(cal_id) FROM webcal_entry";
00122
00123
if ($this->localdb->query($sql))
00124 {
00125 $id = $this->localdb->result(0, 0) + 1;
00126
return $id;
00127 }
00128
else
00129 {
00130 print $this->localdb->error();
00131 }
00132 }
00133 }
00134 ?>