/mod/editpost.php

https://github.com/pombredanne/Free-Friendika · PHP · 123 lines · 90 code · 32 blank · 1 comment · 18 complexity · 74b1b9ea65a97e9e3ba4314976e3500f MD5 · raw file

  1. <?php
  2. require_once('acl_selectors.php');
  3. function editpost_content(&$a) {
  4. $o = '';
  5. if(! local_user()) {
  6. notice( t('Permission denied.') . EOL);
  7. return;
  8. }
  9. $post_id = (($a->argc > 1) ? intval($a->argv[1]) : 0);
  10. if(! $post_id) {
  11. notice( t('Item not found') . EOL);
  12. return;
  13. }
  14. $itm = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
  15. intval($post_id),
  16. intval(local_user())
  17. );
  18. if(! count($itm)) {
  19. notice( t('Item not found') . EOL);
  20. return;
  21. }
  22. $o .= '<h2>' . t('Edit post') . '</h2>';
  23. $tpl = get_markup_template('jot-header.tpl');
  24. $a->page['htmlhead'] .= replace_macros($tpl, array(
  25. '$baseurl' => $a->get_baseurl(),
  26. '$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
  27. '$geotag' => $geotag,
  28. '$nickname' => $a->user['nickname']
  29. ));
  30. $tpl = get_markup_template("jot.tpl");
  31. if(($group) || (is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid'])))))
  32. $lockstate = 'lock';
  33. else
  34. $lockstate = 'unlock';
  35. $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false);
  36. $jotplugins = '';
  37. $jotnets = '';
  38. $mail_disabled = ((function_exists('imap_open') && (! get_config('system','imap_disabled'))) ? 0 : 1);
  39. $mail_enabled = false;
  40. $pubmail_enabled = false;
  41. if(! $mail_disabled) {
  42. $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1",
  43. intval(local_user())
  44. );
  45. if(count($r)) {
  46. $mail_enabled = true;
  47. if(intval($r[0]['pubmail']))
  48. $pubmail_enabled = true;
  49. }
  50. }
  51. if($mail_enabled) {
  52. $selected = (($pubmail_enabled) ? ' checked="checked" ' : '');
  53. $jotnets .= '<div class="profile-jot-net"><input type="checkbox" name="pubmail_enable"' . $selected . ' value="1" /> '
  54. . t("Post to Email") . '</div>';
  55. }
  56. call_hooks('jot_tool', $jotplugins);
  57. call_hooks('jot_networks', $jotnets);
  58. //$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
  59. $o .= replace_macros($tpl,array(
  60. '$return_path' => $_SESSION['return_url'],
  61. '$action' => 'item',
  62. '$share' => t('Edit'),
  63. '$upload' => t('Upload photo'),
  64. '$attach' => t('Attach file'),
  65. '$weblink' => t('Insert web link'),
  66. '$youtube' => t('Insert YouTube video'),
  67. '$video' => t('Insert Vorbis [.ogg] video'),
  68. '$audio' => t('Insert Vorbis [.ogg] audio'),
  69. '$setloc' => t('Set your location'),
  70. '$noloc' => t('Clear browser location'),
  71. '$wait' => t('Please wait'),
  72. '$permset' => t('Permission settings'),
  73. '$ptyp' => $itm[0]['type'],
  74. '$content' => $itm[0]['body'],
  75. '$post_id' => $post_id,
  76. '$baseurl' => $a->get_baseurl(),
  77. '$defloc' => $a->user['default-location'],
  78. '$visitor' => 'none',
  79. '$pvisit' => 'none',
  80. '$emailcc' => t('CC: email addresses'),
  81. '$public' => t('Public post'),
  82. '$jotnets' => $jotnets,
  83. '$emtitle' => t('Example: bob@example.com, mary@example.com'),
  84. '$lockstate' => $lockstate,
  85. '$acl' => '', // populate_acl((($group) ? $group_acl : $a->user), $celeb),
  86. '$bang' => (($group) ? '!' : ''),
  87. '$profile_uid' => $_SESSION['uid'],
  88. '$jotplugins' => $jotplugins,
  89. ));
  90. return $o;
  91. }