init.php 947 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. class UI_Gravatar extends Plugin {
  3. private $host;
  4. private $gravatar_hash = "";
  5. function about() {
  6. return array(1.0,
  7. "Shows your globally recognized avatar (Gravatar) in the UI",
  8. "fox",
  9. false,
  10. "https://git.tt-rss.org/fox/ttrss-ui-gravatar");
  11. }
  12. function init($host) {
  13. $this->host = $host;
  14. $sth = $this->pdo->prepare("SELECT email FROM ttrss_users WHERE id = ?");
  15. $sth->execute([$_SESSION['uid']]);
  16. if ($row = $sth->fetch()) {
  17. $this->gravatar_hash = md5(trim($row['email']));
  18. }
  19. //$host->add_hook($host::HOOK_PREFS_TAB, $this);
  20. }
  21. function get_js() {
  22. if ($this->gravatar_hash) {
  23. return str_replace("%GRAVATAR_HASH%", $this->gravatar_hash,
  24. file_get_contents(__DIR__ . "/init.js"));
  25. } else {
  26. return "";
  27. }
  28. }
  29. function get_css() {
  30. if ($this->gravatar_hash) {
  31. return file_get_contents(__DIR__ . "/init.css");
  32. } else {
  33. return "";
  34. }
  35. }
  36. function api_version() {
  37. return 2;
  38. }
  39. }