$v) { set_pconfig($channel['channel_id'],'autoperms',$k,$v); } } } } function perm_abook_upgrade($abook) { $x = perms_int_to_array($abook['abook_their_perms']); if($x) { foreach($x as $k => $v) { set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'their_perms',$k, $v); } } $x = perms_int_to_array($abook['abook_my_perms']); if($x) { foreach($x as $k => $v) { set_abconfig($abook['abook_channel'],$abook['abook_xchan'],'my_perms',$k, $v); } } } function translate_channel_perms_outbound(&$channel) { $r = q("select * from pconfig where uid = %d and cat = 'perm_limits' ", intval($channel['channel_id']) ); if($r) { foreach($r as $rr) { if($rr['k'] === 'view_stream') $channel['channel_r_stream'] = $rr['v']; if($rr['k'] === 'view_profile') $channel['channel_r_profile'] = $rr['v']; if($rr['k'] === 'view_contacts') $channel['channel_r_abook'] = $rr['v']; if($rr['k'] === 'view_storage') $channel['channel_r_storage'] = $rr['v']; if($rr['k'] === 'view_pages') $channel['channel_r_pages'] = $rr['v']; if($rr['k'] === 'send_stream') $channel['channel_w_stream'] = $rr['v']; if($rr['k'] === 'post_wall') $channel['channel_w_wall'] = $rr['v']; if($rr['k'] === 'post_comments') $channel['channel_w_comment'] = $rr['v']; if($rr['k'] === 'post_mail') $channel['channel_w_mail'] = $rr['v']; if($rr['k'] === 'post_like') $channel['channel_w_like'] = $rr['v']; if($rr['k'] === 'tag_deliver') $channel['channel_w_tagwall'] = $rr['v']; if($rr['k'] === 'chat') $channel['channel_w_chat'] = $rr['v']; if($rr['k'] === 'write_storage') $channel['channel_w_storage'] = $rr['v']; if($rr['k'] === 'write_pages') $channel['channel_w_pages'] = $rr['v']; if($rr['k'] === 'republish') $channel['channel_a_republish'] = $rr['v']; if($rr['k'] === 'delegate') $channel['channel_a_delegate'] = $rr['v']; } $channel['perm_limits'] = $r; } } function translate_channel_perms_inbound($channel) { if($channel['perm_limits']) { foreach($channel['perm_limits'] as $p) { set_pconfig($channel['channel_id'],'perm_limits',$p['k'],$p['v']); } } else { perm_limits_upgrade($channel); } } function translate_abook_perms_outbound(&$abook) { $my_perms = 0; $their_perms = 0; if(! $abook) return; if(array_key_exists('abconfig',$abook) && is_array($abook['abconfig']) && $abook['abconfig']) { foreach($abook['abconfig'] as $p) { if($p['cat'] === 'their_perms') { if($p['k'] === 'view_stream' && intval($p['v'])) $their_perms += PERMS_R_STREAM; if($p['k'] === 'view_profile' && intval($p['v'])) $their_perms += PERMS_R_PROFILE; if($p['k'] === 'view_contacts' && intval($p['v'])) $their_perms += PERMS_R_ABOOK; if($p['k'] === 'view_storage' && intval($p['v'])) $their_perms += PERMS_R_STORAGE; if($p['k'] === 'view_pages' && intval($p['v'])) $their_perms += PERMS_R_PAGES; if($p['k'] === 'send_stream' && intval($p['v'])) $their_perms += PERMS_W_STREAM; if($p['k'] === 'post_wall' && intval($p['v'])) $their_perms += PERMS_W_WALL; if($p['k'] === 'post_comments' && intval($p['v'])) $their_perms += PERMS_W_COMMENT; if($p['k'] === 'post_mail' && intval($p['v'])) $their_perms += PERMS_W_MAIL; if($p['k'] === 'post_like' && intval($p['v'])) $their_perms += PERMS_W_LIKE; if($p['k'] === 'tag_deliver' && intval($p['v'])) $their_perms += PERMS_W_TAGWALL; if($p['k'] === 'chat' && intval($p['v'])) $their_perms += PERMS_W_CHAT; if($p['k'] === 'write_storage' && intval($p['v'])) $their_perms += PERMS_W_STORAGE; if($p['k'] === 'write_pages' && intval($p['v'])) $their_perms += PERMS_W_PAGES; if($p['k'] === 'republish' && intval($p['v'])) $their_perms += PERMS_A_REPUBLISH; if($p['k'] === 'delegate' && intval($p['v'])) $their_perms += PERMS_A_DELEGATE; } if($p['cat'] === 'my_perms') { if($p['k'] === 'view_stream' && intval($p['v'])) $my_perms += PERMS_R_STREAM; if($p['k'] === 'view_profile' && intval($p['v'])) $my_perms += PERMS_R_PROFILE; if($p['k'] === 'view_contacts' && intval($p['v'])) $my_perms += PERMS_R_ABOOK; if($p['k'] === 'view_storage' && intval($p['v'])) $my_perms += PERMS_R_STORAGE; if($p['k'] === 'view_pages' && intval($p['v'])) $my_perms += PERMS_R_PAGES; if($p['k'] === 'send_stream' && intval($p['v'])) $my_perms += PERMS_W_STREAM; if($p['k'] === 'post_wall' && intval($p['v'])) $my_perms += PERMS_W_WALL; if($p['k'] === 'post_comments' && intval($p['v'])) $my_perms += PERMS_W_COMMENT; if($p['k'] === 'post_mail' && intval($p['v'])) $my_perms += PERMS_W_MAIL; if($p['k'] === 'post_like' && intval($p['v'])) $my_perms += PERMS_W_LIKE; if($p['k'] === 'tag_deliver' && intval($p['v'])) $my_perms += PERMS_W_TAGWALL; if($p['k'] === 'chat' && intval($p['v'])) $my_perms += PERMS_W_CHAT; if($p['k'] === 'write_storage' && intval($p['v'])) $my_perms += PERMS_W_STORAGE; if($p['k'] === 'write_pages' && intval($p['v'])) $my_perms += PERMS_W_PAGES; if($p['k'] === 'republish' && intval($p['v'])) $my_perms += PERMS_A_REPUBLISH; if($p['k'] === 'delegate' && intval($p['v'])) $my_perms += PERMS_A_DELEGATE; } } $abook['abook_their_perms'] = $their_perms; $abook['abook_my_perms'] = $my_perms; } } function translate_abook_perms_inbound($channel,$abook) { $new_perms = false; $abook['abook_channel'] = $channel['channel_id']; if(array_key_exists('abconfig',$abook) && is_array($abook['abconfig']) && $abook['abconfig']) { foreach($abook['abconfig'] as $p) { if($p['cat'] == 'their_perms' || $p['cat'] == 'my_perms') { $new_perms = true; break; } } } if($new_perms == false) { perm_abook_upgrade($abook); } }