Add enable/disable for calendars

This commit is contained in:
Bart Visscher 2011-08-29 13:15:36 +02:00
parent c306164426
commit f18af2c60d
6 changed files with 62 additions and 6 deletions

View file

@ -0,0 +1,27 @@
<?php
/*************************************************
* ownCloud - Calendar Plugin *
* *
* (c) Copyright 2011 Georg Ehrke *
* 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'];

View file

@ -136,6 +136,14 @@
<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>

View file

@ -896,3 +896,10 @@ function oc_cal_choosecalendar(){
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;
});
}

View file

@ -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',
@ -55,9 +56,15 @@
* This class manages our calendars
*/
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));
public static function allCalendars($uid, $active=null){
$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,13 @@ 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));

View file

@ -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>";
}

View file

@ -1,5 +1,5 @@
<?php
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
$events = OC_Calendar_Calendar::allCalendarObjects($calendars[0]['id']);
$select_year = $_GET["year"];
$return_events = array();