streams/mod/editpost.php

160 lines
4.5 KiB
PHP
Raw Normal View History

<?php /** @file */
2011-03-18 07:30:34 +00:00
require_once('acl_selectors.php');
2013-07-31 03:01:17 +00:00
require_once('include/crypto.php');
require_once('include/items.php');
require_once('include/taxonomy.php');
2011-03-18 07:30:34 +00:00
function editpost_content(&$a) {
$o = '';
if(! local_user()) {
notice( t('Permission denied.') . EOL);
return;
}
2012-12-21 12:08:48 +00:00
$post_id = ((argc() > 1) ? intval(argv(1)) : 0);
2011-03-18 07:30:34 +00:00
if(! $post_id) {
notice( t('Item not found') . EOL);
return;
}
2013-03-11 01:45:58 +00:00
$itm = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d and author_xchan = '%s' LIMIT 1",
2011-03-18 07:30:34 +00:00
intval($post_id),
2013-03-11 01:45:58 +00:00
intval(local_user()),
dbesc(get_observer_hash())
2011-03-18 07:30:34 +00:00
);
2011-04-20 05:37:17 +00:00
if(! count($itm)) {
2013-03-11 01:45:58 +00:00
notice( t('Item is not editable') . EOL);
2011-03-18 07:30:34 +00:00
return;
}
$plaintext = true;
if(feature_enabled(local_user(),'richtext'))
$plaintext = false;
$channel = $a->get_channel();
2012-12-21 12:08:48 +00:00
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
'$title' => t('Edit post')
));
2011-03-18 07:30:34 +00:00
2012-12-21 12:08:48 +00:00
$a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
2011-03-18 07:30:34 +00:00
'$baseurl' => $a->get_baseurl(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
2011-05-20 08:15:02 +00:00
'$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
2011-03-18 07:30:34 +00:00
'$geotag' => $geotag,
'$nickname' => $channel['channel_address'],
'$expireswhen' => t('Expires YYYY-MM-DD HH:MM'),
2014-01-01 15:18:39 +00:00
'$confirmdelete' => t('Delete item?'),
2011-03-18 07:30:34 +00:00
));
2013-07-31 02:05:34 +00:00
if($itm[0]['item_flags'] & ITEM_OBSCURED) {
$key = get_config('system','prvkey');
if($itm[0]['title'])
$itm[0]['title'] = crypto_unencapsulate(json_decode_plus($itm[0]['title']),$key);
2013-07-31 02:05:34 +00:00
if($itm[0]['body'])
$itm[0]['body'] = crypto_unencapsulate(json_decode_plus($itm[0]['body']),$key);
2013-07-31 02:05:34 +00:00
}
2011-05-11 11:37:13 +00:00
$tpl = get_markup_template("jot.tpl");
2011-03-18 07:30:34 +00:00
$jotplugins = '';
$jotnets = '';
2011-04-18 06:27:11 +00:00
2011-03-18 07:30:34 +00:00
call_hooks('jot_tool', $jotplugins);
call_hooks('jot_networks', $jotnets);
2012-12-21 12:08:48 +00:00
$channel = $a->get_channel();
//$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
2011-03-18 07:30:34 +00:00
$category = '';
$catsenabled = ((feature_enabled(local_user(),'categories')) ? 'categories' : '');
if ($catsenabled){
$itm = fetch_post_tags($itm);
$cats = get_terms_oftype($itm[0]['term'], TERM_CATEGORY);
foreach ($cats as $cat) {
if (strlen($category))
$category .= ', ';
$category .= $cat['term'];
}
}
if($itm[0]['attach']) {
$j = json_decode($itm[0]['attach'],true);
if($j) {
foreach($j as $jj) {
$itm[0]['body'] .= "\n" . '[attachment]' . basename($jj['href']) . ',' . $jj['revision'] . '[/attachment]' . "\n";
}
}
}
2014-01-28 07:49:42 +00:00
$cipher = get_pconfig(get_app()->profile['profile_uid'],'system','default_cipher');
if(! $cipher)
$cipher = 'aes256';
2011-03-18 07:30:34 +00:00
$o .= replace_macros($tpl,array(
'$return_path' => $_SESSION['return_url'],
'$action' => 'item',
'$share' => t('Edit'),
'$upload' => t('Upload photo'),
2011-05-25 09:08:15 +00:00
'$attach' => t('Attach file'),
2011-03-18 07:30:34 +00:00
'$weblink' => t('Insert web link'),
'$youtube' => t('Insert YouTube video'),
'$video' => t('Insert Vorbis [.ogg] video'),
'$audio' => t('Insert Vorbis [.ogg] audio'),
'$setloc' => t('Set your location'),
'$noloc' => t('Clear browser location'),
'$wait' => t('Please wait'),
'$permset' => t('Permission settings'),
2011-05-20 08:15:02 +00:00
'$ptyp' => $itm[0]['type'],
2012-03-22 23:17:10 +00:00
'$content' => undo_post_tagging($itm[0]['body']),
2011-03-18 07:30:34 +00:00
'$post_id' => $post_id,
'$baseurl' => $a->get_baseurl(),
2012-12-21 12:08:48 +00:00
'$defloc' => $channel['channel_location'],
2011-03-18 07:30:34 +00:00
'$visitor' => 'none',
2011-05-20 08:15:02 +00:00
'$pvisit' => 'none',
2011-05-19 00:29:12 +00:00
'$public' => t('Public post'),
2011-03-18 07:30:34 +00:00
'$jotnets' => $jotnets,
'$title' => htmlspecialchars($itm[0]['title'],ENT_COMPAT,'UTF-8'),
'$placeholdertitle' => t('Set title'),
'$category' => $category,
2012-08-06 04:41:58 +00:00
'$placeholdercategory' => t('Categories (comma-separated list)'),
2011-03-18 07:30:34 +00:00
'$emtitle' => t('Example: bob@example.com, mary@example.com'),
'$lockstate' => $lockstate,
2012-12-21 12:08:48 +00:00
'$acl' => '',
'$bang' => '',
'$profile_uid' => local_user(),
'$preview' => ((feature_enabled(local_user(),'preview')) ? t('Preview') : ''),
'$jotplugins' => $jotplugins,
2012-08-06 04:41:58 +00:00
'$sourceapp' => t($a->sourcename),
'$catsenabled' => $catsenabled,
2014-01-28 07:49:42 +00:00
'$defexpire' => datetime_convert('UTC', date_default_timezone_get(),$itm[0]['expires']),
'$feature_expire' => ((feature_enabled(get_app()->profile['profile_uid'],'content_expire') && (! $webpage)) ? 'block' : 'none'),
'$expires' => t('Set expiration date'),
2014-01-28 07:49:42 +00:00
'$feature_encrypt' => ((feature_enabled(get_app()->profile['profile_uid'],'content_encrypt') && (! $webpage)) ? 'block' : 'none'),
'$encrypt' => t('Encrypt text'),
2014-01-28 07:49:42 +00:00
'$cipher' => $cipher,
2013-12-22 13:21:57 +00:00
'$expiryModalOK' => t('OK'),
'$expiryModalCANCEL' => t('Cancel'),
2011-03-18 07:30:34 +00:00
));
return $o;
}