diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2012-06-05 10:38:42 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2012-06-05 10:38:42 +0200 |
commit | 564b0358f91df832afdf3a0fd27eaa349508c964 (patch) | |
tree | 04a866f7a064368d63fa75811d2a9c85ef6c54e1 /apps | |
parent | dcc5b5ca0a67d4e21442bb96d67d9d23fc7f1647 (diff) | |
parent | d194132b6f9f348daec310be2b0db7c43d4b8629 (diff) | |
download | nextcloud-server-564b0358f91df832afdf3a0fd27eaa349508c964.tar.gz nextcloud-server-564b0358f91df832afdf3a0fd27eaa349508c964.zip |
Merge branch 'master' of gitorious.org:owncloud/owncloud
Diffstat (limited to 'apps')
24 files changed, 245 insertions, 131 deletions
diff --git a/apps/calendar/ajax/import/import.php b/apps/calendar/ajax/import/import.php index 904c07c52e7..a3eaed844a1 100644 --- a/apps/calendar/ajax/import/import.php +++ b/apps/calendar/ajax/import/import.php @@ -10,18 +10,22 @@ ob_start(); OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('calendar'); +session_write_close(); $nl="\r\n"; $comps = array('VEVENT'=>true, 'VTODO'=>true, 'VJOURNAL'=>true); -$progressfile = 'import_tmp/' . md5(session_id()) . '.txt'; +global $progresskey; +$progresskey = 'calendar.import-' . $_GET['progresskey']; + +if (isset($_GET['progress']) && $_GET['progress']) { + echo OC_Cache::get($progresskey); + die; +} function writeProgress($pct) { - if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, $pct); - fclose($progressfopen); - } + global $progresskey; + OC_Cache::set($progresskey, $pct, 300); } writeProgress('10'); $file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']); @@ -114,7 +118,5 @@ foreach($uids as $uid) { // finished import writeProgress('100'); sleep(3); -if(is_writable('import_tmp/')){ - unlink($progressfile); -} +OC_Cache::remove($progresskey); OCP\JSON::success(); diff --git a/apps/calendar/import_tmp/Info b/apps/calendar/import_tmp/Info deleted file mode 100644 index abafbce435c..00000000000 --- a/apps/calendar/import_tmp/Info +++ /dev/null @@ -1,2 +0,0 @@ -This folder contains static files with the percentage of the import. -Requires write permission diff --git a/apps/calendar/js/loader.js b/apps/calendar/js/loader.js index 60d92f448ee..838521ec7f5 100644 --- a/apps/calendar/js/loader.js +++ b/apps/calendar/js/loader.js @@ -43,8 +43,8 @@ Calendar_Import={ } $('#newcalendar').attr('readonly', 'readonly'); $('#calendar').attr('disabled', 'disabled'); - var progressfile = $('#progressfile').val(); - $.post(OC.filePath('calendar', 'ajax/import', 'import.php'), {method: String (method), calname: String (calname), path: String (path), file: String (filename), id: String (calid)}, function(data){ + 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){ if(data.status == 'success'){ $('#progressbar').progressbar('option', 'value', 100); $('#import_done').css('display', 'block'); @@ -52,7 +52,7 @@ Calendar_Import={ }); $('#form_container').css('display', 'none'); $('#progressbar_container').css('display', 'block'); - window.setTimeout('Calendar_Import.getimportstatus(\'' + progressfile + '\')', 500); + window.setTimeout('Calendar_Import.getimportstatus(\'' + progresskey + '\')', 500); }); $('#calendar').change(function(){ if($('#calendar option:selected').val() == 'newcal'){ @@ -62,11 +62,11 @@ Calendar_Import={ } }); }, - getimportstatus: function(progressfile){ - $.get(OC.filePath('calendar', 'import_tmp', progressfile), function(percent){ + getimportstatus: function(progresskey){ + $.get(OC.filePath('calendar', 'ajax/import', 'import.php') + '?progress=1&progresskey=' + progresskey, function(percent){ $('#progressbar').progressbar('option', 'value', parseInt(percent)); if(percent < 100){ - window.setTimeout('Calendar_Import.getimportstatus(\'' + progressfile + '\')', 500); + window.setTimeout('Calendar_Import.getimportstatus(\'' + progresskey + '\')', 500); }else{ $('#import_done').css('display', 'block'); } diff --git a/apps/calendar/templates/part.import.php b/apps/calendar/templates/part.import.php index e93ea1af4c9..39cda29c20d 100644 --- a/apps/calendar/templates/part.import.php +++ b/apps/calendar/templates/part.import.php @@ -2,7 +2,7 @@ <div id="form_container"> <input type="hidden" id="filename" value="<?php echo $_['filename'];?>"> <input type="hidden" id="path" value="<?php echo $_['path'];?>"> -<input type="hidden" id="progressfile" value="<?php echo md5(session_id()) . '.txt';?>"> +<input type="hidden" id="progresskey" value="<?php echo rand() ?>"> <p style="text-align:center;"><b><?php echo $l->t('Please choose the calendar'); ?></b></p> <select style="width:100%;" id="calendar" name="calendar"> <?php diff --git a/apps/contacts/import.php b/apps/contacts/import.php index fdea4975d59..0ee35f9fd81 100644 --- a/apps/contacts/import.php +++ b/apps/contacts/import.php @@ -10,16 +10,21 @@ ob_start(); OCP\JSON::checkLoggedIn(); OCP\App::checkAppEnabled('contacts'); +session_write_close(); + $nl = "\n"; -$progressfile = 'import_tmp/' . md5(session_id()) . '.txt'; +global $progresskey; +$progresskey = 'contacts.import-' . $_GET['progresskey']; + +if (isset($_GET['progress']) && $_GET['progress']) { + echo OC_Cache::get($progresskey); + die; +} function writeProgress($pct) { - if(is_writable('import_tmp/')){ - $progressfopen = fopen($progressfile, 'w'); - fwrite($progressfopen, $pct); - fclose($progressfopen); - } + global $progresskey; + OC_Cache::set($progresskey, $pct, 300); } writeProgress('10'); $view = $file = null; @@ -93,9 +98,7 @@ foreach($parts as $part){ //done the import writeProgress('100'); sleep(3); -if(is_writable('import_tmp/')){ - unlink($progressfile); -} +OC_Cache::remove($progresskey); if(isset($_POST['fstype']) && $_POST['fstype'] == 'OC_FilesystemView') { if(!$view->unlink('/' . $_POST['file'])) { OCP\Util::writeLog('contacts','Import: Error unlinking OC_FilesystemView ' . '/' . $_POST['file'], OCP\Util::ERROR); diff --git a/apps/contacts/import_tmp/Info b/apps/contacts/import_tmp/Info deleted file mode 100644 index abafbce435c..00000000000 --- a/apps/contacts/import_tmp/Info +++ /dev/null @@ -1,2 +0,0 @@ -This folder contains static files with the percentage of the import. -Requires write permission diff --git a/apps/contacts/js/loader.js b/apps/contacts/js/loader.js index 8c79ea8a1d6..961e0f425c9 100644 --- a/apps/contacts/js/loader.js +++ b/apps/contacts/js/loader.js @@ -42,8 +42,8 @@ Contacts_Import={ }
$('#newaddressbook').attr('readonly', 'readonly');
$('#contacts').attr('disabled', 'disabled');
- var progressfile = $('#progressfile').val();
- $.post(OC.filePath('contacts', '', 'import.php'), {method: String (method), addressbookname: String (addressbookname), path: String (path), file: String (filename), id: String (addressbookid)}, function(jsondata){
+ var progresskey = $('#progresskey').val(); + $.post(OC.filePath('contacts', '', 'import.php') + '?progresskey='+progresskey, {method: String (method), addressbookname: String (addressbookname), path: String (path), file: String (filename), id: String (addressbookid)}, function(jsondata){ if(jsondata.status == 'success'){
$('#progressbar').progressbar('option', 'value', 100);
$('#import_done').find('p').html(t('contacts', 'Result: ') + jsondata.data.imported + t('contacts', ' imported, ') + jsondata.data.failed + t('contacts', ' failed.'));
@@ -55,7 +55,7 @@ Contacts_Import={ });
$('#form_container').css('display', 'none');
$('#progressbar_container').css('display', 'block');
- window.setTimeout('Contacts_Import.getimportstatus(\'' + progressfile + '\')', 500);
+ window.setTimeout('Contacts_Import.getimportstatus(\'' + progresskey + '\')', 500); });
$('#contacts').change(function(){
if($('#contacts option:selected').val() == 'newaddressbook'){
@@ -65,11 +65,11 @@ Contacts_Import={ }
});
},
- getimportstatus: function(progressfile){
- $.get(OC.filePath('contacts', 'import_tmp', progressfile), function(percent){
+ getimportstatus: function(progresskey){ + $.get(OC.filePath('contacts', '', 'import.php') + '?progress=1&progresskey=' + progresskey, function(percent){ $('#progressbar').progressbar('option', 'value', parseInt(percent));
if(percent < 100){
- window.setTimeout('Contacts_Import.getimportstatus(\'' + progressfile + '\')', 500);
+ window.setTimeout('Contacts_Import.getimportstatus(\'' + progresskey + '\')', 500); }else{
$('#import_done').css('display', 'block');
}
diff --git a/apps/contacts/photo.php b/apps/contacts/photo.php index 729c2dfbcfd..4660d61f618 100644 --- a/apps/contacts/photo.php +++ b/apps/contacts/photo.php @@ -14,7 +14,7 @@ OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('contacts'); function getStandardImage(){ - OCP\Response::setExpiresHeader('P10D'); + //OCP\Response::setExpiresHeader('P10D'); OCP\Response::enableCaching(); OCP\Response::redirect(OCP\Util::imagePath('contacts', 'person_large.png')); } diff --git a/apps/contacts/templates/part.import.php b/apps/contacts/templates/part.import.php index b8793042997..32c8dc50dd6 100644 --- a/apps/contacts/templates/part.import.php +++ b/apps/contacts/templates/part.import.php @@ -2,7 +2,7 @@ <div id="form_container"> <input type="hidden" id="filename" value="<?php echo $_['filename'];?>"> <input type="hidden" id="path" value="<?php echo $_['path'];?>"> - <input type="hidden" id="progressfile" value="<?php echo md5(session_id()) . '.txt';?>"> + <input type="hidden" id="progresskey" value="<?php echo rand() ?>"> <p class="bold" style="text-align:center;"><?php echo $l->t('Please choose the addressbook'); ?></p> <select style="width:100%;" id="contacts" name="contacts"> <?php diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index c0a40081fe3..3bd5a1ceef4 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -53,7 +53,7 @@ </span> </th> <th id="headerSize"><?php echo $l->t( 'Size' ); ?></th> - <th id="headerDate"><span id="modified"><?php echo $l->t( 'Modified' ); ?></span><span class="selectedActions"><a href="" class="delete"><?php echo $l->t('Delete all')?> <img class="svg" alt="<?php echo $l->t('Delete')?>" src="<?php echo OCP\image_path("core", "actions/delete.svg"); ?>" /></a></span></th> + <th id="headerDate"><span id="modified"><?php echo $l->t( 'Modified' ); ?></span><span class="selectedActions"><a href="" class="delete"><?php echo $l->t('Delete')?> <img class="svg" alt="<?php echo $l->t('Delete')?>" src="<?php echo OCP\image_path("core", "actions/delete.svg"); ?>" /></a></span></th> </tr> </thead> <tbody id="fileList" data-readonly="<?php echo $_['readonly'];?>"> diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php index 1d107c1bda0..bee60543339 100644 --- a/apps/files_versions/ajax/getVersions.php +++ b/apps/files_versions/ajax/getVersions.php @@ -10,7 +10,14 @@ $source = strip_tags( $source ); if( OCA_Versions\Storage::isversioned( $source ) ) { $count=5; //show the newest revisions - $versions = OCA_Versions\Storage::getversions( $source, $count); + $versions = OCA_Versions\Storage::getVersions( $source, $count); + $versionsFormatted = array(); + + foreach ( $versions AS $version ) { + + $versionsFormatted[] = OCP\Util::formatDate( $version ); + + } $versionsSorted = array_reverse( $versions ); diff --git a/apps/files_versions/history.php b/apps/files_versions/history.php index 11c07ef86ce..cb4726e8d0e 100644 --- a/apps/files_versions/history.php +++ b/apps/files_versions/history.php @@ -54,7 +54,7 @@ if ( isset( $_GET['path'] ) ) { if( OCA_Versions\Storage::isversioned( $path ) ) { $count = 999; //show the newest revisions - $versions = OCA_Versions\Storage::getversions( $path, $count ); + $versions = OCA_Versions\Storage::getVersions( $path, $count); $tmpl->assign( 'versions', array_reverse( $versions ) ); diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js index 5e46b2a0eed..82d569fa0f6 100644 --- a/apps/files_versions/js/versions.js +++ b/apps/files_versions/js/versions.js @@ -33,7 +33,7 @@ $(document).ready(function(){ }); function createVersionsDropdown(filename, files) { - + var historyUrl = OC.linkTo('files_versions', 'history.php') + '?path='+encodeURIComponent( $( '#dir' ).val() ).replace( /%2F/g, '/' )+'/'+encodeURIComponent( filename ); var html = '<div id="dropdown" class="drop" data-file="'+files+'">'; diff --git a/apps/files_versions/templates/history.php b/apps/files_versions/templates/history.php index 58fea75a0d0..13e104152b7 100644 --- a/apps/files_versions/templates/history.php +++ b/apps/files_versions/templates/history.php @@ -22,8 +22,10 @@ if( isset( $_['message'] ) ) { foreach ( $_['versions'] as $v ) { echo ' '; - echo OCP\Util::formatDate( $v ); - echo ' <a href="'.OCP\Util::linkTo('files_versions', 'history.php').'?path='.urlencode( $_['path'] ).'&revert='. $v .'" class="button">Revert</a><br /><br />'; + echo OCP\Util::formatDate( $v['version'] ); + echo ' <a href="'.OCP\Util::linkTo('files_versions', 'history.php').'?path='.urlencode( $_['path'] ).'&revert='. $v['version'] .'" class="button">Revert</a><br /><br />'; + if ( $v['cur'] ) { echo ' (<b>Current</b>)'; } + echo '<br /><br />'; } diff --git a/apps/files_versions/versions.php b/apps/files_versions/versions.php index f39b5a7f4eb..44ce7c635aa 100644 --- a/apps/files_versions/versions.php +++ b/apps/files_versions/versions.php @@ -27,7 +27,6 @@ class Storage { // // todo: // - port to oc_filesystem to enable network transparency - // - check if it works well together with encryption // - implement expire all function. And find a place to call it ;-) // - add transparent compression. first test if it´s worth it. @@ -35,7 +34,7 @@ class Storage { const DEFAULTFOLDER='versions'; const DEFAULTBLACKLIST='avi mp3 mpg mp4 ctmp'; const DEFAULTMAXFILESIZE=1048576; // 10MB - const DEFAULTMININTERVAL=120; // 2 min + const DEFAULTMININTERVAL=1; // 2 min const DEFAULTMAXVERSIONS=50; /** @@ -76,7 +75,7 @@ class Storage { } else { $uid = \OCP\User::getUser(); } - $versionsfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); + $versionsFolderName=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); $filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/files'; Storage::init(); @@ -103,7 +102,7 @@ class Storage { // check mininterval if the file is being modified by the owner (all shared files should be versioned despite mininterval) if ($uid == \OCP\User::getUser()) { - $matches=glob($versionsfoldername.'/'.$filename.'.v*'); + $matches=glob($versionsFolderName.'/'.$filename.'.v*'); sort($matches); $parts=explode('.v',end($matches)); if((end($parts)+Storage::DEFAULTMININTERVAL)>time()){ @@ -114,12 +113,12 @@ class Storage { // create all parent folders $info=pathinfo($filename); - if(!file_exists($versionsfoldername.'/'.$info['dirname'])) mkdir($versionsfoldername.'/'.$info['dirname'],0700,true); + if(!file_exists($versionsFolderName.'/'.$info['dirname'])) mkdir($versionsFolderName.'/'.$info['dirname'],0700,true); // store a new version of a file - copy($filesfoldername.'/'.$filename,$versionsfoldername.'/'.$filename.'.v'.time()); + copy($filesfoldername.'/'.$filename,$versionsFolderName.'/'.$filename.'.v'.time()); - // expire old revisions + // expire old revisions if necessary Storage::expire($filename); } } @@ -138,12 +137,12 @@ class Storage { } else { $uid = \OCP\User::getUser(); } - $versionsfoldername=\OCP\Config::getSystemValue('datadirectory').'/'.$uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); + $versionsFolderName=\OCP\Config::getSystemValue('datadirectory').'/'.$uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); $filesfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/files'; // rollback - if ( @copy($versionsfoldername.'/'.$filename.'.v'.$revision,$filesfoldername.'/'.$filename) ) { + if ( @copy($versionsFolderName.'/'.$filename.'.v'.$revision,$filesfoldername.'/'.$filename) ) { return true; @@ -169,10 +168,10 @@ class Storage { } else { $uid = \OCP\User::getUser(); } - $versionsfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); + $versionsFolderName=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); // check for old versions - $matches=glob($versionsfoldername.'/'.$filename.'.v*'); + $matches=glob($versionsFolderName.'/'.$filename.'.v*'); if(count($matches)>1){ return true; }else{ @@ -186,10 +185,15 @@ class Storage { /** - * get a list of old versions of a file. + * @brief get a list of all available versions of a file in descending chronological order + * @param $filename file to find versions of, relative to the user files dir + * @param $count number of versions to return + * @returns array */ - public static function getversions($filename,$count=0) { - if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { + public static function getVersions( $filename, $count = 0 ) { + + if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) { + if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) { $pos = strpos($source, '/files', 1); $uid = substr($source, 1, $pos - 1); @@ -197,29 +201,65 @@ class Storage { } else { $uid = \OCP\User::getUser(); } - $versionsfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); - $versions=array(); - - // fetch for old versions - $matches=glob($versionsfoldername.'/'.$filename.'.v*'); - sort($matches); - foreach($matches as $ma) { - $parts=explode('.v',$ma); - $versions[]=(end($parts)); + $versionsFolderName = \OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); + $versions = array(); + + // fetch for old versions + $matches = glob( $versionsFolderName.'/'.$filename.'.v*' ); + + sort( $matches ); + + $i = 0; + + foreach( $matches as $ma ) { + + $i++; + $versions[$i]['cur'] = 0; + $parts = explode( '.v', $ma ); + $versions[$i]['version'] = ( end( $parts ) ); + + // if file with modified date exists, flag it in array as currently enabled version + $curFile['fileName'] = basename( $parts[0] ); + $curFile['filePath'] = \OCP\Config::getSystemValue('datadirectory').\OC_Filesystem::getRoot().'/'.$curFile['fileName']; + + ( \md5_file( $ma ) == \md5_file( $curFile['filePath'] ) ? $versions[$i]['fileMatch'] = 1 : $versions[$i]['fileMatch'] = 0 ); + } + $versions = array_reverse( $versions ); + + foreach( $versions as $key => $value ) { + + // flag the first matched file in array (which will have latest modification date) as current version + if ( $versions[$key]['fileMatch'] ) { + + $versions[$key]['cur'] = 1; + break; + + } + + } + + $versions = array_reverse( $versions ); + // only show the newest commits - if($count<>0 and (count($versions)>$count)) { - $versions=array_slice($versions,count($versions)-$count); + if( $count != 0 and ( count( $versions )>$count ) ) { + + $versions = array_slice( $versions, count( $versions ) - $count ); + } - return($versions); + return( $versions ); - }else{ - return(array()); + } else { + + // if versioning isn't enabled then return an empty array + return( array() ); + } - } + + } @@ -228,6 +268,7 @@ class Storage { */ public static function expire($filename) { if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { + if (\OCP\App::isEnabled('files_sharing') && $source = \OC_Share::getSource('/'.\OCP\User::getUser().'/files'.$filename)) { $pos = strpos($source, '/files', 1); $uid = substr($source, 1, $pos - 1); @@ -235,28 +276,93 @@ class Storage { } else { $uid = \OCP\User::getUser(); } - $versionsfoldername=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); + $versionsFolderName=\OCP\Config::getSystemValue('datadirectory').'/'. $uid .'/'.\OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER); // check for old versions - $matches=glob($versionsfoldername.'/'.$filename.'.v*'); - if(count($matches)>\OCP\Config::getSystemValue('files_versionmaxversions', Storage::DEFAULTMAXVERSIONS)){ - $numbertodelete=count($matches-\OCP\Config::getSystemValue('files_versionmaxversions', Storage::DEFAULTMAXVERSIONS)); + $matches = glob( $versionsFolderName.'/'.$filename.'.v*' ); + + if( count( $matches ) > \OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ) ) { + + $numberToDelete = count( $matches-\OCP\Config::getSystemValue( 'files_versionmaxversions', Storage::DEFAULTMAXVERSIONS ) ); // delete old versions of a file - $deleteitems=array_slice($matches,0,$numbertodelete); - foreach($deleteitems as $de){ - unlink($versionsfoldername.'/'.$filename.'.v'.$de); + $deleteItems = array_slice( $matches, 0, $numberToDelete ); + + foreach( $deleteItems as $de ) { + + unlink( $versionsFolderName.'/'.$filename.'.v'.$de ); + } } } } /** - * expire all old versions. + * @brief erase all old versions of all user files + * @return */ - public static function expireall($filename) { - // todo this should go through all the versions directories and delete all the not needed files and not needed directories. - // useful to be included in a cleanup cronjob. + public static function expireAll() { + + function deleteAll($directory, $empty = false) { + + if(substr($directory,-1) == "/") { + $directory = substr($directory,0,-1); + } + + if(!file_exists($directory) || !is_dir($directory)) { + + return false; + + } elseif(!is_readable($directory)) { + + return false; + + } else { + + $directoryHandle = opendir($directory); + + while ($contents = readdir($directoryHandle)) { + + if( $contents != '.' && $contents != '..') { + + $path = $directory . "/" . $contents; + + if( is_dir($path) ) { + + deleteAll($path); + + } else { + + unlink($path); + + } + } + + } + + closedir( $directoryHandle ); + + if( $empty == false ) { + + if(!rmdir($directory)) { + + return false; + + } + + } + + return true; + } + + } + + /* + // FIXME: make this path dynamic + $dir = '/home/samtuke/owncloud/git/oc5/data/admin/versions'; + + ( deleteAll( $dir, 1 ) ? return true : return false ); + */ } diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php index 0cd825f3e50..b49e52f0bd2 100644 --- a/apps/gallery/ajax/galleryOp.php +++ b/apps/gallery/ajax/galleryOp.php @@ -42,7 +42,8 @@ function handleRemove($name) { function handleGetThumbnails($albumname) { OCP\Response::enableCaching(3600 * 24); // 24 hour - $thumbnail = OC::$CONFIG_DATADIRECTORY.'/../gallery/'.urldecode($albumname).'.png'; + $view = OCP\App::getStorage('gallery'); + $thumbnail = $view->fopen(urldecode($albumname).'.png', 'r'); header('Content-Type: '.OC_Image::getMimeTypeForFile($thumbnail)); OCP\Response::sendFile($thumbnail); } diff --git a/apps/gallery/ajax/sharing.php b/apps/gallery/ajax/sharing.php index 1223320120b..304757b9e91 100644 --- a/apps/gallery/ajax/sharing.php +++ b/apps/gallery/ajax/sharing.php @@ -80,7 +80,8 @@ function handleGetThumbnail($token, $imgpath) { function handleGetAlbumThumbnail($token, $albumname) { $owner = OC_Gallery_Sharing::getTokenOwner($token); - $file = OCP\Config::getSystemValue("datadirectory").'/'. $owner .'/gallery/'.$albumname.'.png'; + $view = OCP\App::getStorage('gallery'); + $file = $view->fopen($albumname.'.png', 'r'); $image = new OC_Image($file); if ($image->valid()) { $image->centerCrop(); @@ -93,7 +94,8 @@ function handleGetAlbumThumbnail($token, $albumname) function handleGetPhoto($token, $photo) { $owner = OC_Gallery_Sharing::getTokenOwner($token); - $file = OCP\Config::getSystemValue( "datadirectory", OC::$SERVERROOT."/data" ).'/'.$owner.'/files'.urldecode($photo); + $view = OCP\App::getStorage('files'); + $file = $view->fopen(urldecode($photo), 'r'); header('Content-Type: '.OC_Image::getMimeTypeForFile($file)); OCP\Response::sendFile($file); } diff --git a/apps/gallery/index.php b/apps/gallery/index.php index e47fb3db5d6..a9fe200c4e4 100644 --- a/apps/gallery/index.php +++ b/apps/gallery/index.php @@ -27,10 +27,6 @@ OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('gallery'); OCP\App::setActiveNavigationEntry( 'gallery_index' ); -if (!file_exists(OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery')) { - mkdir(OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery'); -} - if (!isset($_GET['view'])) { $result = OC_Gallery_Album::find(OCP\USER::getUser()); diff --git a/apps/gallery/js/album_cover.js b/apps/gallery/js/album_cover.js index d1809462f2f..905034f6fd1 100644 --- a/apps/gallery/js/album_cover.js +++ b/apps/gallery/js/album_cover.js @@ -78,14 +78,14 @@ function albumClickHandler(r) { for (var i in r.photos) { Albums.photos.push(r.photos[i]); } - Albums.shared = r.shared; - if (Albums.shared) { - Albums.recursive = r.recursive; - Albums.token = r.token; - } else { - Albums.recursive = false; - Albums.token = ''; - } + Albums.shared = r.shared; + if (Albums.shared) { + Albums.recursive = r.recursive; + Albums.token = r.token; + } else { + Albums.recursive = false; + Albums.token = ''; + } $(document).ready(function(){ var targetDiv = $('#gallery_list'); targetDiv.html(''); diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php index 5f962f12f12..8ac27b1a70d 100644 --- a/apps/gallery/lib/album.php +++ b/apps/gallery/lib/album.php @@ -77,7 +77,7 @@ class OC_Gallery_Album { $sql .= ' AND parent_path = ?'; $args[] = $parent; } - $order = OCP\Config::getUserValue($owner, 'gallery', 'order', 'ASC'); + $order = OCP\Config::getUserValue($owner, 'gallery', 'order', 'ASC'); $sql .= ' ORDER BY album_name ' . $order; $stmt = OCP\DB::prepare($sql); @@ -90,25 +90,22 @@ class OC_Gallery_Album { } public static function changeThumbnailPath($oldname, $newname) { - - $thumbpath = OC::$CONFIG_DATADIRECTORY.'/../gallery/'; - rename($thumbpath.$oldname.'.png', $thumbpath.$newname.'.png'); + $view = OCP\App::getStorage('gallery'); + $view->rename($oldname.'.png', $newname.'.png'); } public static function getAlbumSize($id){ - $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos WHERE album_id = ?'; - $stmt = OCP\DB::prepare($sql); - $result=$stmt->execute(array($id))->fetchRow(); - return $result['size']; + $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos WHERE album_id = ?'; + $stmt = OCP\DB::prepare($sql); + $result=$stmt->execute(array($id))->fetchRow(); + return $result['size']; } - public static function getIntermediateGallerySize($path) { - $path .= '%'; - $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos photos, *PREFIX*gallery_albums albums WHERE photos.album_id = albums.album_id AND uid_owner = ? AND file_path LIKE ?'; - $stmt = OCP\DB::prepare($sql); - $result = $stmt->execute(array(OCP\USER::getUser(), $path))->fetchRow(); - return $result['size']; - } + public static function getIntermediateGallerySize($path) { + $path .= '%'; + $sql = 'SELECT COUNT(*) as size FROM *PREFIX*gallery_photos photos, *PREFIX*gallery_albums albums WHERE photos.album_id = albums.album_id AND uid_owner = ? AND file_path LIKE ?'; + $stmt = OCP\DB::prepare($sql); + $result = $stmt->execute(array(OCP\USER::getUser(), $path))->fetchRow(); + return $result['size']; + } } - -?> diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php index 99384af621a..b4b37236b0e 100644 --- a/apps/gallery/lib/photo.php +++ b/apps/gallery/lib/photo.php @@ -68,17 +68,17 @@ class OC_Gallery_Photo { public static function getThumbnail($image_name, $owner = null) { if (!$owner) $owner = OCP\USER::getUser(); - $save_dir = OCP\Config::getSystemValue("datadirectory").'/'. $owner .'/gallery/'; - $save_dir .= dirname($image_name). '/'; - $image_path = $image_name; - $thumb_file = $save_dir . basename($image_name); - if (!is_dir($save_dir)) { - mkdir($save_dir, 0777, true); + $view = OCP\App::getStorage('gallery'); + $save_dir = dirname($image_name); + if (!$view->is_dir($save_dir)) { + $view->mkdir($save_dir); } - if (file_exists($thumb_file)) { - $image = new OC_Image($thumb_file); + $view->chroot($view->getRoot().'/'.$save_dir); + $thumb_file = basename($image_name); + if ($view->file_exists($thumb_file)) { + $image = new OC_Image($view->fopen($thumb_file, 'r')); } else { - $image_path = OC_Filesystem::getLocalFile($image_path); + $image_path = OC_Filesystem::getLocalFile($image_name); if(!file_exists($image_path)) { return null; } @@ -86,7 +86,7 @@ class OC_Gallery_Photo { if ($image->valid()) { $image->centerCrop(200); $image->fixOrientation(); - $image->save($thumb_file); + $image->save($view->getLocalFile($thumb_file)); } } if ($image->valid()) { diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php index 7a137cb3f50..e11ba1da454 100644 --- a/apps/gallery/lib/scanner.php +++ b/apps/gallery/lib/scanner.php @@ -81,7 +81,8 @@ class OC_Gallery_Scanner { $image->destroy(); } } - imagepng($thumbnail, OCP\Config::getSystemValue("datadirectory").'/'. OCP\USER::getUser() .'/gallery/' . $albumName.'.png'); + $view = OCP\App::getStorage('gallery'); + imagepng($thumbnail, $view->getLocalFile($albumName.'.png')); imagedestroy($thumbnail); } diff --git a/apps/tasks/css/style.css b/apps/tasks/css/style.css index 3cf175e6463..23aac4e9ca7 100644 --- a/apps/tasks/css/style.css +++ b/apps/tasks/css/style.css @@ -9,7 +9,7 @@ #tasks_lists .active{font-weight:bold;} #tasks_list h1{background-color:#1D2D44;color:white;font-size:120%;padding:0 0.5em;} -.task{border-radius:0.4em;position:relative;padding:0.5em 1em;} +.task{border-radius:0.4em;position:relative;padding:0.4em 1em;} .task:nth-child(odd){background-color:#F4F4F4;} .task:hover {background-color:#DDDDDD;} @@ -33,7 +33,7 @@ .task .completed {position:absolute;left:3em;top:0.3em;} .task .summary{padding-left:4em;height:2em;} -.task .summary input{position:relative;left:5px;} +.task .summary input{position:relative;left:5px;top:0.5em;} .task.done .summary{text-decoration:line-through;} .task .tag{border-radius:0.4em;display:inline-block;opacity:0.2;margin:0 0.2em;border:1px solid transparent;padding:0 0.4em;cursor:pointer;} @@ -42,18 +42,19 @@ .task:hover .tag{opacity:0.5} .task:hover .tag:hover{opacity:0.8;} -.task .categories{position:absolute;right:12em;text-align:right;top:0.4em} +.task .categories{position:absolute;right:12em;text-align:right;top:0.5em} .task .categories a{background-color:#1d2d44;color:white;} .task .categories .tag.active{display:none;} .task input.categories{display:none;top:0;text-align:left;} -.task .location{background-color:#442d44;color:white;position:absolute;right:0.6em;width:9.2em;text-align:left;top:0.4em} +.task .location{background-color:#442d44;color:white;position:absolute;right:0.6em;width:9.2em;text-align:left;top:0.5em} .task input.location{display:none;top:0;text-align:left;right:0.3em;background-color:white;color:#333333;} .task .more{display:none;margin-top:0.5em;} .task_less{display:none;} .task .description{position:relative;left:4em;} +.task textarea.description{width:35em;height:4em;} .task .due{position:absolute;right:0.3em;} .task .due .date{width:6em;} .task .due .time{width:6em;} diff --git a/apps/user_openid/user_openid.php b/apps/user_openid/user_openid.php index 3267db3fa0f..e228de95e9e 100644 --- a/apps/user_openid/user_openid.php +++ b/apps/user_openid/user_openid.php @@ -24,7 +24,7 @@ require_once('class.openid.v3.php'); /** - * Class for user management in a SQL Database (e.g. MySQL, SQLite) + * Class for user OpenId backend */ class OC_USER_OPENID extends OC_User_Backend { /** |