mirror of
https://github.com/friendica/friendica
synced 2025-04-30 11:04:29 +02:00
We now use the new account-user-view (and fixed the function name)
This commit is contained in:
parent
780d9f1793
commit
d267ba999c
17 changed files with 97 additions and 36 deletions
|
@ -332,7 +332,7 @@ class Contact
|
|||
return false;
|
||||
}
|
||||
|
||||
$cdata = self::getPublicAndUserContacID($cid, $uid);
|
||||
$cdata = self::getPublicAndUserContactID($cid, $uid);
|
||||
if (empty($cdata['user'])) {
|
||||
return false;
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ class Contact
|
|||
return false;
|
||||
}
|
||||
|
||||
$cdata = self::getPublicAndUserContacID($cid, $uid);
|
||||
$cdata = self::getPublicAndUserContactID($cid, $uid);
|
||||
if (empty($cdata['user'])) {
|
||||
return false;
|
||||
}
|
||||
|
@ -507,7 +507,48 @@ class Contact
|
|||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
public static function getPublicAndUserContacID($cid, $uid)
|
||||
public static function getPublicAndUserContactID($cid, $uid)
|
||||
{
|
||||
// We have to use the legacy function as long as the post update hasn't finished
|
||||
if (DI::config()->get('system', 'post_update_version') < 1427) {
|
||||
return self::legacyGetPublicAndUserContactID($cid, $uid);
|
||||
}
|
||||
|
||||
if (empty($uid) || empty($cid)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$contact = DBA::selectFirst('account-user-view', ['id', 'uid', 'pid'], ['id' => $cid]);
|
||||
if (!DBA::isResult($contact) || !in_array($contact['uid'], [0, $uid])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$pcid = $contact['pid'];
|
||||
if ($contact['uid'] == $uid) {
|
||||
$ucid = $contact['id'];
|
||||
} else {
|
||||
$contact = DBA::selectFirst('account-user-view', ['id', 'uid'], ['pid' => $cid, 'uid' => $uid]);
|
||||
if (DBA::isResult($contact)) {
|
||||
$ucid = $contact['id'];
|
||||
} else {
|
||||
$ucid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ['public' => $pcid, 'user' => $ucid];
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for "getPublicAndUserContactID"
|
||||
*
|
||||
* @param int $cid Either public contact id or user's contact id
|
||||
* @param int $uid User ID
|
||||
*
|
||||
* @return array with public and user's contact id
|
||||
* @throws HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
private static function legacyGetPublicAndUserContactID($cid, $uid)
|
||||
{
|
||||
if (empty($uid) || empty($cid)) {
|
||||
return [];
|
||||
|
@ -2588,7 +2629,7 @@ class Contact
|
|||
*/
|
||||
public static function unfollow(int $cid, int $uid)
|
||||
{
|
||||
$cdata = self::getPublicAndUserContacID($cid, $uid);
|
||||
$cdata = self::getPublicAndUserContactID($cid, $uid);
|
||||
if (empty($cdata['user'])) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class User
|
|||
*/
|
||||
public static function setBlocked($cid, $uid, $blocked)
|
||||
{
|
||||
$cdata = Contact::getPublicAndUserContacID($cid, $uid);
|
||||
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
||||
if (empty($cdata)) {
|
||||
return;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class User
|
|||
*/
|
||||
public static function isBlocked($cid, $uid)
|
||||
{
|
||||
$cdata = Contact::getPublicAndUserContacID($cid, $uid);
|
||||
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
||||
if (empty($cdata)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ class User
|
|||
*/
|
||||
public static function setIgnored($cid, $uid, $ignored)
|
||||
{
|
||||
$cdata = Contact::getPublicAndUserContacID($cid, $uid);
|
||||
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
||||
if (empty($cdata)) {
|
||||
return;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ class User
|
|||
*/
|
||||
public static function isIgnored($cid, $uid)
|
||||
{
|
||||
$cdata = Contact::getPublicAndUserContacID($cid, $uid);
|
||||
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
||||
if (empty($cdata)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ class User
|
|||
*/
|
||||
public static function setCollapsed($cid, $uid, $collapsed)
|
||||
{
|
||||
$cdata = Contact::getPublicAndUserContacID($cid, $uid);
|
||||
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
||||
if (empty($cdata)) {
|
||||
return;
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ class User
|
|||
*/
|
||||
public static function isCollapsed($cid, $uid)
|
||||
{
|
||||
$cdata = Contact::getPublicAndUserContacID($cid, $uid);
|
||||
$cdata = Contact::getPublicAndUserContactID($cid, $uid);
|
||||
if (empty($cdata)) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue