本文整理汇总了PHP中OC_Calendar_Calendar::find方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Calendar_Calendar::find方法的具体用法?PHP OC_Calendar_Calendar::find怎么用?PHP OC_Calendar_Calendar::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Calendar_Calendar
的用法示例。
在下文中一共展示了OC_Calendar_Calendar::find方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addList
/**
* @NoAdminRequired
*/
public function addList()
{
$listName = $this->params('name');
$userId = $this->api->getUserId();
if (trim($listName) == '') {
// OCP\JSON::error(array('message'=>'empty'));
exit;
}
$calendars = \OC_Calendar_Calendar::allCalendars($userId, true);
foreach ($calendars as $cal) {
if ($cal['displayname'] == $listName) {
// OCP\JSON::error(array('message'=>'namenotavailable'));
exit;
}
}
$color = '#CCCCCC';
$calendarId = \OC_Calendar_Calendar::addCalendar($userId, strip_tags($listName), 'VEVENT,VTODO,VJOURNAL', null, 0, $color);
\OC_Calendar_Calendar::setCalendarActive($calendarId, 1);
$list = \OC_Calendar_Calendar::find($calendarId);
$list['tmpID'] = $this->params('tmpID');
$result = array('data' => array('list' => $list));
$response = new JSONResponse();
$response->setData($result);
return $response;
}
示例2: calendar
/**
* @brief exports a calendar and convert all times to UTC
* @param integer $id id of the calendar
* @return string
*/
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) {
$return .= self::generateEvent($event);
}
$return .= "END:VCALENDAR";
return $return;
}
示例3: getCalendar
/**
* @brief returns informations about a calendar
* @param int $id - id of the calendar
* @param bool $security - check access rights or not
* @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)) {
return false;
}
$calendar = OC_Calendar_Calendar::find($id);
// FIXME: Correct arguments to just check for permissions
if ($security === true || $shared === true) {
if (OCP\Share::getItemSharedWithBySource('calendar', $id)) {
return $calendar;
}
}
return $calendar;
}
示例4: add
/**
* add a list
*
* @param $name
* @param $tmpID
* @return array
* @throws \Exception
*/
public function add($name, $tmpID)
{
if (trim($name) == '') {
// OCP\JSON::error(array('message'=>'empty'));
exit;
}
$calendars = \OC_Calendar_Calendar::allCalendars($this->userId, true);
foreach ($calendars as $cal) {
if ($cal['displayname'] == $name) {
// OCP\JSON::error(array('message'=>'namenotavailable'));
exit;
}
}
$color = '#CCCCCC';
$calendarId = \OC_Calendar_Calendar::addCalendar($this->userId, strip_tags($name), 'VEVENT,VTODO,VJOURNAL', null, 0, $color);
\OC_Calendar_Calendar::setCalendarActive($calendarId, 1);
$list = \OC_Calendar_Calendar::find($calendarId);
$list['tmpID'] = $tmpID;
return $list;
}
示例5: getCalendar
public static function getCalendar($id, $security = true, $shared = false)
{
if (!is_numeric($id)) {
return false;
}
$calendar = OC_Calendar_Calendar::find($id);
if ($shared === true) {
if (OC_Calendar_Share::check_access(OCP\USER::getUser(), $id, OC_Calendar_Share::CALENDAR)) {
return $calendar;
}
}
if ($security === true) {
if ($calendar['userid'] != OCP\USER::getUser()) {
return false;
}
}
if ($calendar === false) {
return false;
}
return OC_Calendar_Calendar::find($id);
}
示例6: testBasic
function testBasic()
{
$uid = uniqid();
$this->assertEqual(OC_Calendar_Calendar::allCalendars($uid), array());
$calId1 = OC_Calendar_Calendar::addCalendar($uid, 'test');
$all = OC_Calendar_Calendar::allCalendars($uid);
$this->assertEqual(count($all), 1);
$this->assertEqual($all[0]['id'], $calId1);
$this->assertEqual($all[0]['displayname'], 'test');
$this->assertEqual($all[0]['uri'], 'test');
$calId2 = OC_Calendar_Calendar::addCalendar($uid, 'test');
$this->assertNotEqual($calId1, $calId2);
$all = OC_Calendar_Calendar::allCalendars($uid);
$this->assertEqual(count($all), 2);
$this->assertEqual($all[1]['id'], $calId2);
$this->assertEqual($all[1]['displayname'], 'test');
$this->assertEqual($all[1]['uri'], 'test1');
$cal1 = OC_Calendar_Calendar::find($calId1);
$this->assertEqual($cal1, $all[0]);
OC_Calendar_Calendar::deleteCalendar($calId1);
OC_Calendar_Calendar::deleteCalendar($calId2);
$this->assertEqual(OC_Calendar_Calendar::allCalendars($uid), array());
}
示例7: getowner
/**
* @brief returns the owner of an object
* @param integer $id
* @return string
*/
public static function getowner($id)
{
if ($id == 0) {
return null;
}
$event = self::find($id);
$cal = OC_Calendar_Calendar::find($event['calendarid']);
if ($cal === false || is_array($cal) === false) {
return null;
}
if (array_key_exists('userid', $cal)) {
return $cal['userid'];
} else {
return null;
}
}
示例8: explode
/**
* Copyright (c) 2012 Georg Ehrke <ownclouddev@georgswebsite.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
$data = $_POST['data'];
$data = explode(',', $data);
$data = end($data);
$data = base64_decode($data);
OCP\JSON::checkLoggedIn();
OCP\App::checkAppEnabled('calendar');
$import = new OC_Calendar_Import($data);
$import->setUserID(OCP\User::getUser());
$import->setTimeZone(OC_Calendar_App::$tz);
$import->disableProgressCache();
if (!$import->isValid()) {
OCP\JSON::error();
exit;
}
$newcalendarname = strip_tags($import->createCalendarName());
$newid = OC_Calendar_Calendar::addCalendar(OCP\User::getUser(), $newcalendarname, 'VEVENT,VTODO,VJOURNAL', null, 0, $import->createCalendarColor());
$import->setCalendarID($newid);
$import->import();
$count = $import->getCount();
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 {
OCP\JSON::success(array('message' => $count . ' ' . OC_Calendar_App::$l10n->t('events has been saved in the new calendar') . ' ' . $newcalendarname, 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo(OC_Calendar_Calendar::find($newid))));
}
示例9: foreach
<?php
/**
* Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
OCP\JSON::callCheck();
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']) {
OCP\JSON::error(array('message' => 'namenotavailable'));
exit;
}
}
$userid = OCP\USER::getUser();
$calendarid = OC_Calendar_Calendar::addCalendar($userid, strip_tags($_POST['name']), 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']);
OC_Calendar_Calendar::setCalendarActive($calendarid, 1);
$calendar = OC_Calendar_Calendar::find($calendarid);
$tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields');
$tmpl->assign('calendar', $calendar);
$tmpl->assign('shared', false);
OCP\JSON::success(array('page' => $tmpl->fetchPage(), 'eventSource' => OC_Calendar_Calendar::getEventSourceInfo($calendar)));
示例10: getowner
/**
* @brief returns the owner of an object
* @param integer $id
* @return string
*/
public static function getowner($id)
{
$event = self::find($id);
$cal = OC_Calendar_Calendar::find($event['calendarid']);
return $cal['userid'];
}
示例11: getCalendarObjects
/**
* Returns all calendar objects within a calendar object.
*
* Every item contains an array with the following keys:
* * id - unique identifier which will be used for subsequent updates
* * calendardata - The iCalendar-compatible calnedar data
* * uri - a unique key which will be used to construct the uri. This can be any arbitrary string.
* * lastmodified - a timestamp of the last modification time
* * etag - An arbitrary string, surrounded by double-quotes. (e.g.:
* ' "abcdef"')
* * calendarid - The calendarid as it was passed to this function.
*
* Note that the etag is optional, but it's highly encouraged to return for
* speed reasons.
*
* The calendardata is also optional. If it's not returned
* 'getCalendarObject' will be called later, which *is* expected to return
* calendardata.
*
* @param string $calendarId
* @return array
*/
public function getCalendarObjects($calendarId)
{
$data = array();
if ($calendarId === 'contact_birthdays') {
$app = new \OCA\Contacts\App();
$addressBooks = $app->getAddressBooksForUser();
foreach ($addressBooks as $addressBook) {
foreach ($addressBook->getChildren() as $contact) {
$vevent = $contact->getBirthdayEvent();
if (is_null($vevent)) {
continue;
}
$data[] = $this->OCAddETag(array('id' => 0, 'calendarid' => 'contact_birthdays', 'uri' => $addressBook->getBackend()->name . '::' . $addressBook->getId() . '::' . $contact->getId() . '.ics', 'lastmodified' => $contact->lastModified(), 'summary' => $vevent->SUMMARY, 'calendardata' => $vevent->serialize()));
}
}
} else {
$calendar = OC_Calendar_Calendar::find($calendarId);
$isShared = $calendar['userid'] !== OCP\USER::getUser();
foreach (OC_Calendar_Object::all($calendarId) as $row) {
if (!$isShared) {
$data[] = $this->OCAddETag($row);
} else {
if (substr_count($row['calendardata'], 'CLASS') === 0) {
$data[] = $this->OCAddETag($row);
} else {
$object = \Sabre\VObject\Reader::read($row['calendardata']);
if (!$object) {
return false;
}
$isPrivate = false;
$toCheck = array('VEVENT', 'VJOURNAL', 'VTODO');
foreach ($toCheck as $type) {
foreach ($object->select($type) as $vobject) {
if (isset($vobject->{'CLASS'}) && $vobject->{'CLASS'}->getValue() === 'PRIVATE') {
$isPrivate = true;
}
}
}
if ($isPrivate === false) {
$data[] = $this->OCAddETag($row);
}
}
}
}
}
return $data;
}