Merge branch 'master' into calendar_import
This commit is contained in:
commit
433d15d309
11 changed files with 187 additions and 44 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
93
apps/calendar/lib/export.php
Normal file
93
apps/calendar/lib/export.php
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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');
|
||||
}
|
||||
header('HTTP/1.0 404 Not Found');
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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(){
|
||||
|
|
|
@ -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: ?>
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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,
|
||||
|
|
19
tests/lib/cache/file.php
vendored
19
tests/lib/cache/file.php
vendored
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
4
tests/lib/cache/xcache.php
vendored
4
tests/lib/cache/xcache.php
vendored
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue