+ $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
+ intval($contact_id),
+ intval($owner_uid)
+ );
+ if(count($r)) {
+ $can_post = true;
+ $contact = $r[0];
+ $remote_contact = true;
+ $visitor = $cid;
+ }
+ }
+ }
+ }
+
+ // perhaps they're visiting - but not a community page, so they wouldn't have write access
+
+ if(remote_user() && (! $visitor)) {
+ $contact_id = 0;
+ if(is_array($_SESSION['remote'])) {
+ foreach($_SESSION['remote'] as $v) {
+ if($v['uid'] == $owner_uid) {
+ $contact_id = $v['cid'];
+ break;
+ }
+ }
+ }
+ if($contact_id) {
+ $groups = init_groups_visitor($contact_id);
+ $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
+ intval($contact_id),
+ intval($owner_uid)
+ );
+ if(count($r)) {
+ $contact = $r[0];
+ $remote_contact = true;
+ }
+ }
+ }
+
+ if(! $remote_contact) {
+ if(local_user()) {
+ $contact_id = $_SESSION['cid'];
+ $contact = $a->contact;
+ }
+ }
+
+ if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) {