4 function group_select($selname,$selclass,$preselected = false,$size = 4) {
10 $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n";
12 $r = q("SELECT * FROM `group` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC",
17 $arr = array('group' => $r, 'entry' => $o);
19 // e.g. 'network_pre_group_deny', 'profile_pre_group_allow'
21 call_hooks($a->module . '_pre_' . $selname, $arr);
25 if((is_array($preselected)) && in_array($rr['id'], $preselected))
26 $selected = " selected=\"selected\" ";
29 $trimmed = mb_substr($rr['name'],0,12);
31 $o .= "<option value=\"{$rr['id']}\" $selected title=\"{$rr['name']}\" >$trimmed</option>\r\n";
35 $o .= "</select>\r\n";
37 call_hooks($a->module . '_post_' . $selname, $o);
45 function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false) {
51 // When used for private messages, we limit correspondence to mutual DFRN/Friendika friends and the selector
52 // to one recipient. By default our selector allows multiple selects amongst all contacts.
56 if($privmail || $celeb) {
57 $sql_extra .= sprintf(" AND `rel` = %d ", intval(REL_BUD));
61 $sql_extra .= " AND `network` IN ( 'dfrn' ) ";
64 $sql_extra .= " AND `network` IN ( 'dfrn', 'mail', 'face' ) ";
68 $o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" >\r\n";
70 $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n";
72 $r = q("SELECT `id`, `name`, `url`, `network` FROM `contact`
73 WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `notify` != ''
75 ORDER BY `name` ASC ",
80 $arr = array('contact' => $r, 'entry' => $o);
82 // e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
84 call_hooks($a->module . '_pre_' . $selname, $arr);
88 if((is_array($preselected)) && in_array($rr['id'], $preselected))
89 $selected = " selected=\"selected\" ";
93 $trimmed = mb_substr($rr['name'],0,22);
95 $o .= "<option value=\"{$rr['id']}\" $selected title=\"{$rr['name']}|{$rr['url']}\" >$trimmed</option>\r\n";
100 $o .= "</select>\r\n";
102 call_hooks($a->module . '_post_' . $selname, $o);
107 function fixacl(&$item) {
108 $item = intval(str_replace(array('<','>'),array('',''),$item));
111 function populate_acl($user = null,$celeb = false) {
113 $allow_cid = $allow_gid = $deny_cid = $deny_gid = false;
115 if(is_array($user)) {
116 $allow_cid = ((strlen($user['allow_cid']))
117 ? explode('><', $user['allow_cid']) : array() );
118 $allow_gid = ((strlen($user['allow_gid']))
119 ? explode('><', $user['allow_gid']) : array() );
120 $deny_cid = ((strlen($user['deny_cid']))
121 ? explode('><', $user['deny_cid']) : array() );
122 $deny_gid = ((strlen($user['deny_gid']))
123 ? explode('><', $user['deny_gid']) : array() );
124 array_walk($allow_cid,'fixacl');
125 array_walk($allow_gid,'fixacl');
126 array_walk($deny_cid,'fixacl');
127 array_walk($deny_gid,'fixacl');
131 $o .= '<div id="acl-wrapper">';
132 $o .= '<div id="acl-permit-outer-wrapper">';
133 $o .= '<div id="acl-permit-text">' . t('Visible To:') . '</div>';
134 $o .= '<div id="acl-permit-text-end"></div>';
135 $o .= '<div id="acl-permit-wrapper">';
136 $o .= '<div id="group_allow_wrapper">';
137 $o .= '<label id="acl-allow-group-label" for="group_allow" >' . t('Groups') . '</label>';
138 $o .= group_select('group_allow','group_allow',$allow_gid);
140 $o .= '<div id="contact_allow_wrapper">';
141 $o .= '<label id="acl-allow-contact-label" for="contact_allow" >' . t('Contacts') . '</label>';
142 $o .= contact_select('contact_allow','contact_allow',$allow_cid,4,false,$celeb,true);
144 $o .= '</div>' . "\r\n";
145 $o .= '<div id="acl-allow-end"></div>' . "\r\n";
147 $o .= '<div id="acl-deny-outer-wrapper">';
148 $o .= '<div id="acl-deny-text">' . t('Except For:') . '</div>';
149 $o .= '<div id="acl-deny-text-end"></div>';
150 $o .= '<div id="acl-deny-wrapper">';
151 $o .= '<div id="group_deny_wrapper" >';
152 $o .= '<label id="acl-deny-group-label" for="group_deny" >' . t('Groups') . '</label>';
153 $o .= group_select('group_deny','group_deny', $deny_gid);
155 $o .= '<div id="contact_deny_wrapper" >';
156 $o .= '<label id="acl-deny-contact-label" for="contact_deny" >' . t('Contacts') . '</label>';
157 $o .= contact_select('contact_deny','contact_deny', $deny_cid,4,false, $celeb,true);
159 $o .= '</div>' . "\r\n";
160 $o .= '<div id="acl-deny-end"></div>' . "\r\n";
162 $o .= '</div>' . "\r\n";
163 $o .= '<div id="acl-wrapper-end"></div>' . "\r\n";