]> git.mxchange.org Git - friendica.git/blobdiff - include/acl_selectors.php
attachment display
[friendica.git] / include / acl_selectors.php
index d0952421ea3b92aa78d4a9b79f5a0d42f3481034..b1bcf510864d2907b8d42d74d6b5ed0224d15ee6 100644 (file)
@@ -3,38 +3,52 @@
 
 function group_select($selname,$selclass,$preselected = false,$size = 4) {
 
+       $a = get_app();
+
        $o = '';
 
        $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n";
 
        $r = q("SELECT * FROM `group` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `name` ASC",
-               $_SESSION['uid']
+               intval(local_user())
        );
 
+
+       $arr = array('group' => $r, 'entry' => $o);
+
+       // e.g. 'network_pre_group_deny', 'profile_pre_group_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,12);
 
-                       $o .= "<option value=\"{$rr['id']}\" $selected >{$rr['name']}</option>\r\n";
+                       $o .= "<option value=\"{$rr['id']}\" $selected title=\"{$rr['name']}\" >$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) {
+function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false) {
+
+       $a = get_app();
 
        $o = '';
 
-       // When used for private messages, we limit correspondence to mutual friends and the selector
+       // When used for private messages, we limit correspondence to mutual DFRN/Friendika friends and the selector
        // to one recipient. By default our selector allows multiple selects amongst all contacts.
 
        $sql_extra = '';
@@ -43,6 +57,13 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
                $sql_extra .= sprintf(" AND `rel` = %d ", intval(REL_BUD));
        }
 
+       if($privmail) {
+               $sql_extra .= " AND `network` IN ( 'dfrn' ) ";
+       }
+       elseif($privatenet) {   
+               $sql_extra .= " AND `network` IN ( 'dfrn', 'mail', 'face' ) ";
+       }
+
        if($privmail)
                $o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" >\r\n";
        else 
@@ -55,22 +76,30 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
                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 = '';
-                       if(($privmail) && ($rr['network'] === 'stat'))
-                               $disabled = ' disabled="true" ' ;
-                       else
-                               $disabled = '';
-                       $o .= "<option value=\"{$rr['id']}\" $selected  $disabled title=\"{$rr['url']}\" >{$rr['name']}</option>\r\n";
+
+                       $trimmed = mb_substr($rr['name'],0,22);
+
+                       $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;
 }
@@ -101,7 +130,7 @@ function populate_acl($user = null,$celeb = false) {
        $o = '';
        $o .= '<div id="acl-wrapper">';
        $o .= '<div id="acl-permit-outer-wrapper">';
-       $o .= '<div id="acl-permit-text">' . t('Visible To:') . '</div>';
+       $o .= '<div id="acl-permit-text">' . t('Visible To:') . '</div><div id="jot-public">' . t('everybody') . '</div>';
        $o .= '<div id="acl-permit-text-end"></div>';
        $o .= '<div id="acl-permit-wrapper">';
        $o .= '<div id="group_allow_wrapper">';
@@ -110,7 +139,7 @@ function populate_acl($user = null,$celeb = false) {
        $o .= '</div>';
        $o .= '<div id="contact_allow_wrapper">';
        $o .= '<label id="acl-allow-contact-label" for="contact_allow" >' . t('Contacts') . '</label>';
-       $o .= contact_select('contact_allow','contact_allow',$allow_cid,4,false,$celeb);
+       $o .= contact_select('contact_allow','contact_allow',$allow_cid,4,false,$celeb,true);
        $o .= '</div>';
        $o .= '</div>' . "\r\n";
        $o .= '<div id="acl-allow-end"></div>' . "\r\n";
@@ -125,7 +154,7 @@ function populate_acl($user = null,$celeb = false) {
        $o .= '</div>';
        $o .= '<div id="contact_deny_wrapper" >';
        $o .= '<label id="acl-deny-contact-label" for="contact_deny" >' . t('Contacts') . '</label>';
-       $o .= contact_select('contact_deny','contact_deny', $deny_cid,4,false, $celeb);
+       $o .= contact_select('contact_deny','contact_deny', $deny_cid,4,false, $celeb,true);
        $o .= '</div>';
        $o .= '</div>' . "\r\n";
        $o .= '<div id="acl-deny-end"></div>' . "\r\n";