function status_editor($a, $x, $popup = false) { $o = ''; $geotag = $x['allow_location'] ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : ''; $plaintext = true; // if(feature_enabled(local_channel(),'richtext')) // $plaintext = false; $voting = feature_enabled(local_channel(), 'consensus_tools'); $mimeselect = ''; if (array_key_exists('mimetype', $x) && $x['mimetype']) { if ($x['mimetype'] != 'text/bbcode') { $plaintext = true; } if ($x['mimetype'] === 'choose') { $mimeselect = mimetype_select($x['profile_uid']); } else { $mimeselect = '<input type="hidden" name="mimetype" value="' . $x['mimetype'] . '" />'; } } $layoutselect = ''; if (array_key_exists('layout', $x) && $x['layout']) { if ($x['layout'] === 'choose') { $layoutselect = layout_select($x['profile_uid']); } else { $layoutselect = '<input type="hidden" name="layout_mid" value="' . $x['layout'] . '" />'; } } if (array_key_exists('channel_select', $x) && $x['channel_select']) { require_once 'include/identity.php'; $id_select = identity_selector(); } else { $id_select = ''; } $webpage = x($x, 'webpage') ? $x['webpage'] : ''; $tpl = get_markup_template('jot-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array('$newpost' => 'true', '$baseurl' => $a->get_baseurl(true), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$geotag' => $geotag, '$nickname' => $x['nickname'], '$ispublic' => t('Visible to <strong>everybody</strong>'), '$linkurl' => t('Please enter a link URL:'), '$vidurl' => t('Please enter a video link/URL:'), '$audurl' => t('Please enter an audio link/URL:'), '$term' => t('Tag term:'), '$fileas' => t('Save to Folder:'), '$whereareu' => t('Where are you right now?'), '$expireswhen' => t('Expires YYYY-MM-DD HH:MM'))); $tpl = get_markup_template('jot.tpl'); $jotplugins = ''; $jotnets = ''; $preview = t('Preview'); // $preview = ((feature_enabled($x['profile_uid'],'preview')) ? t('Preview') : ''); if (x($x, 'nopreview')) { $preview = ''; } $defexpire = ($z = get_pconfig($x['profile_uid'], 'system', 'default_post_expire')) && !$webpage ? $z : ''; if ($defexpire) { $defexpire = datetime_convert('UTC', date_default_timezone_get(), $defexpire, 'Y-m-d H:i'); } $cipher = get_pconfig($x['profile_uid'], 'system', 'default_cipher'); if (!$cipher) { $cipher = 'aes256'; } call_hooks('jot_tool', $jotplugins); call_hooks('jot_networks', $jotnets); $o .= replace_macros($tpl, array('$return_path' => x($x, 'return_path') ? $x['return_path'] : $a->query_string, '$action' => $a->get_baseurl(true) . '/item', '$share' => x($x, 'button') ? $x['button'] : t('Share'), '$webpage' => $webpage, '$placeholdpagetitle' => x($x, 'ptlabel') ? $x['ptlabel'] : t('Page link title'), '$pagetitle' => x($x, 'pagetitle') ? $x['pagetitle'] : '', '$id_select' => $id_select, '$id_seltext' => t('Post as'), '$writefiles' => perm_is_allowed($x['profile_uid'], get_observer_hash(), 'post_photos') || perm_is_allowed($x['profile_uid'], get_observer_hash(), 'write_storage'), '$bold' => t('Bold'), '$italic' => t('Italic'), '$underline' => t('Underline'), '$quote' => t('Quote'), '$code' => t('Code'), '$upload' => t('Upload photo'), '$shortupload' => t('upload photo'), '$attach' => t('Attach file'), '$shortattach' => t('attach file'), '$weblink' => t('Insert web link'), '$shortweblink' => t('web link'), '$video' => t('Insert video link'), '$shortvideo' => t('video link'), '$audio' => t('Insert audio link'), '$shortaudio' => t('audio link'), '$setloc' => t('Set your location'), '$shortsetloc' => t('set location'), '$voting' => t('Toggle voting'), '$feature_voting' => $voting, '$consensus' => 0, '$noloc' => get_pconfig($x['profile_uid'], 'system', 'use_browser_location') ? t('Clear browser location') : '', '$shortnoloc' => t('clear location'), '$title' => x($x, 'title') ? htmlspecialchars($x['title'], ENT_COMPAT, 'UTF-8') : '', '$placeholdertitle' => t('Title (optional)'), '$catsenabled' => feature_enabled($x['profile_uid'], 'categories') && !$webpage ? 'categories' : '', '$category' => "", '$placeholdercategory' => t('Categories (optional, comma-separated list)'), '$wait' => t('Please wait'), '$permset' => t('Permission settings'), '$shortpermset' => t('permissions'), '$ptyp' => $notes_cid ? 'note' : 'wall', '$content' => x($x, 'body') ? htmlspecialchars($x['body'], ENT_COMPAT, 'UTF-8') : '', '$post_id' => '', '$baseurl' => $a->get_baseurl(true), '$defloc' => $x['default_location'], '$visitor' => $x['visitor'], '$public' => t('Public post'), '$jotnets' => $jotnets, '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$lockstate' => $x['lockstate'], '$acl' => $x['acl'], '$mimeselect' => $mimeselect, '$layoutselect' => $layoutselect, '$showacl' => array_key_exists('showacl', $x) ? $x['showacl'] : true, '$bang' => $x['bang'], '$profile_uid' => $x['profile_uid'], '$preview' => $preview, '$source' => x($x, 'source') ? $x['source'] : '', '$jotplugins' => $jotplugins, '$defexpire' => $defexpire, '$feature_expire' => feature_enabled($x['profile_uid'], 'content_expire') && !$webpage ? true : false, '$expires' => t('Set expiration date'), '$feature_encrypt' => feature_enabled($x['profile_uid'], 'content_encrypt') && !$webpage ? true : false, '$encrypt' => t('Encrypt text'), '$cipher' => $cipher, '$expiryModalOK' => t('OK'), '$expiryModalCANCEL' => t('Cancel'))); if ($popup === true) { $o = '<div id="jot-popup" style="display:none">' . $o . '</div>'; } return $o; }
function editblock_content(&$a) { if (!$a->profile) { notice(t('Requested profile is not available.') . EOL); $a->error = 404; return; } $which = argv(1); $uid = local_channel(); $owner = 0; $channel = null; $observer = $a->get_observer(); $channel = $a->get_channel(); if ($a->is_sys && is_site_admin()) { $sys = get_sys_channel(); if ($sys && intval($sys['channel_id'])) { $uid = $owner = intval($sys['channel_id']); $channel = $sys; $observer = $sys; } } if (!$owner) { // Figure out who the page owner is. $r = q("select channel_id from channel where channel_address = '%s'", dbesc($which)); if ($r) { $owner = intval($r[0]['channel_id']); } } $ob_hash = $observer ? $observer['xchan_hash'] : ''; if (!perm_is_allowed($owner, $ob_hash, 'write_pages')) { notice(t('Permission denied.') . EOL); return; } $is_owner = $uid && $uid == $owner ? true : false; $o = ''; // Figure out which post we're editing $post_id = argc() > 2 ? intval(argv(2)) : 0; if (!($post_id && $owner)) { notice(t('Item not found') . EOL); return; } $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1", intval($post_id), intval($owner)); if ($itm) { $item_id = q("select * from item_id where service = 'BUILDBLOCK' and iid = %d limit 1", intval($itm[0]['id'])); if ($item_id) { $block_title = $item_id[0]['sid']; } } else { notice(t('Item not found') . EOL); return; } $plaintext = true; $mimeselect = ''; $mimetype = $itm[0]['mimetype']; if ($mimetype != 'text/bbcode') { $plaintext = true; } if (get_config('system', 'page_mimetype')) { $mimeselect = '<input type="hidden" name="mimetype" value="' . $mimetype . '" />'; } else { $mimeselect = mimetype_select($itm[0]['uid'], $mimetype); } $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array('$baseurl' => $a->get_baseurl(), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$ispublic' => ' ', '$geotag' => '', '$nickname' => $channel['channel_address'], '$confirmdelete' => t('Delete block?'))); $tpl = get_markup_template("jot.tpl"); $jotplugins = ''; $jotnets = ''; call_hooks('jot_tool', $jotplugins); call_hooks('jot_networks', $jotnets); $rp = 'blocks/' . $channel['channel_address']; $editor = replace_macros($tpl, array('$return_path' => $rp, '$action' => 'item', '$webpage' => ITEM_BUILDBLOCK, '$share' => t('Edit'), '$bold' => t('Bold'), '$italic' => t('Italic'), '$underline' => t('Underline'), '$quote' => t('Quote'), '$code' => t('Code'), '$writefiles' => perm_is_allowed($owner, get_observer_hash(), 'post_photos') || perm_is_allowed($owner, get_observer_hash(), 'write_storage'), '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$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'), '$ptyp' => $itm[0]['type'], '$mimeselect' => $mimeselect, '$content' => undo_post_tagging($itm[0]['body']), '$post_id' => $post_id, '$baseurl' => $a->get_baseurl(), '$defloc' => $channel['channel_location'], '$visitor' => false, '$public' => t('Public post'), '$jotnets' => $jotnets, '$title' => htmlspecialchars($itm[0]['title'], ENT_COMPAT, 'UTF-8'), '$placeholdertitle' => t('Title (optional)'), '$pagetitle' => $block_title, '$category' => '', '$placeholdercategory' => t('Categories (optional, comma-separated list)'), '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$lockstate' => $lockstate, '$acl' => '', '$bang' => '', '$profile_uid' => intval($channel['channel_id']), '$preview' => t('Preview'), '$jotplugins' => $jotplugins, '$sourceapp' => $itm[0]['app'], '$defexpire' => '', '$feature_expire' => false, '$expires' => t('Set expiration date'))); $o .= replace_macros(get_markup_template('edpost_head.tpl'), array('$title' => t('Edit Block'), '$delete' => $itm[0]['author_xchan'] === $ob_hash || $itm[0]['owner_xchan'] === $ob_hash ? t('Delete') : false, '$id' => $itm[0]['id'], '$editor' => $editor)); return $o; }
function editwebpage_content(&$a) { if (!App::$profile) { notice(t('Requested profile is not available.') . EOL); App::$error = 404; return; } $which = argv(1); $uid = local_channel(); $owner = 0; $channel = null; $observer = App::get_observer(); $channel = App::get_channel(); if (App::$is_sys && is_site_admin()) { $sys = get_sys_channel(); if ($sys && intval($sys['channel_id'])) { $uid = $owner = intval($sys['channel_id']); $channel = $sys; $observer = $sys; } } if (!$owner) { // Figure out who the page owner is. $r = q("select channel_id from channel where channel_address = '%s'", dbesc($which)); if ($r) { $owner = intval($r[0]['channel_id']); } } $ob_hash = $observer ? $observer['xchan_hash'] : ''; if (!perm_is_allowed($owner, $ob_hash, 'write_pages')) { notice(t('Permission denied.') . EOL); return; } $is_owner = $uid && $uid == $owner ? true : false; $o = ''; // Figure out which post we're editing $post_id = argc() > 2 ? intval(argv(2)) : 0; if (!$post_id) { notice(t('Item not found') . EOL); return; } $ob_hash = $observer ? $observer['xchan_hash'] : ''; $perms = get_all_perms($owner, $ob_hash); if (!$perms['write_pages']) { notice(t('Permission denied.') . EOL); return; } // We've already figured out which item we want and whose copy we need, // so we don't need anything fancy here $sql_extra = item_permissions_sql($owner); $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s {$sql_extra} LIMIT 1", intval($post_id), intval($owner)); if (!$itm) { notice(t('Permission denied.') . EOL); return; } if (intval($itm[0]['item_obscured'])) { $key = get_config('system', 'prvkey'); if ($itm[0]['title']) { $itm[0]['title'] = crypto_unencapsulate(json_decode_plus($itm[0]['title']), $key); } if ($itm[0]['body']) { $itm[0]['body'] = crypto_unencapsulate(json_decode_plus($itm[0]['body']), $key); } } $item_id = q("select * from item_id where service = 'WEBPAGE' and iid = %d limit 1", intval($itm[0]['id'])); if ($item_id) { $page_title = $item_id[0]['sid']; } $plaintext = true; $mimetype = $itm[0]['mimetype']; if ($mimetype === 'application/x-php') { if (!$uid || $uid != $itm[0]['uid']) { notice(t('Permission denied.') . EOL); return; } } $mimeselect = ''; if ($mimetype != 'text/bbcode') { $plaintext = true; } if (get_config('system', 'page_mimetype')) { $mimeselect = '<input type="hidden" name="mimetype" value="' . $mimetype . '" />'; } else { $mimeselect = mimetype_select($itm[0]['uid'], $mimetype); } $layout = get_config('system', 'page_layout'); if ($layout) { $layoutselect = '<input type="hidden" name="layout_mid" value="' . $layout . '" />'; } else { $layoutselect = layout_select($itm[0]['uid'], $itm[0]['layout_mid']); } App::$page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array('$baseurl' => z_root(), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$pretext' => '', '$ispublic' => ' ', '$geotag' => $geotag, '$nickname' => $channel['channel_address'], '$confirmdelete' => t('Delete webpage?'), '$bbco_autocomplete' => $mimetype == 'text/bbcode' ? 'bbcode' : '')); $tpl = get_markup_template("jot.tpl"); $jotplugins = ''; $jotnets = ''; call_hooks('jot_tool', $jotplugins); call_hooks('jot_networks', $jotnets); // FIXME A return path with $_SESSION doesn't always work for observer - it may WSoD // instead of loading a sensible page. So, send folk to the webpage list. $rp = 'webpages/' . $which; $editor = replace_macros($tpl, array('$return_path' => $rp, '$webpage' => ITEM_TYPE_WEBPAGE, '$placeholdpagetitle' => t('Page link title'), '$pagetitle' => $page_title, '$writefiles' => perm_is_allowed($owner, get_observer_hash(), 'write_storage'), '$action' => 'item', '$share' => t('Edit'), '$bold' => t('Bold'), '$italic' => t('Italic'), '$underline' => t('Underline'), '$quote' => t('Quote'), '$code' => t('Code'), '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$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' => get_pconfig($uid, 'system', 'use_browser_location') ? t('Clear browser location') : '', '$wait' => t('Please wait'), '$permset' => t('Permission settings'), '$ptyp' => $itm[0]['type'], '$content' => undo_post_tagging($itm[0]['body']), '$post_id' => $post_id, '$baseurl' => z_root(), '$defloc' => $itm[0]['location'], '$visitor' => $is_owner ? true : false, '$acl' => populate_acl($itm[0], false), '$showacl' => $is_owner ? true : false, '$public' => t('Public post'), '$jotnets' => $jotnets, '$mimeselect' => $mimeselect, '$layoutselect' => $layoutselect, '$title' => htmlspecialchars($itm[0]['title'], ENT_COMPAT, 'UTF-8'), '$placeholdertitle' => t('Title (optional)'), '$category' => '', '$placeholdercategory' => t('Categories (optional, comma-separated list)'), '$emtitle' => t('Example: bob@example.com, mary@example.com'), 'lockstate' => strlen($itm[0]['allow_cid']) || strlen($itm[0]['allow_gid']) || strlen($itm[0]['deny_cid']) || strlen($itm[0]['deny_gid']) ? 'lock' : 'unlock', '$bang' => '', '$profile_uid' => intval($owner), '$preview' => t('Preview'), '$jotplugins' => $jotplugins, '$sourceapp' => App::$sourcename, '$defexpire' => '', '$feature_expire' => false, '$expires' => t('Set expiration date'), '$bbcode' => $mimetype == 'text/bbcode' ? true : false)); $o .= replace_macros(get_markup_template('edpost_head.tpl'), array('$title' => t('Edit Webpage'), '$delete' => $itm[0]['author_xchan'] === $ob_hash || $itm[0]['owner_xchan'] === $ob_hash ? t('Delete') : false, '$editor' => $editor, '$id' => $itm[0]['id'])); return $o; }
function editwebpage_content(&$a) { // We first need to figure out who owns the webpage, grab it from an argument $which = argv(1); // $a->get_channel() and stuff don't work here, so we've got to find the owner for ourselves. $r = q("select channel_id from channel where channel_address = '%s'", dbesc($which)); if ($r) { $owner = intval($r[0]['channel_id']); //logger('owner: ' . print_r($owner,true)); } $is_owner = local_user() && local_user() == $owner ? true : false; $o = ''; // Figure out which post we're editing $post_id = argc() > 2 ? intval(argv(2)) : 0; if (!$post_id) { notice(t('Item not found') . EOL); return; } // Now we've got a post and an owner, let's find out if we're allowed to edit it $observer = $a->get_observer(); $ob_hash = $observer ? $observer['xchan_hash'] : ''; $perms = get_all_perms($owner, $ob_hash); if (!$perms['write_pages']) { notice(t('Permission denied.') . EOL); return; } // We've already figured out which item we want and whose copy we need, so we don't need anything fancy here $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1", intval($post_id), intval($owner)); 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); } if ($itm[0]['body']) { $itm[0]['body'] = crypto_unencapsulate(json_decode_plus($itm[0]['body']), $key); } } $item_id = q("select * from item_id where service = 'WEBPAGE' and iid = %d limit 1", $itm[0]['id']); if ($item_id) { $page_title = $item_id[0]['sid']; } $plaintext = true; // if(feature_enabled($itm[0]['uid'],'richtext')) // $plaintext = false; $mimetype = $itm[0]['mimetype']; if ($mimetype === 'application/x-php') { if (!local_user() || local_user() != $itm[0]['uid']) { notice(t('Permission denied.') . EOL); return; } } $mimeselect = ''; if ($mimetype != 'text/bbcode') { $plaintext = true; } if (get_config('system', 'page_mimetype')) { $mimeselect = '<input type="hidden" name="mimetype" value="' . $mimetype . '" />'; } else { $mimeselect = mimetype_select($itm[0]['uid'], $mimetype); } $layout = get_config('system', 'page_layout'); if ($layout) { $layoutselect = '<input type="hidden" name="layout_mid" value="' . $layout . '" />'; } else { $layoutselect = layout_select($itm[0]['uid'], $itm[0]['layout_mid']); } $o .= replace_macros(get_markup_template('edpost_head.tpl'), array('$title' => t('Edit Webpage'))); $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array('$baseurl' => $a->get_baseurl(), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$ispublic' => ' ', '$geotag' => $geotag, '$nickname' => $a->user['nickname'], '$confirmdelete' => t('Delete webpage?'))); $tpl = get_markup_template("jot.tpl"); $jotplugins = ''; $jotnets = ''; call_hooks('jot_tool', $jotplugins); call_hooks('jot_networks', $jotnets); $channel = $a->get_channel(); //$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); //FIXME A return path with $_SESSION doesn't always work for observer - it may WSoD instead of loading a sensible page. So, send folk to the webpage list. $rp = 'webpages/' . $which; $o .= replace_macros($tpl, array('$return_path' => $rp, '$webpage' => ITEM_WEBPAGE, '$placeholdpagetitle' => t('Page link title'), '$pagetitle' => $page_title, '$action' => 'item', '$share' => t('Edit'), '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$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'), '$ptyp' => $itm[0]['type'], '$content' => undo_post_tagging($itm[0]['body']), '$post_id' => $post_id, '$baseurl' => $a->get_baseurl(), '$defloc' => $itm[0]['location'], '$visitor' => $is_owner ? true : false, '$acl' => populate_acl($itm[0], false), '$showacl' => $is_owner ? true : false, '$public' => t('Public post'), '$jotnets' => $jotnets, '$mimeselect' => $mimeselect, '$layoutselect' => $layoutselect, '$title' => htmlspecialchars($itm[0]['title'], ENT_COMPAT, 'UTF-8'), '$placeholdertitle' => t('Set title'), '$category' => '', '$placeholdercategory' => t('Categories (comma-separated list)'), '$emtitle' => t('Example: bob@example.com, mary@example.com'), 'lockstate' => strlen($itm[0]['allow_cid']) || strlen($itm[0]['allow_gid']) || strlen($itm[0]['deny_cid']) || strlen($itm[0]['deny_gid']) ? 'lock' : 'unlock', '$bang' => '', '$profile_uid' => intval($owner), '$preview' => feature_enabled(local_user(), 'preview') ? t('Preview') : '', '$jotplugins' => $jotplugins, '$sourceapp' => t($a->sourcename), '$defexpire' => '', '$feature_expire' => false, '$expires' => t('Set expiration date'))); $ob = get_observer_hash(); if ($itm[0]['author_xchan'] === $ob || $itm[0]['owner_xchan'] === $ob) { $o .= '<br /><br /><a class="page-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Webpage') . '</a><br />'; } return $o; }
/** * This is our general purpose content editor. * It was once nicknamed "jot" and you may see references to "jot" littered throughout the code. * They are referring to the content editor or components thereof. */ function status_editor($a, $x, $popup = false) { $o = ''; $c = channelx_by_n($x['profile_uid']); if ($c && $c['channel_moved']) { return $o; } $plaintext = true; // if(feature_enabled(local_channel(),'richtext')) // $plaintext = false; $feature_voting = feature_enabled($x['profile_uid'], 'consensus_tools'); if (x($x, 'hide_voting')) { $feature_voting = false; } $feature_expire = feature_enabled($x['profile_uid'], 'content_expire') && !$webpage ? true : false; if (x($x, 'hide_expire')) { $feature_expire = false; } $feature_future = feature_enabled($x['profile_uid'], 'delayed_posting') && !$webpage ? true : false; if (x($x, 'hide_future')) { $feature_future = false; } $geotag = $x['allow_location'] ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : ''; $setloc = t('Set your location'); $clearloc = get_pconfig($x['profile_uid'], 'system', 'use_browser_location') ? t('Clear browser location') : ''; if (x($x, 'hide_location')) { $geotag = $setloc = $clearloc = ''; } $mimetype = x($x, 'mimetype') ? $x['mimetype'] : 'text/bbcode'; $mimeselect = x($x, 'mimeselect') ? $x['mimeselect'] : false; if ($mimeselect) { $mimeselect = mimetype_select($x['profile_uid'], $mimetype); } else { $mimeselect = '<input type="hidden" name="mimetype" value="' . $mimetype . '" />'; } $weblink = $mimetype === 'text/bbcode' ? t('Insert web link') : false; if (x($x, 'hide_weblink')) { $weblink = false; } $embedPhotos = t('Embed image from photo albums'); $writefiles = $mimetype === 'text/bbcode' ? perm_is_allowed($x['profile_uid'], get_observer_hash(), 'write_storage') : false; if (x($x, 'hide_attach')) { $writefiles = false; } $layout = x($x, 'layout') ? $x['layout'] : ''; $layoutselect = x($x, 'layoutselect') ? $x['layoutselect'] : false; if ($layoutselect) { $layoutselect = layout_select($x['profile_uid'], $layout); } else { $layoutselect = '<input type="hidden" name="layout_mid" value="' . $layout . '" />'; } if (array_key_exists('channel_select', $x) && $x['channel_select']) { require_once 'include/channel.php'; $id_select = identity_selector(); } else { $id_select = ''; } $webpage = x($x, 'webpage') ? $x['webpage'] : ''; $tpl = get_markup_template('jot-header.tpl'); App::$page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => z_root(), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$pretext' => x($x, 'pretext') ? $x['pretext'] : '', '$geotag' => $geotag, '$nickname' => $x['nickname'], '$linkurl' => t('Please enter a link URL:'), '$term' => t('Tag term:'), '$whereareu' => t('Where are you right now?'), '$editor_autocomplete' => x($x, 'editor_autocomplete') ? $x['editor_autocomplete'] : '', '$bbco_autocomplete' => x($x, 'bbco_autocomplete') ? $x['bbco_autocomplete'] : '', '$modalchooseimages' => t('Choose images to embed'), '$modalchoosealbum' => t('Choose an album'), '$modaldiffalbum' => t('Choose a different album...'), '$modalerrorlist' => t('Error getting album list'), '$modalerrorlink' => t('Error getting photo link'), '$modalerroralbum' => t('Error getting album'))); $tpl = get_markup_template('jot.tpl'); $jotplugins = ''; $preview = t('Preview'); if (x($x, 'hide_preview')) { $preview = ''; } $defexpire = ($z = get_pconfig($x['profile_uid'], 'system', 'default_post_expire')) && !$webpage ? $z : ''; if ($defexpire) { $defexpire = datetime_convert('UTC', date_default_timezone_get(), $defexpire, 'Y-m-d H:i'); } $defpublish = ($z = get_pconfig($x['profile_uid'], 'system', 'default_post_publish')) && !$webpage ? $z : ''; if ($defpublish) { $defpublish = datetime_convert('UTC', date_default_timezone_get(), $defpublish, 'Y-m-d H:i'); } $cipher = get_pconfig($x['profile_uid'], 'system', 'default_cipher'); if (!$cipher) { $cipher = 'aes256'; } call_hooks('jot_tool', $jotplugins); $o .= replace_macros($tpl, array('$return_path' => x($x, 'return_path') ? $x['return_path'] : App::$query_string, '$action' => z_root() . '/item', '$share' => x($x, 'button') ? $x['button'] : t('Share'), '$webpage' => $webpage, '$placeholdpagetitle' => x($x, 'ptlabel') ? $x['ptlabel'] : t('Page link name'), '$pagetitle' => x($x, 'pagetitle') ? $x['pagetitle'] : '', '$id_select' => $id_select, '$id_seltext' => t('Post as'), '$writefiles' => $writefiles, '$bold' => t('Bold'), '$italic' => t('Italic'), '$underline' => t('Underline'), '$quote' => t('Quote'), '$code' => t('Code'), '$attach' => t('Attach file'), '$weblink' => $weblink, '$embedPhotos' => $embedPhotos, '$embedPhotosModalTitle' => t('Embed an image from your albums'), '$embedPhotosModalCancel' => t('Cancel'), '$embedPhotosModalOK' => t('OK'), '$setloc' => $setloc, '$voting' => t('Toggle voting'), '$feature_voting' => $feature_voting, '$consensus' => 0, '$clearloc' => $clearloc, '$title' => x($x, 'title') ? htmlspecialchars($x['title'], ENT_COMPAT, 'UTF-8') : '', '$placeholdertitle' => x($x, 'placeholdertitle') ? $x['placeholdertitle'] : t('Title (optional)'), '$catsenabled' => feature_enabled($x['profile_uid'], 'categories') && !$webpage ? 'categories' : '', '$category' => x($x, 'category') ? $x['category'] : '', '$placeholdercategory' => t('Categories (optional, comma-separated list)'), '$permset' => t('Permission settings'), '$ptyp' => x($x, 'ptyp') ? $x['ptyp'] : '', '$content' => x($x, 'body') ? htmlspecialchars($x['body'], ENT_COMPAT, 'UTF-8') : '', '$attachment' => x($x, 'attachment') ? $x['attachment'] : '', '$post_id' => x($x, 'post_id') ? $x['post_id'] : '', '$defloc' => $x['default_location'], '$visitor' => $x['visitor'], '$lockstate' => $x['lockstate'], '$acl' => $x['acl'], '$mimeselect' => $mimeselect, '$layoutselect' => $layoutselect, '$showacl' => array_key_exists('showacl', $x) ? $x['showacl'] : true, '$bang' => $x['bang'], '$profile_uid' => $x['profile_uid'], '$preview' => $preview, '$source' => x($x, 'source') ? $x['source'] : '', '$jotplugins' => $jotplugins, '$defexpire' => $defexpire, '$feature_expire' => $feature_expire, '$expires' => t('Set expiration date'), '$defpublish' => $defpublish, '$feature_future' => $feature_future, '$future_txt' => t('Set publish date'), '$feature_encrypt' => feature_enabled($x['profile_uid'], 'content_encrypt') && !$webpage ? true : false, '$encrypt' => t('Encrypt text'), '$cipher' => $cipher, '$expiryModalOK' => t('OK'), '$expiryModalCANCEL' => t('Cancel'), '$expanded' => x($x, 'expanded') ? $x['expanded'] : false, '$bbcode' => x($x, 'bbcode') ? $x['bbcode'] : false)); if ($popup === true) { $o = '<div id="jot-popup" style="display:none">' . $o . '</div>'; } return $o; }
function editblock_content(&$a) { if (argc() < 2) { notice(t('Item not found') . EOL); return; } $channel = get_channel_by_nick(argv(1)); if ($c) { $owner = intval($channel['channel_id']); } $o = ''; // Figure out which post we're editing $post_id = argc() > 2 ? intval(argv(2)) : 0; if (!($post_id && $channel)) { notice(t('Item not found') . EOL); return; } // Now we've got a post and an owner, let's find out if we're allowed to edit it if (!perm_is_allowed($channel['channel_id'], get_observer_hash(), 'write_pages')) { notice(t('Permission denied.') . EOL); return; } // We've already figured out which item we want and whose copy we need, so we don't need anything fancy here $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1", intval($post_id), intval($channel['channel_id'])); if ($itm) { $item_id = q("select * from item_id where service = 'BUILDBLOCK' and iid = %d limit 1", $itm[0]['id']); if ($item_id) { $block_title = $item_id[0]['sid']; } } else { notice(t('Item not found') . EOL); return; } $plaintext = true; // You may or may not be a local user. // if(local_user() && feature_enabled(local_user(),'richtext')) // $plaintext = false; $mimeselect = ''; $mimetype = $itm[0]['mimetype']; if ($mimetype != 'text/bbcode') { $plaintext = true; } if (get_config('system', 'page_mimetype')) { $mimeselect = '<input type="hidden" name="mimetype" value="' . $mimetype . '" />'; } else { $mimeselect = mimetype_select($itm[0]['uid'], $mimetype); } $o .= replace_macros(get_markup_template('edpost_head.tpl'), array('$title' => t('Edit Block'))); $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array('$baseurl' => $a->get_baseurl(), '$editselect' => $plaintext ? 'none' : '/(profile-jot-text|prvmail-text)/', '$ispublic' => ' ', '$geotag' => '', '$nickname' => $channel['channel_address'], '$confirmdelete' => t('Delete block?'))); $tpl = get_markup_template("jot.tpl"); $jotplugins = ''; $jotnets = ''; call_hooks('jot_tool', $jotplugins); call_hooks('jot_networks', $jotnets); //$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); // FIXME A return path with $_SESSION doesn't always work for observer - it may WSoD instead of loading a sensible page. //So, send folk to the webpage list. $rp = 'blocks/' . $channel['channel_address']; $o .= replace_macros($tpl, array('$return_path' => $rp, '$action' => 'item', '$webpage' => ITEM_BUILDBLOCK, '$share' => t('Edit'), '$upload' => t('Upload photo'), '$attach' => t('Attach file'), '$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'), '$ptyp' => $itm[0]['type'], '$mimeselect' => $mimeselect, '$content' => undo_post_tagging($itm[0]['body']), '$post_id' => $post_id, '$baseurl' => $a->get_baseurl(), '$defloc' => $channel['channel_location'], '$visitor' => false, '$public' => t('Public post'), '$jotnets' => $jotnets, '$title' => htmlspecialchars($itm[0]['title'], ENT_COMPAT, 'UTF-8'), '$placeholdertitle' => t('Set title'), '$pagetitle' => $block_title, '$category' => '', '$placeholdercategory' => t('Categories (comma-separated list)'), '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$lockstate' => $lockstate, '$acl' => '', '$bang' => '', '$profile_uid' => intval($channel['channel_id']), '$preview' => feature_enabled(local_user(), 'preview') ? t('Preview') : '', '$jotplugins' => $jotplugins, '$sourceapp' => $itm[0]['app'], '$defexpire' => '', '$feature_expire' => false, '$expires' => t('Set expiration date'))); $ob = get_observer_hash(); if ($itm[0]['author_xchan'] === $ob || $itm[0]['owner_xchan'] === $ob) { $o .= '<br /><br /><a class="block-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Block') . '</a><br />'; } return $o; }