summaryrefslogtreecommitdiffstats
path: root/apps/calendar
diff options
context:
space:
mode:
authorGeorg Ehrke <georg.stefan.germany@googlemail.com>2011-08-31 17:29:38 +0200
committerGeorg Ehrke <georg.stefan.germany@googlemail.com>2011-08-31 17:29:38 +0200
commit9a60313c3b7a1abd3aa75d3c914682bfbd03fb07 (patch)
treee918f2d9bf51d3cffd163390b6ce9a574aa20ce1 /apps/calendar
parent57ecf25da71648551dc311e7cd1461de9b276fee (diff)
downloadnextcloud-server-9a60313c3b7a1abd3aa75d3c914682bfbd03fb07.tar.gz
nextcloud-server-9a60313c3b7a1abd3aa75d3c914682bfbd03fb07.zip
commit changes of Bart Visscher, see http://gitorious.org/owncloud-dump/owncloud-dump/commits/calendar
Diffstat (limited to 'apps/calendar')
-rw-r--r--apps/calendar/ajax/activation.php27
-rwxr-xr-xapps/calendar/ajax/getcal.php4
-rw-r--r--apps/calendar/appinfo/database.xml10
-rwxr-xr-xapps/calendar/js/calendar.js50
-rwxr-xr-xapps/calendar/js/calendar_init.js8
-rw-r--r--apps/calendar/lib/calendar.php17
-rw-r--r--apps/calendar/templates/part.choosecalendar.php4
-rw-r--r--apps/calendar/templates/part.getcal.php57
8 files changed, 146 insertions, 31 deletions
diff --git a/apps/calendar/ajax/activation.php b/apps/calendar/ajax/activation.php
new file mode 100644
index 00000000000..adf44468c28
--- /dev/null
+++ b/apps/calendar/ajax/activation.php
@@ -0,0 +1,27 @@
+<?php
+/*************************************************
+ * ownCloud - Calendar Plugin *
+ * *
+ * (c) Copyright 2011 Bart Visscher *
+ * author: Georg Ehrke *
+ * email: ownclouddev at georgswebsite dot de *
+ * homepage: ownclouddev.georgswebsite.de *
+ * manual: ownclouddev.georgswebsite.de/manual *
+ * License: GNU AFFERO GENERAL PUBLIC LICENSE *
+ * *
+ * If you are not able to view the License, *
+ * <http://www.gnu.org/licenses/> *
+ * <http://ownclouddev.georgswebsite.de/license/> *
+ * please write to the Free Software Foundation. *
+ * Address: *
+ * 59 Temple Place, Suite 330, Boston, *
+ * MA 02111-1307 USA *
+ *************************************************/
+require_once ("../../../lib/base.php");
+if(!OC_USER::isLoggedIn()) {
+ die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
+}
+$calendarid = $_POST['calendarid'];
+OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
+$cal = OC_Calendar_Calendar::findCalendar($calendarid);
+echo $cal['active']; \ No newline at end of file
diff --git a/apps/calendar/ajax/getcal.php b/apps/calendar/ajax/getcal.php
index 06ebebc83a0..702c0e057ba 100755
--- a/apps/calendar/ajax/getcal.php
+++ b/apps/calendar/ajax/getcal.php
@@ -17,8 +17,10 @@
* 59 Temple Place, Suite 330, Boston, *
* MA 02111-1307 USA *
*************************************************/
-require_once ("../../lib/base.php");
+require_once ("../../../lib/base.php");
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
+$output = new OC_TEMPLATE("calendar", "part.getcal");
+$output -> printpage();
?> \ No newline at end of file
diff --git a/apps/calendar/appinfo/database.xml b/apps/calendar/appinfo/database.xml
index 36fd56a0516..0d7ec188dfb 100644
--- a/apps/calendar/appinfo/database.xml
+++ b/apps/calendar/appinfo/database.xml
@@ -135,7 +135,15 @@
<notnull>false</notnull>
<length>100</length>
</field>
-
+
+ <field>
+ <name>active</name>
+ <type>integer</type>
+ <default>1</default>
+ <notnull>true</notnull>
+ <length>4</length>
+ </field>
+
<field>
<name>ctag</name>
<type>integer</type>
diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js
index 82e0c3592cd..eb64418bd03 100755
--- a/apps/calendar/js/calendar.js
+++ b/apps/calendar/js/calendar.js
@@ -1,7 +1,7 @@
/*************************************************
* ownCloud - Calendar Plugin *
* *
- * (c) Copyright 2011 Georg Ehrke *
+ * (c) Copyright 2011 Georg Ehrke, Bart Visscher *
* author: Georg Ehrke *
* email: ownclouddev at georgswebsite dot de *
* homepage: ownclouddev.georgswebsite.de *
@@ -461,18 +461,20 @@ function oc_cal_switch2today() {
}
function oc_cal_update_eventsvar(loadyear) {
- $("#js_events").load(oc_webroot + "/apps/calendar/ajax/ajax.php?task=load_events&year=" + loadyear);
- if(document.getElementById("js_events").innerHTML == "nosession") {
+ $.getJSON(oc_webroot + "/apps/calendar/ajax/getcal.php?year=" + loadyear, function(newevents, status) {
+ if(status == "nosession") {
alert("You are not logged in. That can happen if you don't use owncloud for a long time.");
- document.location(oc_webroot);
+ document.location.href = oc_webroot;
}
- if(document.getElementById("js_events").innerHTML == "parsingfail" || typeof (newevents) == "undefined") {
+ if(status == "parsingfail" || typeof (newevents) == "undefined") {
$(function() {
$( "#parsingfail_dialog" ).dialog();
});
} else {
- events.concat(newevents);
+ oc_cal_events[loadyear]= newevents[loadyear];
+ oc_cal_update_view('');
}
+ });
}
function oc_cal_load_cal(loadview) {
@@ -652,19 +654,20 @@ function oc_cal_load_events(loadview) {
newp.id = "onedayview_allday_" + eventnumber;
newp.className = "onedayview_event";
eventcontainer.appendChild(newp);
- document.getElementById("onedayview_allday_" + eventnumber).innerHTML = events[oc_cal_year][oc_cal_month][oc_cal_dayofmonth]["allday"][eventnumber]["description"];
+ newp.innerHTML = oc_cal_events[oc_cal_year][oc_cal_month][oc_cal_dayofmonth]["allday"][eventnumber]["description"];
eventnumber++;
}
}
for( i = 0; i <= 23; i++) {
if( typeof (oc_cal_events[oc_cal_year][oc_cal_month][oc_cal_dayofmonth][i]) != "undefined") {
var eventnumber = 1;
+ var eventcontainer = document.getElementById("onedayview_" + i);
while( typeof (oc_cal_events[oc_cal_year][oc_cal_month][oc_cal_dayofmonth][i][eventnumber]) != "undefined") {
var newp = document.createElement("p");
newp.id = "onedayview_" + i + "_" + eventnumber;
newp.className = "onedayview_event";
eventcontainer.appendChild(newp);
- document.getElementById("onedayview_" + i + "_" + eventnumber).innerHTML = events[oc_cal_year][oc_cal_month][oc_cal_dayofmonth][i][eventnumber]["description"];
+ newp.innerHTML = oc_cal_events[oc_cal_year][oc_cal_month][oc_cal_dayofmonth][i][eventnumber]["description"];
eventnumber++;
}
}
@@ -687,7 +690,7 @@ function oc_cal_load_events(loadview) {
newp.id = "oneweekview_" + weekdays[i] + "_allday_" + eventnumber;
newp.className = "oneweekview_event";
eventcontainer.appendChild(newp);
- document.getElementById("oneweekview_" + weekdays[i] + "_allday_" + eventnumber).innerHTML = oc_cal_events[oc_cal_year][loadevents_month][loadevents_days]["allday"][eventnumber]["description"];
+ newp.innerHTML = oc_cal_events[oc_cal_year][loadevents_month][loadevents_days]["allday"][eventnumber]["description"];
eventnumber++;
}
}
@@ -695,12 +698,12 @@ function oc_cal_load_events(loadview) {
if( typeof (oc_cal_events[oc_cal_year][loadevents_month][loadevents_days][time]) != "undefined") {
var eventnumber = 1;
var eventcontainer = document.getElementById("oneweekview_" + weekdays[i] + "_" + time);
- while( typeof (oc_cal_events[year][loadevents_month][loadevents_days][eventnumber]) != "undefined") {
+ while( typeof (oc_cal_events[oc_cal_year][loadevents_month][loadevents_days][time][eventnumber]) != "undefined") {
var newp = document.createElement("p");
- newp.id = "oneweekview_" + i + "_" + eventnumber;
+ newp.id = "oneweekview_" + weekdays[i] + "_" + time + "_" + eventnumber;
newp.className = "oneweekview_event";
eventcontainer.appendChild(newp);
- document.getElementById("oneweekview_" + i + "_" + eventnumber).innerHTML = oc_cal_events[oc_cal_year][loadevents_month][loadevents_days][i][eventnumber]["description"];
+ newp.innerHTML = oc_cal_events[oc_cal_year][loadevents_month][loadevents_days][time][eventnumber]["description"];
eventnumber++;
}
}
@@ -728,7 +731,7 @@ function oc_cal_load_events(loadview) {
newp.id = "fourweeksview_" + weekdays[weekdaynum] + "_" + weeknum + "_" + pnum;
newp.className = "fourweeksview_event";
eventcontainer.appendChild(newp);
- document.getElementById("fourweeksview_" + weekdays[weekdaynum] + "_" + weeknum + "_" + pnum).innerHTML = oc_cal_events[oc_cal_year][loadevents_month][loadevents_days]["allday"][eventnumber]["description"];
+ newp.innerHTML = oc_cal_events[oc_cal_year][loadevents_month][loadevents_days]["allday"][eventnumber]["description"];
eventnumber++;
pnum++;
}
@@ -737,12 +740,12 @@ function oc_cal_load_events(loadview) {
if( typeof (oc_cal_events[oc_cal_year][loadevents_month][loadevents_days][time]) != "undefined") {
var eventnumber = 1;
var eventcontainer = document.getElementById("events_fourweeksview_" + weekdays[weekdaynum] + "_" + weeknum);
- while( typeof (events[oc_cal_year][loadevents_month][loadevents_days][i][eventnumber]) != "undefined") {
+ while( typeof (oc_cal_events[oc_cal_year][loadevents_month][loadevents_days][time][eventnumber]) != "undefined") {
var newp = document.createElement("p");
- newp.id = "fourweeksview_" + i + "_" + eventnumber;
+ newp.id = "fourweeksview_" + weekdays[i] + "_" + i + "_" + eventnumber;
newp.className = "fourweeksview_event";
eventcontainer.appendChild(newp);
- document.getElementById("fourweeksview_" + i + "_" + eventnumber).innerHTML = oc_cal_events[year][loadevents_month][loadevents_days][i][eventnumber]["description"];
+ newp.innerHTML = oc_cal_events[oc_cal_year][loadevents_month][loadevents_days][time][eventnumber]["description"];
eventnumber++;
pnum++;
}
@@ -777,7 +780,7 @@ function oc_cal_load_events(loadview) {
newp.id = "onemonthview_" + weekdays[weekdaynum] + "_" + weeknum + "_" + pnum;
newp.className = "onemonthview_event";
eventcontainer.appendChild(newp);
- document.getElementById("onemonthview_" + weekdays[weekdaynum] + "_" + weeknum + "_" + pnum).innerHTML = oc_cal_events[oc_cal_year][loadevents_month][loadevents_days]["allday"][eventnumber]["description"];
+ newp.innerHTML = oc_cal_events[oc_cal_year][loadevents_month][loadevents_days]["allday"][eventnumber]["description"];
eventnumber++;
pnum++;
}
@@ -786,12 +789,12 @@ function oc_cal_load_events(loadview) {
if( typeof (oc_cal_events[oc_cal_year][loadevents_month][loadevents_days][time]) != "undefined") {
var eventnumber = 1;
var eventcontainer = document.getElementById("events_onemonthview_" + weekdays[weekdaynum] + "_" + weeknum);
- while( typeof (oc_cal_events[year][loadevents_month][loadevents_days][i][eventnumber]) != "undefined") {
+ while( typeof (oc_cal_events[oc_cal_year][loadevents_month][loadevents_days][time][eventnumber]) != "undefined") {
var newp = document.createElement("p");
- newp.id = "onemonthview_" + i + "_" + eventnumber;
+ newp.id = "onemonthview_" + weekdays[i] + "_" + time + "_" + eventnumber;
newp.className = "onemonthview_event";
eventcontainer.appendChild(newp);
- document.getElementById("onemonthview_" + i + "_" + eventnumber).innerHTML = oc_cal_events[oc_cal_year][loadevents_month][loadevents_days][i][eventnumber]["description"];
+ newp.innerHTML = oc_cal_events[oc_cal_year][loadevents_month][loadevents_days][time][eventnumber]["description"];
eventnumber++;
pnum++;
}
@@ -892,4 +895,11 @@ function oc_cal_choosecalendar(){
}else{
alert(t("calendar", "You can't open more than one dialog per site!"));
}
+}
+
+function oc_cal_calender_activation(checkbox, calendarid){
+ $.post(oc_webroot + "/apps/calendar/ajax/activation.php", { calendarid: calendarid, active: checkbox.checked?1:0 },
+ function(data) {
+ checkbox.checked = data == 1;
+ });
} \ No newline at end of file
diff --git a/apps/calendar/js/calendar_init.js b/apps/calendar/js/calendar_init.js
index 3b5d37161c7..4e71daabf3b 100755
--- a/apps/calendar/js/calendar_init.js
+++ b/apps/calendar/js/calendar_init.js
@@ -27,6 +27,7 @@ $(document).ready(function(){
alert("abc");
}
});
+ oc_cal_update_eventsvar(oc_cal_year);
});
//init date vars
var oc_cal_date = new Date();
@@ -52,8 +53,5 @@ var oc_cal_opendialog = 0;
var oc_cal_datemonthyear = String(oc_cal_dayofmonth) + String(oc_cal_month) + String(oc_cal_year);
var oc_cal_calendars = new Array();
//event vars
-var oc_cal_events = new Array(2011);
-oc_cal_events[2011] = new Array(0,1,2,3,4,5,6,7,8,9,10,11);
-oc_cal_events[2011][7] = new Array();
-oc_cal_events[2011][7][7] = new Array();
-oc_cal_events[2011][7][13] = new Array(); \ No newline at end of file
+var oc_cal_events = new Array();
+oc_cal_events[oc_cal_year] = new Array(0,1,2,3,4,5,6,7,8,9,10,11);
diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php
index 76f6b253b5d..e28e384ba88 100644
--- a/apps/calendar/lib/calendar.php
+++ b/apps/calendar/lib/calendar.php
@@ -42,6 +42,7 @@
* userid VARCHAR(255),
* displayname VARCHAR(100),
* uri VARCHAR(100),
+ * active INTEGER UNSIGNED NOT NULL DEFAULT '0',
* ctag INTEGER UNSIGNED NOT NULL DEFAULT '0',
* description TEXT,
* calendarorder INTEGER UNSIGNED NOT NULL DEFAULT '0',
@@ -56,8 +57,14 @@
*/
class OC_Calendar_Calendar{
public static function allCalendars($uid){
- $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_calendars WHERE userid = ?' );
- $result = $stmt->execute(array($uid));
+ $values = array($uid);
+ $active_where = '';
+ if (!is_null($active)){
+ $active_where = ' AND active = ?';
+ $values[] = $active;
+ }
+ $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*calendar_calendars WHERE userid = ?' . $active_where );
+ $result = $stmt->execute($values);
$calendars = array();
while( $row = $result->fetchRow()){
@@ -121,6 +128,12 @@ class OC_Calendar_Calendar{
return true;
}
+ public static function setCalendarActive($id,$active){
+ $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET active = ? WHERE id = ?' );
+ $stmt->execute(array($active, $id));
+ return true;
+ }
+
public static function touchCalendar($id){
$stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET ctag = ctag + 1 WHERE id = ?' );
$stmt->execute(array($id));
diff --git a/apps/calendar/templates/part.choosecalendar.php b/apps/calendar/templates/part.choosecalendar.php
index 0aef52b4388..3bd7e5ef591 100644
--- a/apps/calendar/templates/part.choosecalendar.php
+++ b/apps/calendar/templates/part.choosecalendar.php
@@ -4,8 +4,8 @@
$option_calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
for($i = 0; $i < count($option_calendars); $i++){
echo "<tr>";
- echo "<td width=\"20px\"><input id=\"checkbox_" . $option_calendars[$i]["id"] . "\" type=\"checkbox\"></td>";
- echo "<td><label for=\"checkbox_" . $option_calendars[$i]["id"] . "\">" . $option_calendars[$i]["displayname"] . "</label></td>";
+ echo "<td width=\"20px\"><input id=\"active_" . $option_calendars[$i]["id"] . "\" type=\"checkbox\" onClick=\"oc_cal_calender_activation(this, " . $option_calendars[$i]["id"] . ")\"></td>";
+ echo "<td><label for=\"active_" . $option_calendars[$i]["id"] . "\">" . $option_calendars[$i]["displayname"] . "</label></td>";
echo "<td width=\"20px\"><a style=\"display: block; opacity: 0.214133;\" href=\"#\" title=\"" . $l->t("Download") . "\" class=\"action\"><img src=\"/owncloud/core/img/actions/download.svg\"></a></td><td width=\"20px\"><a style=\"display: block; opacity: 0.214133;\" href=\"#\" title=\"" . $l->t("Rename") . "\" class=\"action\"><img src=\"/owncloud/core/img/actions/rename.svg\"></a></td>";
echo "</tr>";
}
diff --git a/apps/calendar/templates/part.getcal.php b/apps/calendar/templates/part.getcal.php
new file mode 100644
index 00000000000..2ee121620f0
--- /dev/null
+++ b/apps/calendar/templates/part.getcal.php
@@ -0,0 +1,57 @@
+<?php
+/*************************************************
+ * ownCloud - Calendar Plugin *
+ * *
+ * (c) Copyright 2011 Bart Visscher *
+ * author: Georg Ehrke *
+ * email: ownclouddev at georgswebsite dot de *
+ * homepage: ownclouddev.georgswebsite.de *
+ * manual: ownclouddev.georgswebsite.de/manual *
+ * License: GNU AFFERO GENERAL PUBLIC LICENSE *
+ * *
+ * If you are not able to view the License, *
+ * <http://www.gnu.org/licenses/> *
+ * <http://ownclouddev.georgswebsite.de/license/> *
+ * please write to the Free Software Foundation. *
+ * Address: *
+ * 59 Temple Place, Suite 330, Boston, *
+ * MA 02111-1307 USA *
+ *************************************************/
+$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
+$events = OC_Calendar_Calendar::allCalendarObjects($calendars[0]['id']);
+$select_year = $_GET["year"];
+$return_events = array();
+$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London");
+foreach($events as $event)
+{
+ if ($select_year != substr($event['startdate'], 0, 4))
+ continue;
+ $start_dt = new DateTime($event['startdate'], new DateTimeZone('UTC'));
+ $start_dt->setTimezone(new DateTimeZone($user_timezone));
+ $end_dt = new DateTime($event['enddate'], new DateTimeZone('UTC'));
+ $end_dt->setTimezone(new DateTimeZone($user_timezone));
+ $year = $start_dt->format('Y');
+ $month = $start_dt->format('n') - 1; // return is 0 based
+ $day = $start_dt->format('j');
+ $hour = $start_dt->format('G');
+
+ // hack
+ if (strstr($event['calendardata'], 'DTSTART;VALUE=DATE:')) {
+ $hour = 'allday';
+ }
+ $return_event = array();
+ foreach(array('id', 'calendarid', 'objecttype', 'repeating') as $prop)
+ {
+ $return_event[$prop] = $event[$prop];
+ }
+ $return_event['startdate'] = $start_dt->format('Y-m-d H:i');
+ $return_event['enddate'] = $end_dt->format('Y-m-d H:i');
+ $return_event['description'] = $event['summary'];
+ if (isset($return_events[$year][$month][$day][$hour])){
+ $return_events[$year][$month][$day][$hour][] = $return_event;
+ }else{
+ $return_events[$year][$month][$day][$hour] = array(1 => $return_event);
+ }
+}
+echo json_encode($return_events);
+?> \ No newline at end of file