From 8e79f1717d5270558ffd30c20cc75840b0ecc955 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 15 Feb 2021 16:07:22 +0300 Subject: [PATCH] prefs: unify naming --- classes/handler/public.php | 2 +- classes/pref/filters.php | 32 ++++++++++++++++---------------- classes/pref/prefs.php | 20 ++++++++++---------- classes/pref/system.php | 4 ++-- classes/pref/users.php | 8 ++++---- classes/rpc.php | 2 +- classes/userhelper.php | 4 ++-- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/classes/handler/public.php b/classes/handler/public.php index b11c8ba04..ea2a0c5ef 100755 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -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 "

"."Completed."."

"; diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 62bcb8f59..95f0fcfc0 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -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 "
  • - ".$this->getRuleName($line)."". + ".$this->_get_rule_name($line)."". format_hidden("rule[]", $data)."
  • "; } } @@ -433,7 +433,7 @@ class Pref_Filters extends Handler_Protected { $data = htmlspecialchars((string)json_encode($line)); print "
  • - ".$this->getActionName($line)."". + ".$this->_get_action_name($line)."". format_hidden("action[]", $data)."
  • "; } } @@ -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 ""; } - 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(); diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 6e4deb223..81b7767eb 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -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 { encryptAppPassword($new_password); + $new_password_hash = $this->_encrypt_app_password($new_password); print_warning(T_sprintf("Generated password %s 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 = ""; diff --git a/classes/pref/system.php b/classes/pref/system.php index 2a97ec6f0..f0a5f7b7f 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -23,7 +23,7 @@ class Pref_System extends Handler_Administrative { print preg_replace( '%^.*(.*).*$%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 {
    '> 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."); } diff --git a/classes/pref/users.php b/classes/pref/users.php index bc125d0ce..d2dd06fd8 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -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 {