summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrice Maron <brice@bmaron.net>2012-06-21 20:19:31 +0000
committerBrice Maron <brice@bmaron.net>2012-06-21 20:19:31 +0000
commita5938e4e3766bb7502a3493661ed3bac662f5182 (patch)
tree02fcbe206788e471f122158730004554afec83c5
parent84b9ac2678e6a0b014b730896a12d1531789d8da (diff)
parent37d12144c2debd27271378d2adc5c2b65a25e1f7 (diff)
downloadnextcloud-server-a5938e4e3766bb7502a3493661ed3bac662f5182.tar.gz
nextcloud-server-a5938e4e3766bb7502a3493661ed3bac662f5182.zip
Merge branch 'master' into multi_app_dir
-rw-r--r--apps/calendar/lib/search.php5
-rw-r--r--apps/contacts/js/contacts.js10
-rw-r--r--apps/contacts/lib/search.php2
-rw-r--r--apps/contacts/templates/index.php1
-rw-r--r--apps/contacts/templates/part.contacts.php2
-rw-r--r--apps/files_encryption/tests/proxy.php5
-rw-r--r--apps/files_sharing/sharedstorage.php4
-rw-r--r--apps/files_versions/versions.php86
-rw-r--r--apps/tasks/css/style.css4
-rw-r--r--apps/tasks/js/tasks.js30
-rw-r--r--apps/tasks/templates/tasks.php5
-rw-r--r--lib/filestorage/common.php85
-rw-r--r--lib/filestorage/local.php4
-rw-r--r--lib/filesystemview.php3
14 files changed, 137 insertions, 109 deletions
diff --git a/apps/calendar/lib/search.php b/apps/calendar/lib/search.php
index 6526b4223ac..560330f65e9 100644
--- a/apps/calendar/lib/search.php
+++ b/apps/calendar/lib/search.php
@@ -17,6 +17,9 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{
foreach($calendars as $calendar){
$objects = OC_Calendar_Object::all($calendar['id']);
foreach($objects as $object){
+ if($object['objecttype']!='VEVENT') {
+ continue;
+ }
if(substr_count(strtolower($object['summary']), strtolower($query)) > 0){
$calendardata = OC_VObject::parse($object['calendardata']);
$vevent = $calendardata->VEVENT;
@@ -37,7 +40,7 @@ class OC_Search_Provider_Calendar extends OC_Search_Provider{
$info = $l->t('Date') . ': ' . $start_dt->format('d.m.y H:i') . ' - ' . $end_dt->format('d.m.y H:i');
}
$link = OCP\Util::linkTo('calendar', 'index.php').'?showevent='.urlencode($object['id']);
- $results[]=new OC_Search_Result($object['summary'],$info, $link,$l->t('Cal.'));//$name,$text,$link,$type
+ $results[]=new OC_Search_Result($object['summary'],$info, $link,(string)$l->t('Cal.'));//$name,$text,$link,$type
}
}
}
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index 8ab2a3fbb88..bd8535b4f60 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -256,12 +256,14 @@ Contacts={
}
} else {
newid = id;
+ bookid = bookid?bookid:$('#contacts li[data-id="'+newid+'"]').data('bookid');
}
var localLoadContact = function(newid, bookid) {
if($('.contacts li').length > 0) {
- firstitem.addClass('active');
+ $('#contacts li[data-id="'+newid+'"]').addClass('active');
$.getJSON(OC.filePath('contacts', 'ajax', 'contactdetails.php'),{'id':newid},function(jsondata){
if(jsondata.status == 'success'){
+ $('#contacts h3[data-id="'+bookid+'"]').trigger('click');
Contacts.UI.Card.loadContact(jsondata.data, bookid);
} else {
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
@@ -1503,7 +1505,7 @@ Contacts={
},
Contacts:{
// Reload the contacts list.
- update:function(){
+ update:function(id){
$.getJSON(OC.filePath('contacts', 'ajax', 'contacts.php'),{},function(jsondata){
if(jsondata.status == 'success'){
$('#contacts').html(jsondata.data.page).ready(function() {
@@ -1518,7 +1520,7 @@ Contacts={
})}, 100);
setTimeout(Contacts.UI.Contacts.lazyupdate, 500);*/
});
- Contacts.UI.Card.update();
+ Contacts.UI.Card.update(id);
}
else{
OC.dialogs.alert(jsondata.data.message, t('contacts', 'Error'));
@@ -1707,5 +1709,5 @@ $(document).ready(function(){
$('#contacts_propertymenu_dropdown a').keydown(propertyMenuItem);
Contacts.UI.loadHandlers();
- Contacts.UI.Contacts.update();
+ Contacts.UI.Contacts.update(id);
});
diff --git a/apps/contacts/lib/search.php b/apps/contacts/lib/search.php
index 19330fa9be1..5a5632a1520 100644
--- a/apps/contacts/lib/search.php
+++ b/apps/contacts/lib/search.php
@@ -11,7 +11,7 @@ class OC_Search_Provider_Contacts extends OC_Search_Provider{
$vcards = OC_Contacts_VCard::all($addressbook['id']);
foreach($vcards as $vcard){
if(substr_count(strtolower($vcard['fullname']), strtolower($query)) > 0){
- $link = OCP\Util::linkTo('contacts', 'index.php').'?id='.urlencode($vcard['id']);
+ $link = OCP\Util::linkTo('contacts', 'index.php').'&id='.urlencode($vcard['id']);
$results[]=new OC_Search_Result($vcard['fullname'],'', $link,$l->t('Contact'));//$name,$text,$link,$type
}
}
diff --git a/apps/contacts/templates/index.php b/apps/contacts/templates/index.php
index d16356d4a56..1790ad4e30d 100644
--- a/apps/contacts/templates/index.php
+++ b/apps/contacts/templates/index.php
@@ -1,6 +1,7 @@
<script type='text/javascript'>
var totalurl = '<?php echo OCP\Util::linkToRemote('carddav'); ?>addressbooks';
var categories = <?php echo json_encode($_['categories']); ?>;
+ var id = <?php echo $_['id']; ?>;
var lang = '<?php echo OCP\Config::getUserValue(OCP\USER::getUser(), 'core', 'lang', 'en'); ?>';
</script>
<div id="leftcontent">
diff --git a/apps/contacts/templates/part.contacts.php b/apps/contacts/templates/part.contacts.php
index f0b14c8e5f2..c33c5832e82 100644
--- a/apps/contacts/templates/part.contacts.php
+++ b/apps/contacts/templates/part.contacts.php
@@ -3,7 +3,7 @@ foreach($_['books'] as $id => $addressbook) {
echo '<h3 class="addressbook" data-id="'.$id.'">'.$addressbook['displayname'].'</h3>';
echo '<ul class="contacts hidden" data-id="'.$id.'">';
foreach($addressbook['contacts'] as $contact) {
- echo '<li role="button" data-bookid="'.$contact['addressbookid'].'" data-id="'.$contact['id'].'"><a href="index.php?id='.$contact['id'].'" style="background: url('.link_to('contacts','thumbnail.php').'?id='.$contact['id'].') no-repeat scroll 0 0 transparent;">'.$contact['displayname'].'</a></li>';
+ echo '<li role="button" data-bookid="'.$contact['addressbookid'].'" data-id="'.$contact['id'].'"><a href="'.link_to('contacts','index.php').'&id='.$contact['id'].'" style="background: url('.link_to('contacts','thumbnail.php').'?id='.$contact['id'].') no-repeat scroll 0 0 transparent;">'.$contact['displayname'].'</a></li>';
}
echo '</ul>';
}
diff --git a/apps/files_encryption/tests/proxy.php b/apps/files_encryption/tests/proxy.php
index 4533289265a..fcfc4cfb9f0 100644
--- a/apps/files_encryption/tests/proxy.php
+++ b/apps/files_encryption/tests/proxy.php
@@ -8,10 +8,12 @@
class Test_CryptProxy extends UnitTestCase {
private $oldConfig;
+ private $oldKey;
public function setUp(){
$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;
//set testing key
@@ -36,6 +38,9 @@ class Test_CryptProxy extends UnitTestCase {
public function tearDown(){
OCP\Config::setAppValue('files_encryption','enable_encryption',$this->oldConfig);
+ if(!is_null($this->oldKey)){
+ $_SESSION['enckey']=$this->oldKey;
+ }
}
public function testSimple(){
diff --git a/apps/files_sharing/sharedstorage.php b/apps/files_sharing/sharedstorage.php
index 62c86ee18e4..fed1b834fa3 100644
--- a/apps/files_sharing/sharedstorage.php
+++ b/apps/files_sharing/sharedstorage.php
@@ -25,7 +25,7 @@ require_once( 'lib_share.php' );
/**
* Convert target path to source path and pass the function call to the correct storage provider
*/
-class OC_Filestorage_Shared extends OC_Filestorage {
+class OC_Filestorage_Shared extends OC_Filestorage_Common {
private $datadir;
private $sourcePaths = array();
@@ -492,7 +492,7 @@ class OC_Filestorage_Shared extends OC_Filestorage {
return $this->searchInDir($query);
}
- private function searchInDir($query, $path = "") {
+ protected function searchInDir($query, $path = "") {
$files = array();
if ($dh = $this->opendir($path)) {
while (($filename = readdir($dh)) !== false) {
diff --git a/apps/files_versions/versions.php b/apps/files_versions/versions.php
index 7522538caf2..9c0829ff1de 100644
--- a/apps/files_versions/versions.php
+++ b/apps/files_versions/versions.php
@@ -261,10 +261,8 @@ class Storage {
}
-
-
/**
- * expire old versions of a file.
+ * @brief Erase a file's versions which exceed the set quota
*/
public static function expire($filename) {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
@@ -298,90 +296,16 @@ class Storage {
}
/**
- * @brief erase all old versions of all user files
- * @return
+ * @brief Erase all old versions of all user files
+ * @return true/false
*/
public static function expireAll() {
-
- function deleteAll( $directory, $empty = false ) {
- // strip leading slash
- if( substr( $directory, 0, 1 ) == "/" ) {
-
- $directory = substr( $directory, 1 );
-
- }
-
- // strip trailing slash
- if( substr( $directory, -1) == "/" ) {
-
- $directory = substr( $directory, 0, -1 );
-
- }
-
- $view = new \OC_FilesystemView('');
-
- if ( !$view->file_exists( $directory ) || !$view->is_dir( $directory ) ) {
-
- return false;
-
- } elseif( !$view->is_readable( $directory ) ) {
-
- return false;
-
- } else {
-
- $foldername = \OCP\Config::getSystemValue('datadirectory') .'/' . \OCP\USER::getUser() .'/' . $directory; // have to set an absolute path for use with PHP's opendir as OC version doesn't work
-
- $directoryHandle = $view->opendir( \OCP\USER::getUser() . '/' . $directory );
-
- while ( $contents = readdir( $directoryHandle ) ) {
-
- if ( $contents != '.' && $contents != '..') {
-
- $path = $directory . "/" . $contents;
-
- if ( $view->is_dir( $path ) ) {
-
- deleteAll( $path );
-
- } else {
-
- $view->unlink( \OCP\USER::getUser() .'/' . $path ); // TODO: make unlink use same system path as is_dir
-
- }
- }
-
- }
-
- //$view->closedir( $directoryHandle ); // TODO: implement closedir in OC_FSV
-
- if ( $empty == false ) {
-
- if ( !$view->rmdir( $directory ) ) {
-
- return false;
-
- }
-
- }
-
- return true;
- }
-
- }
+ $view = new \OC_FilesystemView('');
$dir = \OCP\Config::getSystemValue('files_versionsfolder', Storage::DEFAULTFOLDER);
- if ( deleteAll( $dir, true ) ) {
-
- return true;
-
- } else {
-
- return false;
-
- }
+ return $view->deleteAll( $dir, true );
}
diff --git a/apps/tasks/css/style.css b/apps/tasks/css/style.css
index 23aac4e9ca7..80b6e777b5d 100644
--- a/apps/tasks/css/style.css
+++ b/apps/tasks/css/style.css
@@ -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;top:0.5em;}
+.task .summary input{position:absolute;left:5em;top:0;}
.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;}
@@ -58,3 +58,5 @@
.task .due{position:absolute;right:0.3em;}
.task .due .date{width:6em;}
.task .due .time{width:6em;}
+
+.task_delete{position:absolute;bottom:2px;right:5px}
diff --git a/apps/tasks/js/tasks.js b/apps/tasks/js/tasks.js
index 6547b80981c..bc92965bb0b 100644
--- a/apps/tasks/js/tasks.js
+++ b/apps/tasks/js/tasks.js
@@ -97,8 +97,10 @@ OC.Tasks = {
due.find('.time').timepicker('setTime', date.getHours()+':'+date.getMinutes());
}
}
+ var delete_action = task_container.find('.task_delete').click(OC.Tasks.deleteClickHandler);
$('<div>')
.addClass('more')
+ .append(delete_action)
.append(description)
.append(due)
.appendTo(task_container);
@@ -273,6 +275,19 @@ OC.Tasks = {
$task.find('div.location').show();
$task.find('input.location').hide();
},
+ deleteClickHandler:function(event){
+ var $task = $(this).closest('.task'),
+ task = $task.data('task');
+ $.post(OC.filePath('tasks', 'ajax', 'delete.php'),{'id':task.id},function(jsondata){
+ if(jsondata.status == 'success'){
+ $task.remove();
+ }
+ else{
+ alert(jsondata.data.message);
+ }
+ });
+ return false;
+ },
complete_task:function() {
var $task = $(this).closest('.task'),
task = $task.data('task'),
@@ -441,21 +456,6 @@ $(document).ready(function(){
});
});
- $('#tasks_delete').live('click',function(){
- var id = $('#task_details').data('id');
- $.post('ajax/delete.php',{'id':id},function(jsondata){
- if(jsondata.status == 'success'){
- $('#tasks [data-id="'+jsondata.data.id+'"]').remove();
- $('#task_details').data('id','');
- $('#task_details').html('');
- }
- else{
- alert(jsondata.data.message);
- }
- });
- return false;
- });
-
$('#tasks_addtask').click(function(){
var input = $('#tasks_newtask').val();
$.post(OC.filePath('tasks', 'ajax', 'addtask.php'),{text:input},function(jsondata){
diff --git a/apps/tasks/templates/tasks.php b/apps/tasks/templates/tasks.php
index ab6138b613f..8c0c89e4970 100644
--- a/apps/tasks/templates/tasks.php
+++ b/apps/tasks/templates/tasks.php
@@ -2,7 +2,7 @@
<input type="text" id="tasks_newtask">
<input type="button" id="tasks_addtask" value="<?php echo $l->t('Add Task'); ?>">
<input type="button" id="tasks_order_due" value="<?php echo $l->t('Order Due'); ?>">
- <input type="button" id="tasks_order_category" value="<?php echo $l->t('Order Category'); ?>">
+ <input type="button" id="tasks_order_category" value="<?php echo $l->t('Order List'); ?>">
<input type="button" id="tasks_order_complete" value="<?php echo $l->t('Order Complete'); ?>">
<input type="button" id="tasks_order_location" value="<?php echo $l->t('Order Location'); ?>">
<input type="button" id="tasks_order_prio" value="<?php echo $l->t('Order Priority'); ?>">
@@ -25,6 +25,9 @@
<span class="task_less">
<img title="<?php echo $l->t('Less') ?>" src="<?php echo OCP\image_path('core', 'actions/triangle-n.svg') ?>" class="svg"><?php echo $l->t('Less') ?>
</span>
+ <span class="task_delete">
+ <img title="<?php echo $l->t('Delete') ?>" src="<?php echo OCP\image_path('core', 'actions/delete.svg') ?>" class="svg"><?php echo $l->t('Delete') ?>
+ </span>
</p>
<script type='text/javascript'>
var categories = <?php echo json_encode($_['categories']); ?>;
diff --git a/lib/filestorage/common.php b/lib/filestorage/common.php
index f2a5775fd19..ba78fca80e5 100644
--- a/lib/filestorage/common.php
+++ b/lib/filestorage/common.php
@@ -20,6 +20,18 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * Storage backend class for providing common filesystem operation methods
+ * which are not storage-backend specific.
+ *
+ * OC_Filestorage_Common is never used directly; it is extended by all other
+ * storage backends, where its methods may be overridden, and additional
+ * (backend-specific) methods are defined.
+ *
+ * Some OC_Filestorage_Common methods call functions which are first defined
+ * in classes which extend it, e.g. $this->stat() .
+ */
+
abstract class OC_Filestorage_Common extends OC_Filestorage {
public function __construct($parameters){}
@@ -87,6 +99,79 @@ abstract class OC_Filestorage_Common extends OC_Filestorage {
return $count>0;
}
// abstract public function fopen($path,$mode);
+
+ /**
+ * @brief Deletes all files and folders recursively within a directory
+ * @param $directory The directory whose contents will be deleted
+ * @param $empty Flag indicating whether directory will be emptied
+ * @returns true/false
+ *
+ * @note By default the directory specified by $directory will be
+ * deleted together with its contents. To avoid this set $empty to true
+ */
+ public function deleteAll( $directory, $empty = false ) {
+
+ // strip leading slash
+ if( substr( $directory, 0, 1 ) == "/" ) {
+
+ $directory = substr( $directory, 1 );
+
+ }
+
+ // strip trailing slash
+ if( substr( $directory, -1) == "/" ) {
+
+ $directory = substr( $directory, 0, -1 );
+
+ }
+
+ if ( !$this->file_exists( \OCP\USER::getUser() . '/' . $directory ) || !$this->is_dir( \OCP\USER::getUser() . '/' . $directory ) ) {
+
+ return false;
+
+ } elseif( !$this->is_readable( \OCP\USER::getUser() . '/' . $directory ) ) {
+
+ return false;
+
+ } else {
+
+ $directoryHandle = $this->opendir( \OCP\USER::getUser() . '/' . $directory );
+
+ while ( $contents = readdir( $directoryHandle ) ) {
+
+ if ( $contents != '.' && $contents != '..') {
+
+ $path = $directory . "/" . $contents;
+
+ if ( $this->is_dir( $path ) ) {
+
+ deleteAll( $path );
+
+ } else {
+
+ $this->unlink( \OCP\USER::getUser() .'/' . $path ); // TODO: make unlink use same system path as is_dir
+
+ }
+ }
+
+ }
+
+ //$this->closedir( $directoryHandle ); // TODO: implement closedir in OC_FSV
+
+ if ( $empty == false ) {
+
+ if ( !$this->rmdir( $directory ) ) {
+
+ return false;
+
+ }
+
+ }
+
+ return true;
+ }
+
+ }
public function getMimeType($path){
if(!$this->file_exists($path)){
return false;
diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php
index 44a2ab0f634..b2eba051515 100644
--- a/lib/filestorage/local.php
+++ b/lib/filestorage/local.php
@@ -2,7 +2,7 @@
/**
* for local filestore, we only have to map the paths
*/
-class OC_Filestorage_Local extends OC_Filestorage{
+class OC_Filestorage_Local extends OC_Filestorage_Common{
protected $datadir;
private static $mimetypes=null;
public function __construct($arguments){
@@ -172,7 +172,7 @@ class OC_Filestorage_Local extends OC_Filestorage{
return $this->datadir.$path;
}
- private function searchInDir($query,$dir=''){
+ protected function searchInDir($query,$dir=''){
$files=array();
foreach (scandir($this->datadir.$dir) as $item) {
if ($item == '.' || $item == '..') continue;
diff --git a/lib/filesystemview.php b/lib/filesystemview.php
index da622bcf920..99e08c50e75 100644
--- a/lib/filesystemview.php
+++ b/lib/filesystemview.php
@@ -252,6 +252,9 @@ class OC_FilesystemView {
public function unlink($path){
return $this->basicOperation('unlink',$path,array('delete'));
}
+ public function deleteAll( $directory, $empty = false ) {
+ return $this->basicOperation( 'deleteAll', $directory, array('delete'), $empty );
+ }
public function rename($path1,$path2){
$absolutePath1=$this->getAbsolutePath($path1);
$absolutePath2=$this->getAbsolutePath($path2);