Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.0 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. <?php
  2. function starred_init(App $a) {
  3. require_once("include/threads.php");
  4. $starred = 0;
  5. if (! local_user()) {
  6. killme();
  7. }
  8. if ($a->argc > 1) {
  9. $message_id = intval($a->argv[1]);
  10. }
  11. if (! $message_id) {
  12. killme();
  13. }
  14. $r = q("SELECT `starred` FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
  15. intval(local_user()),
  16. intval($message_id)
  17. );
  18. if (! dbm::is_result($r)) {
  19. killme();
  20. }
  21. if (! intval($r[0]['starred'])) {
  22. $starred = 1;
  23. }
  24. $r = q("UPDATE `item` SET `starred` = %d WHERE `uid` = %d AND `id` = %d",
  25. intval($starred),
  26. intval(local_user()),
  27. intval($message_id)
  28. );
  29. update_thread($message_id);
  30. // See if we've been passed a return path to redirect to
  31. $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : '');
  32. if ($return_path) {
  33. $rand = '_=' . time();
  34. if (strpos($return_path, '?')) {
  35. $rand = "&$rand";
  36. } else {
  37. $rand = "?$rand";
  38. }
  39. goaway(App::get_baseurl() . "/" . $return_path . $rand);
  40. }
  41. // the json doesn't really matter, it will either be 0 or 1
  42. echo json_encode($starred);
  43. killme();
  44. }