Fixes to links and forward URLs in filestorage
This commit is contained in:
parent
b2b47dcd7c
commit
cc4001fce7
@ -834,6 +834,45 @@ function get_cloudpath($arr) {
|
|||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_parent_cloudpath($channel_id, $channel_name, $attachHash) {
|
||||||
|
//Build directory tree and redirect
|
||||||
|
$parentHash = $attachHash;
|
||||||
|
do {
|
||||||
|
$parentHash = findFolderHashByAttachHash($channel_id, $parentHash);
|
||||||
|
if ($parentHash) {
|
||||||
|
$parentName = findFilenameByHash($channel_id, $parentHash);
|
||||||
|
$parentFullPath = $parentName."/".$parentFullPath;
|
||||||
|
}
|
||||||
|
} while ($parentHash);
|
||||||
|
$parentFullPath = z_root() . "/cloud/" . $channel_name . "/" . $parentFullPath;
|
||||||
|
goaway($parentFullPath);
|
||||||
|
}
|
||||||
|
function findFolderHashByAttachHash($channel_id, $attachHash) {
|
||||||
|
$r = q("select * from attach where uid = %d and hash = '%s' limit 1",
|
||||||
|
intval($channel_id), dbesc($attachHash)
|
||||||
|
);
|
||||||
|
$hash = "";
|
||||||
|
if($r) {
|
||||||
|
foreach($r as $rr) {
|
||||||
|
$hash = $rr['folder'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $hash;
|
||||||
|
}
|
||||||
|
function findFilenameByHash($channel_id, $attachHash) {
|
||||||
|
$r = q("select * from attach where uid = %d and hash = '%s' limit 1",
|
||||||
|
intval($channel_id), dbesc($attachHash)
|
||||||
|
);
|
||||||
|
$filename = "";
|
||||||
|
if($r) {
|
||||||
|
foreach($r as $rr) {
|
||||||
|
$filename = $rr['filename'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param $in
|
* @param $in
|
||||||
|
@ -1028,16 +1028,16 @@ class RedBrowser extends DAV\Browser\Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$attachId = $this->findAttachIdByHash($attachHash);
|
$attachId = $this->findAttachIdByHash($attachHash);
|
||||||
$fileStorageUrl = str_replace("cloud/","filestorage/",$path);
|
$fileStorageUrl = substr($fullPath, 0, strpos($fullPath,"cloud/")) . "filestorage/".$this->auth->channel_name;
|
||||||
$attachIcon = ""; // "<a href=\"attach/".$attachHash."\" title=\"".$displayName."\"><i class=\"icon-download\"></i></a>";
|
$attachIcon = ""; // "<a href=\"attach/".$attachHash."\" title=\"".$displayName."\"><i class=\"icon-download\"></i></a>";
|
||||||
$html.= "<tr>
|
$html.= "<tr>
|
||||||
<td>$icon</td>
|
<td>$icon</td>
|
||||||
<td><a href=\"{$fullPath}\">{$displayName}</a></td>";
|
<td style=\"min-width: 15em\"><a href=\"{$fullPath}\">{$displayName}</a></td>";
|
||||||
|
|
||||||
if($is_owner) {
|
if($is_owner) {
|
||||||
$html .= "<td>" . (($size) ? $attachIcon : '') . "</td>
|
$html .= "<td>" . (($size) ? $attachIcon : '') . "</td>
|
||||||
<td><a href=\"".$fileStorageUrl."/".$attachId."/edit\" title=\"".t('Edit')."\"><i class=\"icon-pencil btn btn-default\"></i></a></td>
|
<td><a href=\"".$fileStorageUrl."/".$attachId."/edit\" title=\"".t('Edit')."\"><i class=\"icon-pencil btn btn-default\"></i></a></td>
|
||||||
<td><a href=\"".$fileStorageUrl."/".$attachId."/delete\" title=\"".t('Delete')."\"><i class=\"icon-remove btn btn-default drop-icons\"></i></a></td>";
|
<td><a href=\"".$fileStorageUrl."/".$attachId."/delete\" title=\"".t('Delete')."\" onclick=\"return confirm('Are you sure you want to delete this item?');\"><i class=\"icon-remove btn btn-default drop-icons\"></i></a></td>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$html .= "<td></td><td></td><td></td>";
|
$html .= "<td></td><td></td><td></td>";
|
||||||
@ -1090,20 +1090,24 @@ class RedBrowser extends DAV\Browser\Plugin {
|
|||||||
if (get_class($node)==='Sabre\\DAV\\SimpleCollection')
|
if (get_class($node)==='Sabre\\DAV\\SimpleCollection')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$output.= '<tr><td colspan="2"><form method="post" action="">
|
$output.= '<table>
|
||||||
<h3>Create new folder</h3>
|
<tr>
|
||||||
<input type="hidden" name="sabreAction" value="mkcol" />
|
<td><strong>Create new folder</strong> </td>
|
||||||
Name: <input type="text" name="name" />
|
<td><form method="post" action="">
|
||||||
|
<input type="text" name="name" />
|
||||||
<input type="submit" value="create" />
|
<input type="submit" value="create" />
|
||||||
</form>
|
<input type="hidden" name="sabreAction" value="mkcol" />
|
||||||
<form method="post" action="" enctype="multipart/form-data">
|
</form></td>
|
||||||
<h3>Upload file</h3>
|
</tr><tr>
|
||||||
<input type="hidden" name="sabreAction" value="put" />
|
<td><strong>Upload file</strong> </td>
|
||||||
Name (optional): <input type="text" name="name" /><br />
|
<td><form method="post" action="" enctype="multipart/form-data">
|
||||||
File: <input type="file" name="file" /><br />
|
<input type="file" name="file" style="display: inline;"/>
|
||||||
<input type="submit" value="upload" />
|
<input type="submit" value="upload" />
|
||||||
</form>
|
<input type="hidden" name="sabreAction" value="put" />
|
||||||
</td></tr>';
|
<!-- Name (optional): <input type="text" name="name" /> we should rather provide a rename action in edit form-->
|
||||||
|
</form></td>
|
||||||
|
</tr>
|
||||||
|
</table>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,12 +26,13 @@ function filestorage_post(&$a) {
|
|||||||
|
|
||||||
attach_change_permissions($channel_id,$resource,$str_contact_allow,$str_group_allow,$str_contact_deny,$str_group_deny,$recurse = false);
|
attach_change_permissions($channel_id,$resource,$str_contact_allow,$str_group_allow,$str_contact_deny,$str_group_deny,$recurse = false);
|
||||||
|
|
||||||
|
//Build directory tree and redirect
|
||||||
|
$channel = $a->get_channel();
|
||||||
|
$cloudPath = get_parent_cloudpath($channel_id, $channel['channel_address'], $resource) ;
|
||||||
|
echo $cloudPath;die;
|
||||||
|
goaway($cloudPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function filestorage_content(&$a) {
|
function filestorage_content(&$a) {
|
||||||
|
|
||||||
if(argc() > 1)
|
if(argc() > 1)
|
||||||
@ -83,12 +84,12 @@ function filestorage_content(&$a) {
|
|||||||
);
|
);
|
||||||
if(! $r) {
|
if(! $r) {
|
||||||
notice( t('File not found.') . EOL);
|
notice( t('File not found.') . EOL);
|
||||||
goaway(z_root() . '/filestorage/' . $which);
|
goaway(z_root() . '/cloud/' . $which);
|
||||||
}
|
}
|
||||||
|
|
||||||
attach_delete($owner,$r[0]['hash']);
|
attach_delete($owner,$r[0]['hash']);
|
||||||
|
|
||||||
goaway(z_root() . '/filestorage/' . $which);
|
goaway(z_root() . '/cloud/' . $which);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -139,45 +140,6 @@ function filestorage_content(&$a) {
|
|||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("select * from attach where uid = %d order by edited desc",
|
goaway(z_root() . '/cloud/' . $which);
|
||||||
intval($owner)
|
|
||||||
);
|
|
||||||
|
|
||||||
$files = null;
|
|
||||||
|
|
||||||
if($r) {
|
|
||||||
$files = array();
|
|
||||||
foreach($r as $rr) {
|
|
||||||
$files[$rr['id']][] = array(
|
|
||||||
'id' => $rr['id'],
|
|
||||||
'download' => $rr['hash'],
|
|
||||||
'title' => $rr['filename'],
|
|
||||||
'size' => $rr['filesize'],
|
|
||||||
'rev' => $rr['revision'],
|
|
||||||
'dir' => (($rr['flags'] & ATTACH_FLAG_DIR) ? true : false)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$limit = service_class_fetch ($owner,'attach_upload_limit');
|
|
||||||
$r = q("select sum(filesize) as total from attach where aid = %d ",
|
|
||||||
intval($channel['channel_account_id'])
|
|
||||||
);
|
|
||||||
$used = $r[0]['total'];
|
|
||||||
|
|
||||||
$url = z_root() . "/filestorage/" . $which;
|
|
||||||
return $o . replace_macros(get_markup_template("filestorage.tpl"), array(
|
|
||||||
'$baseurl' => $url,
|
|
||||||
'$download' => t('Download'),
|
|
||||||
'$files' => $files,
|
|
||||||
'$channel' => $which,
|
|
||||||
'$edit' => t('Edit'),
|
|
||||||
'$delete' => t('Delete'),
|
|
||||||
'$used' => $used,
|
|
||||||
'$usedlabel' => t('Used: '),
|
|
||||||
'$directory' => t('[directory]'),
|
|
||||||
'$limit' => $limit,
|
|
||||||
'$limitlabel' => t('Limit: '),
|
|
||||||
));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<div id="attach-edit-backlink">< <a href="filestorage/{{$channelnick}}">{{$backlink}}</a></div>
|
<div id="attach-edit-backlink">< <a href="cloud/{{$channelnick}}">{{$backlink}}</a></div>
|
||||||
|
|
||||||
<h1>{{$header}}</h1>
|
<h1>{{$header}}</h1>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user