pdo->prepare("SELECT id, login, access_level, email FROM ttrss_users WHERE id = ?"); $sth->execute([$id]); if ($user = $sth->fetch(PDO::FETCH_ASSOC)) { print json_encode([ "user" => $user, "access_level_names" => $access_level_names ]); } } function userdetails() { $id = (int) clean($_REQUEST["id"]); $sth = $this->pdo->prepare("SELECT login, ".SUBSTRING_FOR_DATE."(last_login,1,16) AS last_login, access_level, (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE owner_uid = id) AS stored_articles, ".SUBSTRING_FOR_DATE."(created,1,16) AS created FROM ttrss_users WHERE id = ?"); $sth->execute([$id]); if ($row = $sth->fetch()) { $last_login = TimeHelper::make_local_datetime( $row["last_login"], true); $created = TimeHelper::make_local_datetime( $row["created"], true); $stored_articles = $row["stored_articles"]; $sth = $this->pdo->prepare("SELECT COUNT(id) as num_feeds FROM ttrss_feeds WHERE owner_uid = ?"); $sth->execute([$id]); $row = $sth->fetch(); $num_feeds = $row["num_feeds"]; ?>
pdo->prepare("SELECT id,title,site_url FROM ttrss_feeds WHERE owner_uid = ? ORDER BY title"); $sth->execute([$id]); ?> find_one($id); if ($user) { $login = clean($_REQUEST["login"]); if ($id == 1) $login = "admin"; if (!$login) return; $user->login = $login; $user->access_level = (int) clean($_REQUEST["access_level"]); $user->email = clean($_REQUEST["email"]); $user->save(); } if ($password) { UserHelper::reset_password($uid, false, $password); } } function remove() { $ids = explode(",", clean($_REQUEST["ids"])); foreach ($ids as $id) { if ($id != $_SESSION["uid"] && $id != 1) { $sth = $this->pdo->prepare("DELETE FROM ttrss_tags WHERE owner_uid = ?"); $sth->execute([$id]); $sth = $this->pdo->prepare("DELETE FROM ttrss_feeds WHERE owner_uid = ?"); $sth->execute([$id]); $sth = $this->pdo->prepare("DELETE FROM ttrss_users WHERE id = ?"); $sth->execute([$id]); } } } function add() { $login = clean($_REQUEST["login"]); $tmp_user_pwd = make_password(); $salt = UserHelper::get_salt(); $pwd_hash = UserHelper::hash_password($tmp_user_pwd, $salt, UserHelper::HASH_ALGOS[0]); if (!$login) return; // no blank usernames if (!UserHelper::find_user_by_login($login)) { $sth = $this->pdo->prepare("INSERT INTO ttrss_users (login,pwd_hash,access_level,last_login,created, salt) VALUES (LOWER(?), ?, 0, null, NOW(), ?)"); $sth->execute([$login, $pwd_hash, $salt]); if ($new_uid = UserHelper::find_user_by_login($login)) { print T_sprintf("Added user %s with password %s", $login, $tmp_user_pwd); } else { print T_sprintf("Could not create user %s", $login); } } else { print T_sprintf("User %s already exists.", $login); } } function resetPass() { UserHelper::reset_password(clean($_REQUEST["id"])); } function index() { global $access_level_names; $user_search = clean($_REQUEST["search"] ?? ""); if (array_key_exists("search", $_REQUEST)) { $_SESSION["prefs_user_search"] = $user_search; } else { $user_search = ($_SESSION["prefs_user_search"] ?? ""); } $sort = clean($_REQUEST["sort"] ?? ""); if (!$sort || $sort == "undefined") { $sort = "login"; } if (!in_array($sort, ["login", "access_level", "created", "num_feeds", "created", "last_login"])) $sort = "login"; if ($sort != "login") $sort = "$sort DESC"; ?>
run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefUsersToolbar") ?>
table_alias('u') ->left_outer_join("ttrss_feeds", ["owner_uid", "=", "u.id"], 'f') ->select_expr('u.*,COUNT(f.id) AS num_feeds') ->where_like("login", $user_search ? "%$user_search%" : "%") ->order_by_expr($sort) ->group_by_expr('u.id') ->find_many(); foreach ($users as $user) { ?>
person
run_hooks(PluginHost::HOOK_PREFS_TAB, "prefUsers") ?>