diff --git a/apps/calendar/ajax/activation.php b/apps/calendar/ajax/activation.php new file mode 100644 index 0000000000..51c5777f64 --- /dev/null +++ b/apps/calendar/ajax/activation.php @@ -0,0 +1,27 @@ + * + * * + * 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(""); +} +$calendarid = $_POST['calendarid']; +OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']); +$cal = OC_Calendar_Calendar::findCalendar($calendarid); +echo $cal['active']; diff --git a/apps/calendar/appinfo/database.xml b/apps/calendar/appinfo/database.xml index 36fd56a051..159ca0127e 100644 --- a/apps/calendar/appinfo/database.xml +++ b/apps/calendar/appinfo/database.xml @@ -136,6 +136,14 @@ 100 + + active + integer + 1 + true + 4 + + ctag integer diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index c825fc1909..bfead8f393 100755 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -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; + }); +} diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php index 76f6b253b5..5a4bed1fbc 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', @@ -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)); diff --git a/apps/calendar/templates/part.choosecalendar.php b/apps/calendar/templates/part.choosecalendar.php index 0aef52b438..3bd7e5ef59 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 ""; - echo ""; - echo ""; + echo ""; + echo ""; echo "t("Download") . "\" class=\"action\">t("Rename") . "\" class=\"action\">"; echo ""; } diff --git a/apps/calendar/templates/part.getcal.php b/apps/calendar/templates/part.getcal.php index 5959564bad..3e9a8f5799 100644 --- a/apps/calendar/templates/part.getcal.php +++ b/apps/calendar/templates/part.getcal.php @@ -1,5 +1,5 @@