Esempio n. 1
0
 /**
  * get a list of Tasks filtered by listID and type
  * 
  * @param  string $listID
  * @param  string $type
  * @return array
  * @throws \Exception
  */
 public function getAll($listID = 'all', $type = 'all')
 {
     if ($listID == 'all') {
         $calendars = \OC_Calendar_Calendar::allCalendars($this->userId, true);
     } else {
         $calendar = \OC_Calendar_App::getCalendar($listID, true, false);
         $calendars = array($calendar);
     }
     $tasks = array();
     $lists = array();
     foreach ($calendars as $calendar) {
         $tasksMap = $this->mapperHelper->createTasksMap($calendar['id']);
         list($lists[], $rootTasks) = $this->mapperHelper->getRootTasks($tasksMap, $type, $calendar['id']);
         $tasks = array_merge($tasks, $rootTasks);
         foreach ($rootTasks as $rootTask) {
             $tasks = array_merge($tasks, $this->mapperHelper->getChildTasks($rootTask['uid'], $tasksMap, true));
         }
     }
     return array('tasks' => array_values($tasks), 'lists' => $lists);
 }
Esempio n. 2
0
if ($_POST['method'] == 'new') {
    $calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser());
    foreach ($calendars as $calendar) {
        if ($calendar['displayname'] == $_POST['calname']) {
            $id = $calendar['id'];
            $newcal = false;
            break;
        }
        $newcal = true;
    }
    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()) {
        OCP\JSON::error(array('error' => 'missingcalendarrights'));
        exit;
    }
    $id = $_POST['id'];
    $import->setOverwrite($_POST['overwrite']);
}
$import->setCalendarID($id);
try {
    $import->import();
} catch (Exception $e) {
    OCP\JSON::error(array('message' => OC_Calendar_App::$l10n->t('Import failed'), 'debug' => $e->getMessage()));
    //write some log
}
$count = $import->getCount();
Esempio n. 3
0
<?php

/**
 * Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\User::checkLoggedIn();
OCP\App::checkAppEnabled('calendar');
$cal = isset($_GET['calid']) ? $_GET['calid'] : null;
$event = isset($_GET['eventid']) ? $_GET['eventid'] : null;
if (!is_null($cal)) {
    $calendar = OC_Calendar_App::getCalendar($cal, true);
    if (!$calendar) {
        header('HTTP/1.0 403 Forbidden');
        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 (!is_null($event)) {
    $data = OC_Calendar_App::getEventObject($_GET['eventid'], true);
    if (!$data) {
        header('HTTP/1.0 403 Forbidden');
        exit;
    }
    header('Content-Type: text/calendar');
    header('Content-Disposition: inline; filename=' . str_replace(' ', '-', $data['summary']) . '.ics');
    echo OC_Calendar_Export::export($event, OC_Calendar_Export::EVENT);
}
Esempio n. 4
0
 /**
  * @brief Converts the shared item sources back into the item in the specified format
  * @param array Shared items
  * @param int Format
  * @return ?
  *
  * The items array is a 3-dimensional array with the item_source as the first key and the share id as the second key to an array with the share info.
  * The key/value pairs included in the share info depend on the function originally called:
  * If called by getItem(s)Shared: id, item_type, item, item_source, share_type, share_with, permissions, stime, file_source
  * If called by getItem(s)SharedWith: id, item_type, item, item_source, item_target, share_type, share_with, permissions, stime, file_source, file_target
  * This function allows the backend to control the output of shared items with custom formats.
  * It is only called through calls to the public getItem(s)Shared(With) functions.
  */
 public function formatItems($items, $format, $parameters = null)
 {
     $calendars = array();
     if ($format == self::FORMAT_CALENDAR) {
         foreach ($items as $item) {
             $calendar = OC_Calendar_App::getCalendar($item['item_source'], false);
             if (!$calendar) {
                 continue;
             }
             // TODO: really check $parameters['permissions'] == 'rw'/'r'
             if ($parameters['permissions'] == 'rw') {
                 continue;
                 // TODO
             }
             $calendar['displaynamename'] = $item['item_target'];
             $calendar['permissions'] = $item['permissions'];
             $calendar['calendarid'] = $calendar['id'];
             $calendar['owner'] = $calendar['userid'];
             $calendars[] = $calendar;
         }
     }
     return $calendars;
 }
Esempio n. 5
0
<?php

