diff options
Diffstat (limited to 'apps/files_trashbin')
-rw-r--r-- | apps/files_trashbin/ajax/delete.php | 24 | ||||
-rw-r--r-- | apps/files_trashbin/ajax/undelete.php | 8 | ||||
-rw-r--r-- | apps/files_trashbin/appinfo/app.php | 6 | ||||
-rw-r--r-- | apps/files_trashbin/js/disableDefaultActions.js | 1 | ||||
-rw-r--r-- | apps/files_trashbin/js/trash.js | 25 | ||||
-rw-r--r-- | apps/files_trashbin/l10n/ca.php | 3 | ||||
-rw-r--r-- | apps/files_trashbin/l10n/cs_CZ.php | 3 | ||||
-rw-r--r-- | apps/files_trashbin/l10n/de_DE.php | 1 | ||||
-rw-r--r-- | apps/files_trashbin/l10n/es.php | 6 | ||||
-rw-r--r-- | apps/files_trashbin/l10n/fr.php | 3 | ||||
-rw-r--r-- | apps/files_trashbin/l10n/it.php | 3 | ||||
-rw-r--r-- | apps/files_trashbin/l10n/ja_JP.php | 3 | ||||
-rw-r--r-- | apps/files_trashbin/l10n/lv.php | 3 | ||||
-rw-r--r-- | apps/files_trashbin/l10n/nl.php | 1 | ||||
-rw-r--r-- | apps/files_trashbin/l10n/ru.php | 9 | ||||
-rw-r--r-- | apps/files_trashbin/l10n/ru_RU.php | 3 | ||||
-rw-r--r-- | apps/files_trashbin/l10n/sk_SK.php | 2 | ||||
-rw-r--r-- | apps/files_trashbin/l10n/sv.php | 1 | ||||
-rw-r--r-- | apps/files_trashbin/lib/hooks.php | 2 | ||||
-rw-r--r-- | apps/files_trashbin/lib/trash.php | 43 | ||||
-rw-r--r-- | apps/files_trashbin/templates/index.php | 2 |
21 files changed, 140 insertions, 12 deletions
diff --git a/apps/files_trashbin/ajax/delete.php b/apps/files_trashbin/ajax/delete.php new file mode 100644 index 00000000000..7a6bd1342ea --- /dev/null +++ b/apps/files_trashbin/ajax/delete.php @@ -0,0 +1,24 @@ +<?php + +OCP\JSON::checkLoggedIn(); +OCP\JSON::callCheck(); + +$file = $_REQUEST['file']; + +$path_parts = pathinfo($file); +if ($path_parts['dirname'] == '.') { + $delimiter = strrpos($file, '.d'); + $filename = substr($file, 0, $delimiter); + $timestamp = substr($file, $delimiter+2); +} else { + $filename = $file; + $timestamp = null; +} + +if (OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp)) { + OCP\JSON::success(array("data" => array("filename" => $file))); +} else { + $l = OC_L10N::get('files_trashbin'); + OCP\JSON::error(array("data" => array("message" => $l->t("Couldn't delete %s permanently", array($file))))); +} + diff --git a/apps/files_trashbin/ajax/undelete.php b/apps/files_trashbin/ajax/undelete.php index ee1c64aaaf2..cc010979c51 100644 --- a/apps/files_trashbin/ajax/undelete.php +++ b/apps/files_trashbin/ajax/undelete.php @@ -22,7 +22,7 @@ foreach ($list as $file) { $timestamp = null; } - if ( !OCA_Trash\Trashbin::restore($file, $filename, $timestamp) ) { + if ( !OCA\Files_Trashbin\Trashbin::restore($file, $filename, $timestamp) ) { $error[] = $filename; } else { $success[$i]['filename'] = $file; @@ -37,8 +37,10 @@ if ( $error ) { foreach ( $error as $e ) { $filelist .= $e.', '; } - OCP\JSON::error(array("data" => array("message" => "Couldn't restore ".rtrim($filelist,', '), "success" => $success, "error" => $error))); + $l = OC_L10N::get('files_trashbin'); + $message = $l->t("Couldn't restore %s", array(rtrim($filelist,', '))); + OCP\JSON::error(array("data" => array("message" => $message, + "success" => $success, "error" => $error))); } else { OCP\JSON::success(array("data" => array("success" => $success))); } - diff --git a/apps/files_trashbin/appinfo/app.php b/apps/files_trashbin/appinfo/app.php index 3741d42c781..b1a15cd13d1 100644 --- a/apps/files_trashbin/appinfo/app.php +++ b/apps/files_trashbin/appinfo/app.php @@ -1,7 +1,7 @@ <?php -OC::$CLASSPATH['OCA_Trash\Hooks'] = 'apps/files_trashbin/lib/hooks.php';
-OC::$CLASSPATH['OCA_Trash\Trashbin'] = 'apps/files_trashbin/lib/trash.php';
+OC::$CLASSPATH['OCA\Files_Trashbin\Hooks'] = 'apps/files_trashbin/lib/hooks.php';
+OC::$CLASSPATH['OCA\Files_Trashbin\Trashbin'] = 'apps/files_trashbin/lib/trash.php';
-OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA_Trash\Hooks", "remove_hook"); +OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Files_Trashbin\Hooks", "remove_hook"); diff --git a/apps/files_trashbin/js/disableDefaultActions.js b/apps/files_trashbin/js/disableDefaultActions.js index 56b95407dd3..27c3e13db4d 100644 --- a/apps/files_trashbin/js/disableDefaultActions.js +++ b/apps/files_trashbin/js/disableDefaultActions.js @@ -1,3 +1,4 @@ /* disable download and sharing actions */
var disableDownloadActions = true;
var disableSharing = true;
+var trashBinApp = true;
\ No newline at end of file diff --git a/apps/files_trashbin/js/trash.js b/apps/files_trashbin/js/trash.js index f1241fce51e..6c810e4c2bd 100644 --- a/apps/files_trashbin/js/trash.js +++ b/apps/files_trashbin/js/trash.js @@ -22,6 +22,31 @@ $(document).ready(function() { }); }; + FileActions.register('all', 'Delete', OC.PERMISSION_READ, function () { + return OC.imagePath('core', 'actions/delete'); + }, function (filename) { + $('.tipsy').remove(); + + var tr=$('tr').filterAttr('data-file', filename); + var deleteAction = $('tr').filterAttr('data-file',filename).children("td.date").children(".action.delete"); + var oldHTML = deleteAction[0].outerHTML; + var newHTML = '<img class="move2trash" data-action="Delete" title="'+t('files', 'delete file permanently')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>'; + deleteAction[0].outerHTML = newHTML; + + $.post(OC.filePath('files_trashbin','ajax','delete.php'), + {file:tr.attr('data-file') }, + function(result){ + if ( result.status == 'success' ) { + var row = document.getElementById(result.data.filename); + row.parentNode.removeChild(row); + } else { + deleteAction[0].outerHTML = oldHTML; + OC.dialogs.alert(result.data.message, 'Error'); + } + }); + + }); + // Sets the select_all checkbox behaviour : $('#select_all').click(function() { if($(this).attr('checked')){ diff --git a/apps/files_trashbin/l10n/ca.php b/apps/files_trashbin/l10n/ca.php index 3af33c8a310..803b0c81ef0 100644 --- a/apps/files_trashbin/l10n/ca.php +++ b/apps/files_trashbin/l10n/ca.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( +"Couldn't delete %s permanently" => "No s'ha pogut esborrar permanentment %s", +"Couldn't restore %s" => "No s'ha pogut restaurar %s", "perform restore operation" => "executa l'operació de restauració", +"delete file permanently" => "esborra el fitxer permanentment", "Name" => "Nom", "Deleted" => "Eliminat", "1 folder" => "1 carpeta", diff --git a/apps/files_trashbin/l10n/cs_CZ.php b/apps/files_trashbin/l10n/cs_CZ.php index caaaea37436..eeb27784d3e 100644 --- a/apps/files_trashbin/l10n/cs_CZ.php +++ b/apps/files_trashbin/l10n/cs_CZ.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( +"Couldn't delete %s permanently" => "Nelze trvale odstranit %s", +"Couldn't restore %s" => "Nelze obnovit %s", "perform restore operation" => "provést obnovu", +"delete file permanently" => "trvale odstranit soubor", "Name" => "Název", "Deleted" => "Smazáno", "1 folder" => "1 složka", diff --git a/apps/files_trashbin/l10n/de_DE.php b/apps/files_trashbin/l10n/de_DE.php index 45e30d85a3b..e293bf0b2eb 100644 --- a/apps/files_trashbin/l10n/de_DE.php +++ b/apps/files_trashbin/l10n/de_DE.php @@ -1,5 +1,6 @@ <?php $TRANSLATIONS = array( "perform restore operation" => "Führe die Wiederherstellung aus", +"delete file permanently" => "Datei entgültig löschen", "Name" => "Name", "Deleted" => "Gelöscht", "1 folder" => "1 Ordner", diff --git a/apps/files_trashbin/l10n/es.php b/apps/files_trashbin/l10n/es.php index 798322cab24..c14b9776473 100644 --- a/apps/files_trashbin/l10n/es.php +++ b/apps/files_trashbin/l10n/es.php @@ -1,8 +1,14 @@ <?php $TRANSLATIONS = array( +"Couldn't delete %s permanently" => "No se puede eliminar %s permanentemente", +"Couldn't restore %s" => "No se puede restaurar %s", +"perform restore operation" => "Restaurar", +"delete file permanently" => "Eliminar archivo permanentemente", "Name" => "Nombre", +"Deleted" => "Eliminado", "1 folder" => "1 carpeta", "{count} folders" => "{count} carpetas", "1 file" => "1 archivo", "{count} files" => "{count} archivos", +"Nothing in here. Your trash bin is empty!" => "Nada aqui. La papelera esta vacia!", "Restore" => "Recuperar" ); diff --git a/apps/files_trashbin/l10n/fr.php b/apps/files_trashbin/l10n/fr.php index 51ade82d908..609b2fa9bd7 100644 --- a/apps/files_trashbin/l10n/fr.php +++ b/apps/files_trashbin/l10n/fr.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( +"Couldn't delete %s permanently" => "Impossible d'effacer %s de façon permanente", +"Couldn't restore %s" => "Impossible de restaurer %s", "perform restore operation" => "effectuer l'opération de restauration", +"delete file permanently" => "effacer définitivement le fichier", "Name" => "Nom", "Deleted" => "Effacé", "1 folder" => "1 dossier", diff --git a/apps/files_trashbin/l10n/it.php b/apps/files_trashbin/l10n/it.php index 7def431a42a..8627682d088 100644 --- a/apps/files_trashbin/l10n/it.php +++ b/apps/files_trashbin/l10n/it.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( +"Couldn't delete %s permanently" => "Impossibile eliminare %s definitivamente", +"Couldn't restore %s" => "Impossibile ripristinare %s", "perform restore operation" => "esegui operazione di ripristino", +"delete file permanently" => "elimina il file definitivamente", "Name" => "Nome", "Deleted" => "Eliminati", "1 folder" => "1 cartella", diff --git a/apps/files_trashbin/l10n/ja_JP.php b/apps/files_trashbin/l10n/ja_JP.php index 0b4e1954e74..2bccf3f3bd5 100644 --- a/apps/files_trashbin/l10n/ja_JP.php +++ b/apps/files_trashbin/l10n/ja_JP.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( +"Couldn't delete %s permanently" => "%s を完全に削除出来ませんでした", +"Couldn't restore %s" => "%s を復元出来ませんでした", "perform restore operation" => "復元操作を実行する", +"delete file permanently" => "ファイルを完全に削除する", "Name" => "名前", "Deleted" => "削除済み", "1 folder" => "1 フォルダ", diff --git a/apps/files_trashbin/l10n/lv.php b/apps/files_trashbin/l10n/lv.php index 017a8d285c0..5ecb99b9892 100644 --- a/apps/files_trashbin/l10n/lv.php +++ b/apps/files_trashbin/l10n/lv.php @@ -1,5 +1,8 @@ <?php $TRANSLATIONS = array( +"Couldn't delete %s permanently" => "Nevarēja pilnībā izdzēst %s", +"Couldn't restore %s" => "Nevarēja atjaunot %s", "perform restore operation" => "veikt atjaunošanu", +"delete file permanently" => "dzēst datni pavisam", "Name" => "Nosaukums", "Deleted" => "Dzēsts", "1 folder" => "1 mape", diff --git a/apps/files_trashbin/l10n/nl.php b/apps/files_trashbin/l10n/nl.php index 4efa6ecf662..a41a5c2fd9c 100644 --- a/apps/files_trashbin/l10n/nl.php +++ b/apps/files_trashbin/l10n/nl.php @@ -1,5 +1,6 @@ <?php $TRANSLATIONS = array( "perform restore operation" => "uitvoeren restore operatie", +"delete file permanently" => "verwijder bestanden definitief", "Name" => "Naam", "Deleted" => "Verwijderd", "1 folder" => "1 map", diff --git a/apps/files_trashbin/l10n/ru.php b/apps/files_trashbin/l10n/ru.php index 23d739a2ff7..f6c85a6800e 100644 --- a/apps/files_trashbin/l10n/ru.php +++ b/apps/files_trashbin/l10n/ru.php @@ -1,7 +1,14 @@ <?php $TRANSLATIONS = array( +"Couldn't delete %s permanently" => "%s не может быть удалён навсегда", +"Couldn't restore %s" => "%s не может быть восстановлен", +"perform restore operation" => "выполнить операцию восстановления", +"delete file permanently" => "удалить файл навсегда", "Name" => "Имя", +"Deleted" => "Удалён", "1 folder" => "1 папка", "{count} folders" => "{count} папок", "1 file" => "1 файл", -"{count} files" => "{count} файлов" +"{count} files" => "{count} файлов", +"Nothing in here. Your trash bin is empty!" => "Здесь ничего нет. Ваша корзина пуста!", +"Restore" => "Восстановить" ); diff --git a/apps/files_trashbin/l10n/ru_RU.php b/apps/files_trashbin/l10n/ru_RU.php index 8ef2658cf24..c5b1408e2cc 100644 --- a/apps/files_trashbin/l10n/ru_RU.php +++ b/apps/files_trashbin/l10n/ru_RU.php @@ -3,5 +3,6 @@ "1 folder" => "1 папка", "{count} folders" => "{количество} папок", "1 file" => "1 файл", -"{count} files" => "{количество} файлов" +"{count} files" => "{количество} файлов", +"Restore" => "Восстановить" ); diff --git a/apps/files_trashbin/l10n/sk_SK.php b/apps/files_trashbin/l10n/sk_SK.php index 81d43614d7b..759850783e2 100644 --- a/apps/files_trashbin/l10n/sk_SK.php +++ b/apps/files_trashbin/l10n/sk_SK.php @@ -1,5 +1,7 @@ <?php $TRANSLATIONS = array( +"Couldn't restore %s" => "Nemožno obnoviť %s", "perform restore operation" => "vykonať obnovu", +"delete file permanently" => "trvalo zmazať súbor", "Name" => "Meno", "Deleted" => "Zmazané", "1 folder" => "1 priečinok", diff --git a/apps/files_trashbin/l10n/sv.php b/apps/files_trashbin/l10n/sv.php index ca4dba04967..5bde85e7056 100644 --- a/apps/files_trashbin/l10n/sv.php +++ b/apps/files_trashbin/l10n/sv.php @@ -1,4 +1,5 @@ <?php $TRANSLATIONS = array( +"perform restore operation" => "utför återställning", "Name" => "Namn", "Deleted" => "Raderad", "1 folder" => "1 mapp", diff --git a/apps/files_trashbin/lib/hooks.php b/apps/files_trashbin/lib/hooks.php index d3bee105b51..d6a62d447b8 100644 --- a/apps/files_trashbin/lib/hooks.php +++ b/apps/files_trashbin/lib/hooks.php @@ -24,7 +24,7 @@ * This class contains all hooks. */ -namespace OCA_Trash; +namespace OCA\Files_Trashbin; class Hooks { diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index a7eff3d44e0..bc6562b2080 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -20,7 +20,7 @@ *
*/
-namespace OCA_Trash;
+namespace OCA\Files_Trashbin;
class Trashbin { @@ -65,7 +65,7 @@ class Trashbin { if ( \OCP\App::isEnabled('files_versions') ) {
if ( $view->is_dir('files_versions'.$file_path) ) {
$view->rename('files_versions'.$file_path, 'versions_trashbin/'. $deleted.'.d'.$timestamp);
- } else if ( $versions = \OCA_Versions\Storage::getVersions($file_path) ) {
+ } else if ( $versions = \OCA\Files_Versions\Storage::getVersions($file_path) ) {
foreach ($versions as $v) {
$view->rename('files_versions'.$v['path'].'.v'.$v['version'], 'versions_trashbin/'. $deleted.'.v'.$v['version'].'.d'.$timestamp);
}
@@ -151,6 +151,45 @@ class Trashbin { } /**
+ * delete file from trash bin permanently
+ * @param $filename path to the file + * @param $timestamp of deletion time
+ * @return true/false
+ */
+ public static function delete($filename, $timestamp=null) {
+
+ $user = \OCP\User::getUser();
+ $view = new \OC_FilesystemView('/'.$user);
+
+ if ( $timestamp ) {
+ $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND id=? AND timestamp=?');
+ $query->execute(array($user,$filename,$timestamp));
+ $file = $filename.'.d'.$timestamp; + } else { + $file = $filename; + } + + if ( \OCP\App::isEnabled('files_versions') ) { + if ($view->is_dir('versions_trashbin/'.$file)) { + $view->unlink('versions_trashbin/'.$file); + } else if ( $versions = self::getVersionsFromTrash($file, $timestamp) ) { + foreach ($versions as $v) { + if ($timestamp ) { + $view->unlink('versions_trashbin/'.$filename.'.v'.$v.'.d'.$timestamp); + } else { + $view->unlink('versions_trashbin/'.$file.'.v'.$v); + } + } + } + }
+ + $view->unlink('/files_trashbin/'.$file); +
+ return true;
+ } + + + /**
* clean up the trash bin
*/
private static function expire() { diff --git a/apps/files_trashbin/templates/index.php b/apps/files_trashbin/templates/index.php index c3e51b4becd..24e4a0e6c69 100644 --- a/apps/files_trashbin/templates/index.php +++ b/apps/files_trashbin/templates/index.php @@ -9,7 +9,7 @@ <div id="emptyfolder"><?php echo $l->t('Nothing in here. Your trash bin is empty!')?></div> <?php endif; ?> -<table> +<table class="hascontrols"> <thead> <tr> <th id='headerName'> |