From 18cfd8dfaaa65859e773641c908fe588dc726768 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 22 Jan 2020 19:34:15 -0500 Subject: [PATCH] Remove references to deprecated profile.is-default and profile.profile-name fields --- boot.php | 2 +- mod/display.php | 2 +- mod/msearch.php | 6 ++---- mod/poco.php | 4 ++-- mod/regmod.php | 2 +- mod/settings.php | 4 ++-- src/Model/Contact.php | 4 ++-- src/Model/Profile.php | 27 +++++++----------------- src/Model/User.php | 4 +--- src/Module/Settings/Profile/Index.php | 5 +---- src/Protocol/ActivityPub/Transmitter.php | 2 +- src/Protocol/DFRN.php | 2 +- src/Protocol/Diaspora.php | 2 +- src/Protocol/OStatus.php | 2 +- src/Worker/Directory.php | 2 +- view/theme/vier/theme.php | 4 ++-- 16 files changed, 28 insertions(+), 46 deletions(-) diff --git a/boot.php b/boot.php index 4e1249e19..2bcbb4ebd 100644 --- a/boot.php +++ b/boot.php @@ -355,7 +355,7 @@ function feed_birthday($uid, $tz) $tz = 'UTC'; } - $profile = DBA::selectFirst('profile', ['dob'], ['is-default' => true, 'uid' => $uid]); + $profile = DBA::selectFirst('profile', ['dob'], ['uid' => $uid]); if (DBA::isResult($profile)) { $tmp_dob = substr($profile['dob'], 5); if (intval($tmp_dob)) { diff --git a/mod/display.php b/mod/display.php index b5edafc5f..8be552013 100644 --- a/mod/display.php +++ b/mod/display.php @@ -102,7 +102,7 @@ function display_init(App $a) if ($nickname != $a->user["nickname"]) { $profile = DBA::fetchFirst("SELECT `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile` INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid` - WHERE `user`.`nickname` = ? AND `profile`.`is-default` AND `contact`.`self` LIMIT 1", + WHERE `user`.`nickname` = ? AND `contact`.`self` LIMIT 1", $nickname ); if (DBA::isResult($profile)) { diff --git a/mod/msearch.php b/mod/msearch.php index 67b8ea6fd..958477600 100644 --- a/mod/msearch.php +++ b/mod/msearch.php @@ -26,8 +26,7 @@ function msearch_post(App $a) "SELECT COUNT(*) AS `total` FROM `profile` JOIN `user` ON `user`.`uid` = `profile`.`uid` - WHERE `is-default` = 1 - AND `user`.`hidewall` = 0 + WHERE `user`.`hidewall` = 0 AND MATCH(`pub_keywords`) AGAINST (?)", $search ); @@ -42,8 +41,7 @@ function msearch_post(App $a) "SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` FROM `user` JOIN `profile` ON `user`.`uid` = `profile`.`uid` - WHERE `is-default` = 1 - AND `user`.`hidewall` = 0 + WHERE `user`.`hidewall` = 0 AND MATCH(`pub_keywords`) AGAINST (?) LIMIT ?, ?", $search, diff --git a/mod/poco.php b/mod/poco.php index 8e7d63418..d8941e51a 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -67,7 +67,7 @@ function poco_init(App $a) { if (! $system_mode && ! $global) { $users = q("SELECT `user`.*,`profile`.`hide-friends` from user left join profile on `user`.`uid` = `profile`.`uid` - where `user`.`nickname` = '%s' and `profile`.`is-default` = 1 limit 1", + where `user`.`nickname` = '%s' limit 1", DBA::escape($nickname) ); if (! DBA::isResult($users) || $users[0]['hidewall'] || $users[0]['hide-friends']) { @@ -140,7 +140,7 @@ function poco_init(App $a) { `profile`.`postal-code` AS `ppostalcode`, `profile`.`country-name` AS `pcountry`, `user`.`account-type` FROM `contact` INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid` - WHERE `self` = 1 AND `profile`.`is-default` + WHERE `self` = 1 AND `contact`.`uid` IN (SELECT `uid` FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1) LIMIT %d, %d", intval($startIndex), intval($itemsPerPage) diff --git a/mod/regmod.php b/mod/regmod.php index a3039b798..ed030723d 100644 --- a/mod/regmod.php +++ b/mod/regmod.php @@ -27,7 +27,7 @@ function user_allow($hash) DBA::update('user', ['blocked' => false, 'verified' => true], ['uid' => $register['uid']]); - $profile = DBA::selectFirst('profile', ['net-publish'], ['uid' => $register['uid'], 'is-default' => true]); + $profile = DBA::selectFirst('profile', ['net-publish'], ['uid' => $register['uid']]); if (DBA::isResult($profile) && $profile['net-publish'] && DI::config()->get('system', 'directory')) { $url = DI::baseUrl() . '/profile/' . $user['nickname']; diff --git a/mod/settings.php b/mod/settings.php index a07ad24cc..3ba5dc2b3 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -611,7 +611,7 @@ function settings_post(App $a) `name` = '%s', `net-publish` = %d, `hide-friends` = %d - WHERE `is-default` = 1 AND `uid` = %d", + WHERE `uid` = %d", intval($publish), DBA::escape($username), intval($net_publish), @@ -978,7 +978,7 @@ function settings_content(App $a) * ACCOUNT SETTINGS */ - $profile = DBA::selectFirst('profile', [], ['is-default' => true, 'uid' => local_user()]); + $profile = DBA::selectFirst('profile', [], ['uid' => local_user()]); if (!DBA::isResult($profile)) { notice(DI::l10n()->t('Unable to find your profile. Please contact your admin.') . EOL); return; diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 08c67f8ef..d20872ed6 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -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]); } } diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 774f419ee..86fb1a94c 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -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 ); diff --git a/src/Model/User.php b/src/Model/User.php index 0e8d11f73..fd7238819 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -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` diff --git a/src/Module/Settings/Profile/Index.php b/src/Module/Settings/Profile/Index.php index ea3df3ca2..b0eb194ed 100644 --- a/src/Module/Settings/Profile/Index.php +++ b/src/Module/Settings/Profile/Index.php @@ -115,10 +115,7 @@ class Index extends BaseSettingsModule 'prv_keywords' => $prv_keywords, 'hide-friends' => $hide_friends, ], - [ - 'uid' => local_user(), - 'is-default' => true, - ] + ['uid' => local_user()] ); if ($result) { diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index c9d39dede..23301456a 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -224,7 +224,7 @@ class Transmitter } $fields = ['locality', 'region', 'country-name']; - $profile = DBA::selectFirst('profile', $fields, ['uid' => $uid, 'is-default' => true]); + $profile = DBA::selectFirst('profile', $fields, ['uid' => $uid]); if (!DBA::isResult($profile)) { return []; } diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index f649df558..424b51906 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -687,7 +687,7 @@ class DFRN `profile`.`pub_keywords`, `profile`.`xmpp`, `profile`.`dob` FROM `profile` INNER JOIN `user` ON `user`.`uid` = `profile`.`uid` - WHERE `profile`.`is-default` AND NOT `user`.`hidewall` AND `user`.`uid` = %d", + WHERE NOT `user`.`hidewall` AND `user`.`uid` = %d", intval($owner['uid']) ); if (DBA::isResult($r)) { diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index beb0485c4..bff56d5af 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -4092,7 +4092,7 @@ class Diaspora FROM `profile` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid` INNER JOIN `contact` ON `profile`.`uid` = `contact`.`uid` - WHERE `user`.`uid` = %d AND `profile`.`is-default` AND `contact`.`self` LIMIT 1", + WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1", intval($uid) ); diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 225c2ec2b..dc30b596f 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -1428,7 +1428,7 @@ class OStatus */ private static function addAuthor(DOMDocument $doc, array $owner, $show_profile = true) { - $profile = DBA::selectFirst('profile', ['homepage', 'publish'], ['uid' => $owner['uid'], 'is-default' => true]); + $profile = DBA::selectFirst('profile', ['homepage', 'publish'], ['uid' => $owner['uid']]); $author = $doc->createElement("author"); XML::addElement($doc, $author, "id", $owner["url"]); if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) { diff --git a/src/Worker/Directory.php b/src/Worker/Directory.php index 4d5393dd8..ac9aeae5b 100644 --- a/src/Worker/Directory.php +++ b/src/Worker/Directory.php @@ -46,7 +46,7 @@ class Directory $r = q("SELECT `url` FROM `contact` INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid` INNER JOIN `user` ON `user`.`uid` = `contact`.`uid` - WHERE `contact`.`self` AND `profile`.`net-publish` AND `profile`.`is-default` AND + WHERE `contact`.`self` AND `profile`.`net-publish` AND NOT `user`.`account_expired` AND `user`.`verified`"); if (DBA::isResult($r)) { diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php index 9188bcbc9..e5d5e1ce9 100644 --- a/view/theme/vier/theme.php +++ b/view/theme/vier/theme.php @@ -140,14 +140,14 @@ function vier_community_info() // last 9 users if ($show_lastusers) { - $publish = (DI::config()->get('system', 'publish_all') ? '' : " AND `publish` = 1 "); + $publish = (DI::config()->get('system', 'publish_all') ? '' : "`publish` = 1"); $order = " ORDER BY `register_date` DESC "; $tpl = Renderer::getMarkupTemplate('ch_directory_item.tpl'); $r = q("SELECT `profile`.*, `user`.`nickname` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` - WHERE `is-default` = 1 $publish AND `user`.`blocked` = 0 $order LIMIT %d , %d ", + WHERE $publish AND `user`.`blocked` = 0 $order LIMIT %d , %d ", 0, 9 );