/**
 * Copyright (c) 2011 Bart Visscher <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
$calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions();
$calendar = OC_Calendar_App::getCalendar($_GET['calendarid']);
$tmpl = new OCP\Template("calendar", "part.editcalendar");
$tmpl->assign('new', false);
$tmpl->assign('calendarcolor_options', $calendarcolor_options);
$tmpl->assign('calendar', $calendar);
$tmpl->printPage();
Esempio n. 6
0
} else {
    echo '<ul>';
    foreach ($_['categories'] as $categorie) {
        echo '<li>' . $categorie . '</li>';
    }
    echo '</ul>';
}
?>
			</td>
			<th width="75px">&nbsp;&nbsp;&nbsp;<?php 
echo $l->t("Calendar");
?>
:</th>
			<td>
			<?php 
$calendar = OC_Calendar_App::getCalendar($_['calendar'], false, false);
echo $calendar['displayname'] . ' ' . $l->t('of') . ' ' . $calendar['userid'];
?>
			</td>
			<th width="75px">&nbsp;</th>
			<td>
				<input type="hidden" name="calendar" value="<?php 
echo $_['calendar_options'][0]['id'];
?>
">
			</td>
		</tr>
	</table>
	<hr>
	<table width="100%">
		<tr>
} else {
    echo '<select id="category" name="categories[]" multiple="multiple" title="' . $l->t("Select category") . '">';
    echo OCP\html_select_options($_['categories'], $_['categories'], array('combine' => true));
    echo '</select>';
}
?>
			</td>
			<th width="75px">&nbsp;&nbsp;&nbsp;<?php 
echo $l->t("Calendar");
?>
:</th>
			<td>
				<select name="calendar" disabled="disabled">
					<option>
					<?php 
$calendar = OC_Calendar_App::getCalendar($_['calendar']);
echo $calendar['displayname'] . ' ' . $l->t('of') . ' ' . $calendar['userid'];
?>
					</option>
					
				</select>
			</td>
			<th width="75px">&nbsp;</th>
			<td>
				<input type="hidden" name="calendar" value="<?php 
echo $_['calendar_options'][0]['id'];
?>
">
			</td>
		</tr>
	</table>
Esempio n. 8
0
<?php

/**
 * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
require_once 'when/When.php';
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
session_write_close();
// Look for the calendar id
$calendar_id = OC_Calendar_App::getCalendar($_GET['calendar_id'], false, false);
if ($calendar_id !== false) {
    if (!is_numeric($calendar_id['userid']) && $calendar_id['userid'] != OCP\User::getUser()) {
        OCP\JSON::error();
        exit;
    }
} else {
    $calendar_id = $_GET['calendar_id'];
}
$start = version_compare(PHP_VERSION, '5.3.0', '>=') ? DateTime::createFromFormat('U', $_GET['start']) : new DateTime('@' . $_GET['start']);
$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) {
    $output = array_merge($output, OC_Calendar_App::generateEventOutput($event, $start, $end));
}
OCP\JSON::encodedPrint(OCP\Util::sanitizeHTML($output));
Esempio n. 9
0
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::callCheck();
$id = strip_tags($_GET['id']);
$idtype = strip_tags($_GET['idtype']);
switch ($idtype) {
    case 'calendar':
    case 'event':
        break;
    default:
        OCP\JSON::error(array('message' => 'unexspected parameter'));
        exit;
}
if ($idtype == 'calendar' && !OC_Calendar_App::getCalendar($id)) {
    OCP\JSON::error(array('message' => 'permission denied'));
    exit;
}
if ($idtype == 'event' && !OC_Calendar_App::getEventObject($id)) {
    OCP\JSON::error(array('message' => 'permission denied'));
    exit;
}
$sharewith = $_GET['sharewith'];
$sharetype = strip_tags($_GET['sharetype']);
switch ($sharetype) {
    case 'user':
    case 'group':
    case 'public':
        break;
    default:
Esempio n. 10
0
/**
 * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
session_write_close();
// Look for the calendar id
$calendar_id = null;
if (strval(intval($_GET['calendar_id'])) == strval($_GET['calendar_id'])) {
    // integer for sure.
    $id = intval($_GET['calendar_id']);
    $calendarrow = OC_Calendar_App::getCalendar($id, true, false);
    // Let's at least security check otherwise we might as well use OC_Calendar_Calendar::find())
    if ($calendarrow !== false) {
        $calendar_id = $id;
    } else {
        if (OCP\Share::getItemSharedWithBySource('calendar', $id) === false) {
            OCP\JSON::encodedPrint(array());
            exit;
        }
    }
}
$calendar_id = is_null($calendar_id) ? strip_tags($_GET['calendar_id']) : $calendar_id;
$start = version_compare(PHP_VERSION, '5.3.0', '>=') ? DateTime::createFromFormat('U', $_GET['start']) : new DateTime('@' . $_GET['start']);
$end = version_compare(PHP_VERSION, '5.3.0', '>=') ? DateTime::createFromFormat('U', $_GET['end']) : new DateTime('@' . $_GET['end']);
$events = OC_Calendar_App::getrequestedEvents($calendar_id, $start, $end);
$output = array();
 /**
  * @NoAdminRequired
  */
 public function getTasks($listID = 'all', $type = 'all')
 {
     $user_timezone = \OC_Calendar_App::getTimezone();
     if ($listID == 'all') {
         $calendars = \OC_Calendar_Calendar::allCalendars($this->userId, true);
     } else {
         $calendar = \OC_Calendar_App::getCalendar($listID, true, false);
         $calendars = array($calendar);
     }
     $tasks = array();
     $lists = array();
     foreach ($calendars as $calendar) {
         $calendar_entries = \OC_Calendar_Object::all($calendar['id']);
         $tasks_selected = array();
         foreach ($calendar_entries as $task) {
             if ($task['objecttype'] != 'VTODO') {
                 continue;
             }
             if (is_null($task['summary'])) {
                 continue;
             }
             $vtodo = Helper::parseVTODO($task['calendardata']);
             try {
                 $task_data = Helper::arrayForJSON($task['id'], $vtodo, $user_timezone, $calendar['id']);
                 switch ($type) {
                     case 'all':
                         $tasks[] = $task_data;
                         break;
                     case 'init':
                         if (!$task_data['completed']) {
                             $tasks[] = $task_data;
                         } else {
                             $tasks_selected[] = $task_data;
                         }
                         break;
                     case 'completed':
                         if ($task_data['completed']) {
                             $tasks[] = $task_data;
                         }
                         break;
                     case 'uncompleted':
                         if (!$task_data['completed']) {
                             $tasks[] = $task_data;
                         }
                         break;
                 }
             } catch (\Exception $e) {
                 \OCP\Util::writeLog('tasks', $e->getMessage(), \OCP\Util::ERROR);
             }
         }
         $nrCompleted = 0;
         $notLoaded = 0;
         usort($tasks_selected, array($this, 'sort_completed'));
         foreach ($tasks_selected as $task_selected) {
             $nrCompleted++;
             if ($nrCompleted > 5) {
                 $notLoaded++;
                 continue;
             }
             $tasks[] = $task_selected;
         }
         $lists[] = array('id' => $calendar['id'], 'notLoaded' => $notLoaded);
     }
     $result = array('data' => array('tasks' => $tasks, 'lists' => $lists));
     $response = new JSONResponse();
     $response->setData($result);
     return $response;
 }
