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.

91 lines
2.0 KiB

10 years ago
10 years ago
10 years ago
  1. <?php
  2. function lockview_content(App $a) {
  3. $type = (($a->argc > 1) ? $a->argv[1] : 0);
  4. if (is_numeric($type)) {
  5. $item_id = intval($type);
  6. $type='item';
  7. } else {
  8. $item_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
  9. }
  10. if(! $item_id)
  11. killme();
  12. if (!in_array($type, array('item','photo','event')))
  13. killme();
  14. $r = q("SELECT * FROM `%s` WHERE `id` = %d LIMIT 1",
  15. dbesc($type),
  16. intval($item_id)
  17. );
  18. if (! dbm::is_result($r)) {
  19. killme();
  20. }
  21. $item = $r[0];
  22. call_hooks('lockview_content', $item);
  23. if($item['uid'] != local_user()) {
  24. echo t('Remote privacy information not available.') . '<br />';
  25. killme();
  26. }
  27. if(($item['private'] == 1) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid']))
  28. && (! strlen($item['deny_cid'])) && (! strlen($item['deny_gid']))) {
  29. echo t('Remote privacy information not available.') . '<br />';
  30. killme();
  31. }
  32. $allowed_users = expand_acl($item['allow_cid']);
  33. $allowed_groups = expand_acl($item['allow_gid']);
  34. $deny_users = expand_acl($item['deny_cid']);
  35. $deny_groups = expand_acl($item['deny_gid']);
  36. $o = t('Visible to:') . '<br />';
  37. $l = array();
  38. if(count($allowed_groups)) {
  39. $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
  40. dbesc(implode(', ', $allowed_groups))
  41. );
  42. if (dbm::is_result($r))
  43. foreach($r as $rr)
  44. $l[] = '<b>' . $rr['name'] . '</b>';
  45. }
  46. if(count($allowed_users)) {
  47. $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
  48. dbesc(implode(', ',$allowed_users))
  49. );
  50. if (dbm::is_result($r))
  51. foreach($r as $rr)
  52. $l[] = $rr['name'];
  53. }
  54. if(count($deny_groups)) {
  55. $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",
  56. dbesc(implode(', ', $deny_groups))
  57. );
  58. if (dbm::is_result($r))
  59. foreach($r as $rr)
  60. $l[] = '<b><strike>' . $rr['name'] . '</strike></b>';
  61. }
  62. if(count($deny_users)) {
  63. $r = q("SELECT `name` FROM `contact` WHERE `id` IN ( %s )",
  64. dbesc(implode(', ',$deny_users))
  65. );
  66. if (dbm::is_result($r))
  67. foreach($r as $rr)
  68. $l[] = '<strike>' . $rr['name'] . '</strike>';
  69. }
  70. echo $o . implode(', ', $l);
  71. killme();
  72. }