prefs: unify naming

This commit is contained in:
Andrew Dolgov 2021-02-15 16:07:22 +03:00
parent 5704deb460
commit 8e79f1717d
7 changed files with 36 additions and 36 deletions

View File

@ -950,7 +950,7 @@ class Handler_Public extends Handler {
WHERE id = ?");
$sth->execute([$id]);
Pref_Users::resetUserPassword($id, true);
Pref_Users::_reset_password($id, true);
print "<p>"."Completed."."</p>";

View File

@ -162,7 +162,7 @@ class Pref_Filters extends Handler_Protected {
print json_encode($rv);
}
private function getfilterrules_list($filter_id) {
private function _get_rules_list($filter_id) {
$sth = $this->pdo->prepare("SELECT reg_exp,
inverse,
match_on,
@ -250,7 +250,7 @@ class Pref_Filters extends Handler_Protected {
while ($line = $sth->fetch()) {
$name = $this->getFilterName($line["id"]);
$name = $this->_get_name($line["id"]);
$match_ok = false;
if ($filter_search) {
@ -292,7 +292,7 @@ class Pref_Filters extends Handler_Protected {
$filter['checkbox'] = false;
$filter['last_triggered'] = $line["last_triggered"] ? TimeHelper::make_local_datetime($line["last_triggered"], false) : null;
$filter['enabled'] = sql_bool_to_bool($line["enabled"]);
$filter['rules'] = $this->getfilterrules_list($line['id']);
$filter['rules'] = $this->_get_rules_list($line['id']);
if (!$filter_search || $match_ok) {
array_push($folder['items'], $filter);
@ -391,7 +391,7 @@ class Pref_Filters extends Handler_Protected {
$data = htmlspecialchars((string)json_encode($line));
print "<li><input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'>
<span onclick='App.dialogOf(this).editRule(this)'>".$this->getRuleName($line)."</span>".
<span onclick='App.dialogOf(this).editRule(this)'>".$this->_get_rule_name($line)."</span>".
format_hidden("rule[]", $data)."</li>";
}
}
@ -433,7 +433,7 @@ class Pref_Filters extends Handler_Protected {
$data = htmlspecialchars((string)json_encode($line));
print "<li><input dojoType='dijit.form.CheckBox' type='checkbox' onclick='Lists.onRowChecked(this)'>
<span onclick='App.dialogOf(this).editAction(this)'>".$this->getActionName($line)."</span>".
<span onclick='App.dialogOf(this).editAction(this)'>".$this->_get_action_name($line)."</span>".
format_hidden("action[]", $data)."</li>";
}
}
@ -482,7 +482,7 @@ class Pref_Filters extends Handler_Protected {
}
}
private function getRuleName($rule) {
private function _get_rule_name($rule) {
if (!$rule) $rule = json_decode(clean($_REQUEST["rule"]), true);
$feeds = $rule["feed_id"];
@ -523,10 +523,10 @@ class Pref_Filters extends Handler_Protected {
}
function printRuleName() {
print $this->getRuleName(json_decode(clean($_REQUEST["rule"]), true));
print $this->_get_rule_name(json_decode(clean($_REQUEST["rule"]), true));
}
private function getActionName($action) {
private function _get_action_name($action) {
$sth = $this->pdo->prepare("SELECT description FROM
ttrss_filter_actions WHERE id = ?");
$sth->execute([(int)$action["action_id"]]);
@ -561,7 +561,7 @@ class Pref_Filters extends Handler_Protected {
}
function printActionName() {
print $this->getActionName(json_decode(clean($_REQUEST["action"]), true));
print $this->_get_action_name(json_decode(clean($_REQUEST["action"]), true));
}
function editSave() {
@ -581,7 +581,7 @@ class Pref_Filters extends Handler_Protected {
$sth->execute([$enabled, $match_any_rule, $inverse, $title, $filter_id, $_SESSION['uid']]);
$this->saveRulesAndActions($filter_id);
$this->_save_rules_and_actions($filter_id);
$this->pdo->commit();
}
@ -596,7 +596,7 @@ class Pref_Filters extends Handler_Protected {
$sth->execute(array_merge($ids, [$_SESSION['uid']]));
}
private function saveRulesAndActions($filter_id)
private function _save_rules_and_actions($filter_id)
{
$sth = $this->pdo->prepare("DELETE FROM ttrss_filters2_rules WHERE filter_id = ?");
@ -696,7 +696,7 @@ class Pref_Filters extends Handler_Protected {
if ($row = $sth->fetch()) {
$filter_id = $row['id'];
$this->saveRulesAndActions($filter_id);
$this->_save_rules_and_actions($filter_id);
}
$this->pdo->commit();
@ -941,7 +941,7 @@ class Pref_Filters extends Handler_Protected {
print "</form>";
}
private function getFilterName($id) {
private function _get_name($id) {
$sth = $this->pdo->prepare(
"SELECT title,match_any_rule,f.inverse AS inverse,COUNT(DISTINCT r.id) AS num_rules,COUNT(DISTINCT a.id) AS num_actions
@ -970,7 +970,7 @@ class Pref_Filters extends Handler_Protected {
$actions = "";
if ($line = $sth->fetch()) {
$actions = $this->getActionName($line);
$actions = $this->_get_action_name($line);
$num_actions -= 1;
}
@ -1012,12 +1012,12 @@ class Pref_Filters extends Handler_Protected {
$this->pdo->commit();
$this->optimizeFilter($base_id);
$this->_optimize($base_id);
}
}
private function optimizeFilter($id) {
private function _optimize($id) {
$this->pdo->beginTransaction();

View File

@ -268,7 +268,7 @@ class Pref_Prefs extends Handler_Protected {
AND owner_uid = :uid");
$sth->execute([":profile" => $_SESSION['profile'], ":uid" => $_SESSION['uid']]);
$this->initialize_user_prefs($_SESSION["uid"], $_SESSION["profile"]);
$this->_init_user_prefs($_SESSION["uid"], $_SESSION["profile"]);
echo __("Your preferences are now set to default values.");
}
@ -588,9 +588,9 @@ class Pref_Prefs extends Handler_Protected {
if ($profile) {
print_notice(__("Some preferences are only available in default profile."));
$this->initialize_user_prefs($_SESSION["uid"], $profile);
$this->_init_user_prefs($_SESSION["uid"], $profile);
} else {
$this->initialize_user_prefs($_SESSION["uid"]);
$this->_init_user_prefs($_SESSION["uid"]);
}
$prefs_available = [];
@ -621,7 +621,7 @@ class Pref_Prefs extends Handler_Protected {
}
$pref_name = $line["pref_name"];
$short_desc = $this->getShortDesc($pref_name);
$short_desc = $this->_get_short_desc($pref_name);
if (!$short_desc)
continue;
@ -629,7 +629,7 @@ class Pref_Prefs extends Handler_Protected {
$prefs_available[$pref_name] = [
'type_name' => $line["type_name"],
'value' => $line['value'],
'help_text' => $this->getHelpText($pref_name),
'help_text' => $this->_get_help_text($pref_name),
'short_desc' => $short_desc
];
}
@ -1318,14 +1318,14 @@ class Pref_Prefs extends Handler_Protected {
}
private function getShortDesc($pref_name) {
private function _get_short_desc($pref_name) {
if (isset($this->pref_help[$pref_name][0])) {
return $this->pref_help[$pref_name][0];
}
return "";
}
private function getHelpText($pref_name) {
private function _get_help_text($pref_name) {
if (isset($this->pref_help[$pref_name][1])) {
return $this->pref_help[$pref_name][1];
}
@ -1380,7 +1380,7 @@ class Pref_Prefs extends Handler_Protected {
<?php
}
private function encryptAppPassword($password) {
private function _encrypt_app_password($password) {
$salt = substr(bin2hex(get_random_bytes(24)), 0, 24);
return "SSHA-512:".hash('sha512', $salt . $password). ":$salt";
@ -1399,7 +1399,7 @@ class Pref_Prefs extends Handler_Protected {
function generateAppPassword() {
$title = clean($_REQUEST['title']);
$new_password = make_password(16);
$new_password_hash = $this->encryptAppPassword($new_password);
$new_password_hash = $this->_encrypt_app_password($new_password);
print_warning(T_sprintf("Generated password <strong>%s</strong> for %s. Please remember it for future reference.", $new_password, $title));
@ -1413,7 +1413,7 @@ class Pref_Prefs extends Handler_Protected {
$this->appPasswordList();
}
static function initialize_user_prefs($uid, $profile = false) {
static function _init_user_prefs($uid, $profile = false) {
if (get_schema_version() < 63) $profile_qpart = "";

View File

@ -23,7 +23,7 @@ class Pref_System extends Handler_Administrative {
print preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', (string)$info);
}
private function log_viewer(int $page, int $severity) {
private function _log_viewer(int $page, int $severity) {
$errno_values = [];
switch ($severity) {
@ -154,7 +154,7 @@ class Pref_System extends Handler_Administrative {
<div dojoType='dijit.layout.AccordionPane' style='padding : 0' title='<i class="material-icons">report</i> <?= __('Event Log') ?>'>
<?php
if (LOG_DESTINATION == "sql") {
$this->log_viewer($page, $severity);
$this->_log_viewer($page, $severity);
} else {
print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging.");
}

View File

@ -166,7 +166,7 @@ class Pref_Users extends Handler_Administrative {
}
}
static function resetUserPassword($uid, $format_output = false) {
static function _reset_password($uid, $format_output = false) {
$pdo = Db::pdo();
@ -199,7 +199,7 @@ class Pref_Users extends Handler_Administrative {
function resetPass() {
$uid = clean($_REQUEST["id"]);
self::resetUserPassword($uid);
self::_reset_password($uid);
}
function index() {
@ -220,7 +220,7 @@ class Pref_Users extends Handler_Administrative {
$sort = "login";
}
$sort = $this->validate_field($sort,
$sort = $this->_validate_field($sort,
["login", "access_level", "created", "num_feeds", "created", "last_login"], "login");
if ($sort != "login") $sort = "$sort DESC";
@ -314,7 +314,7 @@ class Pref_Users extends Handler_Administrative {
<?php
}
function validate_field($string, $allowed, $default = "") {
private function _validate_field($string, $allowed, $default = "") {
if (in_array($string, $allowed))
return $string;
else

View File

@ -52,7 +52,7 @@ class RPC extends Handler_Protected {
$profile_id = $row['id'];
if ($profile_id) {
Pref_Prefs::initialize_user_prefs($_SESSION["uid"], $profile_id);
Pref_Prefs::_init_user_prefs($_SESSION["uid"], $profile_id);
}
}
}

View File

@ -41,7 +41,7 @@ class UserHelper {
$_SESSION["user_agent"] = sha1($_SERVER['HTTP_USER_AGENT']);
$_SESSION["pwd_hash"] = $row["pwd_hash"];
Pref_Prefs::initialize_user_prefs($_SESSION["uid"]);
Pref_Prefs::_init_user_prefs($_SESSION["uid"]);
return true;
}
@ -64,7 +64,7 @@ class UserHelper {
$_SESSION["ip_address"] = UserHelper::get_user_ip();
Pref_Prefs::initialize_user_prefs($_SESSION["uid"]);
Pref_Prefs::_init_user_prefs($_SESSION["uid"]);
return true;
}