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.
 
 
 
 
 
 

140 lines
3.4 KiB

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