From 4bcf19632bc5158095a5d2d5d63dea1b25b146b7 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 28 Oct 2012 18:50:35 -0700 Subject: Now have a solid permissions model. Create a few functions to enumerate them and then we're off to the races. --- include/Contact.php | 93 ----------------------------------------------------- 1 file changed, 93 deletions(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index fc0a6dd25..f442f112c 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -1,100 +1,7 @@ array('channel_r_stream', PERMS_R_STREAM ), - 'view_profile' => array('channel_r_profile', PERMS_R_PROFILE), - 'view_photos' => array('channel_r_photos', PERMS_R_PHOTOS), - 'view_contacts' => array('channel_r_abook', PERMS_R_ABOOK), - - 'send_stream' => array('channel_w_stream', PERMS_W_STREAM), - 'post_wall' => array('channel_w_wall', PERMS_W_WALL), - 'tag_deliver' => array('channel_w_tagwall', PERMS_W_TAGWALL), - 'post_comments' => array('channel_w_comment', PERMS_W_COMMENT), - 'post_mail' => array('channel_w_mail', PERMS_W_MAIL), - 'post_photos' => array('channel_w_photos', PERMS_W_PHOTOS), - 'chat' => array('channel_w_chat', PERMS_W_CHAT), - ); - - - $ret = array(); - - foreach($perms as $k => $v) { - $ret[$k] = z_check_perms($k,$v,$channel,$contact,$is_contact,$is_site,$is_network,$is_anybody); - - } - - return $ret; - -} - -function z_check_perms($k,$v,$channel,$contact,$is_contact,$is_site,$is_network,$is_anybody) { - - $allow = (($contact['self']) ? true : false); - - switch($channel[$v[0]]) { - case PERMS_PUBLIC: - if($is_anybody) - $allow = true; - break; - case PERMS_NETWORK: - if($is_network) - $allow = true; - break; - case PERMS_SITE: - if($is_site) - $allow = true; - break; - case PERMS_CONTACTS: - if($is_contact) - $allow = true; - break; - case PERMS_SPECIFIC: - if($is_contact && is_array($contact) && ($contact['my_perms'] & $v[1])) - $allow = true; - break; - default: - break; - } - return $allow; -} -- cgit v1.2.3