Michal Szczotka <michal@tuxy.org> Calendar plugin.
authorphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 22 Jan 2002 08:27:21 +0000 (08:27 +0000)
committerphilippe_mingo <philippe_mingo@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 22 Jan 2002 08:27:21 +0000 (08:27 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@2196 7612ce4b-ef26-0410-bec9-ea0150e637f0

plugins/calendar/README [new file with mode: 0644]
plugins/calendar/calendar.php [new file with mode: 0644]
plugins/calendar/calendar_data.php [new file with mode: 0644]
plugins/calendar/day.php [new file with mode: 0644]
plugins/calendar/event_create.php [new file with mode: 0644]
plugins/calendar/event_delete.php [new file with mode: 0644]
plugins/calendar/event_edit.php [new file with mode: 0644]
plugins/calendar/functions.php [new file with mode: 0644]
plugins/calendar/setup.php [new file with mode: 0644]

diff --git a/plugins/calendar/README b/plugins/calendar/README
new file mode 100644 (file)
index 0000000..f7e5550
--- /dev/null
@@ -0,0 +1,25 @@
+SQCalendar 0.1
+GPL (C) 2001  Michal Szczotka <michal@tuxy.org>
+http://www.tuxy.org/index.php?path=/projects/sqcalendar/index.php
+
+********** DESCRIPTION ************
+
+Simple calendar plugin for Squirrel Mail (squirrelmail.org). As of now it has 
+month view and day view. Events can be created, deleted and updated.
+
+
+********** REQUIREMENTS  **********
+
+It works with squirrelmail 1.0.6 and 1.2.0-rc2 which are latest at the time 
+of writing
+
+********** INSTALLATION  **********
+
+SEE INSTALL
+
+*************** TODO **************
+
+- single entry of repetitve events (ex. birthday repeats every year)
+- reminder email/javascript/etc
+- weekly view
+
diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
new file mode 100644 (file)
index 0000000..442ab31
--- /dev/null
@@ -0,0 +1,140 @@
+<?php
+/*
+ *
+ *  calendar.php
+ *
+ *  Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
+ *  Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ *  Displays the main calendar page (month view).
+ *
+ *  18 Jan 2002 Adapted to official SM rules philippe@squirrelmail.org.
+ */
+
+require_once('calendar_data.php');
+require_once('functions.php');
+chdir('..');
+require_once('../src/validate.php');
+require_once('../functions/strings.php');
+require_once('../functions/date.php');
+require_once('../config/config.php');
+require_once('../functions/page_header.php');
+require_once('../src/load_prefs.php');
+
+//display upper part of month calendar view
+function startcalendar() {
+    global $year, $month, $day, $color;
+
+    $prev_date = mktime(0, 0, 0, $month - 1, 1, $year);
+    $act_date  = mktime(0, 0, 0, $month, 1, $year);
+    $next_date = mktime(0, 0, 0, $month + 1, 1, $year);
+    $prev_month = date( 'm', $prev_date );
+    $next_month = date( 'm', $next_date);
+    $prev_year = date( 'Y', $prev_date);
+    $next_year = date( 'Y', $next_date );
+
+    echo "<TR BGCOLOR=\"$color[0]\"><TD>" .
+         "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">" .
+         '<tr>'.
+         "<th><a href=\"$self?year=".($year-1)."&month=$month\">&lt;&lt;&nbsp;".($year-1)."</a></th>\n".
+         "<th><a href=\"$self?year=$prev_year&month=$prev_month\">&lt;&nbsp;" .
+         date_intl( 'M', $prev_date). "</a></th>\n".
+         "<th bgcolor=$color[0] colspan=3>" .
+         date_intl( 'F Y', $act_date ) . "</th>\n" .
+         "<th><a href=\"$self?year=$next_year&month=$next_month\">" .
+         date_intl( 'M', $next_date) . "&nbsp;&gt;</a></th>".
+         "<th><a href=\"$self?year=".($year+1)."&month=$month\">".($year+1)."&nbsp;&gt;&gt;</a></th>".
+         '</tr><tr>'.
+         "<th WIDTH=\"14%\" bgcolor=$color[5] width=90>" . _("Sunday") . '</th>'.
+         "<th WIDTH=\"14%\" bgcolor=$color[5] width=90>" . _("Monday") . '</th>'.
+         "<th WIDTH=\"14%\" bgcolor=$color[5] width=90>" . _("Tuesday") . '</th>'.
+         "<th WIDTH=\"14%\" bgcolor=$color[5] width=90>" . _("Wednesday") . '</th>'.
+         "<th WIDTH=\"14%\" bgcolor=$color[5] width=90>" . _("Thursday") . '</th>'.
+         "<th WIDTH=\"14%\" bgcolor=$color[5] width=90>" . _("Friday") . '</th>'.
+         "<th WIDTH=\"14%\" bgcolor=$color[5] width=90>" . _("Saturday") . '</th>'.
+        '</tr>';
+
+}
+
+//main logic for month view of calendar
+function drawmonthview() {
+    global $year, $month, $day, $color, $calendardata, $todayis;
+
+    $aday = 1 - date('w', mktime(0, 0, 0, $month, 1, $year));
+    $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
+    while ($aday <= $days_in_month) {
+        echo '<tr>';
+        for ($j=1; $j<=7; $j++) {
+            $cdate="$month";
+            ($aday<10)?$cdate=$cdate."0$aday":$cdate=$cdate."$aday";
+            $cdate=$cdate."$year";
+            if ( $aday <= $days_in_month && $aday > 0){
+                echo "<TD BGCOLOR=\"$color[4]\" height=50 valign=top>\n" .
+                     "<div align=right>";
+                echo(($cdate==$todayis) ? "<font size=-1 color=$color[1]>[ " . _("TODAY") . " ] " : "<font size=-1>");
+                echo "<a href=day.php?year=$year&month=$month&day=";
+                echo(($aday<10) ? "0" : "");
+                echo "$aday>$aday</a></font></div>";
+            } else {
+                echo "<TD BGCOLOR=\"$color[0]\">\n".
+                     "&nbsp;";
+            }
+            if (isset($calendardata[$cdate])){
+                $i=0;
+                while ($calfoo = each($calendardata[$cdate])) {
+                    $calbar = $calendardata[$cdate][$calfoo[key]];
+                    echo ($calbar[priority]==1) ? "<FONT COLOR=\"$color[1]\">$calbar[title]</FONT><br>\n" : "$calbar[title]<br>\n";
+                    $i=$i+1;
+                    if($i==2){
+                        break;
+                    }
+                }
+            }
+            echo "\n</TD>\n";
+            $aday++;
+        }
+        echo '</tr>';
+    }
+}
+
+//end of monthly view and form to jump to any month and year
+function endcalendar() {
+    global $year, $month, $day, $color;
+
+    echo "          <TR><TD COLSPAN=7>\n".
+         "          <FORM NAME=caljump ACTION=\"calendar.php\" METHOD=POST>\n".
+         "          <SELECT NAME=\"year\">\n";
+    select_option_year($year);
+    echo "          </SELECT>\n".
+         "          <SELECT NAME=\"month\">\n";
+    select_option_month($month);
+    echo "          </SELECT>\n".
+         '         <INPUT TYPE=SUBMIT VALUE="' . _("Go") . "\">\n".
+         "          </FORM>\n".
+         "          </TD></TR>\n".
+         "</TABLE></TD></TR></TABLE>\n";
+}
+
+
+if($month <= 0){
+    $month = date( 'm' );
+}
+if($year <= 0){
+    $year = date( 'Y' );
+}
+if($day <= 0){
+    $day = date( 'd' );
+}
+
+$todayis = date( 'mdY' );
+$calself=basename($PHP_SELF);
+
+displayPageHeader($color, 'None');
+calendar_header();
+readcalendardata();
+startcalendar();
+drawmonthview();
+endcalendar();
+
+?>
+</body></html>
\ No newline at end of file
diff --git a/plugins/calendar/calendar_data.php b/plugins/calendar/calendar_data.php
new file mode 100644 (file)
index 0000000..737537e
--- /dev/null
@@ -0,0 +1,113 @@
+<?php /* Modified at 1 places by ri_once */ ?>
+<?php /* 'php' Added by ri_once */
+/*
+ *  calendar_data.php
+ *
+ *  Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
+ *  Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ *  functions to operate on calendar data files.
+ *
+ *  18 Jan 2002 Adapted to official SM rules philippe@squirrelmail.org.
+ */
+
+// this is array that contains all events
+// it is three dimensional array with fallowing structure
+// $calendardata[date][time] = array(length,priority,title,message);
+$calendardata = array();
+
+//read events into array
+//data is | delimited, just like addresbook
+//files are structured like this:
+//date|time|length|priority|title|message);
+//files are divide by year for performance increase
+function readcalendardata() {
+    global $calendardata, $username, $data_dir, $year;
+
+    $filename = getHashedFile($username, $data_dir, "$username.$year.cal");
+
+    if (file_exists($filename)){
+        $fp = fopen ($filename,'r');
+    }
+    if ($fp){
+        while ($fdata = fgetcsv ($fp, 4096, '|')) {
+            $calendardata[$fdata[0]][$fdata[1]] = array( 'length' => $fdata[2],
+                                                         'priority' => $fdata[3],
+                                                         'title' => $fdata[4],
+                                                         'message' => $fdata[5],
+                                                         'reminder' => $fdata[6] );
+        }
+        fclose ($fp);
+    }
+}
+
+//makes events persistant
+function writecalendardata() {
+    global $calendardata, $username, $data_dir, $year;
+
+    $filetmp = getHashedFile($username, $data_dir, "$username.$year.cal.tmp");
+    $filename = getHashedFile($username, $data_dir, "$username.$year.cal");
+    $fp = fopen ($filetmp,"w");
+    if ($fp) {
+        while ( $calfoo = each ($calendardata)) {
+            while ( $calbar = each ($calfoo[value])) {
+                $calfoobar = $calendardata[$calfoo[key]][$calbar[key]];
+                $calstr = "$calfoo[key]|$calbar[key]|$calfoobar[length]|$calfoobar[priority]|$calfoobar[title]|$calfoobar[message]|$calfoobar[reminder]\n";
+                fwrite($fp, $calstr, 4096);
+            }
+
+        }
+        fclose ($fp);
+        rename($filetmp,$filename);
+    }
+}
+
+//deletes event from file
+function delete_event($date, $time) {
+    global $calendardata, $username, $data_dir, $year;
+
+    $filename = getHashedFile($username, $data_dir, "$username.$year.cal");
+    $fp = fopen ($filename,'r');
+    if ($fp){
+        while ($fdata = fgetcsv ($fp, 4096, "|")) {
+            if (($fdata[0]==$date) && ($fdata[1]==$time)){
+            // do nothing
+            } else {
+                $calendardata[$fdata[0]][$fdata[1]] = array( 'length' => $fdata[2],
+                                                             'priority' => $fdata[3],
+                                                             'title' => $fdata[4],
+                                                             'message' => $fdata[5],
+                                                             'reminder' => $fdata[6] );
+            }
+        }
+        fclose ($fp);
+    }
+    writecalendardata();
+
+}
+
+// same as delete but not saves calendar
+// saving is done inside event_edit.php
+function update_event($date, $time) {
+    global $calendardata, $username, $data_dir, $year;
+
+    $filename = getHashedFile($username, $data_dir, "$username.$year.cal");
+    $fp = fopen ($filename,'r');
+    if ($fp){
+        while ($fdata = fgetcsv ($fp, 4096, '|')) {
+            if (($fdata[0]==$date) && ($fdata[1]==$time)){
+            // do nothing
+            } else {
+                $calendardata[$fdata[0]][$fdata[1]] = array( 'length' => $fdata[2],
+                                                             'priority' => $fdata[3],
+                                                             'title' => $fdata[4],
+                                                             'message' => $fdata[5],
+                                                             'reminder' => $fdata[6] );
+            }
+        }
+        fclose ($fp);
+    }
+}
+
+
+?>
diff --git a/plugins/calendar/day.php b/plugins/calendar/day.php
new file mode 100644 (file)
index 0000000..44d6044
--- /dev/null
@@ -0,0 +1,137 @@
+<?php
+/*
+ *  day.php
+ *
+ *  Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
+ *  Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ *  Displays the day page (day view).
+ *
+ *  18 Jan 2002 Adapted to official SM rules philippe@squirrelmail.org.
+ */
+
+require_once('calendar_data.php');
+require_once('functions.php');
+chdir('..');
+require_once('../src/validate.php');
+require_once('../functions/strings.php');
+require_once('../functions/date.php');
+require_once('../config/config.php');
+require_once('../functions/page_header.php');
+require_once('../src/load_prefs.php');
+
+//displays head of day calendar view
+function day_header() {
+    global $color, $month, $day, $year, $prev_year, $prev_month, $prev_day,
+           $prev_date, $next_month, $next_day, $next_year, $next_date;
+
+    echo "    <TR BGCOLOR=\"$color[0]\"><TD>" .
+         "         <TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">\n" .
+         "         <TR><TH ALIGN=LEFT><A HREF=\"day.php?year=$prev_year&month=$prev_month&day=$prev_day\">&lt;&nbsp;".
+         date_intl('D',$prev_date)."</A></TH>\n" .
+         "         <TH>" .
+         date_intl( 'l, F d Y', mktime(0, 0, 0, $month, $day, $year)) . "</TH>\n" .
+         "         <TH ALIGN=RIGHT><A HREF=\"day.php?year=$next_year&month=$next_month&day=$next_day\">".
+         date_intl('D',$next_date)."&nbsp;&gt;</A></TH></TR>\n";
+}
+
+//events for specific day  are inserted into "daily" array
+function initialize_events() {
+    global $daily_events, $calendardata, $month, $day, $year;
+
+    for ($i=7;$i<23;$i++){
+        if ($i<10){
+            $evntime = '0' . $i . '00';
+        } else {
+            $evntime = $i . '00';
+            }
+        $daily_events[$evntime] = 'empty';
+    }
+
+    $cdate = $month . $day . $year;
+
+    if (isset($calendardata[$cdate])){
+        while ( $calfoo = each($calendardata[$cdate])){
+            $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo[key]];
+        }
+    }
+}
+
+//main loop for displaying daily events
+function display_events() {
+    global $daily_events, $month, $day, $year, $color;
+
+    ksort($daily_events,SORT_STRING);
+    $eo=0;
+    while ($calfoo = each($daily_events)){
+        if ($eo==0){
+            $eo=4;
+        } else {
+            $eo=0;
+        }
+
+        $ehour = substr($calfoo[key],0,2);
+        $eminute = substr($calfoo[key],2,2);
+        if (!is_array($calfoo[value])){
+            echo "         <TR BGCOLOR=\"$color[$eo]\"><TD>$ehour:$eminute</TD>\n" .
+                 "              <TD WIDTH=\"100%\">&nbsp;</TD>\n" .
+                 "              <TD ALIGN=CENTER><FONT SIZE=-1><A HREF=\"event_create.php?year=$year&month=$month&day=$day&hour=".substr($calfoo[key],0,2)."\">".
+                 _("ADD") . "</A></FONT></TD></TR>\n";
+        } else {
+            $calbar=$calfoo[value];
+            if ($calbar[length]!=0){
+                $elength = '-'.date('H:i',mktime($ehour,$eminute+$calbar[length],0,1,1,0));
+            } else {
+                $elength='';
+            }
+            echo "         <TR BGCOLOR=\"$color[$eo]\"><TD>$ehour:$eminute$elength</TD>\n" .
+                 "              <TD WIDTH=\"100%\">[";
+            echo ($calbar[priority]==1) ? "<FONT COLOR=\"$color[1]\">$calbar[title]</FONT>" : "$calbar[title]";
+            echo"] $calbar[message]&nbsp;</TD>\n" .
+                 "              <TD ALIGN=CENTER><FONT SIZE=-1><nobr>\n" .
+                 "<A HREF=\"event_edit.php?year=$year&month=$month&day=$day&hour=".substr($calfoo[key],0,2)."&minute=".substr($calfoo[key],2,2)."\">".
+                 _("EDIT") . "</A>&nbsp;|&nbsp;\n" .
+                 "<A HREF=\"event_delete.php?dyear=$year&dmonth=$month&dday=$day&dhour=".substr($calfoo[key],0,2)."&dminute=".substr($calfoo[key],2,2)."&year=$year&month=$month&day=$day\">" .
+                 _("DEL") . '</A>' .
+                 "              </nobr></FONT></TD></TR>\n";
+    }
+    $i++;
+}
+
+
+}
+
+if ($month <= 0){
+    $month = date( 'm');
+}
+if ($year <= 0){
+    $year = date( 'Y');
+}
+if ($day <= 0){
+    $day = date( 'd');
+}
+
+$prev_date = mktime(0, 0, 0, $month , $day - 1, $year);
+$next_date = mktime(0, 0, 0, $month , $day + 1, $year);
+$prev_day = date ('d',$prev_date);
+$prev_month = date ('m',$prev_date);
+$prev_year = date ('Y',$prev_date);
+$next_day = date ('d',$next_date);
+$next_month = date ('m',$next_date);
+$next_year = date ('Y',$next_date);
+
+$calself=basename($PHP_SELF);
+
+$daily_events = array();
+
+displayPageHeader($color, 'None');
+calendar_header();
+readcalendardata();
+day_header();
+initialize_events();
+display_events();
+
+
+?>
+</table></td></tr></table>
+</body></html>
diff --git a/plugins/calendar/event_create.php b/plugins/calendar/event_create.php
new file mode 100644 (file)
index 0000000..14ee40d
--- /dev/null
@@ -0,0 +1,123 @@
+<?php
+/*
+ *  event_create.php
+ *
+ *  Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
+ *  Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ *  functions to create a event for calendar.
+ *
+ *  18 Jan 2002 Adapted to official SM rules philippe@squirrelmail.org.
+ */
+
+require_once('calendar_data.php');
+require_once('functions.php');
+chdir('..');
+require_once('../src/validate.php');
+require_once('../functions/strings.php');
+require_once('../functions/date.php');
+require_once('../config/config.php');
+require_once('../functions/page_header.php');
+require_once('../src/load_prefs.php');
+
+//main form to gather event info
+function show_event_form() {
+    global $color, $editor_size, $year, $day, $month, $hour;
+
+    echo "\n<FORM name=eventscreate action=\"event_create.php\" METHOD=POST >\n".
+         "      <INPUT TYPE=hidden NAME=\"year\" VALUE=\"$year\">\n".
+         "      <INPUT TYPE=hidden NAME=\"month\" VALUE=\"$month\">\n".
+         "      <INPUT TYPE=hidden NAME=\"day\" VALUE=\"$day\">\n".
+         "      <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . ("Start time:") . "</TD>\n".
+         "      <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
+         "      <SELECT NAME=\"event_hour\">\n";
+    select_option_hour($hour);
+    echo "      </SELECT>\n" .
+         "      &nbsp;:&nbsp;\n" .
+         "      <SELECT NAME=\"event_minute\">\n";
+    select_option_minute("00");
+    echo "      </SELECT>\n".
+         "      </TD></TR>\n".
+         "      <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Length:") . "</TD>\n".
+         "      <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
+         "      <SELECT NAME=\"event_length\">\n";
+    select_option_length("0");
+    echo "      </SELECT>\n".
+         "      </TD></TR>\n".
+         "      <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Priority:") . "</TD>\n".
+         "      <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
+         "      <SELECT NAME=\"event_priority\">\n";
+    select_option_priority("0");
+    echo "      </SELECT>\n".
+         "      </TD></TR>\n".
+         "      <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Title:") . "</TD>\n".
+         "      <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
+         "      <INPUT TYPE=text NAME=\"event_title\" VALUE=\"\" SIZE=30 MAXLENGTH=50><BR>\n".
+         "      </TD></TR>\n".
+         "      <TR><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT COLSPAN=2>\n".
+         "      <TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD></TEXTAREA>\n".
+         "      </TD></TR>\n".
+         "      <TR><TD ALIGN=LEFT BGCOLOR=\"$color[4]\" COLSPAN=2><INPUT TYPE=SUBMIT NAME=send VALUE=\"" .
+         _("Set Event") . "\"></TD></TR>\n";
+    echo "</FORM>\n";
+}
+
+
+if ($month <= 0){
+    $month = date( 'm' );
+}
+if ($year <= 0){
+    $year = date( 'Y' );
+}
+if ($day <= 0){
+    $day = date( 'd' );
+}
+if ($hour <= 0){
+    $hour = '08';
+}
+
+$calself=basename($PHP_SELF);
+
+
+displayPageHeader($color, 'None');
+//load calendar menu
+calendar_header();
+
+
+echo "<TR BGCOLOR=\"$color[0]\"><TD>" .
+     "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">" .
+     '<tr><td COLSPAN=2>' .
+     date_intl( 'l, F d Y', mktime(0, 0, 0, $month, $day, $year)) .
+     '</td></tr>';
+//if form has not been filled in
+if(!isset($event_text)){
+    show_event_form();
+} else {
+    readcalendardata();
+    //make sure that event text is fittting in one line
+    $event_text=nl2br($event_text);
+    $event_text=ereg_replace ("\n", "", $event_text);
+    $event_text=ereg_replace ("\r", "", $event_text);
+    $calendardata["$month$day$year"]["$event_hour$event_minute"] = array("length"=>"$event_length","priority"=>"$event_priority","title"=>"$event_title","message"=>"$event_text");
+    //save
+    writecalendardata();
+    echo "  <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">\n".
+         "    <TR><TH COLSPAN=2 BGCOLOR=\"$color[4]\">\n".
+         _("Event Has been added!") . "<br>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Date:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$month/$day/$year</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Time:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_hour:$event_minute</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Title:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_title</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Message:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_text</TD></TR>\n".
+         "    <TR><TD COLSPAN=2 BGCOLOR=\"$color[4]\">\n".
+         "<A HREF=\"day.php?year=$year&month=$month&day=$day\">" . _("Day View") . "</A>\n".
+         "    </TD></TR>\n".
+         "  </TABLE>\n";
+}
+
+?>
+</table></td></tr></table>
+</body></html>
\ No newline at end of file
diff --git a/plugins/calendar/event_delete.php b/plugins/calendar/event_delete.php
new file mode 100644 (file)
index 0000000..a683f20
--- /dev/null
@@ -0,0 +1,101 @@
+<?php
+/*
+ *  event_delete.php
+ *
+ *  Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
+ *  Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ *  Functions to delete a event. 
+ *
+ *  18 Jan 2002 Adapted to official SM rules philippe@squirrelmail.org.
+ */
+
+require_once('calendar_data.php');
+require_once('functions.php');
+chdir('..');
+require_once('../src/validate.php');
+require_once('../functions/strings.php');
+require_once('../functions/date.php');
+require_once('../config/config.php');
+require_once('../functions/page_header.php');
+require_once('../src/load_prefs.php');
+
+function confirm_deletion()
+{
+    global $calself, $dyear, $dmonth, $dday, $dhour, $dminute, $calendardata, $color, $year, $month, $day;
+
+    $tmparray = $calendardata["$dmonth$dday$dyear"]["$dhour$dminute"];
+
+    echo "  <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">\n".
+         "    <TR><TH COLSPAN=2 BGCOLOR=\"$color[4]\">\n".
+         _("Do you really want to delete this event?") . "<br></th>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Date:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$dmonth/$dday/$dyear</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Time:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$dhour:$dminute</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Title:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[title]</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Message:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[message]</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">\n".
+         "    <FORM NAME=\"delevent\" METHOD=POST ACTION=\"$calself\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"dyear\" VALUE=\"$dyear\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"dmonth\" VALUE=\"$dmonth\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"dday\" VALUE=\"$dday\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"dhour\" VALUE=\"$dhour\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"dminute\" VALUE=\"$dminute\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"confirmed\" VALUE=\"yes\">\n".
+         "       <INPUT TYPE=SUBMIT VALUE=\"Yes\">\n".
+         "    </FORM>\n".
+         "    </TD><TD ALIGN=LEFT BGCOLOR=\"$color[4]\">\n".
+         "    <FORM NAME=\"nodelevent\" METHOD=POST ACTION=\"day.php\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
+         "       <INPUT TYPE=SUBMIT VALUE=\"No\">\n".
+         "    </FORM>\n".
+         "    </TD></TR>\n".
+         "  </TABLE>\n";
+
+
+}
+
+if ($month <= 0){
+    $month = date( 'm' );
+}
+if ($year <= 0){
+    $year = date( 'Y' );
+}
+if ($day <= 0){
+    $day = date( 'd' );
+}
+
+$calself=basename($PHP_SELF);
+
+displayPageHeader($color, 'None');
+//load calendar menu
+calendar_header();
+
+echo "<TR BGCOLOR=\"$color[0]\"><TD>".
+     "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">".
+     '<tr><td>'.
+     date_intl( 'l, F d Y', mktime(0, 0, 0, $month, $day, $year));
+if (isset($dyear) && isset($dmonth) && isset($dday) && isset($dhour) && isset($dminute)){
+    if (isset($confirmed)){
+        delete_event("$dmonth$dday$dyear", "$dhour$dminute");
+        echo '<br><br>' . _("Event deleted!") . "<BR>\n";
+        echo "<A HREF=\"day.php?year=$year&month=$month&day=$day\">Day View</A>\n";
+    } else {
+        readcalendardata();
+        confirm_deletion();
+    }
+} else {
+    echo '<br>' . _("Nothing to delete!");
+}
+
+?>
+</table></td></tr></table>
+</body></html>
\ No newline at end of file
diff --git a/plugins/calendar/event_edit.php b/plugins/calendar/event_edit.php
new file mode 100644 (file)
index 0000000..c8e9c0d
--- /dev/null
@@ -0,0 +1,209 @@
+<?php /* Modified at 1 places by ri_once */ ?>
+<?php
+/*
+ *  event_edit.php
+ *
+ *  Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
+ *  Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ *  Functions to edit an event.
+ *
+ *  18 Jan 2002 Adapted to official SM rules philippe@squirrelmail.org.
+ */
+
+require_once('calendar_data.php');
+require_once('functions.php');
+chdir('..');
+require_once('../src/validate.php');
+require_once('../functions/strings.php');
+require_once('../functions/date.php');
+require_once('../config/config.php');
+require_once('../functions/page_header.php');
+require_once('../src/load_prefs.php');
+
+// update event info
+function show_event_form() {
+    global $color, $editor_size, $year, $day, $month, $hour, $minute, $calendardata;
+
+    $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
+    echo "\n<FORM name=eventupdate action=\"event_edit.php\" METHOD=POST >\n".
+         "      <INPUT TYPE=hidden NAME=\"year\" VALUE=\"$year\">\n".
+         "      <INPUT TYPE=hidden NAME=\"month\" VALUE=\"$month\">\n".
+         "      <INPUT TYPE=hidden NAME=\"day\" VALUE=\"$day\">\n".
+         "      <INPUT TYPE=hidden NAME=\"hour\" VALUE=\"$hour\">\n".
+         "      <INPUT TYPE=hidden NAME=\"minute\" VALUE=\"$minute\">\n".
+         "      <INPUT TYPE=hidden NAME=\"updated\" VALUE=\"yes\">\n".
+         "      <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Date:") . "</TD>\n".
+         "      <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
+         "      <SELECT NAME=\"event_year\">\n";
+    select_option_year($year);
+    echo "      </SELECT>\n" .
+         "      &nbsp;&nbsp;\n" .
+         "      <SELECT NAME=\"event_month\">\n";
+    select_option_month($month);
+    echo "      </SELECT>\n".
+         "      &nbsp;&nbsp;\n".
+         "      <SELECT NAME=\"event_day\">\n";
+    select_option_day($day);
+    echo "      </SELECT>\n".
+         "      </TD></TR>\n".
+         "      <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Time:") . "</TD>\n".
+         "      <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
+         "      <SELECT NAME=\"event_hour\">\n";
+    select_option_hour($hour);
+    echo "      </SELECT>\n".
+         "      &nbsp;:&nbsp;\n".
+         "      <SELECT NAME=\"event_minute\">\n";
+    select_option_minute($minute);
+    echo "      </SELECT>\n".
+         "      </TD></TR>\n".
+         "      <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Length:") . "</TD>\n".
+         "      <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
+         "      <SELECT NAME=\"event_length\">\n";
+    select_option_length($tmparray[length]);
+    echo "      </SELECT>\n".
+         "      </TD></TR>\n".
+         "      <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Priority:") . "</TD>\n".
+         "      <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
+         "      <SELECT NAME=\"event_priority\">\n";
+    select_option_priority($tmparray[priority]);
+    echo "      </SELECT>\n".
+         "      </TD></TR>\n".
+         "      <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Title:") . "</TD>\n".
+         "      <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
+         "      <INPUT TYPE=text NAME=\"event_title\" VALUE=\"$tmparray[title]\" SIZE=30 MAXLENGTH=50><BR>\n".
+         "      </TD></TR>\n".
+         "      <TR><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT COLSPAN=2>\n".
+         "      <TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD>$tmparray[message]</TEXTAREA>\n".
+         "      </TD></TR>\n".
+         "      <TR><TD ALIGN=LEFT BGCOLOR=\"$color[4]\" COLSPAN=2><INPUT TYPE=SUBMIT NAME=send VALUE=\"" .
+         _("Update Event") . "\"></TD></TR>\n".
+         "</FORM>\n";
+}
+
+// self explenatory
+function confirm_update() {
+    global $calself, $year, $month, $day, $hour, $minute, $calendardata, $color, $event_year, $event_month, $event_day, $event_hour, $event_minute, $event_length, $event_priority, $event_title, $event_text;
+
+    $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
+
+    echo "  <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">\n".
+         "    <TR><TH COLSPAN=2 BGCOLOR=\"$color[4]\">\n".
+         _("Do you really want to change this event from:") . "<br>\n".
+         "    </TH></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Date:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$month/$day/$year</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Time:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$hour:$minute</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Priority:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[priority]</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Title:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[title]</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Message:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[message]</TD></TR>\n".
+         "    <TR><TH COLSPAN=2 BGCOLOR=\"$color[4]\">\n".
+         _("to:") . "<br>\n".
+         "    </TH></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Date:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_month/$event_day/$event_year</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . ("Time:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_hour:$event_minute</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Priority:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_priority</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Title:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_title</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Message:") . "</TD>\n".
+         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_text</TD></TR>\n".
+         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">\n".
+         "    <FORM NAME=\"updateevent\" METHOD=POST ACTION=\"$calself\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"hour\" VALUE=\"$hour\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"minute\" VALUE=\"$minute\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"event_year\" VALUE=\"$event_year\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"event_month\" VALUE=\"$event_month\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"event_day\" VALUE=\"$event_day\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"event_hour\" VALUE=\"$event_hour\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"event_minute\" VALUE=\"$event_minute\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"event_priority\" VALUE=\"$event_priority\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"event_length\" VALUE=\"$event_length\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"event_title\" VALUE=\"$event_title\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"event_text\" VALUE=\"$event_text\">\n".
+         "       <INPUT TYPE=hidden NAME=\"updated\" VALUE=\"yes\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"confirmed\" VALUE=\"yes\">\n".
+         '       <INPUT TYPE=SUBMIT VALUE="' . _("Yes") . "\">\n".
+         "    </FORM>\n".
+         "    </TD><TD ALIGN=LEFT BGCOLOR=\"$color[4]\">\n".
+         "    <FORM NAME=\"nodelevent\" METHOD=POST ACTION=\"day.php\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
+         "       <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
+         '       <INPUT TYPE=SUBMIT VALUE="' . _("No") . "\">\n".
+         "    </FORM>\n".
+         "    </TD></TR>\n".
+         "  </TABLE>\n";
+
+}
+
+if ($month <= 0){
+    $month = date( 'm' );
+}
+if ($year <= 0){
+    $year = date( 'Y' );
+}
+if ($day <= 0){
+    $day = date( 'd' );
+}
+if ($hour <= 0){
+    $hour = '08';
+}
+
+$calself=basename($PHP_SELF);
+
+displayPageHeader($color, 'None');
+//load calendar menu
+calendar_header();
+
+echo "<TR BGCOLOR=\"$color[0]\"><TD>" .
+     "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">" .
+     '<tr><td COLSPAN=2>' .
+     date_intl( 'l, F d Y', mktime(0, 0, 0, $month, $day, $year));
+?></td></tr><?php /* 'php' Added by ri_once */
+if (!isset($updated)){
+    //get changes to event
+    readcalendardata();
+    show_event_form();
+} else {
+    if (!isset($confirmed)){
+        //confirm changes
+        readcalendardata();
+        // strip event text so it fits in one line
+        $event_text=nl2br($event_text);
+        $event_text=ereg_replace ("\n", '', $event_text);
+        $event_text=ereg_replace ("\r", '', $event_text);
+        confirm_update();
+    } else {
+        update_event("$month$day$year", "$hour$minute");
+        echo "<tr><td>Event updated!</td></tr>\n";
+        echo "<tr><td><A HREF=\"day.php?year=$year&month=$month&day=$day\">Day View</A></td></tr>\n";
+        $fixdate = date( "mdY", mktime(0, 0, 0, $event_month, $event_day, $event_year));
+        //if event has been moved to different year then act accordingly
+        if ($year==$event_year){
+            $calendardata["$fixdate"]["$event_hour$event_minute"] = array("length"=>"$event_length","priority"=>"$event_priority","title"=>"$event_title","message"=>"$event_text");
+            writecalendardata();
+        } else {
+            writecalendardata();
+            $year=$event_year;
+            $calendardata = array();
+            readcalendardata();
+            $calendardata["$fixdate"]["$event_hour$event_minute"] = array("length"=>"$event_length","priority"=>"$event_priority","title"=>"$event_title","message"=>"$event_text");
+            writecalendardata();
+        }
+    }
+}
+
+?>
+</table></td></tr></table>
+</body></html>
+
diff --git a/plugins/calendar/functions.php b/plugins/calendar/functions.php
new file mode 100644 (file)
index 0000000..d6d3087
--- /dev/null
@@ -0,0 +1,146 @@
+<?php
+/*
+ *  functions.php
+ *
+ *  Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
+ *  Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ *  miscelenous functions.
+ *
+ *  18 Jan 2002 Adapted to official SM rules philippe@squirrelmail.org.
+ */
+
+
+function calendar_header() {
+    //Add Second layer ofCalendar links to upper menu
+    global $color,$year,$day,$month;
+
+    echo "<TABLE BGCOLOR=\"$color[0]\" BORDER=0 WIDTH=\"100%\" CELLSPACING=0 CELLPADDING=2>".
+         "<TR><TD ALIGN=left WIDTH=\"100%\">";
+
+    displayInternalLink("plugins/calendar/calendar.php?year=$year&month=$month",_("Month View"),"right");
+    echo "&nbsp;&nbsp\n";
+    displayInternalLink("plugins/calendar/day.php?year=$year&month=$month&day=$day",_("Day View"),"right");
+    echo "&nbsp;&nbsp\n";
+    // displayInternalLink("plugins/calendar/event_create.php?year=$year&month=$month&day=$day",_("Add Event"),"right");
+    // echo "&nbsp;&nbsp\n";
+    echo '</TD></TR>';
+
+}
+
+function select_option_length($selected) {
+
+    $eventlength = array(
+        "0" => _("0 min."),
+        "15" => _("15 min."),
+        "30" => _("35 min."),
+        "45" => _("45 min."),
+        "60" => _("1 hr."),
+        "90" => _("1.5 hr."),
+        "120" => _("2 hr."),
+        "150" => _("2.5 hr."),
+        "180" => _("3 hr."),
+        "210" => _("3.5 hr."),
+        "240" => _("4 hr."),
+        "300" => _("5 hr."),
+        "360" => _("6 hr.")
+    );
+
+    while( $bar = each($eventlength)) {
+        if($selected==$bar[key]){
+                echo "        <OPTION VALUE=\"".$bar[key]."\" SELECTED>".$bar[value]."</OPTION>\n";
+        } else {
+                echo "        <OPTION VALUE=\"".$bar[key]."\">".$bar[value]."</OPTION>\n";
+        }
+    }
+}
+
+function select_option_minute($selected) {
+    $eventminute = array(
+    "00"=>"00",
+    "05"=>"05",
+    "10"=>"10",
+    "15"=>"15",
+    "20"=>"20",
+    "25"=>"25",
+    "30"=>"30",
+    "35"=>"35",
+    "40"=>"40",
+    "45"=>"45",
+    "50"=>"50",
+    "55"=>"55"
+    );
+
+    while ( $bar = each($eventminute)) {
+        if ($selected==$bar[key]){
+                echo "        <OPTION VALUE=\"".$bar[key]."\" SELECTED>".$bar[value]."</OPTION>\n";
+        } else {
+                echo "        <OPTION VALUE=\"".$bar[key]."\">".$bar[value]."</OPTION>\n";
+        }
+    }
+}
+
+function select_option_hour($selected) {
+
+    for ($i=0;$i<24;$i++){
+        ($i<10)? $ih = "0" . $i : $ih = $i;
+        if ($ih==$selected){
+            echo "            <OPTION VALUE=\"$ih\" SELECTED>$i</OPTION>\n";
+        } else {
+            echo "            <OPTION VALUE=\"$ih\">$i</OPTION>\n";
+        }
+    }
+}
+
+function select_option_priority($selected) {
+    $eventpriority = array(
+        "0" => _("Normal"),
+        "1" => _("High"),
+    );
+
+    while( $bar = each($eventpriority)) {
+        if($selected==$bar[key]){
+                echo "        <OPTION VALUE=\"".$bar[key]."\" SELECTED>".$bar[value]."</OPTION>\n";
+        } else {
+                echo "        <OPTION VALUE=\"".$bar[key]."\">".$bar[value]."</OPTION>\n";
+        }
+    }
+}
+
+function select_option_year($selected) {
+
+    for ($i=1900;$i<2100;$i++){
+        if ($i==$selected){
+            echo "            <OPTION VALUE=\"$i\" SELECTED>$i</OPTION>\n";
+        } else {
+            echo "            <OPTION VALUE=\"$i\">$i</OPTION>\n";
+        }
+    }
+}
+
+function select_option_month($selected) {
+
+    for ($i=1;$i<13;$i++){
+        $im=date('m',mktime(0,0,0,$i,1,1));
+        $is = substr( _( date('F',mktime(0,0,0,$i,1,1)) ), 0, 3 );
+        if ($im==$selected){
+            echo "            <OPTION VALUE=\"$im\" SELECTED>$is</OPTION>\n";
+        } else {
+            echo "            <OPTION VALUE=\"$im\">$is</OPTION>\n";
+        }
+    }
+}
+
+function select_option_day($selected) {
+
+    for ($i=1;$i<32;$i++){
+        ($i<10)? $ih="0".$i : $ih=$i;
+        if ($i==$selected){
+            echo "            <OPTION VALUE=\"$ih\" SELECTED>$i</OPTION>\n";
+        } else {
+            echo "            <OPTION VALUE=\"$ih\">$i</OPTION>\n";
+        }
+    }
+}
+
+?>
\ No newline at end of file
diff --git a/plugins/calendar/setup.php b/plugins/calendar/setup.php
new file mode 100644 (file)
index 0000000..ed27dea
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+/*
+ *  setup.php
+ *
+ *  Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
+ *  Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ *  init plugin into squirrelmail
+ *
+ */
+
+
+function squirrelmail_plugin_init_calendar() {
+    global $squirrelmail_plugin_hooks;
+    $squirrelmail_plugin_hooks['menuline']['calendar'] = 'calendar';
+}
+
+function calendar() {
+    //Add Calendar link to upper menu
+    displayInternalLink('plugins/calendar/calendar.php',_("Calendar"),'right');
+    echo "&nbsp;&nbsp\n";
+}
+
+?>
\ No newline at end of file