]> git.mxchange.org Git - friendica.git/commitdiff
turn groups back into numbers
authorMike Macgirvin <mike@macgirvin.com>
Tue, 13 Jul 2010 09:00:53 +0000 (02:00 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Tue, 13 Jul 2010 09:00:53 +0000 (02:00 -0700)
include/auth.php
mod/item.php
mod/profile.php
view/acl_selectors.php

index 973aabe65489f3ebb8a8a7f028a243dfb32a8c47..5e454745e3879b87848558ef6207de63be2fe746 100644 (file)
@@ -71,23 +71,21 @@ else {
        }
 }
 
-// Returns an array of group names this contact is a member of.
-// Since contact-id's are unique and each "belongs" to a given user uid,
-// this array will only contain group names related to the uid of this
+// Returns an array of group id's this contact is a member of.
+// This array will only contain group id's related to the uid of this
 // DFRN contact. They are *not* neccessarily unique across the entire site. 
 
 
 if(! function_exists('init_groups_visitor')) {
 function init_groups_visitor($contact_id) {
        $groups = array();
-       $r = q("SELECT `group_member`.`gid`, `group`.`name` 
-               FROM `group_member` LEFT JOIN `group` ON `group_member`.`gid` = `group`.`id` 
-               WHERE `group_member`.`contact-id` = %d ",
+       $r = q("SELECT `gid` FROM `group_member` 
+               WHERE `contact-id` = %d ",
                intval($contact_id)
        );
        if(count($r)) {
                foreach($r as $rr)
-                       $groups[] = $rr['name'];
+                       $groups[] = $rr['gid'];
        }
        return $groups;
 }}
index 672084fe85e21a7464aef580c181ec7d3c2250f3..ff3f4113881ed06d4ef7f85b080f7499c0e68d26 100644 (file)
@@ -1,12 +1,7 @@
 <?php
 
-function sanitise_intacl(&$item) {
-       $item = '<' . intval(notags(trim($item))) . '>';
-}
-
-
 function sanitise_acl(&$item) {
-       $item = '<' . notags(trim($item)) . '>';
+       $item = '<' . intval(notags(trim($item))) . '>';
 }
 
 function item_post(&$a) {
@@ -35,7 +30,7 @@ function item_post(&$a) {
        $str_contact_allow = '';
        $contact_allow = $_POST['contact_allow'];
        if(is_array($contact_allow)) {
-               array_walk($contact_allow,'sanitise_intacl');
+               array_walk($contact_allow,'sanitise_acl');
                $str_contact_allow = implode('',$contact_allow);
        }
 
@@ -49,7 +44,7 @@ function item_post(&$a) {
        $str_contact_deny = '';
        $contact_deny = $_POST['contact_deny'];
        if(is_array($contact_deny)) {
-               array_walk($contact_deny,'sanitise_intacl');
+               array_walk($contact_deny,'sanitise_acl');
                $str_contact_deny = implode('',$contact_deny);
        }
 
index 37bf04a0c780e2449ac3c2dd28ccbe2aad7fe23b..5a1ac06391c9c048cb32d42bdec940a4ea2e67c7 100644 (file)
@@ -170,7 +170,7 @@ function profile_content(&$a) {
                $gs = '<<>>'; // should be impossible to match
                if(count($groups)) {
                        foreach($groups as $g)
-                               $gs .= '|<' . dbesc($g) . '>';
+                               $gs .= '|<' . intval($g) . '>';
                } 
                $sql_extra = sprintf(
                        " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' ) 
@@ -180,8 +180,8 @@ function profile_content(&$a) {
 
                        intval($_SESSION['visitor_id']),
                        intval($_SESSION['visitor_id']),
-                       $gs,
-                       $gs
+                       dbesc($gs),
+                       dbesc($gs)
                );
        }
 
index 7a8072af6c78177f274b7abd8d2b2afb38bc1e20..e5df4c65ed8bced48eb99d234927db86ab102c0e 100644 (file)
@@ -13,12 +13,12 @@ function group_select($selname,$selclass,$preselected = false) {
 
        if(count($r)) {
                foreach($r as $rr) {
-                       if((is_array($preselected)) && in_array($rr['name'], $preselected))
+                       if((is_array($preselected)) && in_array($rr['id'], $preselected))
                                $selected = " selected=\"selected\" ";
                        else
                                $selected = '';
 
-                       $o .= "<option value=\"{$rr['name']}\" $selected >{$rr['name']}</option>\r\n";
+                       $o .= "<option value=\"{$rr['id']}\" $selected >{$rr['name']}</option>\r\n";
                }
        
        }