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 if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
30 $r = q("SELECT `id` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `self` = 0
31 AND `network` = 'dfrn' AND `id` = %d AND `uid` = %d LIMIT 1",
36 $change = intval($a->argv[2]);
40 if(($a->argc > 1) && (intval($a->argv[1]))) {
41 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
46 notice( t('Invalid profile identifier.') . EOL );
51 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile-id` = %d",
58 foreach($r as $member)
59 $ingroup[] = $member['id'];
64 if(in_array($change,$ingroup)) {
65 q("UPDATE `contact` SET `profile-id` = 0 WHERE `id` = %d AND `uid` = %d LIMIT 1",
71 q("UPDATE `contact` SET `profile-id` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1",
79 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile-id` = %d",
88 foreach($r as $member)
89 $ingroup[] = $member['id'];
92 $o .= '<h2>' . t('Profile Visibility Editor') . '</h2>';
94 $o .= '<h3>' . t('Profile') . ' \'' . $profile['profile-name'] . '\'</h3>';
96 $o .= '<div id="prof-edit-desc">' . t('Click on a contact to add or remove.') . '</div>';
100 $o .= '<div id="prof-update-wrapper">';
104 $o .= '<div id="prof-members">';
105 $o .= '<h3>' . t('Visible To') . '</h3>';
106 foreach($members as $member) {
108 $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
109 $o .= micropro($member,true,'mpprof');
112 $o .= '</div><div id="prof-members-end"></div>';
113 $o .= '<hr id="prof-separator" />';
114 $o .= '<div id="prof-all-contacts">';
116 $o .= '<h3>' . t("All Contacts \x28with secure profile access\x29") . '</h3>';
117 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0
118 AND `network` = 'dfrn' ORDER BY `name` ASC",
123 foreach($r as $member) {
124 if(! in_array($member['id'],$ingroup)) {
125 $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
126 $o .= micropro($member,true,'mpprof');
131 $o .= '</div><div id="prof-all-contacts-end"></div>';