Esempio n. 12
0
<?php

/**
 * Copyright (c) 2011 Bart Visscher <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
$calendarcolor_options = OC_Calendar_Calendar::getCalendarColorOptions();
$calendar = OC_Calendar_App::getCalendar($_POST['calendarid'], true, true);
$tmpl = new OCP\Template("calendar", "part.editcalendar");
$tmpl->assign('new', false);
$tmpl->assign('calendarcolor_options', $calendarcolor_options);
$tmpl->assign('calendar', $calendar);
$tmpl->printPage();
Esempio n. 13
0
    }
    if (array_key_exists('weekdays', $repeat)) {
        $repeat_weekdays_ = array();
        $days = OC_Calendar_App::getWeeklyOptions();
        foreach ($repeat['weekdays'] as $weekday) {
            $repeat_weekdays_[] = $days[$weekday];
        }
        $repeat['weekdays'] = $repeat_weekdays_;
    }
} else {
    $repeat['repeat'] = 'doesnotrepeat';
}
if ($access == 'owner') {
    $calendar_options = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
} else {
    $calendar_options = array(OC_Calendar_App::getCalendar($data['calendarid'], false));
}
$category_options = OC_Calendar_App::getCategoryOptions();
$repeat_options = OC_Calendar_App::getRepeatOptions();
$repeat_end_options = OC_Calendar_App::getEndOptions();
$repeat_month_options = OC_Calendar_App::getMonthOptions();
$repeat_year_options = OC_Calendar_App::getYearOptions();
$repeat_weekly_options = OC_Calendar_App::getWeeklyOptions();
$repeat_weekofmonth_options = OC_Calendar_App::getWeekofMonth();
$repeat_byyearday_options = OC_Calendar_App::getByYearDayOptions();
$repeat_bymonth_options = OC_Calendar_App::getByMonthOptions();
$repeat_byweekno_options = OC_Calendar_App::getByWeekNoOptions();
$repeat_bymonthday_options = OC_Calendar_App::getByMonthDayOptions();
if ($access == 'owner' || $access == 'rw') {
    $tmpl = new OCP\Template('calendar', 'part.editevent');
} elseif ($access == 'r') {
Esempio n. 14
0
<?php

/**
 * Copyright (c) 2011 Bart Visscher <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
OCP\JSON::callCheck();
$calendarid = $_POST['calendarid'];
$calendar = OC_Calendar_App::getCalendar($calendarid, true);
if (!$calendar) {
    OCP\JSON::error(array('message' => 'permission denied'));
    exit;
}
try {
    OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
} catch (Exception $e) {
    OCP\JSON::error(array('message' => $e->getMessage()));
    exit;
}
$calendar = OC_Calendar_App::getCalendar($calendarid);
OCP\JSON::success(array('active' => $calendar['active'], 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar)));
Esempio n. 15
0
 /**
  * get a list of Tasks filtered by listID and type
  * 
  * @param  string $listID
  * @param  string $type
  * @return array
  * @throws \Exception
  */
 public function getAll($listID = 'all', $type = 'all')
 {
     $user_timezone = \OC_Calendar_App::getTimezone();
     if ($listID == 'all') {
         $calendars = \OC_Calendar_Calendar::allCalendars($this->userId, true);
     } else {
         $calendar = \OC_Calendar_App::getCalendar($listID, true, false);
         $calendars = array($calendar);
     }
     $tasks = array();
     $lists = array();
     foreach ($calendars as $calendar) {
         $calendar_entries = \OC_Calendar_Object::all($calendar['id']);
         $tasks_selected = array();
         foreach ($calendar_entries as $task) {
             if ($task['objecttype'] != 'VTODO') {
                 continue;
             }
             if (is_null($task['summary'])) {
                 continue;
             }
             if (!($vtodo = Helper::parseVTODO($task))) {
                 continue;
             }
             $task_data = Helper::arrayForJSON($task['id'], $vtodo, $user_timezone, $calendar['id']);
             switch ($type) {
                 case 'all':
                     $tasks[] = $task_data;
                     break;
                 case 'init':
                     if (!$task_data['completed']) {
                         $tasks[] = $task_data;
                     } else {
                         $tasks_selected[] = $task_data;
                     }
                     break;
                 case 'completed':
                     if ($task_data['completed']) {
                         $tasks[] = $task_data;
                     }
                     break;
                 case 'uncompleted':
                     if (!$task_data['completed']) {
                         $tasks[] = $task_data;
                     }
                     break;
             }
         }
         $nrCompleted = 0;
         $notLoaded = 0;
         usort($tasks_selected, array($this, 'sort_completed'));
         foreach ($tasks_selected as $task_selected) {
             $nrCompleted++;
             if ($nrCompleted > 5) {
                 $notLoaded++;
                 continue;
             }
             $tasks[] = $task_selected;
         }
         $lists[] = array('id' => $calendar['id'], 'notLoaded' => $notLoaded);
     }
     return array('tasks' => $tasks, 'lists' => $lists);
 }
"><img id="caldav_url_close" style="height: 20px;vertical-align: middle;display: none;" src="<?php 
echo OCP\Util::imagePath('core', 'actions/delete.svg');
?>
" alt="close" onclick="$('#caldav_url').hide();$('#caldav_url_close').hide();"/></p>
	</td>
</tr>
</table><br>
<p><b><?php 
echo $l->t('Shared calendars');
?>
: </b></p>
<table width="100%" style="border: 0;">
<?php 
$share = OC_Calendar_Share::allSharedwithuser(OCP\USER::getUser(), OC_Calendar_Share::CALENDAR);
$count = count($share);
for ($i = 0; $i < $count; $i++) {
    $share[$i]['calendar'] = OC_Calendar_App::getCalendar($share[$i]['calendarid'], false, false);
    echo '<tr>';
    $tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields.shared');
    $tmpl->assign('share', $share[$i]);
    $tmpl->printpage();
    echo '</tr>';
}
?>
</table>
<?php 
if ($count == 0) {
    echo '<p style="text-align:center;"><b>' . $l->t('No shared calendars') . '</b></p>';
}
?>
</div>