summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-06-30 12:50:26 +0200
committerGeorg Ehrke <dev@georgswebsite.de>2012-06-30 12:50:26 +0200
commit433d15d309b0bade290f028b1365eff77f8dd0a8 (patch)
tree1fa3ddc8279091c4c2fa34c45a1bfb19f60568d4
parent34d4eb8edd4b485f65e50fbd4c66f852268f1dab (diff)
parent6e6f90a8a242c96cc90a5ba35248f7abdfddd6b4 (diff)
downloadnextcloud-server-433d15d309b0bade290f028b1365eff77f8dd0a8.tar.gz
nextcloud-server-433d15d309b0bade290f028b1365eff77f8dd0a8.zip
Merge branch 'master' into calendar_import
-rw-r--r--apps/calendar/appinfo/app.php1
-rw-r--r--apps/calendar/export.php19
-rw-r--r--apps/calendar/lib/export.php93
-rw-r--r--apps/calendar/share.php33
-rw-r--r--apps/contacts/js/contacts.js26
-rw-r--r--apps/files_encryption/tests/proxy.php8
-rw-r--r--apps/files_external/templates/settings.php2
-rw-r--r--core/js/multiselect.js18
-rw-r--r--settings/js/users.js8
-rw-r--r--tests/lib/cache/file.php19
-rw-r--r--tests/lib/cache/xcache.php4
11 files changed, 187 insertions, 44 deletions
diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php
index c9e0f14d7a5..3c8cc76133e 100644
--- a/apps/calendar/appinfo/app.php
+++ b/apps/calendar/appinfo/app.php
@@ -8,6 +8,7 @@ OC::$CLASSPATH['OC_Connector_Sabre_CalDAV'] = 'apps/calendar/lib/connector_sabre
OC::$CLASSPATH['OC_Calendar_Repeat'] = 'apps/calendar/lib/repeat.php';
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';
//General Hooks
OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'deleteUser');
//Repeating Events Hooks
diff --git a/apps/calendar/export.php b/apps/calendar/export.php
index 5780d191a57..1374c49cc0d 100644
--- a/apps/calendar/export.php
+++ b/apps/calendar/export.php
@@ -5,35 +5,26 @@
* 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;
-$nl = "\r\n";
if(isset($cal)){
$calendar = OC_Calendar_App::getCalendar($cal, true);
if(!$calendar){
header('HTTP/1.0 404 Not Found');
exit;
}
- $calobjects = OC_Calendar_Object::all($cal);
header('Content-Type: text/Calendar');
- header('Content-Disposition: inline; filename=' . $calendar['displayname'] . '.ics');
- foreach($calobjects as $calobject){
- echo $calobject['calendardata'] . $nl;
- }
+ header('Content-Disposition: inline; filename=' . str_replace(' ', '-', $calendar['displayname']) . '.ics');
+ echo OC_Calendar_Export::export($cal, OC_Calendar_Export::CALENDAR);
}elseif(isset($event)){
$data = OC_Calendar_App::getEventObject($_GET['eventid'], true);
if(!$data){
header('HTTP/1.0 404 Not Found');
exit;
}
- $calendarid = $data['calendarid'];
- $calendar = OC_Calendar_App::getCalendar($calendarid);
header('Content-Type: text/Calendar');
- header('Content-Disposition: inline; filename=' . $data['summary'] . '.ics');
- echo $data['calendardata'];
-}
-?>
+ header('Content-Disposition: inline; filename=' . str_replace(' ', '-', $data['summary']) . '.ics');
+ echo OC_Calendar_Export::export($event, OC_Calendar_Export::EVENT);
+} \ No newline at end of file
diff --git a/apps/calendar/lib/export.php b/apps/calendar/lib/export.php
new file mode 100644
index 00000000000..cd248ce92a6
--- /dev/null
+++ b/apps/calendar/lib/export.php
@@ -0,0 +1,93 @@
+<?php
+/**
+ * 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.
+ */
+/*
+ * This class does export and converts all times to UTC
+ */
+class OC_Calendar_Export{
+ /*
+ * @brief Use one of these constants as second parameter if you call OC_Calendar_Export::export()
+ */
+ const CALENDAR = 'calendar';
+ const EVENT = 'event';
+
+ /*
+ * @brief export a calendar or an event
+ * @param integer $id id of calendar / event
+ * @param string $type use OC_Calendar_Export constants
+ * @return string
+ */
+ public static function export($id, $type){
+ if($type == self::EVENT){
+ $return = self::event($id);
+ }else{
+ $return = self::calendar($id);
+ }
+ return self::fixLineBreaks($return);
+ }
+
+ /*
+ * @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);
+ $return = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud Calendar " . OCP\App::getAppVersion('calendar') . "\n";
+ foreach($events as $event){
+ $return .= self::generateEvent($event);
+ }
+ $return .= "END:VCALENDAR";
+ return $return;
+ }
+
+ /*
+ * @brief exports an event and convert all times to UTC
+ * @param integer $id id of the event
+ * @return string
+ */
+ private static function event($id){
+ $event = OC_Calendar_Object::find($id);
+ $return = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud Calendar " . OCP\App::getAppVersion('calendar') . "\n";
+ $return .= self::generateEvent($event);
+ $return .= "END:VCALENDAR";
+ return $return;
+ }
+
+ /*
+ * @brief generates the VEVENT with UTC dates
+ * @param array $event
+ * @return string
+ */
+ private static function generateEvent($event){
+ $object = OC_VObject::parse($event['calendardata']);
+ $dtstart = $object->VEVENT->DTSTART;
+ $start_dt = $dtstart->getDateTime();
+ $dtend = OC_Calendar_Object::getDTEndFromVEvent($object->VEVENT);
+ $end_dt = $dtend->getDateTime();
+ if($dtstart->getDateType() !== Sabre_VObject_Element_DateTime::DATE){
+ $start_dt->setTimezone(new DateTimeZone('UTC'));
+ $end_dt->setTimezone(new DateTimeZone('UTC'));
+ $object->VEVENT->setDateTime('DTSTART', $start_dt, Sabre_VObject_Property_DateTime::UTC);
+ $object->VEVENT->setDateTime('DTEND', $end_dt, Sabre_VObject_Property_DateTime::UTC);
+ }
+ return $object->VEVENT->serialize();
+ }
+
+ /*
+ * @brief fixes new line breaks
+ * (fixes problems with Apple iCal)
+ * @param string $string to fix
+ * @return string
+ */
+ private static function fixLineBreaks($string){
+ $string = str_replace("\r\n", "\n", $string);
+ $string = str_replace("\r", "\n", $string);
+ $string = str_replace("\n", "\r\n", $string);
+ return $string;
+ }
+}
diff --git a/apps/calendar/share.php b/apps/calendar/share.php
index 68c7d0ffae2..bffcf0b4709 100644
--- a/apps/calendar/share.php
+++ b/apps/calendar/share.php
@@ -1,22 +1,31 @@
<?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.
+ */
$token = strip_tags($_GET['t']);
$shared = OC_Calendar_Share::getElementByToken($token);
-$nl = "\n\r";
if($shared['type'] == OC_Calendar_Share::CALENDAR){
$calendar = OC_Calendar_App::getCalendar($shared['id'], false);
- $calobjects = OC_Calendar_Object::all($shared['id']);
- header('Content-Type: text/Calendar');
- header('Content-Disposition: inline; filename=' . $calendar['displayname'] . '.ics');
- foreach($calobjects as $calobject){
- echo $calobject['calendardata'] . $nl;
+ if(!$calendar){
+ header('HTTP/1.0 404 Not Found');
+ exit;
}
+ header('Content-Type: text/Calendar');
+ header('Content-Disposition: inline; filename=' . str_replace(' ', '-', $calendar['displayname']) . '.ics');
+ echo OC_Calendar_Export::export($shared['id'], OC_Calendar_Export::CALENDAR);
}elseif($shared['type'] == OC_Calendar_Share::EVENT){
$data = OC_Calendar_App::getEventObject($shared['id'], false);
- $calendarid = $data['calendarid'];
- $calendar = OC_Calendar_App::getCalendar($calendarid);
+ if(!$data){
+ header('HTTP/1.0 404 Not Found');
+ exit;
+ }
header('Content-Type: text/Calendar');
- header('Content-Disposition: inline; filename=' . $data['summary'] . '.ics');
- echo $data['calendardata'];
+ header('Content-Disposition: inline; filename=' . str_replace(' ', '-', $data['summary']) . '.ics');
+ echo OC_Calendar_Export::export($shared['id'], OC_Calendar_Export::EVENT);
}else{
- header('Error 404: Not Found');
-} \ No newline at end of file
+ header('HTTP/1.0 404 Not Found');
+ exit;
+}
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index 9d41b70a314..5be1fa61292 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -1621,19 +1621,21 @@ Contacts={
var contactlist = $('#contacts ul[data-id="'+b+'"]');
for(var c in book.contacts) {
if(book.contacts[c].id == undefined) { continue; }
- var contact = Contacts.UI.Card.createEntry(book.contacts[c]);
- if(c == self.batchnum-5) {
- contact.bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
- $(this).unbind(event);
- var bookid = $(this).data('bookid');
- var numsiblings = $('.contacts li[data-bookid="'+bookid+'"]').length;
- if (isInView && numsiblings >= self.batchnum) {
- console.log('This would be a good time to load more contacts.');
- Contacts.UI.Contacts.update(id, bookid, $('#contacts li[data-bookid="'+bookid+'"]').length);
- }
- });
+ if($('#contacts li[data-id="'+book.contacts[c]['id']+'"][data-id="'+book.contacts[c]['bookid']+'"]').length == 0) {
+ var contact = Contacts.UI.Card.createEntry(book.contacts[c]);
+ if(c == self.batchnum-5) {
+ contact.bind('inview', function(event, isInView, visiblePartX, visiblePartY) {
+ $(this).unbind(event);
+ var bookid = $(this).data('bookid');
+ var numsiblings = $('.contacts li[data-bookid="'+bookid+'"]').length;
+ if (isInView && numsiblings >= self.batchnum) {
+ console.log('This would be a good time to load more contacts.');
+ Contacts.UI.Contacts.update(id, bookid, $('#contacts li[data-bookid="'+bookid+'"]').length);
+ }
+ });
+ }
+ contactlist.append(contact);
}
- contactlist.append(contact);
}
});
if($('#contacts h3').length > 1) {
diff --git a/apps/files_encryption/tests/proxy.php b/apps/files_encryption/tests/proxy.php
index fcfc4cfb9f0..5463836a209 100644
--- a/apps/files_encryption/tests/proxy.php
+++ b/apps/files_encryption/tests/proxy.php
@@ -11,6 +11,8 @@ class Test_CryptProxy extends UnitTestCase {
private $oldKey;
public function setUp(){
+ $user=OC_User::getUser();
+
$this->oldConfig=OCP\Config::getAppValue('files_encryption','enable_encryption','true');
OCP\Config::setAppValue('files_encryption','enable_encryption','true');
$this->oldKey=isset($_SESSION['enckey'])?$_SESSION['enckey']:null;
@@ -30,10 +32,12 @@ class Test_CryptProxy extends UnitTestCase {
OC_Filesystem::clearMounts();
OC_Filesystem::mount('OC_Filestorage_Temporary',array(),'/');
+ OC_Filesystem::init('/'.$user.'/files');
+
//set up the users home folder in the temp storage
$rootView=new OC_FilesystemView('');
- $rootView->mkdir('/'.OC_User::getUser());
- $rootView->mkdir('/'.OC_User::getUser().'/files');
+ $rootView->mkdir('/'.$user);
+ $rootView->mkdir('/'.$user.'/files');
}
public function tearDown(){
diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php
index 069599d028f..e651c4574d7 100644
--- a/apps/files_external/templates/settings.php
+++ b/apps/files_external/templates/settings.php
@@ -39,7 +39,7 @@
<?php elseif(strpos($placeholder, '!') !== false): ?>
<label><input type="checkbox" data-parameter="<?php echo $parameter; ?>" <?php if ($value == 'true') echo ' checked="checked"'; ?> /><?php echo substr($placeholder, 1); ?></label>
<?php elseif (strpos($placeholder, '&') !== false): ?>
- <input type="text" class="optional" data-parameter="<?php echo $parameter; ?>" value="<?php echo $value; ?>" placeholder="<?php echo substr($placeholder, 1); ?>" />
+ <input type="text" class="optional" data-parameter="<?php echo $parameter; ?>" value="<?php echo $value; ?>" placeholder="<?php echo substr($placeholder, 5); ?>" />
<?php elseif (strpos($placeholder, '#') !== false): ?>
<input type="hidden" data-parameter="<?php echo $parameter; ?>" value="<?php echo $value; ?>" />
<?php else: ?>
diff --git a/core/js/multiselect.js b/core/js/multiselect.js
index db5afa637c9..c4fd74b0475 100644
--- a/core/js/multiselect.js
+++ b/core/js/multiselect.js
@@ -35,6 +35,7 @@
}
button.click(function(event){
+
var button=$(this);
if(button.parent().children('ul').length>0){
button.parent().children('ul').slideUp(400,function(){
@@ -128,19 +129,30 @@
if(event.keyCode == 13) {
event.preventDefault();
event.stopPropagation();
+ var value = $(this).val();
+ var exists = false;
+ $.each(options,function(index, item) {
+ if ($(item).val() == value) {
+ exists = true;
+ return false;
+ }
+ });
+ if (exists) {
+ return false;
+ }
var li=$(this).parent();
$(this).remove();
li.text('+ '+settings.createText);
li.before(createItem(this));
var select=button.parent().next();
var option=$('<option selected="selected"/>');
- option.attr('value',$(this).val());
+ option.attr('value',value);
option.text($(this).val());
- select.append(options);
+ select.append(option);
li.prev().children('input').trigger('click');
button.parent().data('preventHide',false);
if(settings.createCallback){
- settings.createCallback();
+ settings.createCallback($(this).val());
}
}
});
diff --git a/settings/js/users.js b/settings/js/users.js
index 0de0d1df3bc..90569bcc56b 100644
--- a/settings/js/users.js
+++ b/settings/js/users.js
@@ -40,7 +40,15 @@ $(document).ready(function(){
}else{
checkHandeler=false;
}
+ var addGroup = function(group) {
+ $('select[multiple]').each(function(index, element) {
+ if ($(element).find('option[value="'+group +'"]').length == 0) {
+ $(element).append('<option value="'+group+'">'+group+'</option>');
+ }
+ })
+ };
element.multiSelect({
+ createCallback:addGroup,
createText:'add group',
checked:checked,
oncheck:checkHandeler,
diff --git a/tests/lib/cache/file.php b/tests/lib/cache/file.php
index 226e5068c41..54e60e6569d 100644
--- a/tests/lib/cache/file.php
+++ b/tests/lib/cache/file.php
@@ -21,7 +21,26 @@
*/
class Test_Cache_File extends Test_Cache {
+ function skip() {
+ $this->skipUnless(OC_User::isLoggedIn());
+ }
+
public function setUp(){
+ //clear all proxies and hooks so we can do clean testing
+ OC_FileProxy::clearProxies();
+ OC_Hook::clear('OC_Filesystem');
+
+ //enable only the encryption hook
+ OC_FileProxy::register(new OC_FileProxy_Encryption());
+
+ //set up temporary storage
+ OC_Filesystem::clearMounts();
+ OC_Filesystem::mount('OC_Filestorage_Temporary',array(),'/');
+
+ //set up the users dir
+ $rootView=new OC_FilesystemView('');
+ $rootView->mkdir('/'.OC_User::getUser());
+
$this->instance=new OC_Cache_File();
}
}
diff --git a/tests/lib/cache/xcache.php b/tests/lib/cache/xcache.php
index a5e954f827c..cc2077076ce 100644
--- a/tests/lib/cache/xcache.php
+++ b/tests/lib/cache/xcache.php
@@ -28,4 +28,8 @@ class Test_Cache_XCache extends Test_Cache {
public function setUp(){
$this->instance=new OC_Cache_XCache();
}
+
+ function testTTL(){
+ // ttl doesn't work correctly in the same request
+ }
}