Remove references to deprecated profile.is-default and profile.profile-name fields

This commit is contained in:
Hypolite Petovan 2020-01-22 19:34:15 -05:00
parent d9f7556b4a
commit 18cfd8dfaa
16 changed files with 28 additions and 46 deletions

View file

@ -723,7 +723,7 @@ class Contact
$fields = ['name', 'photo', 'thumb', 'about', 'address', 'locality', 'region',
'country-name', 'gender', 'pub_keywords', 'xmpp', 'net-publish'];
$profile = DBA::selectFirst('profile', $fields, ['uid' => $uid, 'is-default' => true]);
$profile = DBA::selectFirst('profile', $fields, ['uid' => $uid]);
if (!DBA::isResult($profile)) {
return;
}
@ -800,7 +800,7 @@ class Contact
// Update the profile
$fields = ['photo' => DI::baseUrl() . '/photo/profile/' .$uid . '.' . $file_suffix,
'thumb' => DI::baseUrl() . '/photo/avatar/' . $uid .'.' . $file_suffix];
DBA::update('profile', $fields, ['uid' => $uid, 'is-default' => true]);
DBA::update('profile', $fields, ['uid' => $uid]);
}
}

View file

@ -35,8 +35,7 @@ class Profile
*/
public static function getByUID($uid)
{
$profile = DBA::selectFirst('profile', [], ['uid' => $uid, 'is-default' => true]);
return $profile;
return DBA::selectFirst('profile', [], ['uid' => $uid]);
}
/**
@ -151,7 +150,7 @@ class Profile
}
}
$profile = self::getByNickname($nickname, $user['uid'], $profile_id);
$profile = self::getByNickname($nickname, $user['uid']);
if (empty($profile) && empty($profiledata)) {
Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG);
@ -159,17 +158,7 @@ class Profile
}
if (empty($profile)) {
$profile = ['uid' => 0, 'is-default' => false,'name' => $nickname];
}
// fetch user tags if this isn't the default profile
if (!$profile['is-default']) {
$condition = ['uid' => $profile['uid'], 'is-default' => true];
$profile_id = DBA::selectFirst('profile', ['pub_keywords'], $condition);
if (DBA::isResult($profile_id)) {
$profile['pub_keywords'] = $profile_id['pub_keywords'];
}
$profile = ['uid' => 0, 'name' => $nickname];
}
$a->profile = $profile;
@ -1031,7 +1020,7 @@ class Profile
*/
public static function searchProfiles($start = 0, $count = 100, $search = null)
{
$publish = (DI::config()->get('system', 'publish_all') ? '' : " AND `publish` = 1 ");
$publish = (DI::config()->get('system', 'publish_all') ? '' : "`publish` = 1");
$total = 0;
if (!empty($search)) {
@ -1039,7 +1028,7 @@ class Profile
$cnt = DBA::fetchFirst("SELECT COUNT(*) AS `total`
FROM `profile`
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE `is-default` $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed`
WHERE $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed`
AND ((`profile`.`name` LIKE ?) OR
(`user`.`nickname` LIKE ?) OR
(`profile`.`pdesc` LIKE ?) OR
@ -1061,7 +1050,7 @@ class Profile
$cnt = DBA::fetchFirst("SELECT COUNT(*) AS `total`
FROM `profile`
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE `is-default` $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed`");
WHERE $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed`");
}
if (DBA::isResult($cnt)) {
@ -1081,7 +1070,7 @@ class Profile
FROM `profile`
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`
WHERE `is-default` $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed` AND `contact`.`self`
WHERE $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed` AND `contact`.`self`
AND ((`profile`.`name` LIKE ?) OR
(`user`.`nickname` LIKE ?) OR
(`profile`.`pdesc` LIKE ?) OR
@ -1108,7 +1097,7 @@ class Profile
FROM `profile`
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
LEFT JOIN `contact` ON `contact`.`uid` = `user`.`uid`
WHERE `is-default` $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed` AND `contact`.`self`
WHERE $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed` AND `contact`.`self`
$order LIMIT ?,?",
$start, $count
);

View file

@ -782,9 +782,7 @@ class User
'photo' => DI::baseUrl() . "/photo/profile/{$uid}.jpg",
'thumb' => DI::baseUrl() . "/photo/avatar/{$uid}.jpg",
'publish' => $publish,
'is-default' => 1,
'net-publish' => $netpublish,
'profile-name' => DI::l10n()->t('default')
]);
if (!$insert_result) {
DBA::delete('user', ['uid' => $uid]);
@ -1113,7 +1111,7 @@ class User
$userStmt = DBA::p("SELECT `user`.`uid`, `user`.`login_date`, `contact`.`last-item`
FROM `user`
INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid` AND `profile`.`is-default`
INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid`
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
WHERE (`profile`.`publish` OR `profile`.`net-publish`) AND `user`.`verified`
AND NOT `user`.`blocked` AND NOT `user`.`account_removed`