mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-21 17:35:17 +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,
|
||||
'title' => htmlspecialchars_decode($itm[0]['title'],ENT_COMPAT),
|
||||
'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
|
||||
'permissions' => $itm[0],
|
||||
'profile_uid' => $owner_uid,
|
||||
|
|
|
@ -105,9 +105,16 @@ class Rpost extends Controller {
|
|||
|
||||
$channel = App::get_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();
|
||||
|
||||
if($_REQUEST['url']) {
|
||||
|
|
|
@ -60,7 +60,6 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
|
|||
array_walk($deny_gid,'fixacl');
|
||||
}
|
||||
|
||||
|
||||
$channel = ((local_channel()) ? App::get_channel() : '');
|
||||
$has_acl = false;
|
||||
$single_group = false;
|
||||
|
@ -77,7 +76,7 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti
|
|||
$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;
|
||||
$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" ' : '');
|
||||
$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) {
|
||||
foreach ($forums as $f) {
|
||||
$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");
|
||||
$o = replace_macros($tpl, array(
|
||||
'$showall' => $showall_caption,
|
||||
'$onlyme' => t('Only me'),
|
||||
'$groups' => $groups,
|
||||
'$public_selected' => (($has_acl) ? false : true),
|
||||
'$justme_selected' => $just_me,
|
||||
'$custom_selected' => $custom,
|
||||
'$public_selected' => (($has_acl) ? false : ' selected="selected" '),
|
||||
'$justme_selected' => (($just_me) ? ' selected="selected" ' : ''),
|
||||
'$custom_selected' => (($custom) ? ' selected="selected" ' : ''),
|
||||
'$showallOrigin' => $showall_origin,
|
||||
'$showallIcon' => $showall_icon,
|
||||
'$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
|
||||
// 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.
|
||||
$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.
|
||||
$emphasisOpen = '<b><a href="' . z_root() . '/help/acl_dialog_post" target="hubzilla-help">';
|
||||
$emphasisClose = '</a></b>';
|
||||
//$emphasisOpen = '<b><a href="' . z_root() . '/help/acl_dialog_post" target="hubzilla-help">';
|
||||
//$emphasisClose = '</a></b>';
|
||||
|
||||
return $description;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Lib\AccessList;
|
||||
use Zotlabs\Daemon\Run;
|
||||
|
||||
require_once('include/permissions.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) {
|
||||
|
||||
$ret = array('success' => false);
|
||||
$ret = [ 'success' => false ];
|
||||
|
||||
// Check for existence, which will also provide us the owner uid
|
||||
|
||||
$sql_extra = '';
|
||||
if($rev == (-1))
|
||||
if ($rev == (-1)) {
|
||||
$sql_extra = " order by revision desc ";
|
||||
elseif($rev)
|
||||
}
|
||||
elseif ($rev) {
|
||||
$sql_extra = " and revision = " . intval($rev) . " ";
|
||||
}
|
||||
|
||||
$r = q("SELECT uid FROM attach WHERE hash = '%s' $sql_extra LIMIT 1",
|
||||
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
|
||||
|
||||
$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']),
|
||||
dbesc($hash)
|
||||
);
|
||||
|
||||
if(! $r) {
|
||||
if (! $a) {
|
||||
$ret['message'] = t('Permission denied.');
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if($r[0]['folder']) {
|
||||
$x = attach_can_view_folder($r[0]['uid'], $observer_hash, $r[0]['folder']);
|
||||
if ($a[0]['folder']) {
|
||||
$x = attach_can_view_folder($a[0]['uid'], $observer_hash, $a[0]['folder']);
|
||||
if (! $x) {
|
||||
$ret['message'] = t('Permission denied.');
|
||||
return $ret;
|
||||
|
@ -423,7 +426,7 @@ function attach_by_hash_nodata($hash, $observer_hash, $rev = 0) {
|
|||
}
|
||||
|
||||
$ret['success'] = true;
|
||||
$ret['data'] = $r[0];
|
||||
$ret['data'] = array_shift($a);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
@ -1020,7 +1023,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
|
|||
call_hooks('photo_upload_end', $ret);
|
||||
}
|
||||
|
||||
\Zotlabs\Daemon\Run::Summon([ 'Thumbnail' , $hash ]);
|
||||
Run::Summon([ 'Thumbnail' , $hash ]);
|
||||
|
||||
|
||||
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
|
||||
*/
|
||||
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.');
|
||||
return $ret;
|
||||
}
|
||||
|
@ -1075,12 +1079,13 @@ function z_readdir($channel_id, $observer_hash, $pathname, $parent_hash = '') {
|
|||
$ret['message'] = t('Path not available.');
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// recurse
|
||||
return z_readdir($channel_id, $observer_hash, implode('/', $paths), $r[0]['hash']);
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
$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),
|
||||
intval($channel_id),
|
||||
|
@ -1123,11 +1128,11 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
|
|||
|
||||
$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_basepath .= '/';
|
||||
|
||||
|
@ -1153,14 +1158,14 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
|
|||
intval($channel['channel_id'])
|
||||
);
|
||||
if ($r) {
|
||||
if(array_key_exists('force',$arr) && intval($arr['force'])
|
||||
&& (intval($r[0]['is_dir']))) {
|
||||
if (array_key_exists('force',$arr) && intval($arr['force']) && (intval($r[0]['is_dir']))) {
|
||||
$ret['success'] = true;
|
||||
$r = q("select * from attach where id = %d limit 1",
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
if($r)
|
||||
if ($r) {
|
||||
$ret['data'] = $r[0];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
$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 : '');
|
||||
|
||||
if($lfile)
|
||||
if ($lfile) {
|
||||
$lpath = $r[0]['hash'] . (($lpath) ? '/' . $lpath : '');
|
||||
}
|
||||
|
||||
$lfile = $r[0]['folder'];
|
||||
|
||||
|
@ -1203,8 +1209,9 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
|
|||
|
||||
$path = $lpath;
|
||||
}
|
||||
else
|
||||
else {
|
||||
$path = '';
|
||||
}
|
||||
|
||||
$created = datetime_convert();
|
||||
|
||||
|
@ -1251,9 +1258,10 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
|
|||
dbesc($arr['hash']),
|
||||
intval($channel_id)
|
||||
);
|
||||
if($z)
|
||||
if ($z) {
|
||||
$ret['data'] = $z[0];
|
||||
}
|
||||
}
|
||||
else {
|
||||
logger('attach_mkdir: ' . mkdir . ' ' . $os_basepath . $os_path . ' 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) {
|
||||
|
||||
$ret = array('success' => false);
|
||||
$ret = [ 'success' => false ];
|
||||
$channel_id = $channel['channel_id'];
|
||||
|
||||
$sql_options = '';
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
if (! perm_is_allowed($channel_id, $observer_hash, 'write_storage')) {
|
||||
$ret['message'] = t('Permission denied.');
|
||||
|
@ -1315,22 +1324,28 @@ function attach_mkdirp($channel, $observer_hash, $arr = null) {
|
|||
$current_parent = '';
|
||||
|
||||
foreach ($paths as $p) {
|
||||
if(! $p)
|
||||
if (! $p) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$arx = array(
|
||||
$arx = [
|
||||
'filename' => $p,
|
||||
'folder' => $current_parent,
|
||||
'force' => 1
|
||||
);
|
||||
if(array_key_exists('allow_cid',$arr))
|
||||
];
|
||||
|
||||
if (array_key_exists('allow_cid',$arr)) {
|
||||
$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'];
|
||||
if(array_key_exists('allow_gid',$arr))
|
||||
}
|
||||
if (array_key_exists('allow_gid',$arr)) {
|
||||
$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'];
|
||||
}
|
||||
|
||||
$x = attach_mkdir($channel, $observer_hash, $arx);
|
||||
if ($x['success']) {
|
||||
|
@ -1441,8 +1456,9 @@ function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gi
|
|||
if ($sync) {
|
||||
$data = attach_export_data($channel,$resource);
|
||||
|
||||
if($data)
|
||||
Libsync::build_sync_packet($channel['channel_id'],array('file' => array($data)));
|
||||
if ($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) {
|
||||
$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'];
|
||||
else
|
||||
}
|
||||
else {
|
||||
$f = $y[0]['content'];
|
||||
}
|
||||
|
||||
if(is_dir($f))
|
||||
if (is_dir($f)) {
|
||||
@rmdir($f);
|
||||
elseif(file_exists($f))
|
||||
}
|
||||
elseif (file_exists($f)) {
|
||||
unlink($f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// delete from database
|
||||
$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",
|
||||
intval($arr['uid'])
|
||||
);
|
||||
if($r)
|
||||
if ($r) {
|
||||
$basepath .= $r[0]['channel_address'] . '/';
|
||||
}
|
||||
}
|
||||
|
||||
$path = $basepath;
|
||||
|
||||
|
@ -1611,11 +1632,13 @@ function get_cloudpath($arr) {
|
|||
dbesc($lfile)
|
||||
);
|
||||
|
||||
if(! $r)
|
||||
if (! $r) {
|
||||
break;
|
||||
}
|
||||
|
||||
if($lfile)
|
||||
if ($lfile) {
|
||||
$lpath = $r[0]['filename'] . '/' . $lpath;
|
||||
}
|
||||
$lfile = $r[0]['folder'];
|
||||
|
||||
} 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),
|
||||
dbesc($attachHash)
|
||||
);
|
||||
$hash = '';
|
||||
$hash = EMPTY_STR;
|
||||
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'];
|
||||
else
|
||||
}
|
||||
else {
|
||||
$hash = $r[0]['folder'];
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
if(! $path)
|
||||
return '';
|
||||
if (! $path) {
|
||||
return EMPTY_STR;
|
||||
}
|
||||
|
||||
$comps = explode('/',$path);
|
||||
$errors = false;
|
||||
|
@ -1717,8 +1743,9 @@ function find_folder_hash_by_path($channel_id, $path) {
|
|||
}
|
||||
}
|
||||
|
||||
if($errors)
|
||||
return '';
|
||||
if ($errors) {
|
||||
return EMPTY_STR;
|
||||
}
|
||||
|
||||
return $parent_hash;
|
||||
}
|
||||
|
@ -1756,9 +1783,9 @@ function find_filename_by_hash($channel_id, $attachHash) {
|
|||
*/
|
||||
function pipe_streams($in, $out, $bufsize = 16384) {
|
||||
$size = 0;
|
||||
while (!feof($in))
|
||||
while (!feof($in)) {
|
||||
$size += fwrite($out, fread($in, $bufsize));
|
||||
|
||||
}
|
||||
return $size;
|
||||
}
|
||||
|
||||
|
@ -1779,8 +1806,9 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
|
|||
$poster = App::get_observer();
|
||||
|
||||
//if we got no object something went wrong
|
||||
if(!$object)
|
||||
if (!$object) {
|
||||
return;
|
||||
}
|
||||
|
||||
//turn strings into arrays
|
||||
$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);
|
||||
|
||||
//do not send activity for folders for now
|
||||
if($is_dir)
|
||||
if ($is_dir) {
|
||||
return;
|
||||
}
|
||||
|
||||
//check for recursive perms if we are in a 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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//split up returned perms
|
||||
$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
|
||||
//this can e.g. happen when deleting images
|
||||
if(! $y && $verb == 'update') {
|
||||
if ((! $y) && ($verb == 'update')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1938,13 +1969,13 @@ function get_file_activity_object($channel_id, $hash, $url) {
|
|||
$url = rawurlencode($url);
|
||||
|
||||
$links = [];
|
||||
$links[] = array(
|
||||
$links[] = [
|
||||
'rel' => 'alternate',
|
||||
'type' => 'text/html',
|
||||
'href' => $url
|
||||
);
|
||||
];
|
||||
|
||||
$object = array(
|
||||
$object = [
|
||||
'type' => ACTIVITY_OBJ_FILE,
|
||||
'title' => $x[0]['filename'],
|
||||
'id' => $url,
|
||||
|
@ -1967,7 +1998,7 @@ function get_file_activity_object($channel_id, $hash, $url) {
|
|||
'allow_gid' => $x[0]['allow_gid'],
|
||||
'deny_cid' => $x[0]['deny_cid'],
|
||||
'deny_gid' => $x[0]['deny_gid']
|
||||
);
|
||||
];
|
||||
|
||||
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) {
|
||||
if($count_values[$fac_hash] == $count)
|
||||
if ($count_values[$fac_hash] == $count) {
|
||||
$r_arr_allow_cid[] = $fac_hash;
|
||||
}
|
||||
}
|
||||
//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) {
|
||||
if($count_values[$fac_hash] == $count)
|
||||
if ($count_values[$fac_hash] == $count) {
|
||||
$r_arr_allow_cid[] = $fac_hash;
|
||||
}
|
||||
}
|
||||
//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(! $r_arr_allow_cid)
|
||||
if (! $r_arr_allow_cid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ret['allow_gid'] = []; // eventual group members are already collected in $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) {
|
||||
|
||||
return str_replace(
|
||||
array( '%Y', '%m', '%d' ),
|
||||
array( datetime_convert('UTC',date_default_timezone_get(),'now', 'Y'),
|
||||
[ '%Y', '%m', '%d' ],
|
||||
[ 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', 'd')
|
||||
), $s);
|
||||
], $s);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2148,8 +2182,9 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
|
|||
dbesc($hash_ptr),
|
||||
intval($channel['channel_id'])
|
||||
);
|
||||
if(! $r)
|
||||
if (! $r) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ($hash_ptr === $resource_id) {
|
||||
$attach_ptr = $r[0];
|
||||
|
@ -2168,8 +2203,6 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
|
|||
|
||||
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",
|
||||
dbesc($resource_id),
|
||||
intval($channel['channel_id'])
|
||||
|
@ -2181,17 +2214,6 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
|
|||
$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 ",
|
||||
dbesc($resource_id),
|
||||
intval($channel['channel_id'])
|
||||
|
@ -2204,11 +2226,12 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
|
|||
if ($items) {
|
||||
xchan_query($items);
|
||||
$items = fetch_post_tags($items,true);
|
||||
foreach($items as $rr)
|
||||
foreach ($items as $rr) {
|
||||
$ret['item'][] = encode_item($rr,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
@ -2258,7 +2281,8 @@ function get_dirpath_by_cloudpath($channel, $path) {
|
|||
// and the given path must be relative to "/cloud/channelname/".
|
||||
$folders = array_unshift(array_unshift($folders, $g), $f);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
array_unshift($folders, $f);
|
||||
}
|
||||
$clouddir = 'store/' . $nick . '/' ;
|
||||
|
@ -2278,7 +2302,8 @@ function get_dirpath_by_cloudpath($channel, $path) {
|
|||
}
|
||||
if (! $valid) {
|
||||
return null;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
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);
|
||||
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,
|
||||
'src' => $nodepath,
|
||||
'filename' => $node,
|
||||
'filesize' => @filesize($nodepath),
|
||||
'preserve_original' => true
|
||||
));
|
||||
]);
|
||||
if (! $x['success']) {
|
||||
logger('Error copying file: ' . $nodepath, LOGGER_NORMAL);
|
||||
logger('Return value: ' . json_encode($x), LOGGER_NORMAL);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
logger('Error scanning source path', LOGGER_NORMAL);
|
||||
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 = '') {
|
||||
|
||||
$c = channelx_by_n($channel_id);
|
||||
if(! ($c && $resource_id))
|
||||
if (! ($c && $resource_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// 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),
|
||||
intval($channel_id)
|
||||
);
|
||||
if(! $n)
|
||||
if (! $n) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$newdirname = $n[0]['filename'];
|
||||
$newalbumname = $n[0]['display_path'];
|
||||
|
@ -2439,8 +2468,9 @@ function attach_move($channel_id, $resource_id, $new_folder_hash, $newname = '')
|
|||
}
|
||||
|
||||
$matches = false;
|
||||
if(preg_match('/(.*?)\([0-9]{1,}\)$/',$basename,$matches))
|
||||
if (preg_match('/(.*?)\([0-9]{1,}\)$/',$basename,$matches)) {
|
||||
$basename = $matches[1];
|
||||
}
|
||||
|
||||
$v = q("select filename from attach where ( filename = '%s' OR filename like '%s' ) and folder = '%s' ",
|
||||
dbesc($basename . $ext),
|
||||
|
@ -2459,17 +2489,19 @@ function attach_move($channel_id, $resource_id, $new_folder_hash, $newname = '')
|
|||
break;
|
||||
}
|
||||
}
|
||||
if($found)
|
||||
if ($found) {
|
||||
$x++;
|
||||
}
|
||||
while($found);
|
||||
} while ($found);
|
||||
|
||||
$newfilename = $basename . '(' . $x . ')' . $ext;
|
||||
}
|
||||
else
|
||||
else {
|
||||
$newfilename = $basename . $ext;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$t = q("update attach set content = '%s', folder = '%s', filename = '%s' where id = %d",
|
||||
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
|
||||
*/
|
||||
|
@ -2570,8 +2597,9 @@ function attach_folder_rpaths($all_folders,$that_folder) {
|
|||
if ($parent_hash) {
|
||||
do {
|
||||
foreach ($all_folders as $selected) {
|
||||
if(! $selected['is_dir'])
|
||||
if (! $selected['is_dir']) {
|
||||
continue;
|
||||
}
|
||||
if ($selected['hash'] == $parent_hash) {
|
||||
$path = '/' . $selected['filename'] . $path;
|
||||
$parent_hash = $selected['folder'];
|
||||
|
@ -2579,9 +2607,10 @@ function attach_folder_rpaths($all_folders,$that_folder) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if(! $found)
|
||||
if (! $found) {
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
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 : '');
|
||||
$path = $r[0]['filename'] . (($path) ? '/' . $path : '');
|
||||
$attach_hash = $r[0]['folder'];
|
||||
}
|
||||
while($attach_hash);
|
||||
} while ($attach_hash);
|
||||
|
||||
return [ 'os_path' => $os_path, 'path' => $path ];
|
||||
}
|
||||
|
@ -2628,7 +2656,6 @@ function attach_syspaths($channel_id,$attach_hash) {
|
|||
*/
|
||||
|
||||
|
||||
|
||||
function attach_upgrade() {
|
||||
|
||||
$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| )(?<!\\\)([*_]{2})([^\n]+?)\2#','md_bold',$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('#^(\#{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);
|
||||
|
@ -1502,6 +1506,8 @@ function bbcode($Text, $options = []) {
|
|||
// $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
|
||||
$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);
|
||||
|
||||
// blockquotes
|
||||
|
@ -1514,7 +1520,9 @@ function bbcode($Text, $options = []) {
|
|||
$Text = preg_replace('#\[([^\[]+)\]\((?:javascript:)?([^\)]+)\)(?!`)#','<a href="$2">$1</a>',$Text);
|
||||
|
||||
// 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
|
||||
$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'];
|
||||
}
|
||||
$posts_link = z_root() . '/stream/?cid=' . $contact['abook_id'];
|
||||
|
||||
$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) {
|
||||
$menu[] = [
|
||||
|
@ -1068,7 +1078,7 @@ function thread_author_menu($item, $mode = '') {
|
|||
if(isset($pm_url) && $pm_url) {
|
||||
$menu[] = [
|
||||
'menu' => 'prv_message',
|
||||
'title' => t('Message'),
|
||||
'title' => t('Direct Message'),
|
||||
'icon' => 'fw',
|
||||
'action' => '',
|
||||
'href' => $pm_url
|
||||
|
|
Loading…
Reference in a new issue