diff options
-rw-r--r-- | include/attach.php | 45 | ||||
-rw-r--r-- | mod/filestorage.php | 5 | ||||
-rw-r--r-- | view/css/mod_filestorage.css | 4 | ||||
-rw-r--r-- | view/tpl/attach_edit.tpl | 9 |
4 files changed, 56 insertions, 7 deletions
diff --git a/include/attach.php b/include/attach.php index 3524193a6..f14a2c61a 100644 --- a/include/attach.php +++ b/include/attach.php @@ -733,6 +733,51 @@ function attach_delete($channel_id,$resource) { +function get_cloudpath($arr) { + + $basepath = 'store/'; + if($arr['uid']) { + $r = q("select channel_address from channel where channel_id = %d limit 1", + intval($arr['uid']) + ); + if($r) + $basepath .= $r[0]['channel_address'] . '/'; + } + + + $path = $basepath; + + if($arr['folder']) { + + $lpath = ''; + $lfile = $arr['folder']; + + do { + $r = q("select filename, hash, flags, folder from attach where uid = %d and hash = '%s' and ( flags & %d ) + limit 1", + intval($arr['uid']), + dbesc($lfile), + intval(ATTACH_FLAG_DIR) + ); + + if(! $r) + break; + + if($lfile) + $lpath = $r[0]['filename'] . '/' . $lpath; + $lfile = $r[0]['folder']; + + } while ( ($r[0]['folder']) && ($r[0]['flags'] & ATTACH_FLAG_DIR)) ; + + $path .= $lpath; + + } + + $path .= $arr['filename']; + return $path; + +} + diff --git a/mod/filestorage.php b/mod/filestorage.php index 43ea17789..3e87dccb8 100644 --- a/mod/filestorage.php +++ b/mod/filestorage.php @@ -101,7 +101,7 @@ function filestorage_content(&$a) { } $file = intval(argv(2)); - $r = q("select id, folder, filename, revision, flags, hash, allow_cid, allow_gid, deny_cid, deny_gid from attach where id = %d and uid = %d limit 1", + $r = q("select id, uid, folder, filename, revision, flags, hash, allow_cid, allow_gid, deny_cid, deny_gid from attach where id = %d and uid = %d limit 1", intval($file), intval($owner) ); @@ -110,6 +110,7 @@ function filestorage_content(&$a) { $channel = $a->get_channel(); + $cloudpath = get_cloudpath($f); $aclselect_e = populate_acl($f); $is_a_dir = (($f['flags'] & ATTACH_FLAG_DIR) ? true : false); @@ -118,6 +119,7 @@ function filestorage_content(&$a) { $o = replace_macros(get_markup_template('attach_edit.tpl'), array( '$header' => t('Edit file permissions'), '$file' => $f, + '$cloudpath' => z_root() . '/' . $cloudpath, '$uid' => $channel['channel_id'], '$channelnick' => $channel['channel_address'], '$permissions' => t('Permissions'), @@ -126,6 +128,7 @@ function filestorage_content(&$a) { '$backlink' => t('Return to file list'), '$isadir' => $is_a_dir, '$cpdesc' => t('Copy/paste this code to attach file to a post'), + '$cpldesc' => t('Copy/paste this URL to link file from a web page'), '$submit' => t('Submit') )); diff --git a/view/css/mod_filestorage.css b/view/css/mod_filestorage.css index 19e8ddd42..98fa8e93d 100644 --- a/view/css/mod_filestorage.css +++ b/view/css/mod_filestorage.css @@ -1,4 +1,4 @@ -#attach-edit-backlink, #cut-paste-link { +#attach-edit-backlink, #cutpasteinput, #linkpasteinput { margin-bottom: 10px; } @@ -6,6 +6,6 @@ margin-top: 20px; } -#cutpasteinput { +#cutpasteinput, #linkpasteinput { width: 600px; }
\ No newline at end of file diff --git a/view/tpl/attach_edit.tpl b/view/tpl/attach_edit.tpl index fa6f8914f..f9c6e96ce 100644 --- a/view/tpl/attach_edit.tpl +++ b/view/tpl/attach_edit.tpl @@ -22,10 +22,11 @@ </div> {{else}} <div class="cut-paste-desc">{{$cpdesc}}</div> -<div id="cut-paste-link"> -<input type="text" id="cutpasteinput" name="cutpastelink" value="[attachment]{{$file.hash}},{{$file.revision}}[/attachment]" /> -<script>$('#cutpasteinput').select();</script> -</div> +<input type="text" id="cutpasteinput" name="cutpastelink" value="[attachment]{{$file.hash}},{{$file.revision}}[/attachment]" onclick="this.select();" /><br /> + +<div class="cut-paste-desc">{{$cpldesc}}</div> +<input type="text" id="linkpasteinput" name="cutpasteextlink" value="{{$cloudpath}}" onclick="this.select();"/><br /> + {{/if}} <div id="attach-edit-perms" > |