Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
fb493c45
Commit
fb493c45
authored
12 years ago
by
Bart Visscher
Browse files
Options
Downloads
Patches
Plain Diff
Calendar: update share backend using contacts backend as template
parent
6a95e428
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/calendar/lib/share/calendar.php
+58
-11
58 additions, 11 deletions
apps/calendar/lib/share/calendar.php
with
58 additions
and
11 deletions
apps/calendar/lib/share/calendar.php
+
58
−
11
View file @
fb493c45
...
...
@@ -4,6 +4,7 @@
*
* @author Michael Gapczynski
* @copyright 2012 Michael Gapczynski mtgap@owncloud.com
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
...
...
@@ -20,25 +21,65 @@
*/
class
OC_Share_Backend_Calendar
implements
OCP\Share_Backend_Collection
{
const
FORMAT_CALENDAR
=
1
;
const
FORMAT_CALENDAR
=
0
;
private
static
$calendar
;
/**
* @brief Get the source of the item to be stored in the database
* @param string Item
* @param string Owner of the item
* @return mixed|array|false Source
*
* Return an array if the item is file dependent, the array needs two keys: 'item' and 'file'
* Return false if the item does not exist for the user
*
* The formatItems() function will translate the source returned back into the item
*/
public
function
isValidSource
(
$itemSource
,
$uidOwner
)
{
if
(
self
::
$calendar
=
OC_Calendar_App
::
getCalendar
(
$itemSource
))
{
return
true
;
}
$calendar
=
OC_Calendar_App
::
getCalendar
(
$itemSource
);
if
(
$calendar
||
$calendar
[
'userid'
]
!=
$uidOwner
)
{
return
false
;
}
return
true
;
}
/**
* @brief Get a unique name of the item for the specified user
* @param string Item
* @param string|false User the item is being shared with
* @param array|null List of similar item names already existing as shared items
* @return string Target name
*
* This function needs to verify that the user does not already have an item with this name.
* If it does generate a new name e.g. name_#
*/
public
function
generateTarget
(
$itemSource
,
$shareWith
,
$exclude
=
null
)
{
if
(
isset
(
self
::
$calendar
))
{
return
self
::
$calendar
[
'displayname'
];
$calendar
=
OC_Calendar_App
::
getCalendar
(
$itemSource
);
$user_calendars
=
array
();
foreach
(
OC_Contacts_Addressbook
::
all
(
$uid
)
as
$user_calendar
)
{
$user_calendars
[]
=
$user_calendar
[
'displayname'
];
}
return
false
;
$name
=
$calendar
[
'userid'
]
.
"'s "
.
$calendar
[
'displayname'
];
$suffix
=
''
;
while
(
in_array
(
$name
.
$suffix
,
$user_calendars
))
{
$suffix
++
;
}
return
$name
.
$suffix
;
}
/**
* @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
)
{
...
...
@@ -58,7 +99,13 @@ class OC_Share_Backend_Calendar implements OCP\Share_Backend_Collection {
}
public
function
getChildren
(
$itemSource
)
{
// TODO
$query
=
OCP\DB
::
prepare
(
'SELECT id FROM *PREFIX*calendar_objects WHERE calendarid = ?'
);
$result
=
$query
->
execute
(
array
(
$itemSource
));
$sources
=
array
();
while
(
$object
=
$result
->
fetchRow
())
{
$sources
[]
=
$object
[
'id'
];
}
return
$sources
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment