adding space between) and {
This commit is contained in:
parent
3e4bd9fbb5
commit
89ab3bae90
42 changed files with 379 additions and 379 deletions
2
ajax/cache/rescan.php
vendored
2
ajax/cache/rescan.php
vendored
|
@ -8,7 +8,7 @@
|
|||
OCP\JSON::checkLoggedIn();
|
||||
OCP\JSON::checkAppEnabled('calendar');
|
||||
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
|
||||
foreach($calendars as $calendar){
|
||||
foreach($calendars as $calendar) {
|
||||
OC_Calendar_Repeat::cleancalendar($calendar['id']);
|
||||
OC_Calendar_Repeat::generatecalendar($calendar['id']);
|
||||
}
|
||||
|
|
6
ajax/cache/status.php
vendored
6
ajax/cache/status.php
vendored
|
@ -9,13 +9,13 @@ OCP\JSON::checkLoggedIn();
|
|||
OCP\JSON::checkAppEnabled('calendar');
|
||||
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
|
||||
$allcached = true;
|
||||
foreach($calendars as $calendar){
|
||||
if(!OC_Calendar_Repeat::is_calendar_cached($calendar['id'])){
|
||||
foreach($calendars as $calendar) {
|
||||
if(!OC_Calendar_Repeat::is_calendar_cached($calendar['id'])) {
|
||||
$allcached = false;
|
||||
}
|
||||
}
|
||||
$l = new OC_L10N('calendar');
|
||||
if(!$allcached){
|
||||
if(!$allcached) {
|
||||
OCP\JSON::error(array('message'=>'Not all calendars are completely cached', 'l10n'=>$l->t('Not all calendars are completely cached')));
|
||||
}else{
|
||||
OCP\JSON::success(array('message'=>'Everything seems to be completely cached', 'l10n'=>$l->t('Everything seems to be completely cached')));
|
||||
|
|
|
@ -13,7 +13,7 @@ OCP\JSON::callCheck();
|
|||
|
||||
$calendarid = $_POST['calendarid'];
|
||||
$calendar = OC_Calendar_App::getCalendar($calendarid, true);
|
||||
if(!$calendar){
|
||||
if(!$calendar) {
|
||||
OCP\JSON::error(array('message'=>'permission denied'));
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ $cal = $_POST["calendarid"];
|
|||
|
||||
try {
|
||||
$del = OC_Calendar_Calendar::deleteCalendar($cal);
|
||||
if($del == true){
|
||||
if($del == true) {
|
||||
OCP\JSON::success();
|
||||
}else{
|
||||
OCP\JSON::error(array('error'=>'dberror'));
|
||||
|
|
|
@ -13,7 +13,7 @@ OCP\JSON::callCheck();
|
|||
|
||||
$calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions();
|
||||
$calendar = OC_Calendar_App::getCalendar($_GET['calendarid'], true);
|
||||
if(!$calendar){
|
||||
if(!$calendar) {
|
||||
OCP\JSON::error(array('message'=>'permission denied'));
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -11,13 +11,13 @@ OCP\JSON::checkLoggedIn();
|
|||
OCP\JSON::checkAppEnabled('calendar');
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
if(trim($_POST['name']) == ''){
|
||||
if(trim($_POST['name']) == '') {
|
||||
OCP\JSON::error(array('message'=>'empty'));
|
||||
exit;
|
||||
}
|
||||
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
|
||||
foreach($calendars as $cal){
|
||||
if($cal['displayname'] == $_POST['name']){
|
||||
foreach($calendars as $cal) {
|
||||
if($cal['displayname'] == $_POST['name']) {
|
||||
OCP\JSON::error(array('message'=>'namenotavailable'));
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -13,13 +13,13 @@ OCP\JSON::checkLoggedIn();
|
|||
OCP\JSON::checkAppEnabled('calendar');
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
if(trim($_POST['name']) == ''){
|
||||
if(trim($_POST['name']) == '') {
|
||||
OCP\JSON::error(array('message'=>'empty'));
|
||||
exit;
|
||||
}
|
||||
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
|
||||
foreach($calendars as $cal){
|
||||
if($cal['displayname'] == $_POST['name'] && $cal['id'] != $_POST['id']){
|
||||
foreach($calendars as $cal) {
|
||||
if($cal['displayname'] == $_POST['name'] && $cal['id'] != $_POST['id']) {
|
||||
OCP\JSON::error(array('message'=>'namenotavailable'));
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
OCP\JSON::checkLoggedIn();
|
||||
OCP\JSON::checkAppEnabled('calendar');
|
||||
$view = $_POST['v'];
|
||||
switch($view){
|
||||
switch($view) {
|
||||
case 'agendaWeek':
|
||||
case 'month';
|
||||
case 'list':
|
||||
|
|
|
@ -16,7 +16,7 @@ OCP\JSON::checkAppEnabled('calendar');
|
|||
$id = $_POST['id'];
|
||||
$data = OC_Calendar_App::getEventObject($id, false, false);
|
||||
|
||||
if(!$data){
|
||||
if(!$data) {
|
||||
OCP\JSON::error(array('data' => array('message' => OC_Calendar_App::$l10n->t('Wrong calendar'))));
|
||||
exit;
|
||||
}
|
||||
|
@ -58,97 +58,97 @@ $location = $vevent->getAsString('LOCATION');
|
|||
$categories = $vevent->getAsString('CATEGORIES');
|
||||
$description = $vevent->getAsString('DESCRIPTION');
|
||||
$last_modified = $vevent->__get('LAST-MODIFIED');
|
||||
if ($last_modified){
|
||||
if ($last_modified) {
|
||||
$lastmodified = $last_modified->getDateTime()->format('U');
|
||||
}else{
|
||||
$lastmodified = 0;
|
||||
}
|
||||
if($data['repeating'] == 1){
|
||||
if($data['repeating'] == 1) {
|
||||
$rrule = explode(';', $vevent->getAsString('RRULE'));
|
||||
$rrulearr = array();
|
||||
foreach($rrule as $rule){
|
||||
foreach($rrule as $rule) {
|
||||
list($attr, $val) = explode('=', $rule);
|
||||
$rrulearr[$attr] = $val;
|
||||
}
|
||||
if(!isset($rrulearr['INTERVAL']) || $rrulearr['INTERVAL'] == ''){
|
||||
if(!isset($rrulearr['INTERVAL']) || $rrulearr['INTERVAL'] == '') {
|
||||
$rrulearr['INTERVAL'] = 1;
|
||||
}
|
||||
if(array_key_exists('BYDAY', $rrulearr)){
|
||||
if(substr_count($rrulearr['BYDAY'], ',') == 0){
|
||||
if(strlen($rrulearr['BYDAY']) == 2){
|
||||
if(array_key_exists('BYDAY', $rrulearr)) {
|
||||
if(substr_count($rrulearr['BYDAY'], ',') == 0) {
|
||||
if(strlen($rrulearr['BYDAY']) == 2) {
|
||||
$repeat['weekdays'] = array($rrulearr['BYDAY']);
|
||||
}elseif(strlen($rrulearr['BYDAY']) == 3){
|
||||
}elseif(strlen($rrulearr['BYDAY']) == 3) {
|
||||
$repeat['weekofmonth'] = substr($rrulearr['BYDAY'], 0, 1);
|
||||
$repeat['weekdays'] = array(substr($rrulearr['BYDAY'], 1, 2));
|
||||
}elseif(strlen($rrulearr['BYDAY']) == 4){
|
||||
}elseif(strlen($rrulearr['BYDAY']) == 4) {
|
||||
$repeat['weekofmonth'] = substr($rrulearr['BYDAY'], 0, 2);
|
||||
$repeat['weekdays'] = array(substr($rrulearr['BYDAY'], 2, 2));
|
||||
}
|
||||
}else{
|
||||
$byday_days = explode(',', $rrulearr['BYDAY']);
|
||||
foreach($byday_days as $byday_day){
|
||||
if(strlen($byday_day) == 2){
|
||||
foreach($byday_days as $byday_day) {
|
||||
if(strlen($byday_day) == 2) {
|
||||
$repeat['weekdays'][] = $byday_day;
|
||||
}elseif(strlen($byday_day) == 3){
|
||||
}elseif(strlen($byday_day) == 3) {
|
||||
$repeat['weekofmonth'] = substr($byday_day , 0, 1);
|
||||
$repeat['weekdays'][] = substr($byday_day , 1, 2);
|
||||
}elseif(strlen($byday_day) == 4){
|
||||
}elseif(strlen($byday_day) == 4) {
|
||||
$repeat['weekofmonth'] = substr($byday_day , 0, 2);
|
||||
$repeat['weekdays'][] = substr($byday_day , 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(array_key_exists('BYMONTHDAY', $rrulearr)){
|
||||
if(substr_count($rrulearr['BYMONTHDAY'], ',') == 0){
|
||||
if(array_key_exists('BYMONTHDAY', $rrulearr)) {
|
||||
if(substr_count($rrulearr['BYMONTHDAY'], ',') == 0) {
|
||||
$repeat['bymonthday'][] = $rrulearr['BYMONTHDAY'];
|
||||
}else{
|
||||
$bymonthdays = explode(',', $rrulearr['BYMONTHDAY']);
|
||||
foreach($bymonthdays as $bymonthday){
|
||||
foreach($bymonthdays as $bymonthday) {
|
||||
$repeat['bymonthday'][] = $bymonthday;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(array_key_exists('BYYEARDAY', $rrulearr)){
|
||||
if(substr_count($rrulearr['BYYEARDAY'], ',') == 0){
|
||||
if(array_key_exists('BYYEARDAY', $rrulearr)) {
|
||||
if(substr_count($rrulearr['BYYEARDAY'], ',') == 0) {
|
||||
$repeat['byyearday'][] = $rrulearr['BYYEARDAY'];
|
||||
}else{
|
||||
$byyeardays = explode(',', $rrulearr['BYYEARDAY']);
|
||||
foreach($byyeardays as $yearday){
|
||||
foreach($byyeardays as $yearday) {
|
||||
$repeat['byyearday'][] = $yearday;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(array_key_exists('BYWEEKNO', $rrulearr)){
|
||||
if(substr_count($rrulearr['BYWEEKNO'], ',') == 0){
|
||||
if(array_key_exists('BYWEEKNO', $rrulearr)) {
|
||||
if(substr_count($rrulearr['BYWEEKNO'], ',') == 0) {
|
||||
$repeat['byweekno'][] = (string) $rrulearr['BYWEEKNO'];
|
||||
}else{
|
||||
$byweekno = explode(',', $rrulearr['BYWEEKNO']);
|
||||
foreach($byweekno as $weekno){
|
||||
foreach($byweekno as $weekno) {
|
||||
$repeat['byweekno'][] = (string) $weekno;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(array_key_exists('BYMONTH', $rrulearr)){
|
||||
if(array_key_exists('BYMONTH', $rrulearr)) {
|
||||
$months = OC_Calendar_App::getByMonthOptions();
|
||||
if(substr_count($rrulearr['BYMONTH'], ',') == 0){
|
||||
if(substr_count($rrulearr['BYMONTH'], ',') == 0) {
|
||||
$repeat['bymonth'][] = $months[$month];
|
||||
}else{
|
||||
$bymonth = explode(',', $rrulearr['BYMONTH']);
|
||||
foreach($bymonth as $month){
|
||||
foreach($bymonth as $month) {
|
||||
$repeat['bymonth'][] = $months[$month];
|
||||
}
|
||||
}
|
||||
}
|
||||
switch($rrulearr['FREQ']){
|
||||
switch($rrulearr['FREQ']) {
|
||||
case 'DAILY':
|
||||
$repeat['repeat'] = 'daily';
|
||||
break;
|
||||
case 'WEEKLY':
|
||||
if($rrulearr['INTERVAL'] % 2 == 0){
|
||||
if($rrulearr['INTERVAL'] % 2 == 0) {
|
||||
$repeat['repeat'] = 'biweekly';
|
||||
$rrulearr['INTERVAL'] = $rrulearr['INTERVAL'] / 2;
|
||||
}elseif($rrulearr['BYDAY'] == 'MO,TU,WE,TH,FR'){
|
||||
}elseif($rrulearr['BYDAY'] == 'MO,TU,WE,TH,FR') {
|
||||
$repeat['repeat'] = 'weekday';
|
||||
}else{
|
||||
$repeat['repeat'] = 'weekly';
|
||||
|
@ -156,7 +156,7 @@ if($data['repeating'] == 1){
|
|||
break;
|
||||
case 'MONTHLY':
|
||||
$repeat['repeat'] = 'monthly';
|
||||
if(array_key_exists('BYDAY', $rrulearr)){
|
||||
if(array_key_exists('BYDAY', $rrulearr)) {
|
||||
$repeat['month'] = 'weekday';
|
||||
}else{
|
||||
$repeat['month'] = 'monthday';
|
||||
|
@ -164,19 +164,19 @@ if($data['repeating'] == 1){
|
|||
break;
|
||||
case 'YEARLY':
|
||||
$repeat['repeat'] = 'yearly';
|
||||
if(array_key_exists('BYMONTH', $rrulearr)){
|
||||
if(array_key_exists('BYMONTH', $rrulearr)) {
|
||||
$repeat['year'] = 'bydaymonth';
|
||||
}elseif(array_key_exists('BYWEEKNO', $rrulearr)){
|
||||
}elseif(array_key_exists('BYWEEKNO', $rrulearr)) {
|
||||
$repeat['year'] = 'byweekno';
|
||||
}else{
|
||||
$repeat['year'] = 'byyearday';
|
||||
}
|
||||
}
|
||||
$repeat['interval'] = $rrulearr['INTERVAL'];
|
||||
if(array_key_exists('COUNT', $rrulearr)){
|
||||
if(array_key_exists('COUNT', $rrulearr)) {
|
||||
$repeat['end'] = 'count';
|
||||
$repeat['count'] = $rrulearr['COUNT'];
|
||||
}elseif(array_key_exists('UNTIL', $rrulearr)){
|
||||
}elseif(array_key_exists('UNTIL', $rrulearr)) {
|
||||
$repeat['end'] = 'date';
|
||||
$endbydate_day = substr($rrulearr['UNTIL'], 6, 2);
|
||||
$endbydate_month = substr($rrulearr['UNTIL'], 4, 2);
|
||||
|
@ -185,10 +185,10 @@ if($data['repeating'] == 1){
|
|||
}else{
|
||||
$repeat['end'] = 'never';
|
||||
}
|
||||
if(array_key_exists('weekdays', $repeat)){
|
||||
if(array_key_exists('weekdays', $repeat)) {
|
||||
$repeat_weekdays_ = array();
|
||||
$days = OC_Calendar_App::getWeeklyOptions();
|
||||
foreach($repeat['weekdays'] as $weekday){
|
||||
foreach($repeat['weekdays'] as $weekday) {
|
||||
$repeat_weekdays_[] = $days[$weekday];
|
||||
}
|
||||
$repeat['weekdays'] = $repeat_weekdays_;
|
||||
|
@ -242,7 +242,7 @@ $tmpl->assign('endtime', $endtime);
|
|||
$tmpl->assign('description', $description);
|
||||
|
||||
$tmpl->assign('repeat', $repeat['repeat']);
|
||||
if($repeat['repeat'] != 'doesnotrepeat'){
|
||||
if($repeat['repeat'] != 'doesnotrepeat') {
|
||||
$tmpl->assign('repeat_month', $repeat['month']);
|
||||
$tmpl->assign('repeat_weekdays', $repeat['weekdays']);
|
||||
$tmpl->assign('repeat_interval', $repeat['interval']);
|
||||
|
|
|
@ -13,7 +13,7 @@ OCP\JSON::callCheck();
|
|||
|
||||
$id = $_POST['id'];
|
||||
|
||||
if(!array_key_exists('calendar', $_POST)){
|
||||
if(!array_key_exists('calendar', $_POST)) {
|
||||
$cal = OC_Calendar_Object::getCalendarid($id);
|
||||
$_POST['calendar'] = $cal;
|
||||
}else{
|
||||
|
@ -21,7 +21,7 @@ if(!array_key_exists('calendar', $_POST)){
|
|||
}
|
||||
|
||||
$errarr = OC_Calendar_Object::validateRequest($_POST);
|
||||
if($errarr){
|
||||
if($errarr) {
|
||||
//show validate errors
|
||||
OCP\JSON::error($errarr);
|
||||
exit;
|
||||
|
|
|
@ -24,11 +24,11 @@ $dtstart = $vevent->DTSTART;
|
|||
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
|
||||
$start_type = $dtstart->getDateType();
|
||||
$end_type = $dtend->getDateType();
|
||||
if ($allday && $start_type != Sabre_VObject_Property_DateTime::DATE){
|
||||
if ($allday && $start_type != Sabre_VObject_Property_DateTime::DATE) {
|
||||
$start_type = $end_type = Sabre_VObject_Property_DateTime::DATE;
|
||||
$dtend->setDateTime($dtend->getDateTime()->modify('+1 day'), $end_type);
|
||||
}
|
||||
if (!$allday && $start_type == Sabre_VObject_Property_DateTime::DATE){
|
||||
if (!$allday && $start_type == Sabre_VObject_Property_DateTime::DATE) {
|
||||
$start_type = $end_type = Sabre_VObject_Property_DateTime::LOCALTZ;
|
||||
}
|
||||
$dtstart->setDateTime($dtstart->getDateTime()->add($delta), $start_type);
|
||||
|
|
|
@ -13,7 +13,7 @@ if(!OCP\User::isLoggedIn()) {
|
|||
}
|
||||
OCP\JSON::checkAppEnabled('calendar');
|
||||
|
||||
if (!isset($_POST['start'])){
|
||||
if (!isset($_POST['start'])) {
|
||||
OCP\JSON::error();
|
||||
die;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ $start = $_POST['start'];
|
|||
$end = $_POST['end'];
|
||||
$allday = $_POST['allday'];
|
||||
|
||||
if (!$end){
|
||||
if (!$end) {
|
||||
$duration = OCP\Config::getUserValue( OCP\USER::getUser(), 'calendar', 'duration', '60');
|
||||
$end = $start + ($duration * 60);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ OCP\JSON::checkAppEnabled('calendar');
|
|||
OCP\JSON::callCheck();
|
||||
|
||||
$errarr = OC_Calendar_Object::validateRequest($_POST);
|
||||
if($errarr){
|
||||
if($errarr) {
|
||||
//show validate errors
|
||||
OCP\JSON::error($errarr);
|
||||
exit;
|
||||
|
|
|
@ -24,7 +24,7 @@ $start = (version_compare(PHP_VERSION, '5.3.0', '>='))?DateTime::createFromForma
|
|||
$end = (version_compare(PHP_VERSION, '5.3.0', '>='))?DateTime::createFromFormat('U', $_GET['end']):new DateTime('@' . $_GET['end']);
|
||||
$events = OC_Calendar_App::getrequestedEvents($_GET['calendar_id'], $start, $end);
|
||||
$output = array();
|
||||
foreach($events as $event){
|
||||
foreach($events as $event) {
|
||||
$output = array_merge($output, OC_Calendar_App::generateEventOutput($event, $start, $end));
|
||||
}
|
||||
OCP\JSON::encodedPrint(OCP\Util::sanitizeHTML($output));
|
||||
|
|
|
@ -9,8 +9,8 @@ OCP\JSON::checkLoggedIn();
|
|||
OCP\App::checkAppEnabled('calendar');
|
||||
$calname = strip_tags($_POST['calname']);
|
||||
$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser());
|
||||
foreach($calendars as $calendar){
|
||||
if($calendar['displayname'] == $calname){
|
||||
foreach($calendars as $calendar) {
|
||||
if($calendar['displayname'] == $calname) {
|
||||
OCP\JSON::success(array('message'=>'exists'));
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ $import = new OC_Calendar_Import($data);
|
|||
$import->setUserID(OCP\User::getUser());
|
||||
$import->setTimeZone(OC_Calendar_App::$tz);
|
||||
$import->disableProgressCache();
|
||||
if(!$import->isValid()){
|
||||
if(!$import->isValid()) {
|
||||
OCP\JSON::error();
|
||||
exit;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ $newid = OC_Calendar_Calendar::addCalendar(OCP\User::getUser(),$newcalendarname,
|
|||
$import->setCalendarID($newid);
|
||||
$import->import();
|
||||
$count = $import->getCount();
|
||||
if($count == 0){
|
||||
if($count == 0) {
|
||||
OC_Calendar_Calendar::deleteCalendar($newid);
|
||||
OCP\JSON::error(array('message'=>OC_Calendar_App::$l10n->t('The file contained either no events or all events are already saved in your calendar.')));
|
||||
}else{
|
||||
|
|
|
@ -14,7 +14,7 @@ if (isset($_POST['progresskey']) && isset($_POST['getprogress'])) {
|
|||
exit;
|
||||
}
|
||||
$file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']);
|
||||
if(!$file){
|
||||
if(!$file) {
|
||||
OCP\JSON::error(array('error'=>'404'));
|
||||
}
|
||||
$import = new OC_Calendar_Import($file);
|
||||
|
@ -22,28 +22,28 @@ $import->setUserID(OCP\User::getUser());
|
|||
$import->setTimeZone(OC_Calendar_App::$tz);
|
||||
$import->enableProgressCache();
|
||||
$import->setProgresskey($_POST['progresskey']);
|
||||
if(!$import->isValid()){
|
||||
if(!$import->isValid()) {
|
||||
OCP\JSON::error(array('error'=>'notvalid'));
|
||||
exit;
|
||||
}
|
||||
$newcal = false;
|
||||
if($_POST['method'] == 'new'){
|
||||
if($_POST['method'] == 'new') {
|
||||
$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser());
|
||||
foreach($calendars as $calendar){
|
||||
if($calendar['displayname'] == $_POST['calname']){
|
||||
foreach($calendars as $calendar) {
|
||||
if($calendar['displayname'] == $_POST['calname']) {
|
||||
$id = $calendar['id'];
|
||||
$newcal = false;
|
||||
break;
|
||||
}
|
||||
$newcal = true;
|
||||
}
|
||||
if($newcal){
|
||||
if($newcal) {
|
||||
$id = OC_Calendar_Calendar::addCalendar(OCP\USER::getUser(), strip_tags($_POST['calname']),'VEVENT,VTODO,VJOURNAL',null,0,strip_tags($_POST['calcolor']));
|
||||
OC_Calendar_Calendar::setCalendarActive($id, 1);
|
||||
}
|
||||
}else{
|
||||
$calendar = OC_Calendar_App::getCalendar($_POST['id']);
|
||||
if($calendar['userid'] != OCP\USER::getUser()){
|
||||
if($calendar['userid'] != OCP\USER::getUser()) {
|
||||
OCP\JSON::error(array('error'=>'missingcalendarrights'));
|
||||
exit();
|
||||
}
|
||||
|
@ -57,13 +57,13 @@ try{
|
|||
//write some log
|
||||
}
|
||||
$count = $import->getCount();
|
||||
if($count == 0){
|
||||
if($newcal){
|
||||
if($count == 0) {
|
||||
if($newcal) {
|
||||
OC_Calendar_Calendar::deleteCalendar($id);
|
||||
}
|
||||
OCP\JSON::error(array('message'=>OC_Calendar_App::$l10n->t('The file contained either no events or all events are already saved in your calendar.')));
|
||||
}else{
|
||||
if($newcal){
|
||||
if($newcal) {
|
||||
OCP\JSON::success(array('message'=>$count . ' ' . OC_Calendar_App::$l10n->t('events has been saved in the new calendar') . ' ' . strip_tags($_POST['calname'])));
|
||||
}else{
|
||||
OCP\JSON::success(array('message'=>$count . ' ' . OC_Calendar_App::$l10n->t('events has been saved in your calendar')));
|
||||
|
|
|
@ -17,7 +17,7 @@ $lng = $_POST['lng'];
|
|||
|
||||
$timezone = OC_Geo::timezone($lat, $lng);
|
||||
|
||||
if($timezone == OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone')){
|
||||
if($timezone == OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezone')) {
|
||||
OCP\JSON::success();
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
OCP\JSON::checkLoggedIn();
|
||||
OCP\JSON::callCheck();
|
||||
if(isset($_POST["firstday"])){
|
||||
if(isset($_POST["firstday"])) {
|
||||
OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'firstday', $_POST["firstday"]);
|
||||
OCP\JSON::success();
|
||||
}else{
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
OCP\JSON::checkLoggedIn();
|
||||
OCP\JSON::callCheck();
|
||||
if(isset($_POST["timeformat"])){
|
||||
if(isset($_POST["timeformat"])) {
|
||||
OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timeformat', $_POST["timeformat"]);
|
||||
OCP\JSON::success();
|
||||
}else{
|
||||
|
|
|
@ -17,7 +17,7 @@ OCP\JSON::checkAppEnabled('calendar');
|
|||
OCP\JSON::callCheck();
|
||||
|
||||
// Get data
|
||||
if( isset( $_POST['timezone'] ) ){
|
||||
if( isset( $_POST['timezone'] ) ) {
|
||||
$timezone=$_POST['timezone'];
|
||||
OCP\Config::setUserValue( OCP\USER::getUser(), 'calendar', 'timezone', $timezone );
|
||||
OCP\JSON::success(array('data' => array( 'message' => $l->t('Timezone changed') )));
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
OCP\JSON::checkLoggedIn();
|
||||
OCP\JSON::checkAppEnabled('calendar');
|
||||
if(array_key_exists('timezonedetection', $_POST) && $_POST['timezonedetection'] == 'on'){
|
||||
if(array_key_exists('timezonedetection', $_POST) && $_POST['timezonedetection'] == 'on') {
|
||||
OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection', 'true');
|
||||
}else{
|
||||
OCP\Config::setUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection', 'false');
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
OCP\App::checkAppEnabled('calendar');
|
||||
|
||||
if(substr($_SERVER["REQUEST_URI"],0,strlen(OC_App::getAppWebPath('calendar').'/caldav.php')) == OC_App::getAppWebPath('calendar'). '/caldav.php'){
|
||||
if(substr($_SERVER["REQUEST_URI"],0,strlen(OC_App::getAppWebPath('calendar').'/caldav.php')) == OC_App::getAppWebPath('calendar'). '/caldav.php') {
|
||||
$baseuri = OC_App::getAppWebPath('calendar').'/caldav.php';
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ if (version_compare($installedVersion, '0.2.1', '<')) {
|
|||
}
|
||||
if (version_compare($installedVersion, '0.5', '<')) {
|
||||
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
|
||||
foreach($calendars as $calendar){
|
||||
foreach($calendars as $calendar) {
|
||||
OC_Calendar_Repeat::cleanCalendar($calendar['id']);
|
||||
OC_Calendar_Repeat::generateCalendar($calendar['id']);
|
||||
}
|
||||
|
@ -26,20 +26,20 @@ if (version_compare($installedVersion, '0.6', '<=')) {
|
|||
$calendar_stmt = OCP\DB::prepare('SELECT * FROM `*PREFIX*calendar_share_calendar`');
|
||||
$calendar_result = $calendar_stmt->execute();
|
||||
$calendar = array();
|
||||
while( $row = $calendar_result->fetchRow()){
|
||||
while( $row = $calendar_result->fetchRow()) {
|
||||
$calendar[] = $row;
|
||||
}
|
||||
foreach($calendar as $cal){
|
||||
foreach($calendar as $cal) {
|
||||
$stmt = OCP\DB::prepare('INSERT INTO `*PREFIX*share` (`share_with`,`uid_owner`,`item_type`,`item_target`,`permissions`) VALUES(?,?,\'calendar\',?,?)' );
|
||||
$result = $stmt->execute(array($cal['share'],$cal['owner'],$cal['calendarid'], ($cal['permissions'])?31:17));
|
||||
}
|
||||
$event_stmt = OCP\DB::prepare('SELECT * FROM `*PREFIX*calendar_share_event`');
|
||||
$event_result = $event_stmt->execute();
|
||||
$event = array();
|
||||
while( $row = $event_result->fetchRow()){
|
||||
while( $row = $event_result->fetchRow()) {
|
||||
$event[] = $row;
|
||||
}
|
||||
foreach($event as $evnt){
|
||||
foreach($event as $evnt) {
|
||||
$stmt = OCP\DB::prepare('INSERT INTO `*PREFIX*share` (`share_with`,`uid_owner`,`item_type`,`item_target`,`permissions`) VALUES(?,?,\'event\',?,?)' );
|
||||
$result = $stmt->execute(array($evnt['share'],$evnt['owner'],$evnt['eventid'], ($evnt['permissions'])?31:17));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
if(!file_exists('../../lib/base.php')){
|
||||
if(!file_exists('../../lib/base.php')) {
|
||||
die('Please update the path to /lib/base.php in caldav.php or make use of /remote.php/caldav/');
|
||||
}
|
||||
require_once'../../lib/base.php';
|
||||
|
|
|
@ -9,18 +9,18 @@ OCP\User::checkLoggedIn();
|
|||
OCP\App::checkAppEnabled('calendar');
|
||||
$cal = isset($_GET['calid']) ? $_GET['calid'] : NULL;
|
||||
$event = isset($_GET['eventid']) ? $_GET['eventid'] : NULL;
|
||||
if(isset($cal)){
|
||||
if(isset($cal)) {
|
||||
$calendar = OC_Calendar_App::getCalendar($cal, true);
|
||||
if(!$calendar){
|
||||
if(!$calendar) {
|
||||
header('HTTP/1.0 404 Not Found');
|
||||
exit;
|
||||
}
|
||||
header('Content-Type: text/Calendar');
|
||||
header('Content-Disposition: inline; filename=' . str_replace(' ', '-', $calendar['displayname']) . '.ics');
|
||||
echo OC_Calendar_Export::export($cal, OC_Calendar_Export::CALENDAR);
|
||||
}elseif(isset($event)){
|
||||
}elseif(isset($event)) {
|
||||
$data = OC_Calendar_App::getEventObject($_GET['eventid'], true);
|
||||
if(!$data){
|
||||
if(!$data) {
|
||||
header('HTTP/1.0 404 Not Found');
|
||||
exit;
|
||||
}
|
||||
|
|
14
index.php
14
index.php
|
@ -10,13 +10,13 @@ OCP\App::checkAppEnabled('calendar');
|
|||
|
||||
// Create default calendar ...
|
||||
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), false);
|
||||
if( count($calendars) == 0){
|
||||
if( count($calendars) == 0) {
|
||||
OC_Calendar_Calendar::addCalendar(OCP\USER::getUser(),'Default calendar');
|
||||
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), true);
|
||||
}
|
||||
|
||||
$eventSources = array();
|
||||
foreach($calendars as $calendar){
|
||||
foreach($calendars as $calendar) {
|
||||
if($calendar['active'] == 1) {
|
||||
$eventSources[] = OC_Calendar_Calendar::getEventSourceInfo($calendar);
|
||||
}
|
||||
|
@ -33,13 +33,13 @@ OCP\Util::emitHook('OC_Calendar', 'getSources', array('sources' => &$eventSource
|
|||
$categories = OC_Calendar_App::getCategoryOptions();
|
||||
|
||||
//Fix currentview for fullcalendar
|
||||
if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview"){
|
||||
if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "oneweekview") {
|
||||
OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "agendaWeek");
|
||||
}
|
||||
if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "onemonthview"){
|
||||
if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "onemonthview") {
|
||||
OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "month");
|
||||
}
|
||||
if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "listview"){
|
||||
if(OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'currentview', 'month') == "listview") {
|
||||
OCP\Config::setUserValue(OCP\USER::getUser(), "calendar", "currentview", "list");
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ OCP\Util::addscript('3rdparty/fullcalendar', 'fullcalendar');
|
|||
OCP\Util::addStyle('3rdparty/fullcalendar', 'fullcalendar');
|
||||
OCP\Util::addscript('3rdparty/timepicker', 'jquery.ui.timepicker');
|
||||
OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker');
|
||||
if(OCP\Config::getUserValue(OCP\USER::getUser(), "calendar", "timezone") == null || OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection') == 'true'){
|
||||
if(OCP\Config::getUserValue(OCP\USER::getUser(), "calendar", "timezone") == null || OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timezonedetection') == 'true') {
|
||||
OCP\Util::addscript('calendar', 'geo');
|
||||
}
|
||||
OCP\Util::addscript('calendar', 'calendar');
|
||||
|
@ -60,7 +60,7 @@ OCP\App::setActiveNavigationEntry('calendar_index');
|
|||
$tmpl = new OCP\Template('calendar', 'calendar', 'user');
|
||||
$tmpl->assign('eventSources', $eventSources,false);
|
||||
$tmpl->assign('categories', $categories, false);
|
||||
if(array_key_exists('showevent', $_GET)){
|
||||
if(array_key_exists('showevent', $_GET)) {
|
||||
$tmpl->assign('showevent', $_GET['showevent'], false);
|
||||
}
|
||||
$tmpl->printPage();
|
||||
|
|
62
lib/app.php
62
lib/app.php
|
@ -35,8 +35,8 @@ class OC_Calendar_App{
|
|||
* @param bool $shared - check if the user got access via sharing
|
||||
* @return mixed - bool / array
|
||||
*/
|
||||
public static function getCalendar($id, $security = true, $shared = false){
|
||||
if(! is_numeric($id)){
|
||||
public static function getCalendar($id, $security = true, $shared = false) {
|
||||
if(! is_numeric($id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ class OC_Calendar_App{
|
|||
* @param bool $shared - check if the user got access via sharing
|
||||
* @return mixed - bool / array
|
||||
*/
|
||||
public static function getEventObject($id, $security = true, $shared = false){
|
||||
public static function getEventObject($id, $security = true, $shared = false) {
|
||||
$event = OC_Calendar_Object::find($id);
|
||||
if($shared === true || $security === true) {
|
||||
$permissions = self::getPermissions($id, self::EVENT);
|
||||
|
@ -78,13 +78,13 @@ class OC_Calendar_App{
|
|||
* @param bool $security - check access rights or not
|
||||
* @return mixed - bool / object
|
||||
*/
|
||||
public static function getVCalendar($id, $security = true, $shared = false){
|
||||
public static function getVCalendar($id, $security = true, $shared = false) {
|
||||
$event_object = self::getEventObject($id, $security, $shared);
|
||||
if($event_object === false){
|
||||
if($event_object === false) {
|
||||
return false;
|
||||
}
|
||||
$vobject = OC_VObject::parse($event_object['calendardata']);
|
||||
if(is_null($vobject)){
|
||||
if(is_null($vobject)) {
|
||||
return false;
|
||||
}
|
||||
return $vobject;
|
||||
|
@ -96,9 +96,9 @@ class OC_Calendar_App{
|
|||
* @param (int) $lastmodified - time of last modification as unix timestamp
|
||||
* @return (bool)
|
||||
*/
|
||||
public static function isNotModified($vevent, $lastmodified){
|
||||
public static function isNotModified($vevent, $lastmodified) {
|
||||
$last_modified = $vevent->__get('LAST-MODIFIED');
|
||||
if($last_modified && $lastmodified != $last_modified->getDateTime()->format('U')){
|
||||
if($last_modified && $lastmodified != $last_modified->getDateTime()->format('U')) {
|
||||
OCP\JSON::error(array('modified'=>true));
|
||||
exit;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ class OC_Calendar_App{
|
|||
* @brief returns the default categories of ownCloud
|
||||
* @return (array) $categories
|
||||
*/
|
||||
protected static function getDefaultCategories(){
|
||||
protected static function getDefaultCategories() {
|
||||
return array(
|
||||
(string)self::$l10n->t('Birthday'),
|
||||
(string)self::$l10n->t('Business'),
|
||||
|
@ -146,7 +146,7 @@ class OC_Calendar_App{
|
|||
* @brief returns the categories of the vcategories object
|
||||
* @return (array) $categories
|
||||
*/
|
||||
public static function getCategoryOptions(){
|
||||
public static function getCategoryOptions() {
|
||||
$categories = self::getVCategories()->categories();
|
||||
return $categories;
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ class OC_Calendar_App{
|
|||
* @brief returns the options for the repeat rule of an repeating event
|
||||
* @return array - valid inputs for the repeat rule of an repeating event
|
||||
*/
|
||||
public static function getRepeatOptions(){
|
||||
public static function getRepeatOptions() {
|
||||
return OC_Calendar_Object::getRepeatOptions(self::$l10n);
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ class OC_Calendar_App{
|
|||
* @brief returns the options for the end of an repeating event
|
||||
* @return array - valid inputs for the end of an repeating events
|
||||
*/
|
||||
public static function getEndOptions(){
|
||||
public static function getEndOptions() {
|
||||
return OC_Calendar_Object::getEndOptions(self::$l10n);
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ class OC_Calendar_App{
|
|||
* @brief returns the options for an monthly repeating event
|
||||
* @return array - valid inputs for monthly repeating events
|
||||
*/
|
||||
public static function getMonthOptions(){
|
||||
public static function getMonthOptions() {
|
||||
return OC_Calendar_Object::getMonthOptions(self::$l10n);
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ class OC_Calendar_App{
|
|||
* @brief returns the options for an weekly repeating event
|
||||
* @return array - valid inputs for weekly repeating events
|
||||
*/
|
||||
public static function getWeeklyOptions(){
|
||||
public static function getWeeklyOptions() {
|
||||
return OC_Calendar_Object::getWeeklyOptions(self::$l10n);
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ class OC_Calendar_App{
|
|||
* @brief returns the options for an yearly repeating event
|
||||
* @return array - valid inputs for yearly repeating events
|
||||
*/
|
||||
public static function getYearOptions(){
|
||||
public static function getYearOptions() {
|
||||
return OC_Calendar_Object::getYearOptions(self::$l10n);
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ class OC_Calendar_App{
|
|||
* @brief returns the options for an yearly repeating event which occurs on specific days of the year
|
||||
* @return array - valid inputs for yearly repeating events
|
||||
*/
|
||||
public static function getByYearDayOptions(){
|
||||
public static function getByYearDayOptions() {
|
||||
return OC_Calendar_Object::getByYearDayOptions();
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ class OC_Calendar_App{
|
|||
* @brief returns the options for an yearly repeating event which occurs on specific month of the year
|
||||
* @return array - valid inputs for yearly repeating events
|
||||
*/
|
||||
public static function getByMonthOptions(){
|
||||
public static function getByMonthOptions() {
|
||||
return OC_Calendar_Object::getByMonthOptions(self::$l10n);
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ class OC_Calendar_App{
|
|||
* @brief returns the options for an yearly repeating event which occurs on specific week numbers of the year
|
||||
* @return array - valid inputs for yearly repeating events
|
||||
*/
|
||||
public static function getByWeekNoOptions(){
|
||||
public static function getByWeekNoOptions() {
|
||||
return OC_Calendar_Object::getByWeekNoOptions();
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,7 @@ class OC_Calendar_App{
|
|||
* @brief returns the options for an yearly or monthly repeating event which occurs on specific days of the month
|
||||
* @return array - valid inputs for yearly or monthly repeating events
|
||||
*/
|
||||
public static function getByMonthDayOptions(){
|
||||
public static function getByMonthDayOptions() {
|
||||
return OC_Calendar_Object::getByMonthDayOptions();
|
||||
}
|
||||
|
||||
|
@ -274,7 +274,7 @@ class OC_Calendar_App{
|
|||
* @brief returns the options for an monthly repeating event which occurs on specific weeks of the month
|
||||
* @return array - valid inputs for monthly repeating events
|
||||
*/
|
||||
public static function getWeekofMonth(){
|
||||
public static function getWeekofMonth() {
|
||||
return OC_Calendar_Object::getWeekofMonth(self::$l10n);
|
||||
}
|
||||
|
||||
|
@ -339,11 +339,11 @@ class OC_Calendar_App{
|
|||
* @param (int) $end - unixtimestamp of end
|
||||
* @return (array) $events
|
||||
*/
|
||||
public static function getrequestedEvents($calendarid, $start, $end){
|
||||
public static function getrequestedEvents($calendarid, $start, $end) {
|
||||
$events = array();
|
||||
if($calendarid == 'shared_events') {
|
||||
$singleevents = OCP\Share::getItemsSharedWith('event', OC_Share_Backend_Event::FORMAT_EVENT);
|
||||
foreach($singleevents as $singleevent){
|
||||
foreach($singleevents as $singleevent) {
|
||||
$singleevent['summary'] .= ' (' . self::$l10n->t('by') . ' ' . OC_Calendar_Object::getowner($singleevent['id']) . ')';
|
||||
$events[] = $singleevent;
|
||||
}
|
||||
|
@ -367,11 +367,11 @@ class OC_Calendar_App{
|
|||
* @param (int) $end - DateTime object of end
|
||||
* @return (array) $output - readable output
|
||||
*/
|
||||
public static function generateEventOutput($event, $start, $end){
|
||||
if(!isset($event['calendardata']) && !isset($event['vevent'])){
|
||||
public static function generateEventOutput($event, $start, $end) {
|
||||
if(!isset($event['calendardata']) && !isset($event['vevent'])) {
|
||||
return false;
|
||||
}
|
||||
if(!isset($event['calendardata']) && isset($event['vevent'])){
|
||||
if(!isset($event['calendardata']) && isset($event['vevent'])) {
|
||||
$event['calendardata'] = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud's Internal iCal System\n" . $event['vevent']->serialize() . "END:VCALENDAR";
|
||||
}
|
||||
$object = OC_VObject::parse($event['calendardata']);
|
||||
|
@ -386,11 +386,11 @@ class OC_Calendar_App{
|
|||
'description' => isset($vevent->DESCRIPTION)?$vevent->DESCRIPTION->value:'',
|
||||
'lastmodified'=>$lastmodified,
|
||||
'allDay'=>$allday);
|
||||
if(OC_Calendar_Object::isrepeating($id) && OC_Calendar_Repeat::is_cached_inperiod($event['id'], $start, $end)){
|
||||
if(OC_Calendar_Object::isrepeating($id) && OC_Calendar_Repeat::is_cached_inperiod($event['id'], $start, $end)) {
|
||||
$cachedinperiod = OC_Calendar_Repeat::get_inperiod($id, $start, $end);
|
||||
foreach($cachedinperiod as $cachedevent){
|
||||
foreach($cachedinperiod as $cachedevent) {
|
||||
$dynamicoutput = array();
|
||||
if($allday){
|
||||
if($allday) {
|
||||
$start_dt = new DateTime($cachedevent['startdate'], new DateTimeZone('UTC'));
|
||||
$end_dt = new DateTime($cachedevent['enddate'], new DateTimeZone('UTC'));
|
||||
$dynamicoutput['start'] = $start_dt->format('Y-m-d');
|
||||
|
@ -406,11 +406,11 @@ class OC_Calendar_App{
|
|||
$return[] = array_merge($staticoutput, $dynamicoutput);
|
||||
}
|
||||
}else{
|
||||
if(OC_Calendar_Object::isrepeating($id) || $event['repeating'] == 1){
|
||||
if(OC_Calendar_Object::isrepeating($id) || $event['repeating'] == 1) {
|
||||
$object->expand($start, $end);
|
||||
}
|
||||
foreach($object->getComponents() as $singleevent){
|
||||
if(!($singleevent instanceof Sabre_VObject_Component_VEvent)){
|
||||
foreach($object->getComponents() as $singleevent) {
|
||||
if(!($singleevent instanceof Sabre_VObject_Component_VEvent)) {
|
||||
continue;
|
||||
}
|
||||
$dynamicoutput = OC_Calendar_Object::generateStartEndDate($singleevent->DTSTART, OC_Calendar_Object::getDTEndFromVEvent($singleevent), $allday, self::$tz);
|
||||
|
|
|
@ -35,10 +35,10 @@ class OC_Calendar_Calendar{
|
|||
* @param boolean $active Only return calendars with this $active state, default(=false) is don't care
|
||||
* @return array
|
||||
*/
|
||||
public static function allCalendars($uid, $active=false){
|
||||
public static function allCalendars($uid, $active=false) {
|
||||
$values = array($uid);
|
||||
$active_where = '';
|
||||
if (!is_null($active) && $active){
|
||||
if (!is_null($active) && $active) {
|
||||
$active_where = ' AND `active` = ?';
|
||||
$values[] = $active;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class OC_Calendar_Calendar{
|
|||
$result = $stmt->execute($values);
|
||||
|
||||
$calendars = array();
|
||||
while( $row = $result->fetchRow()){
|
||||
while( $row = $result->fetchRow()) {
|
||||
$row['permissions'] = OCP\Share::PERMISSION_CREATE
|
||||
| OCP\Share::PERMISSION_READ | OCP\Share::PERMISSION_UPDATE
|
||||
| OCP\Share::PERMISSION_DELETE | OCP\Share::PERMISSION_SHARE;
|
||||
|
@ -62,7 +62,7 @@ class OC_Calendar_Calendar{
|
|||
* @param string $principaluri
|
||||
* @return array
|
||||
*/
|
||||
public static function allCalendarsWherePrincipalURIIs($principaluri){
|
||||
public static function allCalendarsWherePrincipalURIIs($principaluri) {
|
||||
$uid = self::extractUserID($principaluri);
|
||||
return self::allCalendars($uid);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ class OC_Calendar_Calendar{
|
|||
* @param integer $id
|
||||
* @return associative array
|
||||
*/
|
||||
public static function find($id){
|
||||
public static function find($id) {
|
||||
$stmt = OCP\DB::prepare( 'SELECT * FROM `*PREFIX*calendar_calendars` WHERE `id` = ?' );
|
||||
$result = $stmt->execute(array($id));
|
||||
|
||||
|
@ -101,10 +101,10 @@ class OC_Calendar_Calendar{
|
|||
* @param string $color Default: null, format: '#RRGGBB(AA)'
|
||||
* @return insertid
|
||||
*/
|
||||
public static function addCalendar($userid,$name,$components='VEVENT,VTODO,VJOURNAL',$timezone=null,$order=0,$color=null){
|
||||
public static function addCalendar($userid,$name,$components='VEVENT,VTODO,VJOURNAL',$timezone=null,$order=0,$color=null) {
|
||||
$all = self::allCalendars($userid);
|
||||
$uris = array();
|
||||
foreach($all as $i){
|
||||
foreach($all as $i) {
|
||||
$uris[] = $i['uri'];
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ class OC_Calendar_Calendar{
|
|||
* @param string $color format: '#RRGGBB(AA)'
|
||||
* @return insertid
|
||||
*/
|
||||
public static function addCalendarFromDAVData($principaluri,$uri,$name,$components,$timezone,$order,$color){
|
||||
public static function addCalendarFromDAVData($principaluri,$uri,$name,$components,$timezone,$order,$color) {
|
||||
$userid = self::extractUserID($principaluri);
|
||||
|
||||
$stmt = OCP\DB::prepare( 'INSERT INTO `*PREFIX*calendar_calendars` (`userid`,`displayname`,`uri`,`ctag`,`calendarorder`,`calendarcolor`,`timezone`,`components`) VALUES(?,?,?,?,?,?,?,?)' );
|
||||
|
@ -154,7 +154,7 @@ class OC_Calendar_Calendar{
|
|||
*
|
||||
* Values not null will be set
|
||||
*/
|
||||
public static function editCalendar($id,$name=null,$components=null,$timezone=null,$order=null,$color=null){
|
||||
public static function editCalendar($id,$name=null,$components=null,$timezone=null,$order=null,$color=null) {
|
||||
// Need these ones for checking uri
|
||||
$calendar = self::find($id);
|
||||
if ($calendar['userid'] != OCP\User::getUser()) {
|
||||
|
@ -188,7 +188,7 @@ class OC_Calendar_Calendar{
|
|||
* @param boolean $active
|
||||
* @return boolean
|
||||
*/
|
||||
public static function setCalendarActive($id,$active){
|
||||
public static function setCalendarActive($id,$active) {
|
||||
$calendar = self::find($id);
|
||||
if ($calendar['userid'] != OCP\User::getUser()) {
|
||||
$sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $id);
|
||||
|
@ -211,7 +211,7 @@ class OC_Calendar_Calendar{
|
|||
* @param integer $id
|
||||
* @return boolean
|
||||
*/
|
||||
public static function touchCalendar($id){
|
||||
public static function touchCalendar($id) {
|
||||
$stmt = OCP\DB::prepare( 'UPDATE `*PREFIX*calendar_calendars` SET `ctag` = `ctag` + 1 WHERE `id` = ?' );
|
||||
$stmt->execute(array($id));
|
||||
|
||||
|
@ -223,7 +223,7 @@ class OC_Calendar_Calendar{
|
|||
* @param integer $id
|
||||
* @return boolean
|
||||
*/
|
||||
public static function deleteCalendar($id){
|
||||
public static function deleteCalendar($id) {
|
||||
$calendar = self::find($id);
|
||||
if ($calendar['userid'] != OCP\User::getUser()) {
|
||||
$sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $id);
|
||||
|
@ -255,7 +255,7 @@ class OC_Calendar_Calendar{
|
|||
* @param integer $id2
|
||||
* @return boolean
|
||||
*/
|
||||
public static function mergeCalendar($id1, $id2){
|
||||
public static function mergeCalendar($id1, $id2) {
|
||||
$calendar = self::find($id1);
|
||||
if ($calendar['userid'] != OCP\User::getUser()) {
|
||||
$sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $id1);
|
||||
|
@ -279,14 +279,14 @@ class OC_Calendar_Calendar{
|
|||
* @param array $existing existing calendar URIs
|
||||
* @return string uri
|
||||
*/
|
||||
public static function createURI($name,$existing){
|
||||
public static function createURI($name,$existing) {
|
||||
$strip=array(' ','/','?','&');//these may break sync clients
|
||||
$name=str_replace($strip,'',$name);
|
||||
$name = strtolower($name);
|
||||
|
||||
$newname = $name;
|
||||
$i = 1;
|
||||
while(in_array($newname,$existing)){
|
||||
while(in_array($newname,$existing)) {
|
||||
$newname = $name.$i;
|
||||
$i = $i + 1;
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ class OC_Calendar_Calendar{
|
|||
* @brief gets the userid from a principal path
|
||||
* @return string
|
||||
*/
|
||||
public static function extractUserID($principaluri){
|
||||
public static function extractUserID($principaluri) {
|
||||
list($prefix,$userid) = Sabre_DAV_URLUtil::splitPath($principaluri);
|
||||
return $userid;
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ class OC_Calendar_Calendar{
|
|||
* @brief returns the possible color for calendars
|
||||
* @return array
|
||||
*/
|
||||
public static function getCalendarColorOptions(){
|
||||
public static function getCalendarColorOptions() {
|
||||
return array(
|
||||
'#ff0000', // "Red"
|
||||
'#b3dc6c', // "Green"
|
||||
|
@ -324,7 +324,7 @@ class OC_Calendar_Calendar{
|
|||
* @param array $calendar calendar data
|
||||
* @return array
|
||||
*/
|
||||
public static function getEventSourceInfo($calendar){
|
||||
public static function getEventSourceInfo($calendar) {
|
||||
return array(
|
||||
'url' => OCP\Util::linkTo('calendar', 'ajax/events.php').'?calendar_id='.$calendar['id'],
|
||||
'backgroundColor' => $calendar['calendarcolor'],
|
||||
|
@ -340,10 +340,10 @@ class OC_Calendar_Calendar{
|
|||
* @param string $userid
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isCalendarNameavailable($calendarname, $userid){
|
||||
public static function isCalendarNameavailable($calendarname, $userid) {
|
||||
$calendars = self::allCalendars($userid);
|
||||
foreach($calendars as $calendar){
|
||||
if($calendar['displayname'] == $calendarname){
|
||||
foreach($calendars as $calendar) {
|
||||
if($calendar['displayname'] == $calendarname) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -356,8 +356,8 @@ class OC_Calendar_Calendar{
|
|||
* (this function doesn't pay attention on the alpha value of rgba color codes)
|
||||
* @return boolean
|
||||
*/
|
||||
public static function generateTextColor($calendarcolor){
|
||||
if(substr_count($calendarcolor, '#') == 1){
|
||||
public static function generateTextColor($calendarcolor) {
|
||||
if(substr_count($calendarcolor, '#') == 1) {
|
||||
$calendarcolor = substr($calendarcolor,1);
|
||||
}
|
||||
$red = hexdec(substr($calendarcolor,0,2));
|
||||
|
|
|
@ -21,8 +21,8 @@ class OC_Calendar_Export{
|
|||
* @param string $type use OC_Calendar_Export constants
|
||||
* @return string
|
||||
*/
|
||||
public static function export($id, $type){
|
||||
if($type == self::EVENT){
|
||||
public static function export($id, $type) {
|
||||
if($type == self::EVENT) {
|
||||
$return = self::event($id);
|
||||
}else{
|
||||
$return = self::calendar($id);
|
||||
|
@ -35,11 +35,11 @@ class OC_Calendar_Export{
|
|||
* @param integer $id id of the calendar
|
||||
* @return string
|
||||
*/
|
||||
private static function calendar($id){
|
||||
private static function calendar($id) {
|
||||
$events = OC_Calendar_Object::all($id);
|
||||
$calendar = OC_Calendar_Calendar::find($id);
|
||||
$return = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud Calendar " . OCP\App::getAppVersion('calendar') . "\nX-WR-CALNAME:" . $calendar['displayname'] . "\n";
|
||||
foreach($events as $event){
|
||||
foreach($events as $event) {
|
||||
$return .= self::generateEvent($event);
|
||||
}
|
||||
$return .= "END:VCALENDAR";
|
||||
|
@ -51,7 +51,7 @@ class OC_Calendar_Export{
|
|||
* @param integer $id id of the event
|
||||
* @return string
|
||||
*/
|
||||
private static function event($id){
|
||||
private static function event($id) {
|
||||
$event = OC_Calendar_Object::find($id);
|
||||
$return = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud Calendar " . OCP\App::getAppVersion('calendar') . "\nX-WR-CALNAME:" . $event['summary'] . "\n";
|
||||
$return .= self::generateEvent($event);
|
||||
|
@ -64,13 +64,13 @@ class OC_Calendar_Export{
|
|||
* @param array $event
|
||||
* @return string
|
||||
*/
|
||||
private static function generateEvent($event){
|
||||
private static function generateEvent($event) {
|
||||
$object = OC_VObject::parse($event['calendardata']);
|
||||
$dtstart = $object->VEVENT->DTSTART;
|
||||
$start_dt = $dtstart->getDateTime();
|
||||
$dtend = OC_Calendar_Object::getDTEndFromVEvent($object->VEVENT);
|
||||
$end_dt = $dtend->getDateTime();
|
||||
if($dtstart->getDateType() !== Sabre_VObject_Element_DateTime::DATE){
|
||||
if($dtstart->getDateType() !== Sabre_VObject_Element_DateTime::DATE) {
|
||||
$start_dt->setTimezone(new DateTimeZone('UTC'));
|
||||
$end_dt->setTimezone(new DateTimeZone('UTC'));
|
||||
$object->VEVENT->setDateTime('DTSTART', $start_dt, Sabre_VObject_Property_DateTime::UTC);
|
||||
|
@ -85,7 +85,7 @@ class OC_Calendar_Export{
|
|||
* @param string $string to fix
|
||||
* @return string
|
||||
*/
|
||||
private static function fixLineBreaks($string){
|
||||
private static function fixLineBreaks($string) {
|
||||
$string = str_replace("\r\n", "\n", $string);
|
||||
$string = str_replace("\r", "\n", $string);
|
||||
$string = str_replace("\n", "\r\n", $string);
|
||||
|
|