5 function profperm_init(App $a) {
11 $which = $a->user['nickname'];
12 $profile = $a->argv[1];
14 profile_load($a,$which,$profile);
19 function profperm_content(App $a) {
22 notice( t('Permission denied') . EOL);
28 notice( t('Invalid profile identifier.') . EOL );
32 // Switch to text mod interface if we have more than 'n' contacts or group members
34 $switchtotext = get_pconfig(local_user(),'system','groupedit_image_limit');
35 if($switchtotext === false)
36 $switchtotext = get_config('system','groupedit_image_limit');
37 if($switchtotext === false)
41 if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
42 $r = q("SELECT `id` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `self` = 0
43 AND `network` = '%s' AND `id` = %d AND `uid` = %d LIMIT 1",
48 if (dbm::is_result($r))
49 $change = intval($a->argv[2]);
53 if(($a->argc > 1) && (intval($a->argv[1]))) {
54 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
58 if (! dbm::is_result($r)) {
59 notice( t('Invalid profile identifier.') . EOL );
64 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile-id` = %d",
70 if (dbm::is_result($r))
71 foreach($r as $member)
72 $ingroup[] = $member['id'];
77 if(in_array($change,$ingroup)) {
78 q("UPDATE `contact` SET `profile-id` = 0 WHERE `id` = %d AND `uid` = %d",
84 q("UPDATE `contact` SET `profile-id` = %d WHERE `id` = %d AND `uid` = %d",
92 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile-id` = %d",
100 if (dbm::is_result($r))
101 foreach($r as $member)
102 $ingroup[] = $member['id'];
105 $o .= '<h2>' . t('Profile Visibility Editor') . '</h2>';
107 $o .= '<h3>' . t('Profile') . ' \'' . $profile['profile-name'] . '\'</h3>';
109 $o .= '<div id="prof-edit-desc">' . t('Click on a contact to add or remove.') . '</div>';
113 $o .= '<div id="prof-update-wrapper">';
117 $o .= '<div id="prof-members-title">';
118 $o .= '<h3>' . t('Visible To') . '</h3>';
120 $o .= '<div id="prof-members">';
122 $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false);
124 foreach($members as $member) {
126 $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
127 $o .= micropro($member,true,'mpprof', $textmode);
130 $o .= '</div><div id="prof-members-end"></div>';
131 $o .= '<hr id="prof-separator" />';
133 $o .= '<div id="prof-all-contcts-title">';
134 $o .= '<h3>' . t("All Contacts \x28with secure profile access\x29") . '</h3>';
136 $o .= '<div id="prof-all-contacts">';
138 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0
139 AND `network` = '%s' ORDER BY `name` ASC",
140 intval(local_user()),
144 if (dbm::is_result($r)) {
145 $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
146 foreach($r as $member) {
147 if(! in_array($member['id'],$ingroup)) {
148 $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
149 $o .= micropro($member,true,'mpprof',$textmode);
154 $o .= '</div><div id="prof-all-contacts-end"></div>';