35 lines
1.5 KiB
PHP
35 lines
1.5 KiB
PHP
<?php
|
|
/*************************************************
|
|
* ownCloud - Calendar Plugin *
|
|
* *
|
|
* (c) Copyright 2011 Bart Visscher *
|
|
* License: GNU AFFERO GENERAL PUBLIC LICENSE *
|
|
* *
|
|
* If you are not able to view the License, *
|
|
* <http://www.gnu.org/licenses/> *
|
|
* please write to the Free Software Foundation. *
|
|
* Address: *
|
|
* 59 Temple Place, Suite 330, Boston, *
|
|
* MA 02111-1307 USA *
|
|
*************************************************/
|
|
require_once('../../../lib/base.php');
|
|
|
|
$l10n = new OC_L10N('calendar');
|
|
|
|
// We send json data
|
|
header( "Content-Type: application/jsonrequest" );
|
|
|
|
// Check if we are a user
|
|
if( !OC_User::isLoggedIn()){
|
|
echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t("Authentication error") )));
|
|
exit();
|
|
}
|
|
|
|
$userid = OC_User::getUser();
|
|
$calendarid = OC_Calendar_Calendar::addCalendar($userid, $_POST['name'], $_POST['description'], 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']);
|
|
OC_Calendar_Calendar::setCalendarActive($calendarid, 1);
|
|
$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
|
|
$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields');
|
|
$tmpl->assign('calendar', $calendar);
|
|
echo json_encode( array( "status" => "error", "data" => $tmpl->fetchPage().'' ));
|