]> git.mxchange.org Git - friendica.git/commitdiff
Replace init_groups_visitor with Group::getIdsByContactId
authorHypolite Petovan <mrpetovan@gmail.com>
Sun, 17 Dec 2017 00:21:56 +0000 (19:21 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Sat, 30 Dec 2017 02:55:12 +0000 (21:55 -0500)
include/security.php
mod/cal.php
mod/display.php
mod/photos.php
mod/profile.php
mod/videos.php
src/Model/Group.php
src/Protocol/DFRN.php

index e6437db3c333b052d848ad1cd71909141a8fa14c..1a5629f93578fb6781743d301c27a6f3df545c5b 100644 (file)
@@ -5,6 +5,7 @@ use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
+use Friendica\Model\Group;
 
 /**
  * @brief Calculate the hash that is needed for the "Friendica" cookie
@@ -263,7 +264,7 @@ function permissions_sql($owner_id, $remote_verified = false, $groups = null)
                        );
                        if (DBM::is_result($r)) {
                                $remote_verified = true;
-                               $groups = init_groups_visitor($remote_user);
+                               $groups = Group::getIdsByContactId($remote_user);
                        }
                }
 
@@ -325,7 +326,7 @@ function item_permissions_sql($owner_id, $remote_verified = false, $groups = nul
                        );
                        if (DBM::is_result($r)) {
                                $remote_verified = true;
-                               $groups = init_groups_visitor($remote_user);
+                               $groups = Group::getIdsByContactId($remote_user);
                        }
                }
                if ($remote_verified) {
@@ -424,22 +425,3 @@ function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'f
                killme();
        }
 }
-
-// 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 `gid` FROM `group_member`
-               WHERE `contact-id` = %d ",
-               intval($contact_id)
-       );
-       if (DBM::is_result($r)) {
-               foreach ($r as $rr)
-                       $groups[] = $rr['gid'];
-       }
-       return $groups;
-}}
index cef9857ea934d84bf794682d2c4744453b6784c4..312489ef72983d7284a9de2cbd45936fbcff52f3 100644 (file)
@@ -12,6 +12,7 @@ use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
+use Friendica\Model\Group;
 
 require_once 'include/event.php';
 require_once 'include/redir.php';
@@ -127,7 +128,7 @@ function cal_content(App $a) {
                }
        }
        if($contact_id) {
-               $groups = init_groups_visitor($contact_id);
+               $groups = Group::getIdsByContactId($contact_id);
                $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
                        intval($contact_id),
                        intval($a->profile['profile_uid'])
index 12b10f36f85d96e222a38c336753482ad219ebd1..67e6f435ec380393d5bd5f2b57901cad51447574 100644 (file)
@@ -5,6 +5,7 @@ use Friendica\Core\Config;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
+use Friendica\Model\Group;
 use Friendica\Protocol\DFRN;
 
 function display_init(App $a) {
@@ -270,7 +271,7 @@ function display_content(App $a, $update = false, $update_uid = 0) {
        }
 
        if ($contact_id) {
-               $groups = init_groups_visitor($contact_id);
+               $groups = Group::getIdsByContactId($contact_id);
                $r = dba::fetch_first("SELECT * FROM `contact` WHERE `id` = ? AND `uid` = ? LIMIT 1",
                        $contact_id,
                        $a->profile['uid']
index 4741815758abb2dcc82e4df6a282c2742807a585..68b9752b5eb53c35f6d62c03395a8fae67c642b4 100644 (file)
@@ -9,6 +9,7 @@ use Friendica\Core\Config;
 use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
+use Friendica\Model\Group;
 use Friendica\Model\Photo;
 use Friendica\Network\Probe;
 use Friendica\Object\Image;
@@ -1059,7 +1060,7 @@ function photos_content(App $a) {
                        }
                }
                if ($contact_id) {
-                       $groups = init_groups_visitor($contact_id);
+                       $groups = Group::getIdsByContactId($contact_id);
                        $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
                                intval($contact_id),
                                intval($owner_uid)
index 59835bd4cbf5b3bf85b78818b7f1809c41de0363..fe2475c7af32926acc01c80fe86c1c6fc5817ffa 100644 (file)
@@ -5,6 +5,7 @@ use Friendica\Core\Config;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Database\DBM;
+use Friendica\Model\Group;
 
 require_once('include/contact_widgets.php');
 require_once('include/redir.php');
@@ -137,7 +138,7 @@ function profile_content(App $a, $update = 0) {
        }
 
        if ($contact_id) {
-               $groups = init_groups_visitor($contact_id);
+               $groups = Group::getIdsByContactId($contact_id);
                $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
                        intval($contact_id),
                        intval($a->profile['profile_uid'])
index bb0e0c237fd432aff144e5cd804dcdf853432ab5..11b7e21be76ab84823a8367e66832c0525f5dd79 100644 (file)
@@ -6,6 +6,7 @@ use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
+use Friendica\Model\Group;
 
 require_once('include/items.php');
 require_once('include/acl_selectors.php');
@@ -293,7 +294,7 @@ function videos_content(App $a) {
                        }
                }
                if($contact_id) {
-                       $groups = init_groups_visitor($contact_id);
+                       $groups = Group::getIdsByContactId($contact_id);
                        $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
                                intval($contact_id),
                                intval($owner_uid)
index a23b417cc933dd5ff9004d654f3e1c1c95c20b79..db9ec331e46f34bede096b71443e5fc0a69f6836 100644 (file)
@@ -61,7 +61,7 @@ class Group extends BaseObject
         * @param int $cid
         * @return array
         */
-       private static function getIdsByContactId($cid)
+       public static function getIdsByContactId($cid)
        {
                $condition = ['contact-id' => $cid];
                $stmt = dba::select('group_member', ['gid'], $condition);
index eeedd6324de1170c6047a985507639ae112904a1..070cf598acbed34f3f0146716cd632a9ddb3814c 100644 (file)
@@ -14,6 +14,7 @@ use Friendica\Core\Worker;
 use Friendica\Database\DBM;
 use Friendica\Model\Contact;
 use Friendica\Model\GContact;
+use Friendica\Model\Group;
 use Friendica\Model\Profile;
 use Friendica\Model\User;
 use Friendica\Object\Image;
@@ -167,7 +168,7 @@ class DFRN
 
                        $contact = $r[0];
                        include_once 'include/security.php';
-                       $groups = init_groups_visitor($contact['id']);
+                       $groups = Group::getIdsByContactId($contact['id']);
 
                        if (count($groups)) {
                                for ($x = 0; $x < count($groups); $x ++)