group ACL control using tags (group must be "visible")
This commit is contained in:
parent
a331e1acde
commit
6e81c332b7
52
mod/item.php
52
mod/item.php
@ -490,15 +490,20 @@ function item_post(&$a) {
|
|||||||
if($fullnametagged)
|
if($fullnametagged)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$success = handle_tag($a, $body, $inform, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag);
|
$success = handle_tag($a, $body, $access_tag, $str_tags, (local_user()) ? local_user() : $profile_uid , $tag);
|
||||||
logger('handle_tag: ' . print_r($success,tue));
|
logger('handle_tag: ' . print_r($success,tue), LOGGER_DEBUG);
|
||||||
if($inform) {
|
if(($access_tag) && (! $parent_item)) {
|
||||||
logger('inform: ' . $tag . ' ' . print_r($inform,true));
|
logger('access_tag: ' . $tag . ' ' . print_r($access_tag,true), LOGGER_DEBUG);
|
||||||
if(strpos($inform,'cid:') === 0) {
|
if(strpos($access_tag,'cid:') === 0) {
|
||||||
$str_contact_allow .= '<' . substr($inform,4) . '>';
|
$str_contact_allow .= '<' . substr($access_tag,4) . '>';
|
||||||
$inform = '';
|
$access_tag = '';
|
||||||
|
}
|
||||||
|
elseif(strpos($access_tag,'gid:') === 0) {
|
||||||
|
$str_group_allow .= '<' . substr($access_tag,4) . '>';
|
||||||
|
$access_tag = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($success['replaced']) {
|
if($success['replaced']) {
|
||||||
$tagged[] = $tag;
|
$tagged[] = $tag;
|
||||||
$post_tags[] = array(
|
$post_tags[] = array(
|
||||||
@ -882,14 +887,14 @@ function item_content(&$a) {
|
|||||||
* the appropiate link.
|
* the appropiate link.
|
||||||
*
|
*
|
||||||
* @param unknown_type $body the text to replace the tag in
|
* @param unknown_type $body the text to replace the tag in
|
||||||
* @param unknown_type $inform a comma-seperated string containing everybody to inform
|
* @param unknown_type $access_tag - used to return tag ACL exclusions e.g. @!foo
|
||||||
* @param unknown_type $str_tags string to add the tag to
|
* @param unknown_type $str_tags string to add the tag to
|
||||||
* @param unknown_type $profile_uid
|
* @param unknown_type $profile_uid
|
||||||
* @param unknown_type $tag the tag to replace
|
* @param unknown_type $tag the tag to replace
|
||||||
*
|
*
|
||||||
* @return boolean true if replaced, false if not replaced
|
* @return boolean true if replaced, false if not replaced
|
||||||
*/
|
*/
|
||||||
function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
|
function handle_tag($a, &$body, &$access_tag, &$str_tags, $profile_uid, $tag) {
|
||||||
|
|
||||||
$replaced = false;
|
$replaced = false;
|
||||||
$r = null;
|
$r = null;
|
||||||
@ -989,12 +994,37 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
|
|||||||
if($r) {
|
if($r) {
|
||||||
$profile = $r[0]['xchan_url'];
|
$profile = $r[0]['xchan_url'];
|
||||||
$newname = $r[0]['xchan_name'];
|
$newname = $r[0]['xchan_name'];
|
||||||
//add person's id to $inform if exclusive
|
//add person's id to $access_tag if exclusive
|
||||||
if($exclusive) {
|
if($exclusive) {
|
||||||
$inform .= 'cid:' . $r[0]['xchan_hash'];
|
$access_tag .= 'cid:' . $r[0]['xchan_hash'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// check for a group/collection exclusion tag
|
||||||
|
|
||||||
|
// note that we aren't setting $replaced even though we're replacing text.
|
||||||
|
// This tag isn't going to get a term attached to it. It's only used for
|
||||||
|
// access control. The link points to out own channel just so it doesn't look
|
||||||
|
// weird - as all the other tags are linked to something.
|
||||||
|
|
||||||
|
if(local_user() && local_user() == $profile_uid) {
|
||||||
|
require_once('include/group.php');
|
||||||
|
$grp = group_byname($profile_uid,$name);
|
||||||
|
if($grp) {
|
||||||
|
$g = q("select hash from groups where id = %d and visible = 1 limit 1",
|
||||||
|
intval($grp[0]['id'])
|
||||||
|
);
|
||||||
|
if($g && $exclusive) {
|
||||||
|
$access_tag .= 'gid:' . $g[0]['hash'];
|
||||||
|
}
|
||||||
|
$channel = get_app()->get_channel();
|
||||||
|
if($channel) {
|
||||||
|
$newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . z_root() . '/channel/' . $channel['channel_address'] . ']' . $newname . '[/zrl]';
|
||||||
|
$body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//if there is an url for this persons profile
|
//if there is an url for this persons profile
|
||||||
if(isset($profile)) {
|
if(isset($profile)) {
|
||||||
|
Reference in New Issue
Block a user