1
1
Fork 0

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

@ -355,7 +355,7 @@ function feed_birthday($uid, $tz)
$tz = 'UTC'; $tz = 'UTC';
} }
$profile = DBA::selectFirst('profile', ['dob'], ['is-default' => true, 'uid' => $uid]); $profile = DBA::selectFirst('profile', ['dob'], ['uid' => $uid]);
if (DBA::isResult($profile)) { if (DBA::isResult($profile)) {
$tmp_dob = substr($profile['dob'], 5); $tmp_dob = substr($profile['dob'], 5);
if (intval($tmp_dob)) { if (intval($tmp_dob)) {

View file

@ -102,7 +102,7 @@ function display_init(App $a)
if ($nickname != $a->user["nickname"]) { if ($nickname != $a->user["nickname"]) {
$profile = DBA::fetchFirst("SELECT `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile` $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` 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 $nickname
); );
if (DBA::isResult($profile)) { if (DBA::isResult($profile)) {

View file

@ -26,8 +26,7 @@ function msearch_post(App $a)
"SELECT COUNT(*) AS `total` "SELECT COUNT(*) AS `total`
FROM `profile` FROM `profile`
JOIN `user` ON `user`.`uid` = `profile`.`uid` JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE `is-default` = 1 WHERE `user`.`hidewall` = 0
AND `user`.`hidewall` = 0
AND MATCH(`pub_keywords`) AGAINST (?)", AND MATCH(`pub_keywords`) AGAINST (?)",
$search $search
); );
@ -42,8 +41,7 @@ function msearch_post(App $a)
"SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` "SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid`
FROM `user` FROM `user`
JOIN `profile` ON `user`.`uid` = `profile`.`uid` JOIN `profile` ON `user`.`uid` = `profile`.`uid`
WHERE `is-default` = 1 WHERE `user`.`hidewall` = 0
AND `user`.`hidewall` = 0
AND MATCH(`pub_keywords`) AGAINST (?) AND MATCH(`pub_keywords`) AGAINST (?)
LIMIT ?, ?", LIMIT ?, ?",
$search, $search,

View file

@ -67,7 +67,7 @@ function poco_init(App $a) {
if (! $system_mode && ! $global) { if (! $system_mode && ! $global) {
$users = q("SELECT `user`.*,`profile`.`hide-friends` from user left join profile on `user`.`uid` = `profile`.`uid` $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) DBA::escape($nickname)
); );
if (! DBA::isResult($users) || $users[0]['hidewall'] || $users[0]['hide-friends']) { 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` `profile`.`postal-code` AS `ppostalcode`, `profile`.`country-name` AS `pcountry`, `user`.`account-type`
FROM `contact` INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid` FROM `contact` INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid`
INNER JOIN `user` ON `user`.`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", AND `contact`.`uid` IN (SELECT `uid` FROM `pconfig` WHERE `cat` = 'system' AND `k` = 'suggestme' AND `v` = 1) LIMIT %d, %d",
intval($startIndex), intval($startIndex),
intval($itemsPerPage) intval($itemsPerPage)

View file

@ -27,7 +27,7 @@ function user_allow($hash)
DBA::update('user', ['blocked' => false, 'verified' => true], ['uid' => $register['uid']]); 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')) { if (DBA::isResult($profile) && $profile['net-publish'] && DI::config()->get('system', 'directory')) {
$url = DI::baseUrl() . '/profile/' . $user['nickname']; $url = DI::baseUrl() . '/profile/' . $user['nickname'];

View file

@ -611,7 +611,7 @@ function settings_post(App $a)
`name` = '%s', `name` = '%s',
`net-publish` = %d, `net-publish` = %d,
`hide-friends` = %d `hide-friends` = %d
WHERE `is-default` = 1 AND `uid` = %d", WHERE `uid` = %d",
intval($publish), intval($publish),
DBA::escape($username), DBA::escape($username),
intval($net_publish), intval($net_publish),
@ -978,7 +978,7 @@ function settings_content(App $a)
* ACCOUNT SETTINGS * ACCOUNT SETTINGS
*/ */
$profile = DBA::selectFirst('profile', [], ['is-default' => true, 'uid' => local_user()]); $profile = DBA::selectFirst('profile', [], ['uid' => local_user()]);
if (!DBA::isResult($profile)) { if (!DBA::isResult($profile)) {
notice(DI::l10n()->t('Unable to find your profile. Please contact your admin.') . EOL); notice(DI::l10n()->t('Unable to find your profile. Please contact your admin.') . EOL);
return; return;

View file

@ -723,7 +723,7 @@ class Contact
$fields = ['name', 'photo', 'thumb', 'about', 'address', 'locality', 'region', $fields = ['name', 'photo', 'thumb', 'about', 'address', 'locality', 'region',
'country-name', 'gender', 'pub_keywords', 'xmpp', 'net-publish']; '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)) { if (!DBA::isResult($profile)) {
return; return;
} }
@ -800,7 +800,7 @@ class Contact
// Update the profile // Update the profile
$fields = ['photo' => DI::baseUrl() . '/photo/profile/' .$uid . '.' . $file_suffix, $fields = ['photo' => DI::baseUrl() . '/photo/profile/' .$uid . '.' . $file_suffix,
'thumb' => DI::baseUrl() . '/photo/avatar/' . $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) public static function getByUID($uid)
{ {
$profile = DBA::selectFirst('profile', [], ['uid' => $uid, 'is-default' => true]); return DBA::selectFirst('profile', [], ['uid' => $uid]);
return $profile;
} }
/** /**
@ -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)) { if (empty($profile) && empty($profiledata)) {
Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG); Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG);
@ -159,17 +158,7 @@ class Profile
} }
if (empty($profile)) { if (empty($profile)) {
$profile = ['uid' => 0, 'is-default' => false,'name' => $nickname]; $profile = ['uid' => 0, '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'];
}
} }
$a->profile = $profile; $a->profile = $profile;
@ -1031,7 +1020,7 @@ class Profile
*/ */
public static function searchProfiles($start = 0, $count = 100, $search = null) 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; $total = 0;
if (!empty($search)) { if (!empty($search)) {
@ -1039,7 +1028,7 @@ class Profile
$cnt = DBA::fetchFirst("SELECT COUNT(*) AS `total` $cnt = DBA::fetchFirst("SELECT COUNT(*) AS `total`
FROM `profile` FROM `profile`
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` 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 AND ((`profile`.`name` LIKE ?) OR
(`user`.`nickname` LIKE ?) OR (`user`.`nickname` LIKE ?) OR
(`profile`.`pdesc` LIKE ?) OR (`profile`.`pdesc` LIKE ?) OR
@ -1061,7 +1050,7 @@ class Profile
$cnt = DBA::fetchFirst("SELECT COUNT(*) AS `total` $cnt = DBA::fetchFirst("SELECT COUNT(*) AS `total`
FROM `profile` FROM `profile`
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` 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)) { if (DBA::isResult($cnt)) {
@ -1081,7 +1070,7 @@ class Profile
FROM `profile` FROM `profile`
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
LEFT JOIN `contact` ON `contact`.`uid` = `user`.`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 AND ((`profile`.`name` LIKE ?) OR
(`user`.`nickname` LIKE ?) OR (`user`.`nickname` LIKE ?) OR
(`profile`.`pdesc` LIKE ?) OR (`profile`.`pdesc` LIKE ?) OR
@ -1108,7 +1097,7 @@ class Profile
FROM `profile` FROM `profile`
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
LEFT JOIN `contact` ON `contact`.`uid` = `user`.`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 ?,?", $order LIMIT ?,?",
$start, $count $start, $count
); );

View file

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

View file

@ -115,10 +115,7 @@ class Index extends BaseSettingsModule
'prv_keywords' => $prv_keywords, 'prv_keywords' => $prv_keywords,
'hide-friends' => $hide_friends, 'hide-friends' => $hide_friends,
], ],
[ ['uid' => local_user()]
'uid' => local_user(),
'is-default' => true,
]
); );
if ($result) { if ($result) {

View file

@ -224,7 +224,7 @@ class Transmitter
} }
$fields = ['locality', 'region', 'country-name']; $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)) { if (!DBA::isResult($profile)) {
return []; return [];
} }

View file

@ -687,7 +687,7 @@ class DFRN
`profile`.`pub_keywords`, `profile`.`xmpp`, `profile`.`dob` `profile`.`pub_keywords`, `profile`.`xmpp`, `profile`.`dob`
FROM `profile` FROM `profile`
INNER JOIN `user` ON `user`.`uid` = `profile`.`uid` 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']) intval($owner['uid'])
); );
if (DBA::isResult($r)) { if (DBA::isResult($r)) {

View file

@ -4092,7 +4092,7 @@ class Diaspora
FROM `profile` FROM `profile`
INNER JOIN `user` ON `profile`.`uid` = `user`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid`
INNER JOIN `contact` ON `profile`.`uid` = `contact`.`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) intval($uid)
); );

View file

@ -1428,7 +1428,7 @@ class OStatus
*/ */
private static function addAuthor(DOMDocument $doc, array $owner, $show_profile = true) 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"); $author = $doc->createElement("author");
XML::addElement($doc, $author, "id", $owner["url"]); XML::addElement($doc, $author, "id", $owner["url"]);
if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) { if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {

View file

@ -46,7 +46,7 @@ class Directory
$r = q("SELECT `url` FROM `contact` $r = q("SELECT `url` FROM `contact`
INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid` INNER JOIN `profile` ON `profile`.`uid` = `contact`.`uid`
INNER JOIN `user` ON `user`.`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`"); NOT `user`.`account_expired` AND `user`.`verified`");
if (DBA::isResult($r)) { if (DBA::isResult($r)) {

View file

@ -140,14 +140,14 @@ function vier_community_info()
// last 9 users // last 9 users
if ($show_lastusers) { 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 "; $order = " ORDER BY `register_date` DESC ";
$tpl = Renderer::getMarkupTemplate('ch_directory_item.tpl'); $tpl = Renderer::getMarkupTemplate('ch_directory_item.tpl');
$r = q("SELECT `profile`.*, `user`.`nickname` $r = q("SELECT `profile`.*, `user`.`nickname`
FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` 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, 0,
9 9
); );