]> git.mxchange.org Git - friendica.git/blobdiff - include/acl_selectors.php
Merge https://github.com/friendica/friendica into pull
[friendica.git] / include / acl_selectors.php
index c3e26082e3eb498f1c1a88d0fbeef724a1c86398..461ad0c3640c276d449169490e01556eb47ce5d5 100644 (file)
@@ -1,6 +1,11 @@
 <?php
+/**
+ * 
+ */
 
-
+/**
+ * @package acl_selectors 
+ */
 function group_select($selname,$selclass,$preselected = false,$size = 4) {
 
        $a = get_app();
@@ -96,7 +101,7 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
        $sql_extra = '';
 
        if($x['mutual']) {
-               $sql_extra .= sprintf(" AND `rel` = %d ", intval(REL_BUD));
+               $sql_extra .= sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND));
        }
 
        if(intval($x['exclude']))
@@ -108,14 +113,16 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
                $str_nets = implode(',',$x['networks']);
                $sql_extra .= " AND `network` IN ( $str_nets ) ";
        }
+       
+       $tabindex = (x($options, 'tabindex') ? "tabindex=\"" . $options["tabindex"] . "\"" : "");
 
        if($x['single'])
-               $o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"" . $x['size'] . "\" >\r\n";
+               $o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"" . $x['size'] . "\" $tabindex >\r\n";
        else 
-               $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"" . $x['size'] . "$\" >\r\n";
+               $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"" . $x['size'] . "$\" $tabindex >\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` != ''
+               WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != ''
                $sql_extra
                ORDER BY `name` ASC ",
                intval(local_user())
@@ -151,37 +158,37 @@ function contact_selector($selname, $selclass, $preselected = false, $options) {
 
 
 
-function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false) {
+function contact_select($selname, $selclass, $preselected = false, $size = 4, $privmail = false, $celeb = false, $privatenet = false, $tabindex = null) {
 
        $a = get_app();
 
        $o = '';
 
-       // When used for private messages, we limit correspondence to mutual DFRN/Friendika friends and the selector
+       // When used for private messages, we limit correspondence to mutual DFRN/Friendica friends and the selector
        // to one recipient. By default our selector allows multiple selects amongst all contacts.
 
        $sql_extra = '';
 
        if($privmail || $celeb) {
-               $sql_extra .= sprintf(" AND `rel` = %d ", intval(REL_BUD));
+               $sql_extra .= sprintf(" AND `rel` = %d ", intval(CONTACT_IS_FRIEND));
        }
 
        if($privmail) {
-               $sql_extra .= " AND `network` IN ( 'dfrn' ) ";
+               $sql_extra .= " AND `network` IN ( 'dfrn', 'dspr' ) ";
        }
        elseif($privatenet) {   
-               $sql_extra .= " AND `network` IN ( 'dfrn', 'mail', 'face' ) ";
+               $sql_extra .= " AND `network` IN ( 'dfrn', 'mail', 'face', 'dspr' ) ";
        }
 
-
+       $tabindex = ($tabindex > 0 ? "tabindex=\"$tabindex\"" : "");
 
        if($privmail)
-               $o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" >\r\n";
+               $o .= "<select name=\"$selname\" id=\"$selclass\" class=\"$selclass\" size=\"$size\" $tabindex >\r\n";
        else 
-               $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" >\r\n";
+               $o .= "<select name=\"{$selname}[]\" id=\"$selclass\" class=\"$selclass\" multiple=\"multiple\" size=\"$size\" $tabindex >\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` != ''
+               WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 AND `notify` != ''
                $sql_extra
                ORDER BY `name` ASC ",
                intval(local_user())
@@ -239,7 +246,7 @@ function populate_acl($user = null,$celeb = false) {
                array_walk($deny_gid,'fixacl');
        }
 
-       $o = '';
+       /*$o = '';
        $o .= '<div id="acl-wrapper">';
        $o .= '<div id="acl-permit-outer-wrapper">';
        $o .= '<div id="acl-permit-text">' . t('Visible To:') . '</div><div id="jot-public">' . t('everybody') . '</div>';
@@ -272,7 +279,20 @@ function populate_acl($user = null,$celeb = false) {
        $o .= '<div id="acl-deny-end"></div>' . "\r\n";
        $o .= '</div>';
        $o .= '</div>' . "\r\n";
-       $o .= '<div id="acl-wrapper-end"></div>' . "\r\n";
+       $o .= '<div id="acl-wrapper-end"></div>' . "\r\n";*/
+       
+       $tpl = get_markup_template("acl_selector.tpl");
+       $o = replace_macros($tpl, array(
+               '$showall'=> t("Visible to everybody"),
+               '$show'          => t("show"),
+               '$hide'          => t("don't show"),
+               '$allowcid' => json_encode($allow_cid),
+               '$allowgid' => json_encode($allow_gid),
+               '$denycid' => json_encode($deny_cid),
+               '$denygid' => json_encode($deny_gid),
+       ));
+       
+       
        return $o;
 
 }