summaryrefslogtreecommitdiffstats
path: root/apps/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'apps/calendar')
-rw-r--r--apps/calendar/appinfo/app.php4
-rw-r--r--apps/calendar/js/loader.js2
-rw-r--r--apps/calendar/lib/share.php21
-rw-r--r--apps/calendar/lib/share/calendar.php64
-rw-r--r--apps/calendar/lib/share/event.php40
-rw-r--r--apps/calendar/lib/share_backend.php44
-rw-r--r--apps/calendar/templates/part.choosecalendar.rowfields.php2
7 files changed, 163 insertions, 14 deletions
diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php
index 5c05c57bcad..9ae255853d5 100644
--- a/apps/calendar/appinfo/app.php
+++ b/apps/calendar/appinfo/app.php
@@ -10,6 +10,8 @@ OC::$CLASSPATH['OC_Calendar_Share'] = 'apps/calendar/lib/share.php';
OC::$CLASSPATH['OC_Search_Provider_Calendar'] = 'apps/calendar/lib/search.php';
OC::$CLASSPATH['OC_Calendar_Export'] = 'apps/calendar/lib/export.php';
OC::$CLASSPATH['OC_Calendar_Import'] = 'apps/calendar/lib/import.php';
+OC::$CLASSPATH['OC_Share_Backend_Calendar'] = 'apps/calendar/lib/share/calendar.php';
+OC::$CLASSPATH['OC_Share_Backend_Event'] = 'apps/calendar/lib/share/event.php';
//General Hooks
OCP\Util::connectHook('OC_User', 'post_createUser', 'OC_Calendar_Hooks', 'createUser');
OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'deleteUser');
@@ -34,3 +36,5 @@ OCP\App::addNavigationEntry( array(
'icon' => OCP\Util::imagePath( 'calendar', 'icon.svg' ),
'name' => $l->t('Calendar')));
OC_Search::registerProvider('OC_Search_Provider_Calendar');
+OCP\Share::registerBackend('calendar', 'OC_Share_Backend_Calendar');
+OCP\Share::registerBackend('event', 'OC_Share_Backend_Event');
diff --git a/apps/calendar/js/loader.js b/apps/calendar/js/loader.js
index b28d19ab00e..253abafc427 100644
--- a/apps/calendar/js/loader.js
+++ b/apps/calendar/js/loader.js
@@ -173,7 +173,7 @@ Calendar_Import={
}
$(document).ready(function(){
if(typeof FileActions !== 'undefined'){
- FileActions.register('text/calendar','importCalendar', '', Calendar_Import.Dialog.open);
+ FileActions.register('text/calendar','importCalendar', FileActions.PERMISSION_READ, '', Calendar_Import.Dialog.open);
FileActions.setDefault('text/calendar','importCalendar');
};
});
diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php
index 4fe88171403..e5ffc04143a 100644
--- a/apps/calendar/lib/share.php
+++ b/apps/calendar/lib/share.php
@@ -18,19 +18,16 @@ class OC_Calendar_Share{
* @return: array $return - information about calendars
*/
public static function allSharedwithuser($userid, $type, $active=null, $permission=null){
- $group_where = self::group_sql(OC_Group::getUserGroups($userid));
- $permission_where = self::permission_sql($permission);
- if($type == self::CALENDAR){
- $active_where = self::active_sql($active);
- }else{
- $active_where = '';
- }
- $stmt = OCP\DB::prepare("SELECT * FROM *PREFIX*calendar_share_" . $type . " WHERE ((share = ? AND sharetype = 'user') " . $group_where . ") AND owner <> ? " . $permission_where . " " . $active_where);
- $result = $stmt->execute(array($userid, $userid));
- $return = array();
- while( $row = $result->fetchRow()){
- $return[] = $row;
+ $format = OC_Share_Backend_Calendar::FORMAT_CALENDAR;
+ if ($type == self::EVENT) {
+ $format = OC_Share_Backend_Event::FORMAT_EVENT;
}
+ $return = OCP\Share::getItemsSharedWith($type,
+ $format,
+ array(
+ 'active' => $active,
+ 'permissions' => $permission,
+ ));
return $return;
}
/**
diff --git a/apps/calendar/lib/share/calendar.php b/apps/calendar/lib/share/calendar.php
new file mode 100644
index 00000000000..0ddca2400a9
--- /dev/null
+++ b/apps/calendar/lib/share/calendar.php
@@ -0,0 +1,64 @@
+<?php
+/**
+* ownCloud
+*
+* @author Michael Gapczynski
+* @copyright 2012 Michael Gapczynski mtgap@owncloud.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+class OC_Share_Backend_Calendar implements OCP\Share_Backend_Collection {
+
+ const FORMAT_CALENDAR = 0;
+
+ private static $calendar;
+
+ public function isValidSource($itemSource, $uidOwner) {
+ if (self::$calendar = OC_Calendar_App::getCalendar($itemSource)) {
+ return true;
+ }
+ return false;
+ }
+
+ public function generateTarget($itemSource, $shareWith, $exclude = null) {
+ if (isset(self::$calendar)) {
+ return self::$calendar['displayname'];
+ }
+ return false;
+ }
+
+ 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);
+ // TODO: really check $parameters['permissions'] == 'rw'/'r'
+ if ($parameters['permissions'] == 'rw') {
+ continue; // TODO
+ }
+ $calendar['displaynamename'] = $item['item_target'];
+ $calendar['calendarid'] = $calendar['id'];
+ $calendar['owner'] = $calendar['userid'];
+ $calendars[] = $calendar;
+ }
+ }
+ return $calendars;
+ }
+
+ public function getChildren($itemSource) {
+ // TODO
+ }
+
+} \ No newline at end of file
diff --git a/apps/calendar/lib/share/event.php b/apps/calendar/lib/share/event.php
new file mode 100644
index 00000000000..5bb72ee6c98
--- /dev/null
+++ b/apps/calendar/lib/share/event.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+class OC_Share_Backend_Event implements OCP\Share_Backend {
+
+ const FORMAT_EVENT = 0;
+
+ private static $event;
+
+ public function isValidSource($itemSource, $uidOwner) {
+ self::$event = OC_Calendar_Object::find($itemSource);
+ if (self::$event) {
+ return true;
+ }
+ return false;
+ }
+
+ public function generateTarget($itemSource, $shareWith, $exclude = null) {
+ // TODO Get default calendar and check for conflicts
+ return self::$event['summary'];
+ }
+
+ public function formatItems($items, $format, $parameters = null) {
+ $events = array();
+ if ($format == self::FORMAT_EVENT) {
+ foreach ($items as $item) {
+ $event = OC_Calendar_Object::find($item['item_source']);
+ $event['summary'] = $item['item_target'];
+ $events[] = $event;
+ }
+ }
+ return $events;
+ }
+
+}
diff --git a/apps/calendar/lib/share_backend.php b/apps/calendar/lib/share_backend.php
new file mode 100644
index 00000000000..f937c0d1c34
--- /dev/null
+++ b/apps/calendar/lib/share_backend.php
@@ -0,0 +1,44 @@
+<?php
+/**
+* ownCloud
+*
+* @author Michael Gapczynski
+* @copyright 2012 Michael Gapczynski mtgap@owncloud.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+class OC_Share_Backend_Calendar extends OCP\Share_Backend {
+
+ public function getSource($item, $uid) {
+ $query = OCP\DB::prepare('SELECT id FROM *PREFIX*calendar_calendars WHERE userid = ? AND displayname = ? LIMIT 1');
+ return $query->execute(array($uid, $item))->fetchAll();
+ }
+
+ public function generateTarget($item, $uid) {
+
+ }
+
+ public function getItems($sources) {
+
+ }
+
+}
+
+class OC_Share_Backend_Event extends OCP\Share_Backend {
+
+}
+
+
+?> \ No newline at end of file
diff --git a/apps/calendar/templates/part.choosecalendar.rowfields.php b/apps/calendar/templates/part.choosecalendar.rowfields.php
index d29113c9a61..64aaa797197 100644
--- a/apps/calendar/templates/part.choosecalendar.rowfields.php
+++ b/apps/calendar/templates/part.choosecalendar.rowfields.php
@@ -5,7 +5,7 @@
<label for="active_<?php echo $_['calendar']['id'] ?>"><?php echo $_['calendar']['displayname'] ?></label>
</td>
<td width="20px">
- <a href="#" onclick="Calendar.UI.Share.dropdown('<?php echo OCP\USER::getUser() ?>', <?php echo $_['calendar']['id'] ?>);" title="<?php echo $l->t('Share Calendar') ?>" class="action"><img class="svg action" src="<?php echo (!$_['shared']) ? OCP\Util::imagePath('core', 'actions/share.svg') : OCP\Util::imagePath('core', 'actions/shared.svg') ?>"></a>
+ <a href="#" class="share" data-item-type="calendar" data-item="<?php echo $_['calendar']['id']; ?>" title="<?php echo $l->t('Share Calendar') ?>" class="action"><img class="svg action" src="<?php echo (!$_['shared']) ? OCP\Util::imagePath('core', 'actions/share.svg') : OCP\Util::imagePath('core', 'actions/shared.svg') ?>"></a>
</td>
<td width="20px">
<a href="#" onclick="Calendar.UI.showCalDAVUrl('<?php echo OCP\USER::getUser() ?>', '<?php echo rawurlencode(html_entity_decode($_['calendar']['uri'], ENT_QUOTES, 'UTF-8')) ?>');" title="<?php echo $l->t('CalDav Link') ?>" class="action"><img class="svg action" src="<?php echo OCP\Util::imagePath('core', 'actions/public.svg') ?>"></a>