本文整理汇总了PHP中OC_Calendar_Calendar::setCalendarActive方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Calendar_Calendar::setCalendarActive方法的具体用法?PHP OC_Calendar_Calendar::setCalendarActive怎么用?PHP OC_Calendar_Calendar::setCalendarActive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Calendar_Calendar
的用法示例。
在下文中一共展示了OC_Calendar_Calendar::setCalendarActive方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
function import()
{
switch ($this->appinfo->version) {
default:
// All versions of the app have had the same db structure, so all can use the same import function
$query = $this->content->prepare('SELECT * FROM `calendar_calendars` WHERE `userid` = ?');
$results = $query->execute(array($this->olduid));
$idmap = array();
while ($row = $results->fetchRow()) {
// Import each calendar
$calendarquery = OCP\DB::prepare('INSERT INTO `*PREFIX*calendar_calendars` (`userid`,`displayname`,`uri`,`ctag`,`calendarorder`,`calendarcolor`,`timezone`,`components`) VALUES(?,?,?,?,?,?,?,?)');
$calendarquery->execute(array($this->uid, $row['displayname'], $row['uri'], $row['ctag'], $row['calendarorder'], $row['calendarcolor'], $row['timezone'], $row['components']));
// Map the id
$idmap[$row['id']] = OCP\DB::insertid('*PREFIX*calendar_calendars');
// Make the calendar active
OC_Calendar_Calendar::setCalendarActive($idmap[$row['id']], true);
}
// Now tags
foreach ($idmap as $oldid => $newid) {
$query = $this->content->prepare('SELECT * FROM `calendar_objects` WHERE `calendarid` = ?');
$results = $query->execute(array($oldid));
while ($row = $results->fetchRow()) {
// Import the objects
$objectquery = OCP\DB::prepare('INSERT INTO `*PREFIX*calendar_objects` (`calendarid`,`objecttype`,`startdate`,`enddate`,`repeating`,`summary`,`calendardata`,`uri`,`lastmodified`) VALUES(?,?,?,?,?,?,?,?,?)');
$objectquery->execute(array($newid, $row['objecttype'], $row['startdate'], $row['enddate'], $row['repeating'], $row['summary'], $row['calendardata'], $row['uri'], $row['lastmodified']));
}
}
// All done!
break;
}
return true;
}
示例2: 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;
}
示例3: 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;
}
示例4: foreach
exit;
}
$newcal = false;
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()));
示例5: foreach
exit;
}
$calendars = OC_Calendar_Calendar::allCalendars(OCP\USER::getUser());
foreach ($calendars as $cal) {
if ($cal['userid'] != OCP\User::getUser()) {
continue;
}
if ($cal['displayname'] == $_POST['name'] && $cal['id'] != $_POST['id']) {
OCP\JSON::error(array('message' => 'namenotavailable'));
exit;
}
}
$calendarid = $_POST['id'];
try {
OC_Calendar_Calendar::editCalendar($calendarid, strip_tags($_POST['name']), null, null, null, $_POST['color']);
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
} catch (Exception $e) {
OCP\JSON::error(array('message' => $e->getMessage()));
exit;
}
$calendar = OC_Calendar_Calendar::find($calendarid);
$tmpl = new OCP\Template('calendar', 'part.choosecalendar.rowfields');
$tmpl->assign('calendar', $calendar);
$shared = false;
if ($calendar['userid'] != OCP\User::getUser()) {
$sharedCalendar = OCP\Share::getItemSharedWithBySource('calendar', $calendarid);
if ($sharedCalendar && $sharedCalendar['permissions'] & OCP\Share::PERMISSION_UPDATE) {
$shared = true;
}
}
$tmpl->assign('shared', $shared);