diff --git a/README.txt b/README.txt index a552a3a..514fcfa 100644 --- a/README.txt +++ b/README.txt @@ -1,22 +1,11 @@ -OC6,7 Version development finished. -Further features will be for OC9 only -This build was tested with OC8.2.2+9.0.0 -------------------------------------------------------------- support: patrick@gen7.de -Installation ------------- - -- Install the app via appstore or place it manually to the apps folder inside your owncloud instance - -- That's all, database table setup and other stuff will be done automatically Language support - DE,EN Myself - FR Translation by Rachid Mokrani (rachid.mokrani@ifpen.fr) -- JP Translation by Tetsuro Yano (ynote) - -Please make sure to use the correct version!! +- JP Translation by Tetsuro Yano (ynote) \ No newline at end of file diff --git a/workin2gether/ajax/workin2gether.php b/workin2gether/ajax/workin2gether.php index bc20df1..a140ac4 100644 --- a/workin2gether/ajax/workin2gether.php +++ b/workin2gether/ajax/workin2gether.php @@ -9,10 +9,7 @@ \OCP\JSON::checkAppEnabled('workin2gether'); \OCP\JSON::callCheck(); -$path = stripslashes($_POST['path']); $safe = null; -$owner = null; -$id = null; $naming = ""; db_fetcher($naming, 'suffix', "rule_username"); @@ -24,59 +21,80 @@ $safe = $_POST['safe']; } -if (isset($_POST['owner'])) { - $owner = $_POST['owner']; -} - -if (isset($_POST['id'])) { - $id = $_POST['id']; -} +$owner = null; +$id = null; +$path = null; +if (!isset($_POST['batch'])){ -if (!is_null($owner) && $owner !== '') { - $query = \OCP\DB::prepare("SELECT X.path, Y.id FROM *PREFIX*filecache X INNER JOIN *PREFIX*storages Y ON X.storage = Y.numeric_id where X.fileid = ? LIMIT 1"); - $result = $query->execute(array($id))->fetchAll(); + $path = stripslashes($_POST['path']); + if (isset($_POST['owner'])) { + $owner = $_POST['owner']; + } - $original_path = $result[0]['path']; - $storage_id = str_replace("home::", "", $result[0]['id']) . '/'; + if (isset($_POST['id'])) { + $id = $_POST['id']; + } - $lockpath = $storage_id.$original_path; + echo check( $id , $owner , $path , $safe , $extended , $naming , $l); +} +else{ + $files = json_decode($_POST['path'],true); + $folder = $_POST['folder']; + for( $i = 0; $i < count($files); $i++ ) + { + $ret = check( $files[$i][0] , $files[$i][2] , $folder.$files[$i][1] , $safe , $extended , $naming , $l ); + if ($ret !== null) + $files[$i][3] = $ret; + } + echo json_encode($files); } -else $lockpath = \OCP\USER::getUser()."/files".cleanPath($path); -$lockfile = $lockpath; -$db_lock_state = \OCP\DB::prepare("SELECT * FROM *PREFIX*" . app::table . " WHERE name = ?")->execute(array($lockfile))->fetchAll(); +function check( $_id , $_owner , $_path , $_safe , $_extended , $_naming , $l ) +{ + if (!is_null($_owner) && $_owner !== '') { + $query = \OCP\DB::prepare("SELECT X.path, Y.id FROM *PREFIX*filecache X INNER JOIN *PREFIX*storages Y ON X.storage = Y.numeric_id where X.fileid = ? LIMIT 1"); + $result = $query->execute(array($_id))->fetchAll(); + $original_path = $result[0]['path']; + $storage_id = str_replace("home::", "", $result[0]['id']) . '/'; + $lockpath = $storage_id.$original_path; + } + else $lockpath = \OCP\USER::getUser()."/files".cleanPath($_path); -if ($db_lock_state!=null) { - if($safe=="false") { - $lockedby_name = $db_lock_state[0]['locked_by']; - ShowUserName($lockedby_name); + $lockfile = $lockpath; + $db_lock_state = \OCP\DB::prepare("SELECT * FROM *PREFIX*" . app::table . " WHERE name = ?")->execute(array($lockfile))->fetchAll(); - if( extended_precheck( $extended, $lockedby_name ) != 0 ){ - echo " ".$l->t("No permission"); - return; - } + if ($db_lock_state!=null) { + if( $_safe === "false" ) { + $lockedby_name = $db_lock_state[0]['locked_by']; + ShowUserName($lockedby_name); - \OCP\DB::prepare("DELETE FROM *PREFIX*" . app::table . " WHERE name=?")->execute(array($lockfile)); - } - else{ - $lockedby_name = $db_lock_state[0]['locked_by']; - ShowDisplayName($lockedby_name); - echo " ".$l->t("Locked")." ".$l->t("by")." ".$lockedby_name; + if( extended_precheck( $_extended, $lockedby_name ) != 0 ){ + return " ".$l->t("No permission"); + } + + \OCP\DB::prepare("DELETE FROM *PREFIX*" . app::table . " WHERE name=?")->execute(array($lockfile)); + } + else{ + $lockedby_name = $db_lock_state[0]['locked_by']; + ShowDisplayName($lockedby_name); + return " ".$l->t("Locked")." ".$l->t("by")." ".$lockedby_name; + } } -} -else { - if($safe=="false") { - $lockedby_name = \OCP\User::getUser(); - if($naming=="rule_displayname") { - $lockedby_name = \OCP\User::getDisplayName(); - $lockedby_name .= "|".\OCP\User::getUser(); + else { + if( $_safe === "false" ) { + $lockedby_name = \OCP\User::getUser(); + if($_naming=="rule_displayname") { + $lockedby_name = \OCP\User::getDisplayName(); + $lockedby_name .= "|".\OCP\User::getUser(); + } + + \OCP\DB::prepare("INSERT INTO *PREFIX*".app::table."(name,locked_by) VALUES(?,?)")->execute(array($lockfile,$lockedby_name)); + + ShowDisplayName($lockedby_name); //Korrektur bei DisplayName + return " ".$l->t("Locked")." ".$l->t("by")." ".$lockedby_name; } - - \OCP\DB::prepare("INSERT INTO *PREFIX*".app::table."(name,locked_by) VALUES(?,?)")->execute(array($lockfile,$lockedby_name)); - - ShowDisplayName($lockedby_name); //Korrektur bei DisplayName - echo " ".$l->t("Locked")." ".$l->t("by")." ".$lockedby_name; } + return null; } function cleanPath($path){ diff --git a/workin2gether/appinfo/app.php b/workin2gether/appinfo/app.php index 6c0973f..1ef0107 100644 --- a/workin2gether/appinfo/app.php +++ b/workin2gether/appinfo/app.php @@ -16,7 +16,7 @@ public static function launch() { if(\OC_User::getUser()!=false) { - \OCP\Util::addScript( self::name, 'workin2gether_v2'); + \OCP\Util::addScript( self::name, 'workin2gether_v3'); \OCP\Util::addstyle( self::name, 'styles'); diff --git a/workin2gether/appinfo/info.xml b/workin2gether/appinfo/info.xml index 0bf4394..481b799 100644 --- a/workin2gether/appinfo/info.xml +++ b/workin2gether/appinfo/info.xml @@ -11,7 +11,7 @@ ]]> AGPL Patrick Hoffmann - 0.9.4 + 0.9.6 social 164016 https://github.com/Patt92/Workin2Gether/issues diff --git a/workin2gether/appinfo/version b/workin2gether/appinfo/version deleted file mode 100644 index ddbecfe..0000000 --- a/workin2gether/appinfo/version +++ /dev/null @@ -1 +0,0 @@ -0.9.0.2 \ No newline at end of file diff --git a/workin2gether/js/workin2gether_v2.js b/workin2gether/js/workin2gether_v3.js similarity index 78% rename from workin2gether/js/workin2gether_v2.js rename to workin2gether/js/workin2gether_v3.js index 14332c9..73c5480 100644 --- a/workin2gether/js/workin2gether_v2.js +++ b/workin2gether/js/workin2gether_v3.js @@ -3,37 +3,33 @@ var fontcolor = 'ffffff'; $(document).ready(function(){ - text = ""; - lockedtext = t('workin2gether','Locked'); lockstate = t('workin2gether','Locked'); if (typeof FileActions !== 'undefined' && $('#dir').length>0) { - //Initiate the FileAction for file OCA.Files.fileActions.registerAction({ name:'getstate_w2g', - displayName: t('workin2gether',text), + displayName: '', mime: 'all', permissions: OC.PERMISSION_ALL, type: OCA.Files.FileActions.TYPE_INLINE, icon: function(){ return OC.imagePath('workin2gether','lock.png')}, actionHandler: function(filename,context) { - getState(context.$file.attr('data-id'),filename,context.$file.attr('data-share-owner'),"false"); + getStateSingle(context.$file.attr('data-id'),filename,context.$file.attr('data-share-owner'),"false"); } }); - - //Walk through all files in the active Filelist - $('#content').delegate('#fileList', 'fileActionsReady',function(ev){ - var $fileList = ev.fileList.$fileList; + var _files = []; - $fileList.find('tr').each(function(){ - $filename = $(this).attr('data-file'); - $owner = $(this).attr('data-share-owner'); - $id = $(this).attr('data-id'); - getState($id,$filename,$owner,"true"); - }); + //Walk through all files in the active Filelist + $('#content').delegate('#fileList', 'fileActionsReady',function(ev){ + var $fileList = ev.fileList.$fileList; + $fileList.find('tr').each(function(){ + _files.push( [ $(this).attr('data-id') , $(this).attr('data-file') , $(this).attr('data-share-owner') , '' ] ); + }); + + getStateAll(_files,"true"); }); } @@ -76,7 +72,7 @@ function toggle_control(filename) var actionname = 'getstate_w2g'; if($_tr.indexOf(filename)!=-1) { - if($_tr.indexOf(lockedtext)==-1 && $_tr.indexOf(lockstate)==-1) + if($_tr.indexOf(lockstate)==-1) { //unlock $tr.find('a.action[data-action!='+actionname+']').removeClass('locked'); $tr.find('a.action[data-action!='+actionname+']').addClass('permanent'); @@ -86,9 +82,9 @@ function toggle_control(filename) $tr.find('td.date').removeClass('statelock'); $tr.find('td').removeClass('statelock'); $tr.find('a.statelock').addClass('name'); - } - else if($_tr.indexOf(lockedtext)!=-1||$_tr.indexOf(lockstate)!=-1) - { //lock + } + else if($_tr.indexOf(lockstate)!=-1) + { //lock $tr.find('a.permanent[data-action!='+actionname+']').removeClass('permanent'); $tr.find('a.action[data-action='+actionname+']').addClass('w2g_active'); $tr.find('a.action[data-action!='+actionname+']:not([class*=favorite])').addClass('locked'); @@ -96,7 +92,7 @@ function toggle_control(filename) $tr.find('td.filesize').addClass('statelock'); $tr.find('td.date').addClass('statelock'); $tr.find('td').addClass('statelock'); - } + } } }); @@ -107,7 +103,7 @@ function toggle_control(filename) } //Get the current state -function getState(_id, _filename, _owner, _safe) +function getStateSingle(_id, _filename, _owner, _safe) { oc_dir = $('#dir').val(); oc_path = oc_dir +'/'+_filename; @@ -120,7 +116,29 @@ function getState(_id, _filename, _owner, _safe) }); } -//Push the status +function getStateAll(_array, _safe) +{ + oc_dir = $('#dir').val(); + if (oc_dir !== '/') oc_dir += '/'; + + $.ajax({ + url: OC.filePath('workin2gether','ajax','workin2gether.php'), + type: "post", + data: { batch: "true", path: JSON.stringify(_array), safe: _safe , folder: escapeHTML(oc_dir)}, + success: function(data){PushAll(data)}, + }); + +} + +function PushAll( data ) +{ + data = JSON.parse(data); + for ( var i = 0; i < data.length ; i++ ) + { + postmode(data[i][1],data[i][3]); + } +} + function postmode(filename,data) { filename = filename.replace(/%20/g,' ');