aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/acl_selectors.php99
1 files changed, 99 insertions, 0 deletions
diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index 921a8275b..c19a0f5d3 100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
@@ -41,6 +41,104 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
}
+function contact_selector($selname, $selclass, $preselected = false, $options) {
+
+ $a = get_app();
+
+ $mutual = false;
+ $networks = null;
+ $single = false;
+
+ if($is_array($options)) {
+ if(x($options,'mutual_friends'))
+ $mutual = true;
+ if(x($options,'single'))
+ $single = true;
+ if(x($options,'multiple'))
+ $single = false;
+ if(x($options,'networks')) {
+ switch($options['networks']) {
+ case 'DFRN_ONLY':
+ $networks = array('dfrn');
+ break;
+ case 'PRIVATE':
+ if(is_array($a->user) && $a->user['prvnets'])
+ $networks = array('dfrn','mail','dspr');
+ else
+ $networks = array('dfrn','face','mail', 'dspr');
+ break;
+ case 'TWO_WAY':
+ if(is_array($a->user) && $a->user['prvnets'])
+ $networks = array('dfrn','mail','dspr');
+ else
+ $networks = array('dfrn','face','mail','dspr','stat');
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ $x = array('options' => $options, 'single' => $single, 'mutual' => $mutual, 'networks' => $networks);
+
+ call_hooks('contact_select_options', $x);
+
+ $o = '';
+
+ $sql_extra = '';
+
+ if($x['mutual']) {
+ $sql_extra .= sprintf(" AND `rel` = %d ", intval(REL_BUD));
+ }
+
+ if(is_array($x['networks']) && count($x['networks'])) {
+ for($y = 0; $y < count($x['networks']) ; $y ++)
+ $x['networks'][$y] = "'" . dbesc($x['networks'][$y]) . "'";
+ $str_nets = implode(',',$x['networks']);
+ $sql_extra .= " AND `network` IN ( $str_nets ) ";
+ }
+
+ if($x['single'])
+ $o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" >\r\n";
+ else
+ $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n";
+
+ $r = q("SELECT `id`, `name`, `url`, `network` FROM `contact`
+ WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `notify` != ''
+ $sql_extra
+ ORDER BY `name` ASC ",
+ intval(local_user())
+ );
+
+
+ $arr = array('contact' => $r, 'entry' => $o);
+
+ // e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
+
+ call_hooks($a->module . '_pre_' . $selname, $arr);
+
+ if(count($r)) {
+ foreach($r as $rr) {
+ if((is_array($preselected)) && in_array($rr['id'], $preselected))
+ $selected = " selected=\"selected\" ";
+ else
+ $selected = '';
+
+ $trimmed = mb_substr($rr['name'],0,20);
+
+ $o .= "<option value=\"{$rr['id']}\" $selected title=\"{$rr['name']}|{$rr['url']}\" >$trimmed</option>\r\n";
+ }
+
+ }
+
+ $o .= "</select>\r\n";
+
+ call_hooks($a->module . '_post_' . $selname, $o);
+
+ return $o;
+}
+
+
function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false) {
@@ -106,6 +204,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
return $o;
}
+
function fixacl(&$item) {
$item = intval(str_replace(array('<','>'),array('',''),$item));
}