3 function profperm_init(&$a) {
8 $which = $a->user['nickname'];
9 $profile = $a->argv[1];
11 profile_load($a,$which,$profile);
16 function profperm_content(&$a) {
19 notice( t('Permission denied') . EOL);
25 notice( t('Invalid profile identifier.') . EOL );
29 // Switch to text mod interface if we have more than 'n' contacts or group members
31 $switchtotext = get_pconfig(local_user(),'system','groupedit_image_limit');
32 if($switchtotext === false)
33 $switchtotext = get_config('system','groupedit_image_limit');
34 if($switchtotext === false)
38 if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
39 $r = q("SELECT `id` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `self` = 0
40 AND `network` = 'dfrn' AND `id` = %d AND `uid` = %d LIMIT 1",
45 $change = intval($a->argv[2]);
49 if(($a->argc > 1) && (intval($a->argv[1]))) {
50 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
55 notice( t('Invalid profile identifier.') . EOL );
60 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile-id` = %d",
67 foreach($r as $member)
68 $ingroup[] = $member['id'];
73 if(in_array($change,$ingroup)) {
74 q("UPDATE `contact` SET `profile-id` = 0 WHERE `id` = %d AND `uid` = %d",
80 q("UPDATE `contact` SET `profile-id` = %d WHERE `id` = %d AND `uid` = %d",
88 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile-id` = %d",
97 foreach($r as $member)
98 $ingroup[] = $member['id'];
101 $o .= '<h2>' . t('Profile Visibility Editor') . '</h2>';
103 $o .= '<h3>' . t('Profile') . ' \'' . $profile['profile-name'] . '\'</h3>';
105 $o .= '<div id="prof-edit-desc">' . t('Click on a contact to add or remove.') . '</div>';
109 $o .= '<div id="prof-update-wrapper">';
113 $o .= '<div id="prof-members-title">';
114 $o .= '<h3>' . t('Visible To') . '</h3>';
116 $o .= '<div id="prof-members">';
118 $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false);
120 foreach($members as $member) {
122 $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
123 $o .= micropro($member,true,'mpprof', $textmode);
126 $o .= '</div><div id="prof-members-end"></div>';
127 $o .= '<hr id="prof-separator" />';
129 $o .= '<div id="prof-all-contcts-title">';
130 $o .= '<h3>' . t("All Contacts \x28with secure profile access\x29") . '</h3>';
132 $o .= '<div id="prof-all-contacts">';
134 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0
135 AND `network` = 'dfrn' ORDER BY `name` ASC",
140 $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
141 foreach($r as $member) {
142 if(! in_array($member['id'],$ingroup)) {
143 $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
144 $o .= micropro($member,true,'mpprof',$textmode);
149 $o .= '</div><div id="prof-all-contacts-end"></div>';