1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-13 17:15:55 +00:00

Switch 'Handler_Public->login' to ORM, fix 'Handler_Public->getProfiles'

This commit is contained in:
wn_
2021-03-17 15:49:07 +00:00
parent 7ea48f7a4b
commit f057c124d1

View File

@@ -268,6 +268,7 @@ class Handler_Public extends Handler {
if ($login) { if ($login) {
$profiles = ORM::for_table('ttrss_settings_profiles') $profiles = ORM::for_table('ttrss_settings_profiles')
->table_alias('p') ->table_alias('p')
->select_many('title' , ['profile_id' => 'p.id'])
->join('ttrss_users', ['p.owner_uid', '=', 'u.id'], 'u') ->join('ttrss_users', ['p.owner_uid', '=', 'u.id'], 'u')
->where_raw('LOWER(u.login) = LOWER(?)', [$login]) ->where_raw('LOWER(u.login) = LOWER(?)', [$login])
->order_by_asc('title') ->order_by_asc('title')
@@ -276,7 +277,7 @@ class Handler_Public extends Handler {
$rv = [ [ "value" => 0, "label" => __("Default profile") ] ]; $rv = [ [ "value" => 0, "label" => __("Default profile") ] ];
foreach ($profiles as $profile) { foreach ($profiles as $profile) {
array_push($rv, [ "label" => $profile->title, "value" => $profile->id ]); array_push($rv, [ "label" => $profile->title, "value" => $profile->profile_id ]);
} }
} }
@@ -370,18 +371,13 @@ class Handler_Public extends Handler {
$_SESSION["safe_mode"] = $safe_mode; $_SESSION["safe_mode"] = $safe_mode;
if (!empty($_POST["profile"])) { if (!empty($_POST["profile"])) {
$profile = (int) clean($_POST["profile"]); $profile = (int) clean($_POST["profile"]);
$sth = $this->pdo->prepare("SELECT id FROM ttrss_settings_profiles $profile_obj = ORM::for_table('ttrss_settings_profiles')
WHERE id = ? AND owner_uid = ?"); ->where(['id' => $profile, 'owner_uid' => $_SESSION['uid']])
$sth->execute([$profile, $_SESSION['uid']]); ->find_one();
if ($sth->fetch()) { $_SESSION["profile"] = $profile_obj ? $profile : null;
$_SESSION["profile"] = $profile;
} else {
$_SESSION["profile"] = null;
}
} }
} else { } else {