Skip to content

Commit

Permalink
Update 0.9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Hoffmann committed May 26, 2017
1 parent 0f2aa43 commit f637d67
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 82 deletions.
13 changes: 1 addition & 12 deletions README.txt
Original file line number Diff line number Diff line change
@@ -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: [email protected]

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 ([email protected])
- JP Translation by Tetsuro Yano (ynote)

Please make sure to use the correct version!!
- JP Translation by Tetsuro Yano (ynote)
108 changes: 63 additions & 45 deletions workin2gether/ajax/workin2gether.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion workin2gether/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion workin2gether/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
]]></description>
<licence>AGPL</licence>
<author>Patrick Hoffmann</author>
<version>0.9.4</version>
<version>0.9.6</version>
<category>social</category>
<ocsid>164016</ocsid>
<bugs>https://github.com/Patt92/Workin2Gether/issues</bugs>
Expand Down
1 change: 0 additions & 1 deletion workin2gether/appinfo/version

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
}

Expand Down Expand Up @@ -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');
Expand All @@ -86,17 +82,17 @@ 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');
$tr.find('a.name').addClass('namelock').removeClass('name').addClass('ignore-click');
$tr.find('td.filesize').addClass('statelock');
$tr.find('td.date').addClass('statelock');
$tr.find('td').addClass('statelock');
}
}
}
});

Expand All @@ -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;
Expand All @@ -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,' ');
Expand Down

0 comments on commit f637d67

Please sign in to comment.