3 function can_write_wall(&$a,$owner) {
7 if((! (local_user())) && (! (remote_user())))
12 if(($uid) && ($uid == $owner)) {
18 // user remembered decision and avoid a DB lookup for each and every display item
19 // DO NOT use this function if there are going to be multiple owners
23 elseif($verified === 1)
26 $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` LEFT JOIN `user` on `user`.`uid` = `contact`.`uid`
27 WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
28 AND `user`.`blockwall` = 0 AND `readonly` = 0 AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page-flags` = %d ) LIMIT 1",
30 intval(remote_user()),
31 intval(CONTACT_IS_SHARING),
32 intval(CONTACT_IS_FRIEND),
33 intval(PAGE_COMMUNITY)
49 function permissions_sql($owner_id,$remote_verified = false,$groups = null) {
51 $local_user = local_user();
52 $remote_user = remote_user();
55 * Construct permissions
57 * default permissions - anonymous user
60 $sql = " AND allow_cid = ''
67 * Profile owner - everything is visible
70 if(($local_user) && ($local_user == $owner_id)) {
75 * Authenticated visitor. Unless pre-verified,
76 * check that the contact belongs to this $owner_id
77 * and load the groups the visitor belongs to.
78 * If pre-verified, the caller is expected to have already
79 * done this and passed the groups into this function.
82 elseif($remote_user) {
84 if(! $remote_verified) {
85 $r = q("SELECT id FROM contact WHERE id = %d AND uid = %d AND blocked = 0 LIMIT 1",
90 $remote_verified = true;
91 $groups = init_groups_visitor($remote_user);
94 if($remote_verified) {
96 $gs = '<<>>'; // should be impossible to match
98 if(is_array($groups) && count($groups)) {
99 foreach($groups as $g)
100 $gs .= '|<' . intval($g) . '>';
104 " AND ( allow_cid = '' OR allow_cid REGEXP '<%d>' )
105 AND ( deny_cid = '' OR NOT deny_cid REGEXP '<%d>' )
106 AND ( allow_gid = '' OR allow_gid REGEXP '%s' )
107 AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s')
109 intval($remote_user),
110 intval($remote_user),