mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-21 19:35:24 +00:00
Merge branch 'dev' of /home/macgirvin/roadhouse into dev
This commit is contained in:
commit
8ba6890d39
6 changed files with 308 additions and 246 deletions
|
@ -110,7 +110,7 @@ class Editpost extends \Zotlabs\Web\Controller {
|
||||||
'visitor' => true,
|
'visitor' => true,
|
||||||
'title' => htmlspecialchars_decode($itm[0]['title'],ENT_COMPAT),
|
'title' => htmlspecialchars_decode($itm[0]['title'],ENT_COMPAT),
|
||||||
'category' => $category,
|
'category' => $category,
|
||||||
'showacl' => ((intval($itm[0]['unpublished'])) ? true : false),
|
'showacl' => ((intval($itm[0]['item_unpublished'])) ? true : false),
|
||||||
// @todo - need acl and lockstate when item_unpublished is 1
|
// @todo - need acl and lockstate when item_unpublished is 1
|
||||||
'permissions' => $itm[0],
|
'permissions' => $itm[0],
|
||||||
'profile_uid' => $owner_uid,
|
'profile_uid' => $owner_uid,
|
||||||
|
|
|
@ -105,9 +105,16 @@ class Rpost extends Controller {
|
||||||
|
|
||||||
$channel = App::get_channel();
|
$channel = App::get_channel();
|
||||||
|
|
||||||
|
|
||||||
$acl = new AccessControl($channel);
|
$acl = new AccessControl($channel);
|
||||||
|
|
||||||
|
if (array_key_exists('to',$_REQUEST) && $_REQUEST['to']) {
|
||||||
|
$acl->set([ 'allow_cid' => '<' . $_REQUEST['to'] . '>',
|
||||||
|
'allow_gid' => EMPTY_STR,
|
||||||
|
'deny_cid' => EMPTY_STR,
|
||||||
|
'deny_gid' => EMPTY_STR ]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$channel_acl = $acl->get();
|
$channel_acl = $acl->get();
|
||||||
|
|
||||||
if($_REQUEST['url']) {
|
if($_REQUEST['url']) {
|
||||||
|
|
|
@ -60,7 +60,6 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
|
||||||
array_walk($deny_gid,'fixacl');
|
array_walk($deny_gid,'fixacl');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$channel = ((local_channel()) ? App::get_channel() : '');
|
$channel = ((local_channel()) ? App::get_channel() : '');
|
||||||
$has_acl = false;
|
$has_acl = false;
|
||||||
$single_group = false;
|
$single_group = false;
|
||||||
|
@ -77,7 +76,7 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
|
||||||
$custom = false;
|
$custom = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($allow_cid) === 1 && $channel && $allow_cid[0] = $channel['channel_hash'] && (! $allow_gid) && (! $deny_gid) && (! $deny_cid)) {
|
if (count($allow_cid) === 1 && $channel && $allow_cid[0] === $channel['channel_hash'] && (! $allow_gid) && (! $deny_gid) && (! $deny_cid)) {
|
||||||
$just_me = true;
|
$just_me = true;
|
||||||
$custom = false;
|
$custom = false;
|
||||||
}
|
}
|
||||||
|
@ -105,12 +104,11 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
|
||||||
$selected = (($single_group && 'zot:' . $channel['channel_hash'] === $allow_gid[0]) ? ' selected = "selected" ' : '');
|
$selected = (($single_group && 'zot:' . $channel['channel_hash'] === $allow_gid[0]) ? ' selected = "selected" ' : '');
|
||||||
$groups .= '<option id="vg3" value="zot:' . $channel['channel_hash'] . '"' . $selected . '>' . t('My Zot connections') . ' ' . t('(Virtual List)') . '</option>' . "\r\n";
|
$groups .= '<option id="vg3" value="zot:' . $channel['channel_hash'] . '"' . $selected . '>' . t('My Zot connections') . ' ' . t('(Virtual List)') . '</option>' . "\r\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$forums = get_forum_channels(local_channel(),1);
|
|
||||||
|
|
||||||
|
$forums = get_forum_channels(local_channel(),1);
|
||||||
|
$selected = false;
|
||||||
if ($forums) {
|
if ($forums) {
|
||||||
foreach ($forums as $f) {
|
foreach ($forums as $f) {
|
||||||
$selected = (($single_group && $f['hash'] === $allow_cid[0]) ? ' selected = "selected" ' : '');
|
$selected = (($single_group && $f['hash'] === $allow_cid[0]) ? ' selected = "selected" ' : '');
|
||||||
|
@ -118,14 +116,26 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// preset acl with DM to a single xchan (not a group)
|
||||||
|
if ($selected === false && count($allow_cid) === 1 && $channel && $allow_cid[0] !== $channel['channel_hash'] && (! $allow_gid) && (! $deny_gid) && (! $deny_cid)) {
|
||||||
|
$f = q("select * from xchan where xchan_hash = '%s'",
|
||||||
|
dbesc($allow_cid[0])
|
||||||
|
);
|
||||||
|
if ($f) {
|
||||||
|
$custom = false;
|
||||||
|
$selected = ' selected="selected" ';
|
||||||
|
$groups .= '<option id="^DM" value="^' . $f[0]['xchan_hash'] . '"' . $selected . '>' . $f[0]['xchan_name'] . ' ' . t('(DM)') . '</option>' . "\r\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$tpl = get_markup_template("acl_selector.tpl");
|
$tpl = get_markup_template("acl_selector.tpl");
|
||||||
$o = replace_macros($tpl, array(
|
$o = replace_macros($tpl, array(
|
||||||
'$showall' => $showall_caption,
|
'$showall' => $showall_caption,
|
||||||
'$onlyme' => t('Only me'),
|
'$onlyme' => t('Only me'),
|
||||||
'$groups' => $groups,
|
'$groups' => $groups,
|
||||||
'$public_selected' => (($has_acl) ? false : true),
|
'$public_selected' => (($has_acl) ? false : ' selected="selected" '),
|
||||||
'$justme_selected' => $just_me,
|
'$justme_selected' => (($just_me) ? ' selected="selected" ' : ''),
|
||||||
'$custom_selected' => $custom,
|
'$custom_selected' => (($custom) ? ' selected="selected" ' : ''),
|
||||||
'$showallOrigin' => $showall_origin,
|
'$showallOrigin' => $showall_origin,
|
||||||
'$showallIcon' => $showall_icon,
|
'$showallIcon' => $showall_icon,
|
||||||
'$select_label' => t('Who can see this?'),
|
'$select_label' => t('Who can see this?'),
|
||||||
|
@ -165,11 +175,11 @@ function get_post_aclDialogDescription() {
|
||||||
// *shown* the post, istead of who is able to see the post, i.e. make it clear that clicking
|
// *shown* the post, istead of who is able to see the post, i.e. make it clear that clicking
|
||||||
// the "Show" button on a group does not post it to the feed of people in that group, it
|
// the "Show" button on a group does not post it to the feed of people in that group, it
|
||||||
// mearly allows those people to view the post if they are viewing/following this channel.
|
// mearly allows those people to view the post if they are viewing/following this channel.
|
||||||
$description = t('Post permissions cannot be changed after a post is shared.</br />These permissions set who is allowed to view the post.');
|
$description = t('Post permissions cannot be changed after a post is shared.<br>These permissions set who is allowed to view the post.');
|
||||||
|
|
||||||
// Lets keep the emphasis styling seperate from the translation. It may change.
|
// Lets keep the emphasis styling seperate from the translation. It may change.
|
||||||
$emphasisOpen = '<b><a href="' . z_root() . '/help/acl_dialog_post" target="hubzilla-help">';
|
//$emphasisOpen = '<b><a href="' . z_root() . '/help/acl_dialog_post" target="hubzilla-help">';
|
||||||
$emphasisClose = '</a></b>';
|
//$emphasisClose = '</a></b>';
|
||||||
|
|
||||||
return $description;
|
return $description;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
use Zotlabs\Lib\Libsync;
|
use Zotlabs\Lib\Libsync;
|
||||||
use Zotlabs\Lib\AccessList;
|
use Zotlabs\Lib\AccessList;
|
||||||
|
use Zotlabs\Daemon\Run;
|
||||||
|
|
||||||
require_once('include/permissions.php');
|
require_once('include/permissions.php');
|
||||||
require_once('include/security.php');
|
require_once('include/security.php');
|
||||||
|
@ -377,15 +378,17 @@ function attach_can_view_folder($uid,$ob_hash,$folder_hash,$token = EMPTY_STR) {
|
||||||
*/
|
*/
|
||||||
function attach_by_hash_nodata($hash, $observer_hash, $rev = 0) {
|
function attach_by_hash_nodata($hash, $observer_hash, $rev = 0) {
|
||||||
|
|
||||||
$ret = array('success' => false);
|
$ret = [ 'success' => false ];
|
||||||
|
|
||||||
// Check for existence, which will also provide us the owner uid
|
// Check for existence, which will also provide us the owner uid
|
||||||
|
|
||||||
$sql_extra = '';
|
$sql_extra = '';
|
||||||
if($rev == (-1))
|
if ($rev == (-1)) {
|
||||||
$sql_extra = " order by revision desc ";
|
$sql_extra = " order by revision desc ";
|
||||||
elseif($rev)
|
}
|
||||||
|
elseif ($rev) {
|
||||||
$sql_extra = " and revision = " . intval($rev) . " ";
|
$sql_extra = " and revision = " . intval($rev) . " ";
|
||||||
|
}
|
||||||
|
|
||||||
$r = q("SELECT uid FROM attach WHERE hash = '%s' $sql_extra LIMIT 1",
|
$r = q("SELECT uid FROM attach WHERE hash = '%s' $sql_extra LIMIT 1",
|
||||||
dbesc($hash)
|
dbesc($hash)
|
||||||
|
@ -404,18 +407,18 @@ function attach_by_hash_nodata($hash, $observer_hash, $rev = 0) {
|
||||||
|
|
||||||
// Now we'll see if we can access the attachment
|
// Now we'll see if we can access the attachment
|
||||||
|
|
||||||
$r = q("select id, aid, uid, hash, creator, filename, filetype, filesize, revision, folder, os_storage, is_photo, os_path, display_path, is_dir, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d and hash = '%s' $sql_extra limit 1",
|
$a = q("select id, aid, uid, hash, creator, filename, filetype, filesize, revision, folder, os_storage, is_photo, os_path, display_path, is_dir, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where uid = %d and hash = '%s' $sql_extra limit 1",
|
||||||
intval($r[0]['uid']),
|
intval($r[0]['uid']),
|
||||||
dbesc($hash)
|
dbesc($hash)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(! $r) {
|
if (! $a) {
|
||||||
$ret['message'] = t('Permission denied.');
|
$ret['message'] = t('Permission denied.');
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($r[0]['folder']) {
|
if ($a[0]['folder']) {
|
||||||
$x = attach_can_view_folder($r[0]['uid'], $observer_hash, $r[0]['folder']);
|
$x = attach_can_view_folder($a[0]['uid'], $observer_hash, $a[0]['folder']);
|
||||||
if (! $x) {
|
if (! $x) {
|
||||||
$ret['message'] = t('Permission denied.');
|
$ret['message'] = t('Permission denied.');
|
||||||
return $ret;
|
return $ret;
|
||||||
|
@ -423,7 +426,7 @@ function attach_by_hash_nodata($hash, $observer_hash, $rev = 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret['success'] = true;
|
$ret['success'] = true;
|
||||||
$ret['data'] = $r[0];
|
$ret['data'] = array_shift($a);
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
@ -1020,7 +1023,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
|
||||||
call_hooks('photo_upload_end', $ret);
|
call_hooks('photo_upload_end', $ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
\Zotlabs\Daemon\Run::Summon([ 'Thumbnail' , $hash ]);
|
Run::Summon([ 'Thumbnail' , $hash ]);
|
||||||
|
|
||||||
|
|
||||||
if($dosync) {
|
if($dosync) {
|
||||||
|
@ -1055,9 +1058,10 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
|
||||||
* * \e array \b data array of attach DB entries without data component
|
* * \e array \b data array of attach DB entries without data component
|
||||||
*/
|
*/
|
||||||
function z_readdir($channel_id, $observer_hash, $pathname, $parent_hash = '') {
|
function z_readdir($channel_id, $observer_hash, $pathname, $parent_hash = '') {
|
||||||
$ret = array('success' => false);
|
|
||||||
|
|
||||||
if(! perm_is_allowed($channel_id, get_observer_hash(), 'view_storage')) {
|
$ret = [ 'success' => false ];
|
||||||
|
|
||||||
|
if (! perm_is_allowed($channel_id, $observer_hash, 'view_storage')) {
|
||||||
$ret['message'] = t('Permission denied.');
|
$ret['message'] = t('Permission denied.');
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
@ -1075,12 +1079,13 @@ function z_readdir($channel_id, $observer_hash, $pathname, $parent_hash = '') {
|
||||||
$ret['message'] = t('Path not available.');
|
$ret['message'] = t('Path not available.');
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
// recurse
|
||||||
return z_readdir($channel_id, $observer_hash, implode('/', $paths), $r[0]['hash']);
|
return z_readdir($channel_id, $observer_hash, implode('/', $paths), $r[0]['hash']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
$paths = array($pathname);
|
$paths = array($pathname);
|
||||||
|
}
|
||||||
|
|
||||||
$r = q("select id, aid, uid, hash, creator, filename, filetype, filesize, revision, folder, os_path, display_path, is_photo, is_dir, os_storage, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where id = %d and folder = '%s' and filename = '%s' and is_dir != 0 " . permissions_sql($channel_id),
|
$r = q("select id, aid, uid, hash, creator, filename, filetype, filesize, revision, folder, os_path, display_path, is_photo, is_dir, os_storage, flags, created, edited, allow_cid, allow_gid, deny_cid, deny_gid from attach where id = %d and folder = '%s' and filename = '%s' and is_dir != 0 " . permissions_sql($channel_id),
|
||||||
intval($channel_id),
|
intval($channel_id),
|
||||||
|
@ -1123,11 +1128,11 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
|
||||||
|
|
||||||
$os_basepath = 'store/' . $channel['channel_address'];
|
$os_basepath = 'store/' . $channel['channel_address'];
|
||||||
|
|
||||||
logger('basepath: ' . $os_basepath);
|
logger('basepath: ' . $os_basepath, LOGGER_DEBUG);
|
||||||
|
|
||||||
if(! is_dir($os_basepath))
|
if (! is_dir($os_basepath)) {
|
||||||
os_mkdir($os_basepath,STORAGE_DEFAULT_PERMISSIONS, true);
|
os_mkdir($os_basepath,STORAGE_DEFAULT_PERMISSIONS, true);
|
||||||
|
}
|
||||||
|
|
||||||
$os_basepath .= '/';
|
$os_basepath .= '/';
|
||||||
|
|
||||||
|
@ -1153,14 +1158,14 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
|
||||||
intval($channel['channel_id'])
|
intval($channel['channel_id'])
|
||||||
);
|
);
|
||||||
if ($r) {
|
if ($r) {
|
||||||
if(array_key_exists('force',$arr) && intval($arr['force'])
|
if (array_key_exists('force',$arr) && intval($arr['force']) && (intval($r[0]['is_dir']))) {
|
||||||
&& (intval($r[0]['is_dir']))) {
|
|
||||||
$ret['success'] = true;
|
$ret['success'] = true;
|
||||||
$r = q("select * from attach where id = %d limit 1",
|
$r = q("select * from attach where id = %d limit 1",
|
||||||
intval($r[0]['id'])
|
intval($r[0]['id'])
|
||||||
);
|
);
|
||||||
if($r)
|
if ($r) {
|
||||||
$ret['data'] = $r[0];
|
$ret['data'] = $r[0];
|
||||||
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
$ret['message'] = t('duplicate filename or path');
|
$ret['message'] = t('duplicate filename or path');
|
||||||
|
@ -1194,8 +1199,9 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
|
||||||
|
|
||||||
$dpath = $r[0]['filename'] . (($dpath) ? '/' . $dpath : '');
|
$dpath = $r[0]['filename'] . (($dpath) ? '/' . $dpath : '');
|
||||||
|
|
||||||
if($lfile)
|
if ($lfile) {
|
||||||
$lpath = $r[0]['hash'] . (($lpath) ? '/' . $lpath : '');
|
$lpath = $r[0]['hash'] . (($lpath) ? '/' . $lpath : '');
|
||||||
|
}
|
||||||
|
|
||||||
$lfile = $r[0]['folder'];
|
$lfile = $r[0]['folder'];
|
||||||
|
|
||||||
|
@ -1203,8 +1209,9 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
|
||||||
|
|
||||||
$path = $lpath;
|
$path = $lpath;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
$path = '';
|
$path = '';
|
||||||
|
}
|
||||||
|
|
||||||
$created = datetime_convert();
|
$created = datetime_convert();
|
||||||
|
|
||||||
|
@ -1251,9 +1258,10 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
|
||||||
dbesc($arr['hash']),
|
dbesc($arr['hash']),
|
||||||
intval($channel_id)
|
intval($channel_id)
|
||||||
);
|
);
|
||||||
if($z)
|
if ($z) {
|
||||||
$ret['data'] = $z[0];
|
$ret['data'] = $z[0];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
logger('attach_mkdir: ' . mkdir . ' ' . $os_basepath . $os_path . ' failed.');
|
logger('attach_mkdir: ' . mkdir . ' ' . $os_basepath . $os_path . ' failed.');
|
||||||
$ret['message'] = t('mkdir failed.');
|
$ret['message'] = t('mkdir failed.');
|
||||||
|
@ -1284,17 +1292,18 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
|
||||||
*/
|
*/
|
||||||
function attach_mkdirp($channel, $observer_hash, $arr = null) {
|
function attach_mkdirp($channel, $observer_hash, $arr = null) {
|
||||||
|
|
||||||
$ret = array('success' => false);
|
$ret = [ 'success' => false ];
|
||||||
$channel_id = $channel['channel_id'];
|
$channel_id = $channel['channel_id'];
|
||||||
|
|
||||||
$sql_options = '';
|
$sql_options = '';
|
||||||
|
|
||||||
$basepath = 'store/' . $channel['channel_address'];
|
$basepath = 'store/' . $channel['channel_address'];
|
||||||
|
|
||||||
logger('basepath: ' . $basepath);
|
logger('basepath: ' . $basepath, LOGGER_DEBUG);
|
||||||
|
|
||||||
if(! is_dir($basepath))
|
if (! is_dir($basepath)) {
|
||||||
os_mkdir($basepath,STORAGE_DEFAULT_PERMISSIONS, true);
|
os_mkdir($basepath,STORAGE_DEFAULT_PERMISSIONS, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (! perm_is_allowed($channel_id, $observer_hash, 'write_storage')) {
|
if (! perm_is_allowed($channel_id, $observer_hash, 'write_storage')) {
|
||||||
$ret['message'] = t('Permission denied.');
|
$ret['message'] = t('Permission denied.');
|
||||||
|
@ -1315,22 +1324,28 @@ function attach_mkdirp($channel, $observer_hash, $arr = null) {
|
||||||
$current_parent = '';
|
$current_parent = '';
|
||||||
|
|
||||||
foreach ($paths as $p) {
|
foreach ($paths as $p) {
|
||||||
if(! $p)
|
if (! $p) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$arx = array(
|
$arx = [
|
||||||
'filename' => $p,
|
'filename' => $p,
|
||||||
'folder' => $current_parent,
|
'folder' => $current_parent,
|
||||||
'force' => 1
|
'force' => 1
|
||||||
);
|
];
|
||||||
if(array_key_exists('allow_cid',$arr))
|
|
||||||
|
if (array_key_exists('allow_cid',$arr)) {
|
||||||
$arx['allow_cid'] = $arr['allow_cid'];
|
$arx['allow_cid'] = $arr['allow_cid'];
|
||||||
if(array_key_exists('deny_cid',$arr))
|
}
|
||||||
|
if (array_key_exists('deny_cid',$arr)) {
|
||||||
$arx['deny_cid'] = $arr['deny_cid'];
|
$arx['deny_cid'] = $arr['deny_cid'];
|
||||||
if(array_key_exists('allow_gid',$arr))
|
}
|
||||||
|
if (array_key_exists('allow_gid',$arr)) {
|
||||||
$arx['allow_gid'] = $arr['allow_gid'];
|
$arx['allow_gid'] = $arr['allow_gid'];
|
||||||
if(array_key_exists('deny_gid',$arr))
|
}
|
||||||
|
if (array_key_exists('deny_gid',$arr)) {
|
||||||
$arx['deny_gid'] = $arr['deny_gid'];
|
$arx['deny_gid'] = $arr['deny_gid'];
|
||||||
|
}
|
||||||
|
|
||||||
$x = attach_mkdir($channel, $observer_hash, $arx);
|
$x = attach_mkdir($channel, $observer_hash, $arx);
|
||||||
if ($x['success']) {
|
if ($x['success']) {
|
||||||
|
@ -1441,8 +1456,9 @@ function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gi
|
||||||
if ($sync) {
|
if ($sync) {
|
||||||
$data = attach_export_data($channel,$resource);
|
$data = attach_export_data($channel,$resource);
|
||||||
|
|
||||||
if($data)
|
if ($data) {
|
||||||
Libsync::build_sync_packet($channel['channel_id'],array('file' => array($data)));
|
Libsync::build_sync_packet($channel['channel_id'], [ 'file' => [ $data ] ]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1505,17 +1521,21 @@ function attach_delete($channel_id, $resource, $is_photo = 0) {
|
||||||
|
|
||||||
if ($y) {
|
if ($y) {
|
||||||
$y[0]['content'] = dbunescbin($y[0]['content']);
|
$y[0]['content'] = dbunescbin($y[0]['content']);
|
||||||
if(strpos($y[0]['content'],'store') === false)
|
if (strpos($y[0]['content'],'store') === false) {
|
||||||
$f = 'store/' . $channel_address . '/' . $y[0]['content'];
|
$f = 'store/' . $channel_address . '/' . $y[0]['content'];
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
$f = $y[0]['content'];
|
$f = $y[0]['content'];
|
||||||
|
}
|
||||||
|
|
||||||
if(is_dir($f))
|
if (is_dir($f)) {
|
||||||
@rmdir($f);
|
@rmdir($f);
|
||||||
elseif(file_exists($f))
|
}
|
||||||
|
elseif (file_exists($f)) {
|
||||||
unlink($f);
|
unlink($f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// delete from database
|
// delete from database
|
||||||
$z = q("DELETE FROM attach WHERE hash = '%s' AND uid = %d",
|
$z = q("DELETE FROM attach WHERE hash = '%s' AND uid = %d",
|
||||||
|
@ -1594,9 +1614,10 @@ function get_cloudpath($arr) {
|
||||||
$r = q("select channel_address from channel where channel_id = %d limit 1",
|
$r = q("select channel_address from channel where channel_id = %d limit 1",
|
||||||
intval($arr['uid'])
|
intval($arr['uid'])
|
||||||
);
|
);
|
||||||
if($r)
|
if ($r) {
|
||||||
$basepath .= $r[0]['channel_address'] . '/';
|
$basepath .= $r[0]['channel_address'] . '/';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$path = $basepath;
|
$path = $basepath;
|
||||||
|
|
||||||
|
@ -1611,11 +1632,13 @@ function get_cloudpath($arr) {
|
||||||
dbesc($lfile)
|
dbesc($lfile)
|
||||||
);
|
);
|
||||||
|
|
||||||
if(! $r)
|
if (! $r) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if($lfile)
|
if ($lfile) {
|
||||||
$lpath = $r[0]['filename'] . '/' . $lpath;
|
$lpath = $r[0]['filename'] . '/' . $lpath;
|
||||||
|
}
|
||||||
$lfile = $r[0]['folder'];
|
$lfile = $r[0]['folder'];
|
||||||
|
|
||||||
} while ( ($r[0]['folder']) && intval($r[0]['is_dir']));
|
} while ( ($r[0]['folder']) && intval($r[0]['is_dir']));
|
||||||
|
@ -1674,13 +1697,15 @@ function find_folder_hash_by_attach_hash($channel_id, $attachHash, $recurse = fa
|
||||||
intval($channel_id),
|
intval($channel_id),
|
||||||
dbesc($attachHash)
|
dbesc($attachHash)
|
||||||
);
|
);
|
||||||
$hash = '';
|
$hash = EMPTY_STR;
|
||||||
if ($r && $r[0]['folder']) {
|
if ($r && $r[0]['folder']) {
|
||||||
if($recurse)
|
if ($recurse) {
|
||||||
$hash = find_folder_hash_by_attach_hash($channel_id,$r[0]['folder'],true) . '/' . $r[0]['folder'];
|
$hash = find_folder_hash_by_attach_hash($channel_id,$r[0]['folder'],true) . '/' . $r[0]['folder'];
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
$hash = $r[0]['folder'];
|
$hash = $r[0]['folder'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $hash;
|
return $hash;
|
||||||
}
|
}
|
||||||
|
@ -1694,8 +1719,9 @@ function find_folder_hash_by_attach_hash($channel_id, $attachHash, $recurse = fa
|
||||||
*/
|
*/
|
||||||
function find_folder_hash_by_path($channel_id, $path) {
|
function find_folder_hash_by_path($channel_id, $path) {
|
||||||
|
|
||||||
if(! $path)
|
if (! $path) {
|
||||||
return '';
|
return EMPTY_STR;
|
||||||
|
}
|
||||||
|
|
||||||
$comps = explode('/',$path);
|
$comps = explode('/',$path);
|
||||||
$errors = false;
|
$errors = false;
|
||||||
|
@ -1717,8 +1743,9 @@ function find_folder_hash_by_path($channel_id, $path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($errors)
|
if ($errors) {
|
||||||
return '';
|
return EMPTY_STR;
|
||||||
|
}
|
||||||
|
|
||||||
return $parent_hash;
|
return $parent_hash;
|
||||||
}
|
}
|
||||||
|
@ -1756,9 +1783,9 @@ function find_filename_by_hash($channel_id, $attachHash) {
|
||||||
*/
|
*/
|
||||||
function pipe_streams($in, $out, $bufsize = 16384) {
|
function pipe_streams($in, $out, $bufsize = 16384) {
|
||||||
$size = 0;
|
$size = 0;
|
||||||
while (!feof($in))
|
while (!feof($in)) {
|
||||||
$size += fwrite($out, fread($in, $bufsize));
|
$size += fwrite($out, fread($in, $bufsize));
|
||||||
|
}
|
||||||
return $size;
|
return $size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1779,8 +1806,9 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
|
||||||
$poster = App::get_observer();
|
$poster = App::get_observer();
|
||||||
|
|
||||||
//if we got no object something went wrong
|
//if we got no object something went wrong
|
||||||
if(!$object)
|
if (!$object) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//turn strings into arrays
|
//turn strings into arrays
|
||||||
$arr_allow_cid = expand_acl($allow_cid);
|
$arr_allow_cid = expand_acl($allow_cid);
|
||||||
|
@ -1794,8 +1822,9 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
|
||||||
$is_dir = (intval($object['is_dir']) ? true : false);
|
$is_dir = (intval($object['is_dir']) ? true : false);
|
||||||
|
|
||||||
//do not send activity for folders for now
|
//do not send activity for folders for now
|
||||||
if($is_dir)
|
if ($is_dir) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//check for recursive perms if we are in a folder
|
//check for recursive perms if we are in a folder
|
||||||
if ($object['folder']) {
|
if ($object['folder']) {
|
||||||
|
@ -1804,8 +1833,10 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
|
||||||
|
|
||||||
$r_perms = attach_recursive_perms($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $arr_deny_gid, $folder_hash);
|
$r_perms = attach_recursive_perms($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $arr_deny_gid, $folder_hash);
|
||||||
|
|
||||||
if($r_perms === false) //nobody has recursive perms - nobody must be notified
|
if ($r_perms === false) {
|
||||||
|
// nobody has recursive perms - nobody must be notified
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//split up returned perms
|
//split up returned perms
|
||||||
$arr_allow_cid = $r_perms['allow_cid'];
|
$arr_allow_cid = $r_perms['allow_cid'];
|
||||||
|
@ -1900,7 +1931,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
|
||||||
|
|
||||||
//don't create new activity if we have an update request but there is no item to update
|
//don't create new activity if we have an update request but there is no item to update
|
||||||
//this can e.g. happen when deleting images
|
//this can e.g. happen when deleting images
|
||||||
if(! $y && $verb == 'update') {
|
if ((! $y) && ($verb == 'update')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1938,13 +1969,13 @@ function get_file_activity_object($channel_id, $hash, $url) {
|
||||||
$url = rawurlencode($url);
|
$url = rawurlencode($url);
|
||||||
|
|
||||||
$links = [];
|
$links = [];
|
||||||
$links[] = array(
|
$links[] = [
|
||||||
'rel' => 'alternate',
|
'rel' => 'alternate',
|
||||||
'type' => 'text/html',
|
'type' => 'text/html',
|
||||||
'href' => $url
|
'href' => $url
|
||||||
);
|
];
|
||||||
|
|
||||||
$object = array(
|
$object = [
|
||||||
'type' => ACTIVITY_OBJ_FILE,
|
'type' => ACTIVITY_OBJ_FILE,
|
||||||
'title' => $x[0]['filename'],
|
'title' => $x[0]['filename'],
|
||||||
'id' => $url,
|
'id' => $url,
|
||||||
|
@ -1967,7 +1998,7 @@ function get_file_activity_object($channel_id, $hash, $url) {
|
||||||
'allow_gid' => $x[0]['allow_gid'],
|
'allow_gid' => $x[0]['allow_gid'],
|
||||||
'deny_cid' => $x[0]['deny_cid'],
|
'deny_cid' => $x[0]['deny_cid'],
|
||||||
'deny_gid' => $x[0]['deny_gid']
|
'deny_gid' => $x[0]['deny_gid']
|
||||||
);
|
];
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
@ -2052,9 +2083,10 @@ function attach_recursive_perms($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($arr_allow_cid as $fac_hash) {
|
foreach ($arr_allow_cid as $fac_hash) {
|
||||||
if($count_values[$fac_hash] == $count)
|
if ($count_values[$fac_hash] == $count) {
|
||||||
$r_arr_allow_cid[] = $fac_hash;
|
$r_arr_allow_cid[] = $fac_hash;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//logger(EOL . 'r_arr_allow_cid: ' . print_r($r_arr_allow_cid,true));
|
//logger(EOL . 'r_arr_allow_cid: ' . print_r($r_arr_allow_cid,true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2068,9 +2100,10 @@ function attach_recursive_perms($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($arr_allow_cid as $fac_hash) {
|
foreach ($arr_allow_cid as $fac_hash) {
|
||||||
if($count_values[$fac_hash] == $count)
|
if ($count_values[$fac_hash] == $count) {
|
||||||
$r_arr_allow_cid[] = $fac_hash;
|
$r_arr_allow_cid[] = $fac_hash;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//logger(EOL . 'groups - r_arr_allow_cid: ' . print_r($r_arr_allow_cid,true));
|
//logger(EOL . 'groups - r_arr_allow_cid: ' . print_r($r_arr_allow_cid,true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2104,8 +2137,9 @@ function attach_recursive_perms($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $
|
||||||
}
|
}
|
||||||
|
|
||||||
//if no channel is allowed return false
|
//if no channel is allowed return false
|
||||||
if(! $r_arr_allow_cid)
|
if (! $r_arr_allow_cid) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$ret['allow_gid'] = []; // eventual group members are already collected in $r_arr_allow_cid
|
$ret['allow_gid'] = []; // eventual group members are already collected in $r_arr_allow_cid
|
||||||
$ret['allow_cid'] = $r_arr_allow_cid;
|
$ret['allow_cid'] = $r_arr_allow_cid;
|
||||||
|
@ -2118,11 +2152,11 @@ function attach_recursive_perms($arr_allow_cid, $arr_allow_gid, $arr_deny_cid, $
|
||||||
function filepath_macro($s) {
|
function filepath_macro($s) {
|
||||||
|
|
||||||
return str_replace(
|
return str_replace(
|
||||||
array( '%Y', '%m', '%d' ),
|
[ '%Y', '%m', '%d' ],
|
||||||
array( datetime_convert('UTC',date_default_timezone_get(),'now', 'Y'),
|
[ datetime_convert('UTC',date_default_timezone_get(),'now', 'Y'),
|
||||||
datetime_convert('UTC',date_default_timezone_get(),'now', 'm'),
|
datetime_convert('UTC',date_default_timezone_get(),'now', 'm'),
|
||||||
datetime_convert('UTC',date_default_timezone_get(),'now', 'd')
|
datetime_convert('UTC',date_default_timezone_get(),'now', 'd')
|
||||||
), $s);
|
], $s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2148,8 +2182,9 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
|
||||||
dbesc($hash_ptr),
|
dbesc($hash_ptr),
|
||||||
intval($channel['channel_id'])
|
intval($channel['channel_id'])
|
||||||
);
|
);
|
||||||
if(! $r)
|
if (! $r) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if ($hash_ptr === $resource_id) {
|
if ($hash_ptr === $resource_id) {
|
||||||
$attach_ptr = $r[0];
|
$attach_ptr = $r[0];
|
||||||
|
@ -2168,8 +2203,6 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
|
||||||
|
|
||||||
if ($attach_ptr['is_photo']) {
|
if ($attach_ptr['is_photo']) {
|
||||||
|
|
||||||
// This query could potentially result in a few megabytes of data use.
|
|
||||||
|
|
||||||
$r = q("select * from photo where resource_id = '%s' and uid = %d order by imgscale asc",
|
$r = q("select * from photo where resource_id = '%s' and uid = %d order by imgscale asc",
|
||||||
dbesc($resource_id),
|
dbesc($resource_id),
|
||||||
intval($channel['channel_id'])
|
intval($channel['channel_id'])
|
||||||
|
@ -2181,17 +2214,6 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
|
||||||
$ret['photo'] = $r;
|
$ret['photo'] = $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This query can be used instead in memory starved environments. There will be a corresponding
|
|
||||||
// performance hit during sync because the data will need to be fetched over the network.
|
|
||||||
// $r = q("select aid,uid,xchan,resource_id,created,edited,title,description,album,filename,mimetype,height,width,filesize,imgscale,photo_usage,profile,is_nsfw,os_storage,display_path,photo_flags,allow_cid,allow_gid,deny_cid,deny_gid from photo where resource_id = '%s' and uid = %d order by imgscale asc",
|
|
||||||
// dbesc($resource_id),
|
|
||||||
// intval($channel['channel_id'])
|
|
||||||
// );
|
|
||||||
|
|
||||||
// if($r) {
|
|
||||||
// $ret['photo'] = $r;
|
|
||||||
// }
|
|
||||||
|
|
||||||
$r = q("select * from item where resource_id = '%s' and resource_type = 'photo' and uid = %d ",
|
$r = q("select * from item where resource_id = '%s' and resource_type = 'photo' and uid = %d ",
|
||||||
dbesc($resource_id),
|
dbesc($resource_id),
|
||||||
intval($channel['channel_id'])
|
intval($channel['channel_id'])
|
||||||
|
@ -2204,11 +2226,12 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
|
||||||
if ($items) {
|
if ($items) {
|
||||||
xchan_query($items);
|
xchan_query($items);
|
||||||
$items = fetch_post_tags($items,true);
|
$items = fetch_post_tags($items,true);
|
||||||
foreach($items as $rr)
|
foreach ($items as $rr) {
|
||||||
$ret['item'][] = encode_item($rr,true);
|
$ret['item'][] = encode_item($rr,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
@ -2258,7 +2281,8 @@ function get_dirpath_by_cloudpath($channel, $path) {
|
||||||
// and the given path must be relative to "/cloud/channelname/".
|
// and the given path must be relative to "/cloud/channelname/".
|
||||||
$folders = array_unshift(array_unshift($folders, $g), $f);
|
$folders = array_unshift(array_unshift($folders, $g), $f);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
array_unshift($folders, $f);
|
array_unshift($folders, $f);
|
||||||
}
|
}
|
||||||
$clouddir = 'store/' . $nick . '/' ;
|
$clouddir = 'store/' . $nick . '/' ;
|
||||||
|
@ -2278,7 +2302,8 @@ function get_dirpath_by_cloudpath($channel, $path) {
|
||||||
}
|
}
|
||||||
if (! $valid) {
|
if (! $valid) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return $clouddir . $subdir;
|
return $clouddir . $subdir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2324,20 +2349,22 @@ function copy_folder_to_cloudfiles($channel, $observer_hash, $srcpath, $cloudpat
|
||||||
logger('Error copying contents of folder: ' . $nodepath, LOGGER_NORMAL);
|
logger('Error copying contents of folder: ' . $nodepath, LOGGER_NORMAL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} elseif(is_file($nodepath) && is_readable($nodepath)) {
|
}
|
||||||
$x = attach_store($channel, $observer_hash, 'import', array(
|
elseif (is_file($nodepath) && is_readable($nodepath)) {
|
||||||
|
$x = attach_store($channel, $observer_hash, 'import', [
|
||||||
'directory' => $cloudpath,
|
'directory' => $cloudpath,
|
||||||
'src' => $nodepath,
|
'src' => $nodepath,
|
||||||
'filename' => $node,
|
'filename' => $node,
|
||||||
'filesize' => @filesize($nodepath),
|
'filesize' => @filesize($nodepath),
|
||||||
'preserve_original' => true
|
'preserve_original' => true
|
||||||
));
|
]);
|
||||||
if (! $x['success']) {
|
if (! $x['success']) {
|
||||||
logger('Error copying file: ' . $nodepath, LOGGER_NORMAL);
|
logger('Error copying file: ' . $nodepath, LOGGER_NORMAL);
|
||||||
logger('Return value: ' . json_encode($x), LOGGER_NORMAL);
|
logger('Return value: ' . json_encode($x), LOGGER_NORMAL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
logger('Error scanning source path', LOGGER_NORMAL);
|
logger('Error scanning source path', LOGGER_NORMAL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2365,8 +2392,9 @@ function copy_folder_to_cloudfiles($channel, $observer_hash, $srcpath, $cloudpat
|
||||||
function attach_move($channel_id, $resource_id, $new_folder_hash, $newname = '') {
|
function attach_move($channel_id, $resource_id, $new_folder_hash, $newname = '') {
|
||||||
|
|
||||||
$c = channelx_by_n($channel_id);
|
$c = channelx_by_n($channel_id);
|
||||||
if(! ($c && $resource_id))
|
if (! ($c && $resource_id)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// find the resource to be moved
|
// find the resource to be moved
|
||||||
|
@ -2390,8 +2418,9 @@ function attach_move($channel_id, $resource_id, $new_folder_hash, $newname = '')
|
||||||
dbesc($new_folder_hash),
|
dbesc($new_folder_hash),
|
||||||
intval($channel_id)
|
intval($channel_id)
|
||||||
);
|
);
|
||||||
if(! $n)
|
if (! $n) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$newdirname = $n[0]['filename'];
|
$newdirname = $n[0]['filename'];
|
||||||
$newalbumname = $n[0]['display_path'];
|
$newalbumname = $n[0]['display_path'];
|
||||||
|
@ -2439,8 +2468,9 @@ function attach_move($channel_id, $resource_id, $new_folder_hash, $newname = '')
|
||||||
}
|
}
|
||||||
|
|
||||||
$matches = false;
|
$matches = false;
|
||||||
if(preg_match('/(.*?)\([0-9]{1,}\)$/',$basename,$matches))
|
if (preg_match('/(.*?)\([0-9]{1,}\)$/',$basename,$matches)) {
|
||||||
$basename = $matches[1];
|
$basename = $matches[1];
|
||||||
|
}
|
||||||
|
|
||||||
$v = q("select filename from attach where ( filename = '%s' OR filename like '%s' ) and folder = '%s' ",
|
$v = q("select filename from attach where ( filename = '%s' OR filename like '%s' ) and folder = '%s' ",
|
||||||
dbesc($basename . $ext),
|
dbesc($basename . $ext),
|
||||||
|
@ -2459,17 +2489,19 @@ function attach_move($channel_id, $resource_id, $new_folder_hash, $newname = '')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($found)
|
if ($found) {
|
||||||
$x++;
|
$x++;
|
||||||
}
|
}
|
||||||
while($found);
|
} while ($found);
|
||||||
|
|
||||||
$newfilename = $basename . '(' . $x . ')' . $ext;
|
$newfilename = $basename . '(' . $x . ')' . $ext;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
$newfilename = $basename . $ext;
|
$newfilename = $basename . $ext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$t = q("update attach set content = '%s', folder = '%s', filename = '%s' where id = %d",
|
$t = q("update attach set content = '%s', folder = '%s', filename = '%s' where id = %d",
|
||||||
dbescbin($newstorepath),
|
dbescbin($newstorepath),
|
||||||
|
@ -2528,11 +2560,6 @@ function attach_move($channel_id, $resource_id, $new_folder_hash, $newname = '')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to generate a select input box of all your folders
|
* Used to generate a select input box of all your folders
|
||||||
*/
|
*/
|
||||||
|
@ -2570,8 +2597,9 @@ function attach_folder_rpaths($all_folders,$that_folder) {
|
||||||
if ($parent_hash) {
|
if ($parent_hash) {
|
||||||
do {
|
do {
|
||||||
foreach ($all_folders as $selected) {
|
foreach ($all_folders as $selected) {
|
||||||
if(! $selected['is_dir'])
|
if (! $selected['is_dir']) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if ($selected['hash'] == $parent_hash) {
|
if ($selected['hash'] == $parent_hash) {
|
||||||
$path = '/' . $selected['filename'] . $path;
|
$path = '/' . $selected['filename'] . $path;
|
||||||
$parent_hash = $selected['folder'];
|
$parent_hash = $selected['folder'];
|
||||||
|
@ -2579,9 +2607,10 @@ function attach_folder_rpaths($all_folders,$that_folder) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(! $found)
|
if (! $found) {
|
||||||
$error = true;
|
$error = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
while ((! $found) && (! $error) && ($parent_hash != ''));
|
while ((! $found) && (! $error) && ($parent_hash != ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2610,8 +2639,7 @@ function attach_syspaths($channel_id,$attach_hash) {
|
||||||
$os_path = $r[0]['hash'] . (($os_path) ? '/' . $os_path : '');
|
$os_path = $r[0]['hash'] . (($os_path) ? '/' . $os_path : '');
|
||||||
$path = $r[0]['filename'] . (($path) ? '/' . $path : '');
|
$path = $r[0]['filename'] . (($path) ? '/' . $path : '');
|
||||||
$attach_hash = $r[0]['folder'];
|
$attach_hash = $r[0]['folder'];
|
||||||
}
|
} while ($attach_hash);
|
||||||
while($attach_hash);
|
|
||||||
|
|
||||||
return [ 'os_path' => $os_path, 'path' => $path ];
|
return [ 'os_path' => $os_path, 'path' => $path ];
|
||||||
}
|
}
|
||||||
|
@ -2628,7 +2656,6 @@ function attach_syspaths($channel_id,$attach_hash) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function attach_upgrade() {
|
function attach_upgrade() {
|
||||||
|
|
||||||
$r = q("select id, uid, hash from attach where os_path = '' and display_path = '' limit 100");
|
$r = q("select id, uid, hash from attach where os_path = '' and display_path = '' limit 100");
|
||||||
|
|
|
@ -1495,6 +1495,10 @@ function bbcode($Text, $options = []) {
|
||||||
$Text = preg_replace_callback('#(^|\n| )(?<!\\\)([*_]{3})([^\n]+?)\2#','md_bolditalic',$Text);
|
$Text = preg_replace_callback('#(^|\n| )(?<!\\\)([*_]{3})([^\n]+?)\2#','md_bolditalic',$Text);
|
||||||
$Text = preg_replace_callback('#(^|\n| )(?<!\\\)([*_]{2})([^\n]+?)\2#','md_bold',$Text);
|
$Text = preg_replace_callback('#(^|\n| )(?<!\\\)([*_]{2})([^\n]+?)\2#','md_bold',$Text);
|
||||||
$Text = preg_replace_callback('#(^|\n| )(?<!\\\)([*_])([^\n|`]+?)\2#m','md_italic',$Text);
|
$Text = preg_replace_callback('#(^|\n| )(?<!\\\)([*_])([^\n|`]+?)\2#m','md_italic',$Text);
|
||||||
|
|
||||||
|
// strip the backslash from escaped bold/italic markdown sequences
|
||||||
|
$Text = preg_replace('#(\\\)([*_])#','$2',$Text);
|
||||||
|
|
||||||
$Text = preg_replace_callback('{ ^(.+?)[ ]*\n(=+|-+)[ ]*\n+ }mx','md_topheader', $Text);
|
$Text = preg_replace_callback('{ ^(.+?)[ ]*\n(=+|-+)[ ]*\n+ }mx','md_topheader', $Text);
|
||||||
$Text = preg_replace_callback('#^(\#{1,6})\s+([^\#]+?)\s*\#*$#m','md_header', $Text);
|
$Text = preg_replace_callback('#^(\#{1,6})\s+([^\#]+?)\s*\#*$#m','md_header', $Text);
|
||||||
$Text = preg_replace_callback('#(^|\n)([`~]{3,})(?: *\.?([a-zA-Z0-9\-.]+))?\n+([\s\S]+?)\n+\2(\n|$)#','md_codeblock',$Text);
|
$Text = preg_replace_callback('#(^|\n)([`~]{3,})(?: *\.?([a-zA-Z0-9\-.]+))?\n+([\s\S]+?)\n+\2(\n|$)#','md_codeblock',$Text);
|
||||||
|
@ -1502,6 +1506,8 @@ function bbcode($Text, $options = []) {
|
||||||
// $Text = preg_replace('#^(?:\0(.*?)\0\n)?( {4}|\t)(.*?)$#m','<pre><code>$3</code></pre>',$Text);
|
// $Text = preg_replace('#^(?:\0(.*?)\0\n)?( {4}|\t)(.*?)$#m','<pre><code>$3</code></pre>',$Text);
|
||||||
// markdown inline code blocks must be preceded by space or linebreak
|
// markdown inline code blocks must be preceded by space or linebreak
|
||||||
$Text = preg_replace('#(^|\n| )(?<!\\\)`([^\n]+?)`#','$1<code class="inline-code">$2</code>', $Text);
|
$Text = preg_replace('#(^|\n| )(?<!\\\)`([^\n]+?)`#','$1<code class="inline-code">$2</code>', $Text);
|
||||||
|
// strip backslash escape for inline code
|
||||||
|
$Text = preg_replace('#(\\\)`#','`',$Text);
|
||||||
$Text = preg_replace('#<\/code><\/pre>\n<pre><code(>| .*?>)#','<br>',$Text);
|
$Text = preg_replace('#<\/code><\/pre>\n<pre><code(>| .*?>)#','<br>',$Text);
|
||||||
|
|
||||||
// blockquotes
|
// blockquotes
|
||||||
|
@ -1514,7 +1520,9 @@ function bbcode($Text, $options = []) {
|
||||||
$Text = preg_replace('#\[([^\[]+)\]\((?:javascript:)?([^\)]+)\)(?!`)#','<a href="$2">$1</a>',$Text);
|
$Text = preg_replace('#\[([^\[]+)\]\((?:javascript:)?([^\)]+)\)(?!`)#','<a href="$2">$1</a>',$Text);
|
||||||
|
|
||||||
// unordered lists
|
// unordered lists
|
||||||
$Text = preg_replace('#^ *[*\-+] +(.*?)$#m','<ul><li>$1</li></ul>',$Text);
|
$Text = preg_replace('#^(?<!\\\)[*\-+] +(.*?)$#m','<ul><li>$1</li></ul>',$Text);
|
||||||
|
// strip the backslash escape if present
|
||||||
|
$Text = preg_replace('#^(\\\)([*\-+]) #m','$2',$Text);
|
||||||
// order lists
|
// order lists
|
||||||
$Text = preg_replace('#^\d+[\.] +(.*?)$#m','<ol><li>$1</li></ol>',$Text);
|
$Text = preg_replace('#^\d+[\.] +(.*?)$#m','<ol><li>$1</li></ol>',$Text);
|
||||||
|
|
||||||
|
|
|
@ -1020,10 +1020,20 @@ function thread_author_menu($item, $mode = '') {
|
||||||
$contact_url = z_root() . '/connedit/' . $contact['abook_id'];
|
$contact_url = z_root() . '/connedit/' . $contact['abook_id'];
|
||||||
}
|
}
|
||||||
$posts_link = z_root() . '/stream/?cid=' . $contact['abook_id'];
|
$posts_link = z_root() . '/stream/?cid=' . $contact['abook_id'];
|
||||||
|
|
||||||
$clean_url = $item['author']['xchan_url'];
|
$clean_url = $item['author']['xchan_url'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$can_dm = false;
|
||||||
|
|
||||||
|
if ($local_channel && $contact) {
|
||||||
|
$can_dm = perm_is_allowed($local_channel,$item['author_xchan'],'send_stream');
|
||||||
|
}
|
||||||
|
elseif ($item['author']['xchan_network'] === 'activitypub') {
|
||||||
|
$can_dm = true;
|
||||||
|
}
|
||||||
|
// if ($can_dm) {
|
||||||
|
// $pm_url = z_root() . '/rpost?to=' . urlencode($item['author_xchan']);
|
||||||
|
// }
|
||||||
|
|
||||||
if($profile_link) {
|
if($profile_link) {
|
||||||
$menu[] = [
|
$menu[] = [
|
||||||
|
@ -1068,7 +1078,7 @@ function thread_author_menu($item, $mode = '') {
|
||||||
if(isset($pm_url) && $pm_url) {
|
if(isset($pm_url) && $pm_url) {
|
||||||
$menu[] = [
|
$menu[] = [
|
||||||
'menu' => 'prv_message',
|
'menu' => 'prv_message',
|
||||||
'title' => t('Message'),
|
'title' => t('Direct Message'),
|
||||||
'icon' => 'fw',
|
'icon' => 'fw',
|
||||||
'action' => '',
|
'action' => '',
|
||||||
'href' => $pm_url
|
'href' => $pm_url
|
||||||
|
|
Loading…
Reference in a new issue