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.

82 lines
1.6KB

  1. <?php
  2. /**
  3. * @file mod/notes.php
  4. */
  5. use Friendica\App;
  6. use Friendica\Content\Nav;
  7. use Friendica\Content\Pager;
  8. use Friendica\Core\L10n;
  9. use Friendica\Database\DBA;
  10. use Friendica\Model\Item;
  11. use Friendica\Model\Profile;
  12. function notes_init(App $a)
  13. {
  14. if (! local_user()) {
  15. return;
  16. }
  17. $profile = 0;
  18. $which = $a->user['nickname'];
  19. Nav::setSelected('home');
  20. //Profile::load($a, $which, $profile);
  21. }
  22. function notes_content(App $a, $update = false)
  23. {
  24. if (!local_user()) {
  25. notice(L10n::t('Permission denied.') . EOL);
  26. return;
  27. }
  28. $o = Profile::getTabs($a, true);
  29. if (!$update) {
  30. $o .= '<h3>' . L10n::t('Personal Notes') . '</h3>';
  31. $x = [
  32. 'is_owner' => true,
  33. 'allow_location' => (($a->user['allow_location']) ? true : false),
  34. 'default_location' => $a->user['default-location'],
  35. 'nickname' => $a->user['nickname'],
  36. 'lockstate' => 'lock',
  37. 'acl' => '',
  38. 'bang' => '',
  39. 'visitor' => 'block',
  40. 'profile_uid' => local_user(),
  41. 'button' => L10n::t('Save'),
  42. 'acl_data' => '',
  43. ];
  44. $o .= status_editor($a, $x, $a->contact['id']);
  45. }
  46. $condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
  47. 'contact-id'=> $a->contact['id']];
  48. $pager = new Pager($a->query_string, 40);
  49. $params = ['order' => ['created' => true],
  50. 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
  51. $r = Item::selectThreadForUser(local_user(), ['uri'], $condition, $params);
  52. $count = 0;
  53. if (DBA::isResult($r)) {
  54. $notes = Item::inArray($r);
  55. $count = count($notes);
  56. $o .= conversation($a, $notes, $pager, 'notes', $update);
  57. }
  58. $o .= $pager->renderMinimal($count);
  59. return $o;
  60. }