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.

130 lines
2.6 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
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
9 years ago
9 years ago
10 years ago
  1. <?php
  2. function notes_init(App $a) {
  3. if (! local_user()) {
  4. return;
  5. }
  6. $profile = 0;
  7. $which = $a->user['nickname'];
  8. nav_set_selected('home');
  9. // profile_load($a,$which,$profile);
  10. }
  11. function notes_content(App $a, $update = false) {
  12. if (! local_user()) {
  13. notice( t('Permission denied.') . EOL);
  14. return;
  15. }
  16. require_once("include/bbcode.php");
  17. require_once('include/security.php');
  18. require_once('include/conversation.php');
  19. require_once('include/acl_selectors.php');
  20. $groups = array();
  21. $o = '';
  22. $remote_contact = false;
  23. $contact_id = $_SESSION['cid'];
  24. $contact = $a->contact;
  25. $is_owner = true;
  26. $o ="";
  27. $o .= profile_tabs($a,True);
  28. if(! $update) {
  29. $o .= '<h3>' . t('Personal Notes') . '</h3>';
  30. $commpage = false;
  31. $commvisitor = false;
  32. $x = array(
  33. 'is_owner' => $is_owner,
  34. 'allow_location' => (($a->user['allow_location']) ? true : false),
  35. 'default_location' => $a->user['default-location'],
  36. 'nickname' => $a->user['nickname'],
  37. 'lockstate' => 'lock',
  38. 'acl' => '',
  39. 'bang' => '',
  40. 'visitor' => 'block',
  41. 'profile_uid' => local_user(),
  42. 'button' => t('Save'),
  43. 'acl_data' => '',
  44. );
  45. $o .= status_editor($a,$x,$a->contact['id']);
  46. }
  47. // Construct permissions
  48. // default permissions - anonymous user
  49. $sql_extra = " AND `allow_cid` = '<" . $a->contact['id'] . ">' ";
  50. $r = q("SELECT COUNT(*) AS `total`
  51. FROM `item` %s
  52. WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
  53. AND `contact`.`self` AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
  54. $sql_extra ",
  55. item_joins(), item_condition(),
  56. intval(local_user())
  57. );
  58. if (dbm::is_result($r)) {
  59. $a->set_pager_total($r[0]['total']);
  60. $a->set_pager_itemspage(40);
  61. }
  62. $r = q("SELECT `item`.`id` AS `item_id` FROM `item` %s
  63. WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
  64. AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
  65. $sql_extra
  66. ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
  67. item_joins(), item_condition(),
  68. intval(local_user()),
  69. intval($a->pager['start']),
  70. intval($a->pager['itemspage'])
  71. );
  72. $parents_arr = array();
  73. $parents_str = '';
  74. if (dbm::is_result($r)) {
  75. foreach($r as $rr)
  76. $parents_arr[] = $rr['item_id'];
  77. $parents_str = implode(', ', $parents_arr);
  78. $r = q("SELECT %s FROM `item` %s
  79. WHERE %s AND `item`.`uid` = %d AND `item`.`parent` IN (%s)
  80. $sql_extra
  81. ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
  82. item_fieldlists(), item_joins(), item_condition(),
  83. intval(local_user()),
  84. dbesc($parents_str)
  85. );
  86. if (dbm::is_result($r)) {
  87. $items = conv_sort($r,"`commented`");
  88. $o .= conversation($a,$items,'notes',$update);
  89. }
  90. }
  91. $o .= paginate($a);
  92. return $o;
  93. }