3 function profperm_init(App $a) {
9 $which = $a->user['nickname'];
10 $profile = $a->argv[1];
12 profile_load($a,$which,$profile);
17 function profperm_content(App $a) {
20 notice( t('Permission denied') . EOL);
26 notice( t('Invalid profile identifier.') . EOL );
30 // Switch to text mod interface if we have more than 'n' contacts or group members
32 $switchtotext = get_pconfig(local_user(),'system','groupedit_image_limit');
33 if($switchtotext === false)
34 $switchtotext = get_config('system','groupedit_image_limit');
35 if($switchtotext === false)
39 if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
40 $r = q("SELECT `id` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `self` = 0
41 AND `network` = '%s' AND `id` = %d AND `uid` = %d LIMIT 1",
46 if (dbm::is_result($r))
47 $change = intval($a->argv[2]);
51 if(($a->argc > 1) && (intval($a->argv[1]))) {
52 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
56 if (! dbm::is_result($r)) {
57 notice( t('Invalid profile identifier.') . EOL );
62 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile-id` = %d",
68 if (dbm::is_result($r))
69 foreach($r as $member)
70 $ingroup[] = $member['id'];
75 if(in_array($change,$ingroup)) {
76 q("UPDATE `contact` SET `profile-id` = 0 WHERE `id` = %d AND `uid` = %d",
82 q("UPDATE `contact` SET `profile-id` = %d WHERE `id` = %d AND `uid` = %d",
90 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile-id` = %d",
98 if (dbm::is_result($r))
99 foreach($r as $member)
100 $ingroup[] = $member['id'];
103 $o .= '<h2>' . t('Profile Visibility Editor') . '</h2>';
105 $o .= '<h3>' . t('Profile') . ' \'' . $profile['profile-name'] . '\'</h3>';
107 $o .= '<div id="prof-edit-desc">' . t('Click on a contact to add or remove.') . '</div>';
111 $o .= '<div id="prof-update-wrapper">';
115 $o .= '<div id="prof-members-title">';
116 $o .= '<h3>' . t('Visible To') . '</h3>';
118 $o .= '<div id="prof-members">';
120 $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false);
122 foreach($members as $member) {
124 $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
125 $o .= micropro($member,true,'mpprof', $textmode);
128 $o .= '</div><div id="prof-members-end"></div>';
129 $o .= '<hr id="prof-separator" />';
131 $o .= '<div id="prof-all-contcts-title">';
132 $o .= '<h3>' . t("All Contacts \x28with secure profile access\x29") . '</h3>';
134 $o .= '<div id="prof-all-contacts">';
136 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0
137 AND `network` = '%s' ORDER BY `name` ASC",
138 intval(local_user()),
142 if (dbm::is_result($r)) {
143 $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
144 foreach($r as $member) {
145 if(! in_array($member['id'],$ingroup)) {
146 $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
147 $o .= micropro($member,true,'mpprof',$textmode);
152 $o .= '</div><div id="prof-all-contacts-end"></div>';