Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

mood.php 3.2 KiB

hace 8 años
hace 8 años
hace 8 años
hace 8 años
hace 8 años
hace 8 años
hace 8 años
hace 8 años
hace 8 años
hace 8 años
hace 8 años
hace 8 años
hace 8 años
hace 8 años
hace 8 años
hace 8 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. require_once('include/security.php');
  3. require_once('include/bbcode.php');
  4. require_once('include/items.php');
  5. function mood_init(App $a) {
  6. if (! local_user()) {
  7. return;
  8. }
  9. $uid = local_user();
  10. $verb = notags(trim($_GET['verb']));
  11. if(! $verb)
  12. return;
  13. $verbs = get_mood_verbs();
  14. if(! in_array($verb,$verbs))
  15. return;
  16. $activity = ACTIVITY_MOOD . '#' . urlencode($verb);
  17. $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : 0);
  18. logger('mood: verb ' . $verb, LOGGER_DEBUG);
  19. if($parent) {
  20. $r = q("select uri, private, allow_cid, allow_gid, deny_cid, deny_gid
  21. from item where id = %d and parent = %d and uid = %d limit 1",
  22. intval($parent),
  23. intval($parent),
  24. intval($uid)
  25. );
  26. if (dbm::is_result($r)) {
  27. $parent_uri = $r[0]['uri'];
  28. $private = $r[0]['private'];
  29. $allow_cid = $r[0]['allow_cid'];
  30. $allow_gid = $r[0]['allow_gid'];
  31. $deny_cid = $r[0]['deny_cid'];
  32. $deny_gid = $r[0]['deny_gid'];
  33. }
  34. }
  35. else {
  36. $private = 0;
  37. $allow_cid = $a->user['allow_cid'];
  38. $allow_gid = $a->user['allow_gid'];
  39. $deny_cid = $a->user['deny_cid'];
  40. $deny_gid = $a->user['deny_gid'];
  41. }
  42. $poster = $a->contact;
  43. $uri = item_new_uri($a->get_hostname(),$uid);
  44. $action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['url'] . ']' . $poster['name'] . '[/url]' , $verbs[$verb]);
  45. $arr = array();
  46. $arr['guid'] = get_guid(32);
  47. $arr['uid'] = $uid;
  48. $arr['uri'] = $uri;
  49. $arr['parent-uri'] = (($parent_uri) ? $parent_uri : $uri);
  50. $arr['type'] = 'activity';
  51. $arr['wall'] = 1;
  52. $arr['contact-id'] = $poster['id'];
  53. $arr['owner-name'] = $poster['name'];
  54. $arr['owner-link'] = $poster['url'];
  55. $arr['owner-avatar'] = $poster['thumb'];
  56. $arr['author-name'] = $poster['name'];
  57. $arr['author-link'] = $poster['url'];
  58. $arr['author-avatar'] = $poster['thumb'];
  59. $arr['title'] = '';
  60. $arr['allow_cid'] = $allow_cid;
  61. $arr['allow_gid'] = $allow_gid;
  62. $arr['deny_cid'] = $deny_cid;
  63. $arr['deny_gid'] = $deny_gid;
  64. $arr['last-child'] = 1;
  65. $arr['visible'] = 1;
  66. $arr['verb'] = $activity;
  67. $arr['private'] = $private;
  68. $arr['origin'] = 1;
  69. $arr['body'] = $action;
  70. $item_id = item_store($arr);
  71. if($item_id) {
  72. q("UPDATE `item` SET `plink` = '%s' WHERE `uid` = %d AND `id` = %d",
  73. dbesc(App::get_baseurl() . '/display/' . $poster['nickname'] . '/' . $item_id),
  74. intval($uid),
  75. intval($item_id)
  76. );
  77. proc_run(PRIORITY_HIGH, "include/notifier.php", "tag", $item_id);
  78. }
  79. call_hooks('post_local_end', $arr);
  80. proc_run(PRIORITY_HIGH, "include/notifier.php", "like", $post_id);
  81. return;
  82. }
  83. function mood_content(App $a) {
  84. if (! local_user()) {
  85. notice( t('Permission denied.') . EOL);
  86. return;
  87. }
  88. $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : '0');
  89. $verbs = get_mood_verbs();
  90. $shortlist = array();
  91. foreach($verbs as $k => $v)
  92. if($v !== 'NOTRANSLATION')
  93. $shortlist[] = array($k,$v);
  94. $tpl = get_markup_template('mood_content.tpl');
  95. $o = replace_macros($tpl,array(
  96. '$title' => t('Mood'),
  97. '$desc' => t('Set your current mood and tell your friends'),
  98. '$verbs' => $shortlist,
  99. '$parent' => $parent,
  100. '$submit' => t('Submit'),
  101. ));
  102. return $o;
  103. }