adding space between) and {

master
Thomas Mueller 2012-09-07 15:21:03 +02:00
parent 3e4bd9fbb5
commit 89ab3bae90
42 changed files with 379 additions and 379 deletions

View File

@ -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']);
}

View File

@ -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')));

View File

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

View File

@ -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'));

View File

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

View File

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

View File

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

View File

@ -8,7 +8,7 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
$view = $_POST['v'];
switch($view){
switch($view) {
case 'agendaWeek':
case 'month';
case 'list':

View File

@ -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']);

View File

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

View File

@ -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);

View File

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

View File

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

View File

@ -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));

View File

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

View File

@ -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{

View File

@ -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')));

View File

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

View File

@ -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{

View File

@ -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{

View File

@ -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') )));

View File

@ -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');

View File

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

View File

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

View File

@ -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';

View File

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

View File

@ -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();

View File

@ -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);

View File

@ -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));

View File

@ -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);

View File

@ -74,14 +74,14 @@ class OC_Calendar_Import{
* @param string $tz timezone of the user
* @return boolean
*/
public function __construct($ical){
public function __construct($ical) {
$this->error = null;
$this->ical = $ical;
$this->abscount = 0;
$this->count = 0;
try{
$this->calobject = OC_VObject::parse($this->ical);
}catch(Exception $e){
}catch(Exception $e) {
//MISSING: write some log
$this->error = true;
return false;
@ -93,13 +93,13 @@ class OC_Calendar_Import{
* @brief imports a calendar
* @return boolean
*/
public function import(){
if(!$this->isValid()){
public function import() {
if(!$this->isValid()) {
return false;
}
$numofcomponents = count($this->calobject->getComponents());
foreach($this->calobject->getComponents() as $object){
if(!($object instanceof Sabre_VObject_Component_VEvent) && !($object instanceof Sabre_VObject_Component_VJournal) && !($object instanceof Sabre_VObject_Component_VTodo)){
foreach($this->calobject->getComponents() as $object) {
if(!($object instanceof Sabre_VObject_Component_VEvent) && !($object instanceof Sabre_VObject_Component_VJournal) && !($object instanceof Sabre_VObject_Component_VTodo)) {
continue;
}
$dtend = OC_Calendar_Object::getDTEndFromVEvent($object);
@ -111,7 +111,7 @@ class OC_Calendar_Import{
$vcalendar = $this->createVCalendar($object->serialize());
$insertid = OC_Calendar_Object::add($this->id, $vcalendar);
$this->abscount++;
if($this->isDuplicate($insertid)){
if($this->isDuplicate($insertid)) {
OC_Calendar_Object::delete($insertid);
}else{
$this->count++;
@ -126,7 +126,7 @@ class OC_Calendar_Import{
* @brief sets the timezone
* @return boolean
*/
public function setTimeZone($tz){
public function setTimeZone($tz) {
$this->tz = $tz;
return true;
}
@ -135,7 +135,7 @@ class OC_Calendar_Import{
* @brief sets the progresskey
* @return boolean
*/
public function setProgresskey($progresskey){
public function setProgresskey($progresskey) {
$this->progresskey = $progresskey;
return true;
}
@ -144,8 +144,8 @@ class OC_Calendar_Import{
* @brief checks if something went wrong while initialization
* @return boolean
*/
public function isValid(){
if(is_null($this->error)){
public function isValid() {
if(is_null($this->error)) {
return true;
}
return false;
@ -155,7 +155,7 @@ class OC_Calendar_Import{
* @brief returns the percentage of progress
* @return integer
*/
public function getProgress(){
public function getProgress() {
return $this->progress;
}
@ -163,7 +163,7 @@ class OC_Calendar_Import{
* @brief enables the cache for the percentage of progress
* @return boolean
*/
public function enableProgressCache(){
public function enableProgressCache() {
$this->cacheprogress = true;
return true;
}
@ -172,7 +172,7 @@ class OC_Calendar_Import{
* @brief disables the cache for the percentage of progress
* @return boolean
*/
public function disableProgressCache(){
public function disableProgressCache() {
$this->cacheprogress = false;
return false;
}
@ -181,11 +181,11 @@ class OC_Calendar_Import{
* @brief generates a new calendar name
* @return string
*/
public function createCalendarName(){
public function createCalendarName() {
$calendars = OC_Calendar_Calendar::allCalendars($this->userid);
$calendarname = $guessedcalendarname = !is_null($this->guessCalendarName())?($this->guessCalendarName()):(OC_Calendar_App::$l10n->t('New Calendar'));
$i = 1;
while(!OC_Calendar_Calendar::isCalendarNameavailable($calendarname, $this->userid)){
while(!OC_Calendar_Calendar::isCalendarNameavailable($calendarname, $this->userid)) {
$calendarname = $guessedcalendarname . ' (' . $i . ')';
$i++;
}
@ -196,8 +196,8 @@ class OC_Calendar_Import{
* @brief generates a new calendar color
* @return string
*/
public function createCalendarColor(){
if(is_null($this->guessCalendarColor())){
public function createCalendarColor() {
if(is_null($this->guessCalendarColor())) {
return '#9fc6e7';
}
return $this->guessCalendarColor();
@ -208,7 +208,7 @@ class OC_Calendar_Import{
* @param integer $id of the calendar
* @return boolean
*/
public function setCalendarID($id){
public function setCalendarID($id) {
$this->id = $id;
return true;
}
@ -218,7 +218,7 @@ class OC_Calendar_Import{
* @param string $id of the user
* @return boolean
*/
public function setUserID($userid){
public function setUserID($userid) {
$this->userid = $userid;
return true;
}
@ -228,7 +228,7 @@ class OC_Calendar_Import{
* @param string $id of the user
* @return boolean
*/
public function getCount(){
public function getCount() {
return $this->count;
}
@ -240,7 +240,7 @@ class OC_Calendar_Import{
* @brief generates an unique ID
* @return string
*/
//private function createUID(){
//private function createUID() {
// return substr(md5(rand().time()),0,10);
//}
@ -249,7 +249,7 @@ class OC_Calendar_Import{
* @param string $uid uid to check
* @return boolean
*/
//private function isUIDAvailable($uid){
//private function isUIDAvailable($uid) {
//
//}
@ -258,8 +258,8 @@ class OC_Calendar_Import{
* @param string $vobject
* @return string
*/
private function createVCalendar($vobject){
if(is_object($vobject)){
private function createVCalendar($vobject) {
if(is_object($vobject)) {
$vobject = @$vobject->serialize();
}
$vcalendar = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud Calendar " . OCP\App::getAppVersion('calendar') . "\n";
@ -273,14 +273,14 @@ class OC_Calendar_Import{
* @param integer $insertid id of the new object
* @return boolean
*/
private function isDuplicate($insertid){
private function isDuplicate($insertid) {
$newobject = OC_Calendar_Object::find($insertid);
$stmt = OCP\DB::prepare('SELECT COUNT(*) AS `count` FROM `*PREFIX*calendar_objects`
INNER JOIN `*PREFIX*calendar_calendars` ON `calendarid`=`*PREFIX*calendar_calendars`.`id`
WHERE `objecttype`=? AND `startdate`=? AND `enddate`=? AND `repeating`=? AND `summary`=? AND `calendardata`=? AND `userid` = ?');
$result = $stmt->execute(array($newobject['objecttype'],$newobject['startdate'],$newobject['enddate'],$newobject['repeating'],$newobject['summary'],$newobject['calendardata'], $this->userid));
$result = $result->fetchRow();
if($result['count'] >= 2){
if($result['count'] >= 2) {
return true;
}
return false;
@ -291,9 +291,9 @@ class OC_Calendar_Import{
* @param integer $percentage
* @return boolean
*/
private function updateProgress($percentage){
private function updateProgress($percentage) {
$this->progress = $percentage;
if($this->cacheprogress){
if($this->cacheprogress) {
OC_Cache::set($this->progresskey, $this->progress, 300);
}
return true;
@ -307,8 +307,8 @@ class OC_Calendar_Import{
* @brief guesses the calendar color
* @return mixed - string or boolean
*/
public function guessCalendarColor(){
if(!is_null($this->calobject->__get('X-APPLE-CALENDAR-COLOR'))){
public function guessCalendarColor() {
if(!is_null($this->calobject->__get('X-APPLE-CALENDAR-COLOR'))) {
return $this->calobject->__get('X-APPLE-CALENDAR-COLOR');
}
return null;
@ -318,8 +318,8 @@ class OC_Calendar_Import{
* @brief guesses the calendar description
* @return mixed - string or boolean
*/
public function guessCalendarDescription(){
if(!is_null($this->calobject->__get('X-WR-CALDESC'))){
public function guessCalendarDescription() {
if(!is_null($this->calobject->__get('X-WR-CALDESC'))) {
return $this->calobject->__get('X-WR-CALDESC');
}
return null;
@ -329,8 +329,8 @@ class OC_Calendar_Import{
* @brief guesses the calendar name
* @return mixed - string or boolean
*/
public function guessCalendarName(){
if(!is_null($this->calobject->__get('X-WR-CALNAME'))){
public function guessCalendarName() {
if(!is_null($this->calobject->__get('X-WR-CALNAME'))) {
return $this->calobject->__get('X-WR-CALNAME');
}
return null;

View File

@ -39,12 +39,12 @@ class OC_Calendar_Object{
* The objects are associative arrays. You'll find the original vObject in
* ['calendardata']
*/
public static function all($id){
public static function all($id) {
$stmt = OCP\DB::prepare( 'SELECT * FROM `*PREFIX*calendar_objects` WHERE `calendarid` = ?' );
$result = $stmt->execute(array($id));
$calendarobjects = array();
while( $row = $result->fetchRow()){
while( $row = $result->fetchRow()) {
$calendarobjects[] = $row;
}
@ -61,7 +61,7 @@ class OC_Calendar_Object{
* The objects are associative arrays. You'll find the original vObject
* in ['calendardata']
*/
public static function allInPeriod($id, $start, $end){
public static function allInPeriod($id, $start, $end) {
$stmt = OCP\DB::prepare( 'SELECT * FROM `*PREFIX*calendar_objects` WHERE `calendarid` = ?'
.' AND ((`startdate` >= ? AND `startdate` <= ? AND `repeating` = 0)'
.' OR (`enddate` >= ? AND `enddate` <= ? AND `repeating` = 0)'
@ -74,7 +74,7 @@ class OC_Calendar_Object{
$end));
$calendarobjects = array();
while( $row = $result->fetchRow()){
while( $row = $result->fetchRow()) {
$calendarobjects[] = $row;
}
@ -86,7 +86,7 @@ class OC_Calendar_Object{
* @param integer $id
* @return associative array
*/
public static function find($id){
public static function find($id) {
$stmt = OCP\DB::prepare( 'SELECT * FROM `*PREFIX*calendar_objects` WHERE `id` = ?' );
$result = $stmt->execute(array($id));
@ -99,7 +99,7 @@ class OC_Calendar_Object{
* @param string $uri the uri ('filename')
* @return associative array
*/
public static function findWhereDAVDataIs($cid,$uri){
public static function findWhereDAVDataIs($cid,$uri) {
$stmt = OCP\DB::prepare( 'SELECT * FROM `*PREFIX*calendar_objects` WHERE `calendarid` = ? AND `uri` = ?' );
$result = $stmt->execute(array($cid,$uri));
@ -112,7 +112,7 @@ class OC_Calendar_Object{
* @param string $data object
* @return insertid
*/
public static function add($id,$data){
public static function add($id,$data) {
$calendar = OC_Calendar_Calendar::find($id);
if ($calendar['userid'] != OCP\User::getUser()) {
$sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $id);
@ -128,7 +128,7 @@ class OC_Calendar_Object{
OC_Calendar_App::loadCategoriesFromVCalendar($object);
list($type,$startdate,$enddate,$summary,$repeating,$uid) = self::extractData($object);
if(is_null($uid)){
if(is_null($uid)) {
$object->setUID();
$data = $object->serialize();
}
@ -151,7 +151,7 @@ class OC_Calendar_Object{
* @param string $data object
* @return insertid
*/
public static function addFromDAVData($id,$uri,$data){
public static function addFromDAVData($id,$uri,$data) {
$calendar = OC_Calendar_Calendar::find($id);
if ($calendar['userid'] != OCP\User::getUser()) {
$sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $id);
@ -181,7 +181,7 @@ class OC_Calendar_Object{
* @param string $data object
* @return boolean
*/
public static function edit($id, $data){
public static function edit($id, $data) {
$oldobject = self::find($id);
$calendar = OC_Calendar_Calendar::find($oldobject['calendarid']);
@ -215,7 +215,7 @@ class OC_Calendar_Object{
* @param string $data object
* @return boolean
*/
public static function editFromDAVData($cid,$uri,$data){
public static function editFromDAVData($cid,$uri,$data) {
$oldobject = self::findWhereDAVDataIs($cid,$uri);
$calendar = OC_Calendar_Calendar::find($cid);
@ -246,7 +246,7 @@ class OC_Calendar_Object{
* @param integer $id id of object
* @return boolean
*/
public static function delete($id){
public static function delete($id) {
$oldobject = self::find($id);
$calendar = OC_Calendar_Calendar::find($oldobject['calendarid']);
if ($calendar['userid'] != OCP\User::getUser()) {
@ -273,7 +273,7 @@ class OC_Calendar_Object{
* @param string $uri the uri of the object
* @return boolean
*/
public static function deleteFromDAVData($cid,$uri){
public static function deleteFromDAVData($cid,$uri) {
$oldobject = self::findWhereDAVDataIs($cid, $uri);
$calendar = OC_Calendar_Calendar::find($cid);
if ($calendar['userid'] != OCP\User::getUser()) {
@ -294,7 +294,7 @@ class OC_Calendar_Object{
return true;
}
public static function moveToCalendar($id, $calendarid){
public static function moveToCalendar($id, $calendarid) {
$calendar = OC_Calendar_Calendar::find($calendarid);
if ($calendar['userid'] != OCP\User::getUser()) {
$sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $id);
@ -319,7 +319,7 @@ class OC_Calendar_Object{
* @brief Creates a UID
* @return string
*/
protected static function createUID(){
protected static function createUID() {
return substr(md5(rand().time()),0,10);
}
@ -330,34 +330,34 @@ class OC_Calendar_Object{
*
* [type, start, end, summary, repeating, uid]
*/
protected static function extractData($object){
protected static function extractData($object) {
$return = array('',null,null,'',0,null);
// Child to use
$children = 0;
$use = null;
foreach($object->children as $property){
if($property->name == 'VEVENT'){
foreach($object->children as $property) {
if($property->name == 'VEVENT') {
$children++;
$thisone = true;
foreach($property->children as &$element){
if($element->name == 'RECURRENCE-ID'){
foreach($property->children as &$element) {
if($element->name == 'RECURRENCE-ID') {
$thisone = false;
}
} unset($element);
if($thisone){
if($thisone) {
$use = $property;
}
}
elseif($property->name == 'VTODO' || $property->name == 'VJOURNAL'){
elseif($property->name == 'VTODO' || $property->name == 'VJOURNAL') {
$return[0] = $property->name;
foreach($property->children as &$element){
if($element->name == 'SUMMARY'){
foreach($property->children as &$element) {
if($element->name == 'SUMMARY') {
$return[3] = $element->value;
}
elseif($element->name == 'UID'){
elseif($element->name == 'UID') {
$return[5] = $element->value;
}
};
@ -370,29 +370,29 @@ class OC_Calendar_Object{
}
// find the data
if(!is_null($use)){
if(!is_null($use)) {
$return[0] = $use->name;
foreach($use->children as $property){
if($property->name == 'DTSTART'){
foreach($use->children as $property) {
if($property->name == 'DTSTART') {
$return[1] = self::getUTCforMDB($property->getDateTime());
}
elseif($property->name == 'DTEND'){
elseif($property->name == 'DTEND') {
$return[2] = self::getUTCforMDB($property->getDateTime());
}
elseif($property->name == 'SUMMARY'){
elseif($property->name == 'SUMMARY') {
$return[3] = $property->value;
}
elseif($property->name == 'RRULE'){
elseif($property->name == 'RRULE') {
$return[4] = 1;
}
elseif($property->name == 'UID'){
elseif($property->name == 'UID') {
$return[5] = $property->value;
}
}
}
// More than one child means reoccuring!
if($children > 1){
if($children > 1) {
$return[4] = 1;
}
return $return;
@ -406,7 +406,7 @@ class OC_Calendar_Object{
* This function creates a date string that can be used by MDB2.
* Furthermore it converts the time to UTC.
*/
public static function getUTCforMDB($datetime){
public static function getUTCforMDB($datetime) {
return date('Y-m-d H:i', $datetime->format('U') - $datetime->getOffset());
}
@ -415,21 +415,21 @@ class OC_Calendar_Object{
* @param object $vevent vevent object
* @return object
*/
public static function getDTEndFromVEvent($vevent){
public static function getDTEndFromVEvent($vevent) {
if ($vevent->DTEND) {
$dtend = $vevent->DTEND;
}else{
$dtend = clone $vevent->DTSTART;
// clone creates a shallow copy, also clone DateTime
$dtend->setDateTime(clone $dtend->getDateTime(), $dtend->getDateType());
if ($vevent->DURATION){
if ($vevent->DURATION) {
$duration = strval($vevent->DURATION);
$invert = 0;
if ($duration[0] == '-'){
if ($duration[0] == '-') {
$duration = substr($duration, 1);
$invert = 1;
}
if ($duration[0] == '+'){
if ($duration[0] == '+') {
$duration = substr($duration, 1);
}
$interval = new DateInterval($duration);
@ -444,7 +444,7 @@ class OC_Calendar_Object{
* @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($l10n){
public static function getRepeatOptions($l10n) {
return array(
'doesnotrepeat' => $l10n->t('Does not repeat'),
'daily' => $l10n->t('Daily'),
@ -460,7 +460,7 @@ class OC_Calendar_Object{
* @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($l10n){
public static function getEndOptions($l10n) {
return array(
'never' => $l10n->t('never'),
'count' => $l10n->t('by occurrences'),
@ -472,7 +472,7 @@ class OC_Calendar_Object{
* @brief returns the options for an monthly repeating event
* @return array - valid inputs for monthly repeating events
*/
public static function getMonthOptions($l10n){
public static function getMonthOptions($l10n) {
return array(
'monthday' => $l10n->t('by monthday'),
'weekday' => $l10n->t('by weekday')
@ -483,7 +483,7 @@ class OC_Calendar_Object{
* @brief returns the options for an weekly repeating event
* @return array - valid inputs for weekly repeating events
*/
public static function getWeeklyOptions($l10n){
public static function getWeeklyOptions($l10n) {
return array(
'MO' => $l10n->t('Monday'),
'TU' => $l10n->t('Tuesday'),
@ -499,7 +499,7 @@ class OC_Calendar_Object{
* @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($l10n){
public static function getWeekofMonth($l10n) {
return array(
'auto' => $l10n->t('events week of month'),
'1' => $l10n->t('first'),
@ -515,9 +515,9 @@ class OC_Calendar_Object{
* @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 = array();
foreach(range(1,366) as $num){
foreach(range(1,366) as $num) {
$return[(string) $num] = (string) $num;
}
return $return;
@ -527,9 +527,9 @@ class OC_Calendar_Object{
* @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 = array();
foreach(range(1,31) as $num){
foreach(range(1,31) as $num) {
$return[(string) $num] = (string) $num;
}
return $return;
@ -539,7 +539,7 @@ class OC_Calendar_Object{
* @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($l10n){
public static function getByMonthOptions($l10n) {
return array(
'1' => $l10n->t('January'),
'2' => $l10n->t('February'),
@ -560,7 +560,7 @@ class OC_Calendar_Object{
* @brief returns the options for an yearly repeating event
* @return array - valid inputs for yearly repeating events
*/
public static function getYearOptions($l10n){
public static function getYearOptions($l10n) {
return array(
'bydate' => $l10n->t('by events date'),
'byyearday' => $l10n->t('by yearday(s)'),
@ -573,7 +573,7 @@ class OC_Calendar_Object{
* @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 range(1, 52);
}
@ -582,10 +582,10 @@ class OC_Calendar_Object{
* @param array $request
* @return mixed (array / boolean)
*/
public static function validateRequest($request){
public static function validateRequest($request) {
$errnum = 0;
$errarr = array('title'=>'false', 'cal'=>'false', 'from'=>'false', 'fromtime'=>'false', 'to'=>'false', 'totime'=>'false', 'endbeforestart'=>'false');
if($request['title'] == ''){
if($request['title'] == '') {
$errarr['title'] = 'true';
$errnum++;
}
@ -593,7 +593,7 @@ class OC_Calendar_Object{
$fromday = substr($request['from'], 0, 2);
$frommonth = substr($request['from'], 3, 2);
$fromyear = substr($request['from'], 6, 4);
if(!checkdate($frommonth, $fromday, $fromyear)){
if(!checkdate($frommonth, $fromday, $fromyear)) {
$errarr['from'] = 'true';
$errnum++;
}
@ -606,89 +606,89 @@ class OC_Calendar_Object{
$today = substr($request['to'], 0, 2);
$tomonth = substr($request['to'], 3, 2);
$toyear = substr($request['to'], 6, 4);
if(!checkdate($tomonth, $today, $toyear)){
if(!checkdate($tomonth, $today, $toyear)) {
$errarr['to'] = 'true';
$errnum++;
}
if($request['repeat'] != 'doesnotrepeat'){
if(is_nan($request['interval']) && $request['interval'] != ''){
if($request['repeat'] != 'doesnotrepeat') {
if(is_nan($request['interval']) && $request['interval'] != '') {
$errarr['interval'] = 'true';
$errnum++;
}
if(array_key_exists('repeat', $request) && !array_key_exists($request['repeat'], self::getRepeatOptions(OC_Calendar_App::$l10n))){
if(array_key_exists('repeat', $request) && !array_key_exists($request['repeat'], self::getRepeatOptions(OC_Calendar_App::$l10n))) {
$errarr['repeat'] = 'true';
$errnum++;
}
if(array_key_exists('advanced_month_select', $request) && !array_key_exists($request['advanced_month_select'], self::getMonthOptions(OC_Calendar_App::$l10n))){
if(array_key_exists('advanced_month_select', $request) && !array_key_exists($request['advanced_month_select'], self::getMonthOptions(OC_Calendar_App::$l10n))) {
$errarr['advanced_month_select'] = 'true';
$errnum++;
}
if(array_key_exists('advanced_year_select', $request) && !array_key_exists($request['advanced_year_select'], self::getYearOptions(OC_Calendar_App::$l10n))){
if(array_key_exists('advanced_year_select', $request) && !array_key_exists($request['advanced_year_select'], self::getYearOptions(OC_Calendar_App::$l10n))) {
$errarr['advanced_year_select'] = 'true';
$errnum++;
}
if(array_key_exists('weekofmonthoptions', $request) && !array_key_exists($request['weekofmonthoptions'], self::getWeekofMonth(OC_Calendar_App::$l10n))){
if(array_key_exists('weekofmonthoptions', $request) && !array_key_exists($request['weekofmonthoptions'], self::getWeekofMonth(OC_Calendar_App::$l10n))) {
$errarr['weekofmonthoptions'] = 'true';
$errnum++;
}
if($request['end'] != 'never'){
if(!array_key_exists($request['end'], self::getEndOptions(OC_Calendar_App::$l10n))){
if($request['end'] != 'never') {
if(!array_key_exists($request['end'], self::getEndOptions(OC_Calendar_App::$l10n))) {
$errarr['end'] = 'true';
$errnum++;
}
if($request['end'] == 'count' && is_nan($request['byoccurrences'])){
if($request['end'] == 'count' && is_nan($request['byoccurrences'])) {
$errarr['byoccurrences'] = 'true';
$errnum++;
}
if($request['end'] == 'date'){
if($request['end'] == 'date') {
list($bydate_day, $bydate_month, $bydate_year) = explode('-', $request['bydate']);
if(!checkdate($bydate_month, $bydate_day, $bydate_year)){
if(!checkdate($bydate_month, $bydate_day, $bydate_year)) {
$errarr['bydate'] = 'true';
$errnum++;
}
}
}
if(array_key_exists('weeklyoptions', $request)){
foreach($request['weeklyoptions'] as $option){
if(!in_array($option, self::getWeeklyOptions(OC_Calendar_App::$l10n))){
if(array_key_exists('weeklyoptions', $request)) {
foreach($request['weeklyoptions'] as $option) {
if(!in_array($option, self::getWeeklyOptions(OC_Calendar_App::$l10n))) {
$errarr['weeklyoptions'] = 'true';
$errnum++;
}
}
}
if(array_key_exists('byyearday', $request)){
foreach($request['byyearday'] as $option){
if(!array_key_exists($option, self::getByYearDayOptions())){
if(array_key_exists('byyearday', $request)) {
foreach($request['byyearday'] as $option) {
if(!array_key_exists($option, self::getByYearDayOptions())) {
$errarr['byyearday'] = 'true';
$errnum++;
}
}
}
if(array_key_exists('weekofmonthoptions', $request)){
if(is_nan((double)$request['weekofmonthoptions'])){
if(array_key_exists('weekofmonthoptions', $request)) {
if(is_nan((double)$request['weekofmonthoptions'])) {
$errarr['weekofmonthoptions'] = 'true';
$errnum++;
}
}
if(array_key_exists('bymonth', $request)){
foreach($request['bymonth'] as $option){
if(!in_array($option, self::getByMonthOptions(OC_Calendar_App::$l10n))){
if(array_key_exists('bymonth', $request)) {
foreach($request['bymonth'] as $option) {
if(!in_array($option, self::getByMonthOptions(OC_Calendar_App::$l10n))) {
$errarr['bymonth'] = 'true';
$errnum++;
}
}
}
if(array_key_exists('byweekno', $request)){
foreach($request['byweekno'] as $option){
if(!array_key_exists($option, self::getByWeekNoOptions())){
if(array_key_exists('byweekno', $request)) {
foreach($request['byweekno'] as $option) {
if(!array_key_exists($option, self::getByWeekNoOptions())) {
$errarr['byweekno'] = 'true';
$errnum++;
}
}
}
if(array_key_exists('bymonthday', $request)){
foreach($request['bymonthday'] as $option){
if(!array_key_exists($option, self::getByMonthDayOptions())){
if(array_key_exists('bymonthday', $request)) {
foreach($request['bymonthday'] as $option) {
if(!array_key_exists($option, self::getByMonthDayOptions())) {
$errarr['bymonthday'] = 'true';
$errnum++;
}
@ -699,26 +699,26 @@ class OC_Calendar_Object{
$errarr['totime'] = 'true';
$errnum++;
}
if($today < $fromday && $frommonth == $tomonth && $fromyear == $toyear){
if($today < $fromday && $frommonth == $tomonth && $fromyear == $toyear) {
$errarr['endbeforestart'] = 'true';
$errnum++;
}
if($today == $fromday && $frommonth > $tomonth && $fromyear == $toyear){
if($today == $fromday && $frommonth > $tomonth && $fromyear == $toyear) {
$errarr['endbeforestart'] = 'true';
$errnum++;
}
if($today == $fromday && $frommonth == $tomonth && $fromyear > $toyear){
if($today == $fromday && $frommonth == $tomonth && $fromyear > $toyear) {
$errarr['endbeforestart'] = 'true';
$errnum++;
}
if(!$allday && $fromday == $today && $frommonth == $tomonth && $fromyear == $toyear){
if(!$allday && $fromday == $today && $frommonth == $tomonth && $fromyear == $toyear) {
list($tohours, $tominutes) = explode(':', $request['totime']);
list($fromhours, $fromminutes) = explode(':', $request['fromtime']);
if($tohours < $fromhours){
if($tohours < $fromhours) {
$errarr['endbeforestart'] = 'true';
$errnum++;
}
if($tohours == $fromhours && $tominutes < $fromminutes){
if($tohours == $fromhours && $tominutes < $fromminutes) {
$errarr['endbeforestart'] = 'true';
$errnum++;
}
@ -735,7 +735,7 @@ class OC_Calendar_Object{
* @param string $time
* @return boolean
*/
protected static function checkTime($time){
protected static function checkTime($time) {
list($hours, $minutes) = explode(':', $time);
return empty($time)
|| $hours < 0 || $hours > 24
@ -746,7 +746,7 @@ class OC_Calendar_Object{
* @brief creates an VCalendar Object from the request data
* @param array $request
* @return object created $vcalendar
*/ public static function createVCalendarFromRequest($request){
*/ public static function createVCalendarFromRequest($request) {
$vcalendar = new OC_VObject('VCALENDAR');
$vcalendar->add('PRODID', 'ownCloud Calendar');
$vcalendar->add('VERSION', '2.0');
@ -766,36 +766,36 @@ class OC_Calendar_Object{
* @param object $vcalendar
* @return object updated $vcalendar
*/
public static function updateVCalendarFromRequest($request, $vcalendar){
public static function updateVCalendarFromRequest($request, $vcalendar) {
$title = $request["title"];
$location = $request["location"];
$categories = $request["categories"];
$allday = isset($request["allday"]);
$from = $request["from"];
$to = $request["to"];
if (!$allday){
if (!$allday) {
$fromtime = $request['fromtime'];
$totime = $request['totime'];
}
$vevent = $vcalendar->VEVENT;
$description = $request["description"];
$repeat = $request["repeat"];
if($repeat != 'doesnotrepeat'){
if($repeat != 'doesnotrepeat') {
$rrule = '';
$interval = $request['interval'];
$end = $request['end'];
$byoccurrences = $request['byoccurrences'];
switch($repeat){
switch($repeat) {
case 'daily':
$rrule .= 'FREQ=DAILY';
break;
case 'weekly':
$rrule .= 'FREQ=WEEKLY';
if(array_key_exists('weeklyoptions', $request)){
if(array_key_exists('weeklyoptions', $request)) {
$byday = '';
$daystrings = array_flip(self::getWeeklyOptions(OC_Calendar_App::$l10n));
foreach($request['weeklyoptions'] as $days){
if($byday == ''){
foreach($request['weeklyoptions'] as $days) {
if($byday == '') {
$byday .= $daystrings[$days];
}else{
$byday .= ',' .$daystrings[$days];
@ -814,10 +814,10 @@ class OC_Calendar_Object{
break;
case 'monthly':
$rrule .= 'FREQ=MONTHLY';
if($request['advanced_month_select'] == 'monthday'){
if($request['advanced_month_select'] == 'monthday') {
break;
}elseif($request['advanced_month_select'] == 'weekday'){
if($request['weekofmonthoptions'] == 'auto'){
}elseif($request['advanced_month_select'] == 'weekday') {
if($request['weekofmonthoptions'] == 'auto') {
list($_day, $_month, $_year) = explode('-', $from);
$weekofmonth = floor($_day/7);
}else{
@ -825,14 +825,14 @@ class OC_Calendar_Object{
}
$days = array_flip(self::getWeeklyOptions(OC_Calendar_App::$l10n));
$byday = '';
foreach($request['weeklyoptions'] as $day){
if($byday == ''){
foreach($request['weeklyoptions'] as $day) {
if($byday == '') {
$byday .= $weekofmonth . $days[$day];
}else{
$byday .= ',' . $weekofmonth . $days[$day];
}
}
if($byday == ''){
if($byday == '') {
$byday = 'MO,TU,WE,TH,FR,SA,SU';
}
$rrule .= ';BYDAY=' . $byday;
@ -840,35 +840,35 @@ class OC_Calendar_Object{
break;
case 'yearly':
$rrule .= 'FREQ=YEARLY';
if($request['advanced_year_select'] == 'bydate'){
if($request['advanced_year_select'] == 'bydate') {
}elseif($request['advanced_year_select'] == 'byyearday'){
}elseif($request['advanced_year_select'] == 'byyearday') {
list($_day, $_month, $_year) = explode('-', $from);
$byyearday = date('z', mktime(0,0,0, $_month, $_day, $_year)) + 1;
if(array_key_exists('byyearday', $request)){
foreach($request['byyearday'] as $yearday){
if(array_key_exists('byyearday', $request)) {
foreach($request['byyearday'] as $yearday) {
$byyearday .= ',' . $yearday;
}
}
$rrule .= ';BYYEARDAY=' . $byyearday;
}elseif($request['advanced_year_select'] == 'byweekno'){
}elseif($request['advanced_year_select'] == 'byweekno') {
list($_day, $_month, $_year) = explode('-', $from);
$rrule .= ';BYDAY=' . strtoupper(substr(date('l', mktime(0,0,0, $_month, $_day, $_year)), 0, 2));
$byweekno = '';
foreach($request['byweekno'] as $weekno){
if($byweekno == ''){
foreach($request['byweekno'] as $weekno) {
if($byweekno == '') {
$byweekno = $weekno;
}else{
$byweekno .= ',' . $weekno;
}
}
$rrule .= ';BYWEEKNO=' . $byweekno;
}elseif($request['advanced_year_select'] == 'bydaymonth'){
if(array_key_exists('weeklyoptions', $request)){
}elseif($request['advanced_year_select'] == 'bydaymonth') {
if(array_key_exists('weeklyoptions', $request)) {
$days = array_flip(self::getWeeklyOptions(OC_Calendar_App::$l10n));
$byday = '';
foreach($request['weeklyoptions'] as $day){
if($byday == ''){
foreach($request['weeklyoptions'] as $day) {
if($byday == '') {
$byday .= $days[$day];
}else{
$byday .= ',' . $days[$day];
@ -876,11 +876,11 @@ class OC_Calendar_Object{
}
$rrule .= ';BYDAY=' . $byday;
}
if(array_key_exists('bymonth', $request)){
if(array_key_exists('bymonth', $request)) {
$monthes = array_flip(self::getByMonthOptions(OC_Calendar_App::$l10n));
$bymonth = '';
foreach($request['bymonth'] as $month){
if($bymonth == ''){
foreach($request['bymonth'] as $month) {
if($bymonth == '') {
$bymonth .= $monthes[$month];
}else{
$bymonth .= ',' . $monthes[$month];
@ -889,10 +889,10 @@ class OC_Calendar_Object{
$rrule .= ';BYMONTH=' . $bymonth;
}
if(array_key_exists('bymonthday', $request)){
if(array_key_exists('bymonthday', $request)) {
$bymonthday = '';
foreach($request['bymonthday'] as $monthday){
if($bymonthday == ''){
foreach($request['bymonthday'] as $monthday) {
if($bymonthday == '') {
$bymonthday .= $monthday;
}else{
$bymonthday .= ',' . $monthday;
@ -906,13 +906,13 @@ class OC_Calendar_Object{
default:
break;
}
if($interval != ''){
if($interval != '') {
$rrule .= ';INTERVAL=' . $interval;
}
if($end == 'count'){
if($end == 'count') {
$rrule .= ';COUNT=' . $byoccurrences;
}
if($end == 'date'){
if($end == 'date') {
list($bydate_day, $bydate_month, $bydate_year) = explode('-', $request['bydate']);
$rrule .= ';UNTIL=' . $bydate_year . $bydate_month . $bydate_day;
}
@ -927,7 +927,7 @@ class OC_Calendar_Object{
$vevent->setDateTime('DTSTAMP', 'now', Sabre_VObject_Property_DateTime::UTC);
$vevent->setString('SUMMARY', $title);
if($allday){
if($allday) {
$start = new DateTime($from);
$end = new DateTime($to.' +1 day');
$vevent->setDateTime('DTSTART', $start, Sabre_VObject_Property_DateTime::DATE);
@ -946,7 +946,7 @@ class OC_Calendar_Object{
$vevent->setString('DESCRIPTION', $description);
$vevent->setString('CATEGORIES', $categories);
/*if($repeat == "true"){
/*if($repeat == "true") {
$vevent->RRULE = $repeat;
}*/
@ -958,7 +958,7 @@ class OC_Calendar_Object{
* @param integer $id
* @return string
*/
public static function getowner($id){
public static function getowner($id) {
$event = self::find($id);
$cal = OC_Calendar_Calendar::find($event['calendarid']);
return $cal['userid'];
@ -969,7 +969,7 @@ class OC_Calendar_Object{
* @param integer $id
* @return integer
*/
public static function getCalendarid($id){
public static function getCalendarid($id) {
$event = self::find($id);
return $event['calendarid'];
}
@ -979,7 +979,7 @@ class OC_Calendar_Object{
* @param integer $id
* @return boolean
*/
public static function isrepeating($id){
public static function isrepeating($id) {
$event = self::find($id);
return ($event['repeating'] == 1)?true:false;
}
@ -992,14 +992,14 @@ class OC_Calendar_Object{
* @param string $tz
* @return array
*/
public static function generateStartEndDate($dtstart, $dtend, $allday, $tz){
public static function generateStartEndDate($dtstart, $dtend, $allday, $tz) {
$start_dt = $dtstart->getDateTime();
$end_dt = $dtend->getDateTime();
$return = array();
if($allday){
if($allday) {
$return['start'] = $start_dt->format('Y-m-d');
$end_dt->modify('-1 minute');
while($start_dt >= $end_dt){
while($start_dt >= $end_dt) {
$end_dt->modify('+1 day');
}
$return['end'] = $end_dt->format('Y-m-d');

View File

@ -15,11 +15,11 @@ class OC_Calendar_Repeat{
* @param (int) $id - id of the event
* @return (array)
*/
public static function get($id){
public static function get($id) {
$stmt = OCP\DB::prepare('SELECT * FROM `*PREFIX*calendar_repeat` WHERE `eventid` = ?');
$result = $stmt->execute(array($id));
$return = array();
while($row = $result->fetchRow()){
while($row = $result->fetchRow()) {
$return[] = $row;
}
return $return;
@ -31,7 +31,7 @@ class OC_Calendar_Repeat{
* @param (DateTime) $until - end for period in UTC
* @return (array)
*/
public static function get_inperiod($id, $from, $until){
public static function get_inperiod($id, $from, $until) {
$stmt = OCP\DB::prepare( 'SELECT * FROM `*PREFIX*calendar_repeat` WHERE `eventid` = ?'
.' AND ((`startdate` >= ? AND `startdate` <= ?)'
.' OR (`enddate` >= ? AND `enddate` <= ?))');
@ -39,7 +39,7 @@ class OC_Calendar_Repeat{
OC_Calendar_Object::getUTCforMDB($from), OC_Calendar_Object::getUTCforMDB($until),
OC_Calendar_Object::getUTCforMDB($from), OC_Calendar_Object::getUTCforMDB($until)));
$return = array();
while($row = $result->fetchRow()){
while($row = $result->fetchRow()) {
$return[] = $row;
}
return $return;
@ -49,11 +49,11 @@ class OC_Calendar_Repeat{
* @param (int) $id - id of the calendar
* @return (array)
*/
public static function getCalendar($id){
public static function getCalendar($id) {
$stmt = OCP\DB::prepare('SELECT * FROM `*PREFIX*calendar_repeat` WHERE `calid` = ?');
$result = $stmt->execute(array($id));
$return = array();
while($row = $result->fetchRow()){
while($row = $result->fetchRow()) {
$return[] = $row;
}
return $return;
@ -65,7 +65,7 @@ class OC_Calendar_Repeat{
* @param (string) $until - end for period in UTC
* @return (array)
*/
public static function getCalendar_inperiod($id, $from, $until){
public static function getCalendar_inperiod($id, $from, $until) {
$stmt = OCP\DB::prepare( 'SELECT * FROM `*PREFIX*calendar_repeat` WHERE `calid` = ?'
.' AND ((`startdate` >= ? AND `startdate` <= ?)'
.' OR (`enddate` >= ? AND `enddate` <= ?))');
@ -73,7 +73,7 @@ class OC_Calendar_Repeat{
$from, $until,
$from, $until));
$return = array();
while($row = $result->fetchRow()){
while($row = $result->fetchRow()) {
$return[] = $row;
}
return $return;
@ -83,9 +83,9 @@ class OC_Calendar_Repeat{
* @param (int) id - id of the event
* @return (bool)
*/
public static function generate($id){
public static function generate($id) {
$event = OC_Calendar_Object::find($id);
if($event['repeating'] == 0){
if($event['repeating'] == 0) {
return false;
}
$object = OC_VObject::parse($event['calendardata']);
@ -94,8 +94,8 @@ class OC_Calendar_Repeat{
$end = new DateTime('31-12-' . date('Y') . ' 23:59:59', new DateTimeZone('UTC'));
$end->modify('+5 years');
$object->expand($start, $end);
foreach($object->getComponents() as $vevent){
if(!($vevent instanceof Sabre_VObject_Component_VEvent)){
foreach($object->getComponents() as $vevent) {
if(!($vevent instanceof Sabre_VObject_Component_VEvent)) {
continue;
}
$startenddate = OC_Calendar_Object::generateStartEndDate($vevent->DTSTART, OC_Calendar_Object::getDTEndFromVEvent($vevent), ($vevent->DTSTART->getDateType() == Sabre_VObject_Element_DateTime::DATE)?true:false, 'UTC');
@ -109,9 +109,9 @@ class OC_Calendar_Repeat{
* @param (int) id - id of the calendar
* @return (bool)
*/
public static function generateCalendar($id){
public static function generateCalendar($id) {
$allobjects = OC_Calendar_Object::all($id);
foreach($allobjects as $event){
foreach($allobjects as $event) {
self::generate($event['id']);
}
return true;
@ -121,7 +121,7 @@ class OC_Calendar_Repeat{
* @param (int) id - id of the event
* @return (bool)
*/
public static function update($id){
public static function update($id) {
self::clean($id);
self::generate($id);
return true;
@ -131,7 +131,7 @@ class OC_Calendar_Repeat{
* @param (int) id - id of the calendar
* @return (bool)
*/
public static function updateCalendar($id){
public static function updateCalendar($id) {
self::cleanCalendar($id);
self::generateCalendar($id);
return true;
@ -141,8 +141,8 @@ class OC_Calendar_Repeat{
* @param (int) id - id of the event
* @return (bool)
*/
public static function is_cached($id){
if(count(self::get($id)) != 0){
public static function is_cached($id) {
if(count(self::get($id)) != 0) {
return true;
}else{
return false;
@ -155,8 +155,8 @@ class OC_Calendar_Repeat{
* @param (DateTime) $until - end for period in UTC
* @return (bool)
*/
public static function is_cached_inperiod($id, $start, $end){
if(count(self::get_inperiod($id, $start, $end)) != 0){
public static function is_cached_inperiod($id, $start, $end) {
if(count(self::get_inperiod($id, $start, $end)) != 0) {
return true;
}else{
return false;
@ -168,16 +168,16 @@ class OC_Calendar_Repeat{
* @param (int) id - id of the calendar
* @return (bool)
*/
public static function is_calendar_cached($id){
public static function is_calendar_cached($id) {
$cachedevents = count(self::getCalendar($id));
$repeatingevents = 0;
$allevents = OC_Calendar_Object::all($id);
foreach($allevents as $event){
if($event['repeating'] === 1){
foreach($allevents as $event) {
if($event['repeating'] === 1) {
$repeatingevents++;
}
}
if($cachedevents < $repeatingevents){
if($cachedevents < $repeatingevents) {
return false;
}else{
return true;
@ -188,7 +188,7 @@ class OC_Calendar_Repeat{
* @param (int) id - id of the event
* @return (bool)
*/
public static function clean($id){
public static function clean($id) {
$stmt = OCP\DB::prepare('DELETE FROM `*PREFIX*calendar_repeat` WHERE `eventid` = ?');
$stmt->execute(array($id));
}
@ -197,7 +197,7 @@ class OC_Calendar_Repeat{
* @param (int) id - id of the calendar
* @return (bool)
*/
public static function cleanCalendar($id){
public static function cleanCalendar($id) {
$stmt = OCP\DB::prepare('DELETE FROM `*PREFIX*calendar_repeat` WHERE `calid` = ?');
$stmt->execute(array($id));
}

View File

@ -36,7 +36,7 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract {
$raw = OC_Calendar_Calendar::allCalendarsWherePrincipalURIIs($principalUri);
$calendars = array();
foreach( $raw as $row ){
foreach( $raw as $row ) {
$components = explode(',',$row['components']);
if($row['userid'] != OCP\USER::getUser()) {
@ -108,7 +108,7 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract {
if(!isset($newValues['timezone'])) $newValues['timezone'] = null;
if(!isset($newValues['calendarorder'])) $newValues['calendarorder'] = 0;
if(!isset($newValues['calendarcolor'])) $newValues['calendarcolor'] = null;
if(!is_null($newValues['calendarcolor']) && strlen($newValues['calendarcolor']) == 9){
if(!is_null($newValues['calendarcolor']) && strlen($newValues['calendarcolor']) == 9) {
$newValues['calendarcolor'] = substr($newValues['calendarcolor'], 0, 7);
}
@ -198,7 +198,7 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract {
if(!isset($newValues['timezone'])) $newValues['timezone'] = null;
if(!isset($newValues['calendarorder'])) $newValues['calendarorder'] = null;
if(!isset($newValues['calendarcolor'])) $newValues['calendarcolor'] = null;
if(!is_null($newValues['calendarcolor']) && strlen($newValues['calendarcolor']) == 9){
if(!is_null($newValues['calendarcolor']) && strlen($newValues['calendarcolor']) == 9) {
$newValues['calendarcolor'] = substr($newValues['calendarcolor'], 0, 7);
}
@ -215,7 +215,7 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract {
* @return void
*/
public function deleteCalendar($calendarId) {
if(preg_match( '=iCal/[1-4]?.*Mac OS X/10.[1-6](.[0-9])?=', $_SERVER['HTTP_USER_AGENT'] )){
if(preg_match( '=iCal/[1-4]?.*Mac OS X/10.[1-6](.[0-9])?=', $_SERVER['HTTP_USER_AGENT'] )) {
throw new Sabre_DAV_Exception_Forbidden("Action is not possible with OSX 10.6.x", 403);
}
@ -246,7 +246,7 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract {
*/
public function getCalendarObjects($calendarId) {
$data = array();
foreach(OC_Calendar_Object::all($calendarId) as $row){
foreach(OC_Calendar_Object::all($calendarId) as $row) {
$data[] = $this->OCAddETag($row);
}
return $data;
@ -266,7 +266,7 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract {
*/
public function getCalendarObject($calendarId,$objectUri) {
$data = OC_Calendar_Object::findWhereDAVDataIs($calendarId,$objectUri);
if(is_array($data)){
if(is_array($data)) {
$data = $this->OCAddETag($data);
}
return $data;
@ -292,7 +292,7 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract {
* @param string $calendarData
* @return void
*/
public function updateCalendarObject($calendarId,$objectUri,$calendarData){
public function updateCalendarObject($calendarId,$objectUri,$calendarData) {
OC_Calendar_Object::editFromDAVData($calendarId,$objectUri,$calendarData);
}
@ -303,7 +303,7 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract {
* @param string $objectUri
* @return void
*/
public function deleteCalendarObject($calendarId,$objectUri){
public function deleteCalendarObject($calendarId,$objectUri) {
OC_Calendar_Object::deleteFromDAVData($calendarId,$objectUri);
}
@ -314,7 +314,7 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract {
*
* Adds a key "etag" to the row
*/
private function OCAddETag($row){
private function OCAddETag($row) {
$row['etag'] = '"'.md5($row['calendarid'].$row['uri'].$row['calendardata'].$row['lastmodified']).'"';
return $row;
}

View File

@ -1,26 +1,26 @@
<?php
class OC_Search_Provider_Calendar extends OC_Search_Provider{
function search($query){
function search($query) {
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser(), true);
if(count($calendars)==0 || !OCP\App::isEnabled('calendar')){
if(count($calendars)==0 || !OCP\App::isEnabled('calendar')) {
//return false;
}
$results=array();
$searchquery=array();
if(substr_count($query, ' ') > 0){
if(substr_count($query, ' ') > 0) {
$searchquery = explode(' ', $query);
}else{
$searchquery[] = $query;
}
$user_timezone = OC_Calendar_App::getTimezone();
$l = new OC_l10n('calendar');
foreach($calendars as $calendar){
foreach($calendars as $calendar) {
$objects = OC_Calendar_Object::all($calendar['id']);
foreach($objects as $object){
foreach($objects as $object) {
if($object['objecttype']!='VEVENT') {
continue;
}
if(substr_count(strtolower($object['summary']), strtolower($query)) > 0){
if(substr_count(strtolower($object['summary']), strtolower($query)) > 0) {
$calendardata = OC_VObject::parse($object['calendardata']);
$vevent = $calendardata->VEVENT;
$dtstart = $vevent->DTSTART;
@ -29,9 +29,9 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{
$start_dt->setTimezone(new DateTimeZone($user_timezone));
$end_dt = $dtend->getDateTime();
$end_dt->setTimezone(new DateTimeZone($user_timezone));
if ($dtstart->getDateType() == Sabre_VObject_Property_DateTime::DATE){
if ($dtstart->getDateType() == Sabre_VObject_Property_DateTime::DATE) {
$end_dt->modify('-1 sec');
if($start_dt->format('d.m.Y') != $end_dt->format('d.m.Y')){
if($start_dt->format('d.m.Y') != $end_dt->format('d.m.Y')) {
$info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y') . ' - ' . $end_dt->format('d.m.Y');
}else{
$info = $l->t('Date') . ': ' . $start_dt->format('d.m.Y');

View File

@ -23,7 +23,7 @@
var firstDay = '<?php echo (OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'firstday', 'mo') == 'mo' ? '1' : '0'); ?>';
$(document).ready(function() {
<?php
if(array_key_exists('showevent', $_)){
if(array_key_exists('showevent', $_)) {
$data = OC_Calendar_App::getEventObject($_['showevent']);
$date = substr($data['startdate'], 0, 10);
list($year, $month, $day) = explode('-', $date);

View File

@ -3,7 +3,7 @@
<table width="100%" style="border: 0;">
<?php
$option_calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
for($i = 0; $i < count($option_calendars); $i++){
for($i = 0; $i < count($option_calendars); $i++) {
echo "<tr data-id='".$option_calendars[$i]['id']."'>";
$tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields');
$tmpl->assign('calendar', $option_calendars[$i]);

View File

@ -31,7 +31,7 @@
<select id="calendarcolor_<?php echo $_['calendar']['id'] ?>" class="colorpicker">
<?php
if (!isset($_['calendar']['calendarcolor'])) {$_['calendar']['calendarcolor'] = false;}
foreach($_['calendarcolor_options'] as $color){
foreach($_['calendarcolor_options'] as $color) {
echo '<option value="' . $color . '"' . ($_['calendar']['calendarcolor'] == $color ? ' selected="selected"' : '') . '>' . $color . '</option>';
}
?>

View File

@ -52,7 +52,7 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid
<tr>
<th width="75px"></th>
<td>
<input onclick="Calendar.UI.lockTime();" type="checkbox"<?php if($_['allday']){echo 'checked="checked"';} ?> id="allday_checkbox" name="allday">
<input onclick="Calendar.UI.lockTime();" type="checkbox"<?php if($_['allday']) {echo 'checked="checked"';} ?> id="allday_checkbox" name="allday">
<label for="allday_checkbox"><?php echo $l->t("All Day Event");?></label>
</td>
</tr>
@ -246,6 +246,6 @@ echo 'Calendar.UI.Share.idtype = "event";' . "\n" . 'Calendar.UI.Share.currentid
<div id="tabs-4">//Attendees</div>-->
<?php if($_['eventid'] != 'new' && $_['permissions'] & OCP\Share::PERMISSION_SHARE) { ?>
<div id="tabs-5">
<?php if($_['eventid'] != 'new'){ echo $this->inc('part.share'); } ?>
<?php if($_['eventid'] != 'new') { echo $this->inc('part.share'); } ?>
</div>
<?php } ?>

View File

@ -1,7 +1,7 @@
<?php
//Prerendering for iCalendar file
$file = OC_Filesystem::file_get_contents($_['path'] . '/' . $_['filename']);
if(!$file){
if(!$file) {
OCP\JSON::error(array('error'=>'404'));
}
$import = new OC_Calendar_Import($file);
@ -24,7 +24,7 @@ $defaultcolors = OC_Calendar_Calendar::getCalendarColorOptions();
<div id="calendar_import_form_message"><?php echo $l->t('Please choose a calendar'); ?></div>
<select style="width:100%;" id="calendar_import_calendar" name="calendar_import_calendar">
<?php
for($i = 0;$i<count($calendar_options);$i++){
for($i = 0;$i<count($calendar_options);$i++) {
$calendar_options[$i]['displayname'] = $calendar_options[$i]['displayname'];
}
echo OCP\html_select_options($calendar_options, $calendar_options[0]['id'], array('value'=>'id', 'label'=>'displayname'));
@ -36,7 +36,7 @@ $defaultcolors = OC_Calendar_Calendar::getCalendarColorOptions();
<input id="calendar_import_newcalendar" class="" type="text" placeholder="<?php echo $l->t('Name of new calendar'); ?>" value="<?php echo $guessedcalendarname ?>"><br>
<div id="calendar_import_defaultcolors">
<?php
foreach($defaultcolors as $color){
foreach($defaultcolors as $color) {
echo '<span class="calendar-colorpicker-color" rel="' . $color . '" style="background-color: ' . $color . ';"></span>';
}
?>

View File

@ -19,11 +19,11 @@
<th width="75px"><?php echo $l->t("Category");?>:</th>
<td>
<?php
if(count($_['categories']) == 0 || $_['categories'] == ''){
if(count($_['categories']) == 0 || $_['categories'] == '') {
echo $l->t('No categories selected');
}else{
echo '<ul>';
foreach($_['categories'] as $categorie){
foreach($_['categories'] as $categorie) {
echo '<li>' . $categorie . '</li>';
}
echo '</ul>';
@ -48,7 +48,7 @@
<tr>
<th width="75px"></th>
<td>
<input onclick="Calendar.UI.lockTime();" type="checkbox"<?php if($_['allday']){echo 'checked="checked"';} ?> id="allday_checkbox" name="allday" disabled="disabled">
<input onclick="Calendar.UI.lockTime();" type="checkbox"<?php if($_['allday']) {echo 'checked="checked"';} ?> id="allday_checkbox" name="allday" disabled="disabled">
<?php echo $l->t("All Day Event");?>
</td>
</tr>

View File

@ -7,7 +7,7 @@
*/
class Test_Calendar_Calendars extends UnitTestCase {
function testBasic(){
function testBasic() {
$uid=uniqid();
$this->assertEqual(OC_Calendar_Calendar::allCalendars($uid),array());