diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php index 22b91a41ef..3c8cc76133 100644 --- a/apps/calendar/appinfo/app.php +++ b/apps/calendar/appinfo/app.php @@ -9,12 +9,17 @@ 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 OCP\Util::connectHook('OC_Calendar', 'addEvent', 'OC_Calendar_Repeat', 'generate'); OCP\Util::connectHook('OC_Calendar', 'editEvent', 'OC_Calendar_Repeat', 'update'); OCP\Util::connectHook('OC_Calendar', 'deleteEvent', 'OC_Calendar_Repeat', 'clean'); OCP\Util::connectHook('OC_Calendar', 'moveEvent', 'OC_Calendar_Repeat', 'update'); OCP\Util::connectHook('OC_Calendar', 'deleteCalendar', 'OC_Calendar_Repeat', 'cleanCalendar'); +//Sharing Hooks +OCP\Util::connectHook('OC_Calendar', 'deleteEvent', 'OC_Calendar_Share', 'post_eventdelete'); +OCP\Util::connectHook('OC_Calendar', 'deleteCalendar', 'OC_Calendar_Share', 'post_caldelete'); OCP\Util::addscript('calendar','loader'); OCP\Util::addscript("3rdparty", "chosen/chosen.jquery.min"); OCP\Util::addStyle("3rdparty", "chosen/chosen"); diff --git a/apps/calendar/js/loader.js b/apps/calendar/js/loader.js index 0fc5018e89..cef95afc3a 100644 --- a/apps/calendar/js/loader.js +++ b/apps/calendar/js/loader.js @@ -44,7 +44,7 @@ Calendar_Import={ $('#newcalendar').attr('readonly', 'readonly'); $('#calendar').attr('disabled', 'disabled'); var progresskey = $('#progresskey').val(); - $.post(OC.filePath('calendar', 'ajax/import', 'import.php') + '?progresskey='+progresskey, {method: String (method), calname: String (calname), path: String (path), file: String (filename), id: String (calid)}, function(data){ + $.post(OC.filePath('calendar', 'ajax/import', 'import.php'), {progresskey: progresskey, method: String (method), calname: String (calname), path: String (path), file: String (filename), id: String (calid)}, function(data){ if(data.status == 'success'){ $('#progressbar').progressbar('option', 'value', 100); $('#import_done').css('display', 'block'); diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php index 344c89f36b..ca897a36dc 100644 --- a/apps/calendar/lib/app.php +++ b/apps/calendar/lib/app.php @@ -368,12 +368,14 @@ class OC_Calendar_App{ * @return (array) $output - readable output */ public static function generateEventOutput($event, $start, $end){ - if(isset($event['calendardata'])){ - $object = OC_VObject::parse($event['calendardata']); - $vevent = $object->VEVENT; - }else{ - $vevent = $event['vevent']; + if(!isset($event['calendardata']) && !isset($event['vevent'])){ + return false; } + if(!isset($event['calendardata']) && isset($event['vevent'])){ + $event['calendardata'] = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud's Internal iCal System\n" . $event['vevent']->serialize() . "END:VCALENDAR"; + } + $object = OC_VObject::parse($event['calendardata']); + $vevent = $object->VEVENT; $return = array(); $id = $event['id']; $allday = ($vevent->DTSTART->getDateType() == Sabre_VObject_Element_DateTime::DATE)?true:false; @@ -404,7 +406,7 @@ class OC_Calendar_App{ $return[] = array_merge($staticoutput, $dynamicoutput); } }else{ - if(OC_Calendar_Object::isrepeating($id)){ + if(OC_Calendar_Object::isrepeating($id) || $event['repeating'] == 1){ $object->expand($start, $end); } foreach($object->getComponents() as $singleevent){ @@ -412,7 +414,7 @@ class OC_Calendar_App{ continue; } $dynamicoutput = OC_Calendar_Object::generateStartEndDate($singleevent->DTSTART, OC_Calendar_Object::getDTEndFromVEvent($singleevent), $allday, self::$tz); - $return[] = array_merge($staticoutput, $dynamicoutput); + $return[] = array_merge($staticoutput, $dynamicoutput); } } return $return; diff --git a/apps/calendar/lib/share.php b/apps/calendar/lib/share.php index 54c531892f..01502f1c6b 100644 --- a/apps/calendar/lib/share.php +++ b/apps/calendar/lib/share.php @@ -258,7 +258,7 @@ class OC_Calendar_Share{ } /* - * @brief delete all shared calendars / events after a user was deleted + * @brief deletes all shared calendars / events after a user was deleted * @param (string) $userid * @return (bool) */ @@ -273,4 +273,26 @@ class OC_Calendar_Share{ $stmt->execute(array($userid)); return true; } + + /* + * @brief deletes all shared events of a calendar + * @param integer $calid + * @return boolean + */ + public static function post_caldelete($calid){ + $stmt = OCP\DB::prepare('DELETE FROM *PREFIX*calendar_share_calendar WHERE calendarid = ?'); + $stmt->execute(array($calid)); + return true; + } + + /* + * @brief deletes all shares of an event + * @param integer $eventid + * @return boolean + */ + public static function post_eventdelete($eventid){ + $stmt = OCP\DB::prepare('DELETE FROM *PREFIX*calendar_share_event WHERE eventid = ?'); + $stmt->execute(array($eventid)); + return true; + } } \ No newline at end of file diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js index 9d41b70a31..5be1fa6129 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/contacts/lib/hooks.php b/apps/contacts/lib/hooks.php index 9794a9c9b9..d91d3c565b 100644 --- a/apps/contacts/lib/hooks.php +++ b/apps/contacts/lib/hooks.php @@ -90,9 +90,10 @@ class OC_Contacts_Hooks{ if ($birthday) { $date = new DateTime($birthday); $vevent = new OC_VObject('VEVENT'); - $vevent->setDateTime('LAST-MODIFIED', new DateTime($vcard->REV)); + //$vevent->setDateTime('LAST-MODIFIED', new DateTime($vcard->REV)); $vevent->setDateTime('DTSTART', $date, Sabre_VObject_Element_DateTime::DATE); $vevent->setString('DURATION', 'P1D'); + $vevent->setString('UID', substr(md5(rand().time()),0,10)); // DESCRIPTION? $vevent->setString('RRULE', 'FREQ=YEARLY'); $title = str_replace('{name}', $vcard->getAsString('FN'), OC_Contacts_App::$l10n->t('{name}\'s Birthday')); @@ -101,6 +102,7 @@ class OC_Contacts_Hooks{ 'vevent' => $vevent, 'repeating' => true, 'summary' => $title, + 'calendardata' => "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud Contacts " . OCP\App::getAppVersion('contacts') . "\n" . $vevent->serialize() . "END:VCALENDAR" ); } } diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 3ba473e023..86c5185bf7 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -451,7 +451,7 @@ $(document).ready(function() { $(this).append(input); input.focus(); input.change(function(){ - var name=$(this).val(); + var name=getUniqueName($(this).val()); if(type != 'web' && name.indexOf('/')!=-1){ $('#notification').text(t('files','Invalid name, \'/\' is not allowed.')); $('#notification').fadeIn(); @@ -496,6 +496,7 @@ $(document).ready(function() { }else{//or the domain localName=(localName.match(/:\/\/(.[^/]+)/)[1]).replace('www.',''); } + localName = getUniqueName(localName); $.post( OC.filePath('files','ajax','newfile.php'), {dir:$('#dir').val(),source:name,filename:localName}, @@ -737,7 +738,10 @@ getMimeIcon.cache={}; function getUniqueName(name){ if($('tr').filterAttr('data-file',name).length>0){ var parts=name.split('.'); - var extension=parts.pop(); + var extension = ""; + if (parts.length > 1) { + extension=parts.pop(); + } var base=parts.join('.'); numMatch=base.match(/\((\d+)\)/); var num=2; @@ -747,7 +751,10 @@ function getUniqueName(name){ base.pop(); base=base.join('(').trim(); } - name=base+' ('+num+').'+extension; + name=base+' ('+num+')'; + if (extension) { + name = name+'.'+extension; + } return getUniqueName(name); } return name; diff --git a/apps/files_encryption/tests/proxy.php b/apps/files_encryption/tests/proxy.php index fcfc4cfb9f..5463836a20 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/js/dropbox.js b/apps/files_external/js/dropbox.js index 67f3c46a6e..08796cbbdc 100644 --- a/apps/files_external/js/dropbox.js +++ b/apps/files_external/js/dropbox.js @@ -23,7 +23,6 @@ $(document).ready(function() { }); } } - return false; } }); diff --git a/apps/files_external/js/google.js b/apps/files_external/js/google.js index 84c74c5742..55042194c7 100644 --- a/apps/files_external/js/google.js +++ b/apps/files_external/js/google.js @@ -24,7 +24,6 @@ $(document).ready(function() { }); } } - return false; } }); diff --git a/apps/files_external/js/settings.js b/apps/files_external/js/settings.js index 57188a6a26..1c366a79c7 100644 --- a/apps/files_external/js/settings.js +++ b/apps/files_external/js/settings.js @@ -27,7 +27,7 @@ OC.MountConfig={ } }); if (addMountPoint) { - if ($('#externalStorage').data('admin')) { + if ($('#externalStorage').data('admin') === true) { var isPersonal = false; var multiselect = $(tr).find('.chzn-select').val(); var oldGroups = $(tr).find('.applicable').data('applicable-groups'); @@ -73,7 +73,8 @@ $(document).ready(function() { $('#selectBackend').live('change', function() { var tr = $(this).parent().parent(); - $('#externalStorage tbody').last().append($(tr).clone()); + $('#externalStorage tbody').append($(tr).clone()); + $('#externalStorage tbody tr').last().find('.mountPoint input').val(''); var selected = $(this).find('option:selected').text(); var backendClass = $(this).val(); $(this).parent().text(selected); @@ -103,6 +104,7 @@ $(document).ready(function() { }); $('.chz-select').chosen(); $(tr).find('td').last().attr('class', 'remove'); + $(tr).find('td').last().removeAttr('style'); $(tr).removeAttr('id'); $(this).remove(); }); @@ -117,7 +119,7 @@ $(document).ready(function() { if (mountPoint == '') { return false; } - if ($('#externalStorage').data('admin')) { + if ($('#externalStorage').data('admin') === true) { var isPersonal = false; var multiselect = $(tr).find('.chzn-select').val(); $.each(multiselect, function(index, value) { diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index d136f04f3e..d0fe2aca85 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -20,10 +20,14 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ private static $tempFiles=array(); public function __construct($params){ - $this->host=$params['host']; + $host = $params['host']; + //remove leading http[s], will be generated in createBaseUri() + if (substr($host,0,8) == "https://") $host = substr($host, 8); + else if (substr($host,0,7) == "http://") $host = substr($host, 7); + $this->host=$host; $this->user=$params['user']; $this->password=$params['password']; - $this->secure=isset($params['secure'])?(bool)$params['secure']:false; + $this->secure=(isset($params['secure']) && $params['secure'] == 'true')?true:false; $this->root=isset($params['root'])?$params['root']:'/'; if(!$this->root || $this->root[0]!='/'){ $this->root='/'.$this->root; @@ -46,7 +50,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ private function createBaseUri(){ $baseUri='http'; if($this->secure){ - $baseUri.'s'; + $baseUri.='s'; } $baseUri.='://'.$this->host.$this->root; return $baseUri; @@ -69,13 +73,15 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ $stripLength=strlen($this->root)+strlen($path); $id=md5('webdav'.$this->root.$path); OC_FakeDirStream::$dirs[$id]=array(); + $skip = true; foreach($response as $file=>$data){ - //strip root and path - $file=trim(substr($file,$stripLength)); - $file=trim($file,'/'); - if($file){ - OC_FakeDirStream::$dirs[$id][]=$file; + // Skip the first file, because it is the current directory + if ($skip) { + $skip = false; + continue; } + $file = urldecode(basename($file)); + OC_FakeDirStream::$dirs[$id][]=$file; } return opendir('fakedir://'.$id); }catch(Exception $e){ @@ -240,15 +246,11 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{ $path=$this->cleanPath($path); try{ $response=$this->client->propfind($path, array('{DAV:}getlastmodified','{DAV:}getcontentlength')); - if(isset($response['{DAV:}getlastmodified']) and isset($response['{DAV:}getcontentlength'])){ - return array( - 'mtime'=>strtotime($response['{DAV:}getlastmodified']), - 'size'=>(int)$response['{DAV:}getcontentlength'], - 'ctime'=>-1, - ); - }else{ - return array(); - } + return array( + 'mtime'=>strtotime($response['{DAV:}getlastmodified']), + 'size'=>(int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0, + 'ctime'=>-1, + ); }catch(Exception $e){ return array(); } diff --git a/apps/files_external/personal.php b/apps/files_external/personal.php index 32e0874244..b758e7e7eb 100755 --- a/apps/files_external/personal.php +++ b/apps/files_external/personal.php @@ -26,7 +26,7 @@ $backends = OC_Mount_Config::getBackends(); // Remove local storage unset($backends['OC_Filestorage_Local']); $tmpl = new OCP\Template('files_external', 'settings'); -$tmpl->assign('isAdminPage', false); +$tmpl->assign('isAdminPage', false, false); $tmpl->assign('mounts', OC_Mount_Config::getPersonalMountPoints()); $tmpl->assign('backends', $backends); return $tmpl->fetchPage(); diff --git a/apps/files_external/settings.php b/apps/files_external/settings.php index 983855ecdc..acc9036b29 100644 --- a/apps/files_external/settings.php +++ b/apps/files_external/settings.php @@ -23,7 +23,7 @@ OCP\Util::addScript('files_external', 'settings'); OCP\Util::addStyle('files_external', 'settings'); $tmpl = new OCP\Template('files_external', 'settings'); -$tmpl->assign('isAdminPage', true); +$tmpl->assign('isAdminPage', true, false); $tmpl->assign('mounts', OC_Mount_Config::getSystemMountPoints()); $tmpl->assign('backends', OC_Mount_Config::getBackends()); $tmpl->assign('groups', OC_Group::getGroups()); diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index 6c37df8001..e651c4574d 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -1,7 +1,7 @@