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.

137 lines
3.4 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
9 years ago
9 years ago
11 years ago
  1. <?php
  2. function notes_init(&$a) {
  3. if(! local_user())
  4. return;
  5. $profile = 0;
  6. $which = $a->user['nickname'];
  7. nav_set_selected('home');
  8. // profile_load($a,$which,$profile);
  9. }
  10. function notes_content(&$a,$update = false) {
  11. if(! local_user()) {
  12. notice( t('Permission denied.') . EOL);
  13. return;
  14. }
  15. require_once("include/bbcode.php");
  16. require_once('include/security.php');
  17. require_once('include/conversation.php');
  18. require_once('include/acl_selectors.php');
  19. $groups = array();
  20. $o = '';
  21. $remote_contact = false;
  22. $contact_id = $_SESSION['cid'];
  23. $contact = $a->contact;
  24. $is_owner = true;
  25. $o ="";
  26. $o .= profile_tabs($a,True);
  27. if(! $update) {
  28. $o .= '<h3>' . t('Personal Notes') . '</h3>';
  29. $commpage = false;
  30. $commvisitor = false;
  31. $x = array(
  32. 'is_owner' => $is_owner,
  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' => t('Save'),
  42. 'acl_data' => '',
  43. );
  44. $o .= status_editor($a,$x,$a->contact['id']);
  45. }
  46. // Construct permissions
  47. // default permissions - anonymous user
  48. $sql_extra = " AND `allow_cid` = '<" . $a->contact['id'] . ">' ";
  49. $r = q("SELECT COUNT(*) AS `total`
  50. FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
  51. WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0
  52. AND `item`.`deleted` = 0 AND `item`.`type` = 'note'
  53. AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` = 1
  54. AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0
  55. $sql_extra ",
  56. intval(local_user())
  57. );
  58. if(count($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`, `contact`.`uid` AS `contact-uid`
  63. FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
  64. WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0
  65. and `item`.`moderated` = 0 AND `item`.`type` = 'note'
  66. AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` = 1
  67. AND `item`.`id` = `item`.`parent` AND `item`.`wall` = 0
  68. $sql_extra
  69. ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
  70. intval(local_user()),
  71. intval($a->pager['start']),
  72. intval($a->pager['itemspage'])
  73. );
  74. $parents_arr = array();
  75. $parents_str = '';
  76. if(count($r)) {
  77. foreach($r as $rr)
  78. $parents_arr[] = $rr['item_id'];
  79. $parents_str = implode(', ', $parents_arr);
  80. $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
  81. `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`network`, `contact`.`rel`,
  82. `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
  83. `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
  84. FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
  85. WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
  86. AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
  87. AND `item`.`parent` IN ( %s )
  88. $sql_extra
  89. ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
  90. intval(local_user()),
  91. dbesc($parents_str)
  92. );
  93. if(count($r)) {
  94. $items = conv_sort($r,"`commented`");
  95. $o .= conversation($a,$items,'notes',$update);
  96. }
  97. }
  98. $o .= paginate($a);
  99. return $o;
  100. }