3 * @file mod/profperm.php
6 use Friendica\Core\Config;
7 use Friendica\Core\L10n;
8 use Friendica\Core\PConfig;
9 use Friendica\Database\DBM;
10 use Friendica\Model\Profile;
12 function profperm_init(App $a)
18 $which = $a->user['nickname'];
19 $profile = $a->argv[1];
21 Profile::load($a, $which, $profile);
25 function profperm_content(App $a) {
28 notice(L10n::t('Permission denied') . EOL);
34 notice(L10n::t('Invalid profile identifier.') . EOL );
40 // Switch to text mod interface if we have more than 'n' contacts or group members
42 $switchtotext = PConfig::get(local_user(),'system','groupedit_image_limit');
43 if (is_null($switchtotext)) {
44 $switchtotext = Config::get('system','groupedit_image_limit', 400);
47 if(($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) {
48 $r = q("SELECT `id` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `self` = 0
49 AND `network` = '%s' AND `id` = %d AND `uid` = %d LIMIT 1",
54 if (DBM::is_result($r))
55 $change = intval($a->argv[2]);
59 if(($a->argc > 1) && (intval($a->argv[1]))) {
60 $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is-default` = 0 LIMIT 1",
64 if (! DBM::is_result($r)) {
65 notice(L10n::t('Invalid profile identifier.') . EOL );
70 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile-id` = %d",
76 if (DBM::is_result($r))
77 foreach($r as $member)
78 $ingroup[] = $member['id'];
83 if(in_array($change,$ingroup)) {
84 q("UPDATE `contact` SET `profile-id` = 0 WHERE `id` = %d AND `uid` = %d",
90 q("UPDATE `contact` SET `profile-id` = %d WHERE `id` = %d AND `uid` = %d",
98 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `profile-id` = %d",
106 if (DBM::is_result($r))
107 foreach($r as $member)
108 $ingroup[] = $member['id'];
111 $o .= '<h2>' . L10n::t('Profile Visibility Editor') . '</h2>';
113 $o .= '<h3>' . L10n::t('Profile') . ' \'' . $profile['profile-name'] . '\'</h3>';
115 $o .= '<div id="prof-edit-desc">' . L10n::t('Click on a contact to add or remove.') . '</div>';
119 $o .= '<div id="prof-update-wrapper">';
123 $o .= '<div id="prof-members-title">';
124 $o .= '<h3>' . L10n::t('Visible To') . '</h3>';
126 $o .= '<div id="prof-members">';
128 $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false);
130 foreach($members as $member) {
132 $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
133 $o .= micropro($member,true,'mpprof', $textmode);
136 $o .= '</div><div id="prof-members-end"></div>';
137 $o .= '<hr id="prof-separator" />';
139 $o .= '<div id="prof-all-contcts-title">';
140 $o .= '<h3>' . L10n::t("All Contacts \x28with secure profile access\x29") . '</h3>';
142 $o .= '<div id="prof-all-contacts">';
144 $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0
145 AND `network` = '%s' ORDER BY `name` ASC",
146 intval(local_user()),
150 if (DBM::is_result($r)) {
151 $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false);
152 foreach($r as $member) {
153 if(! in_array($member['id'],$ingroup)) {
154 $member['click'] = 'profChangeMember(' . $profile['id'] . ',' . $member['id'] . '); return true;';
155 $o .= micropro($member,true,'mpprof',$textmode);
160 $o .= '</div><div id="prof-all-contacts-end"></div>';