whitespace

This commit is contained in:
Mario Vavti 2016-05-04 11:49:29 +02:00
parent 7c57da3a28
commit 0db8d3f6c6

View File

@ -4,46 +4,43 @@ namespace Zotlabs\Module;
require_once('include/identity.php'); require_once('include/identity.php');
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');
class Editblock extends \Zotlabs\Web\Controller { class Editblock extends \Zotlabs\Web\Controller {
function init() { function init() {
if(argc() > 1 && argv(1) === 'sys' && is_site_admin()) { if(argc() > 1 && argv(1) === 'sys' && is_site_admin()) {
$sys = get_sys_channel(); $sys = get_sys_channel();
if($sys && intval($sys['channel_id'])) { if($sys && intval($sys['channel_id'])) {
\App::$is_sys = true; \App::$is_sys = true;
} }
} }
if(argc() > 1) if(argc() > 1)
$which = argv(1); $which = argv(1);
else else
return; return;
profile_load($a,$which); profile_load($a,$which);
} }
function get() {
function get() {
if(! \App::$profile) { if(! \App::$profile) {
notice( t('Requested profile is not available.') . EOL ); notice( t('Requested profile is not available.') . EOL );
\App::$error = 404; \App::$error = 404;
return; return;
} }
$which = argv(1); $which = argv(1);
$uid = local_channel(); $uid = local_channel();
$owner = 0; $owner = 0;
$channel = null; $channel = null;
$observer = \App::get_observer(); $observer = \App::get_observer();
$channel = \App::get_channel(); $channel = \App::get_channel();
if(\App::$is_sys && is_site_admin()) { if(\App::$is_sys && is_site_admin()) {
$sys = get_sys_channel(); $sys = get_sys_channel();
if($sys && intval($sys['channel_id'])) { if($sys && intval($sys['channel_id'])) {
@ -52,7 +49,7 @@ class Editblock extends \Zotlabs\Web\Controller {
$observer = $sys; $observer = $sys;
} }
} }
if(! $owner) { if(! $owner) {
// Figure out who the page owner is. // Figure out who the page owner is.
$r = q("select channel_id from channel where channel_address = '%s'", $r = q("select channel_id from channel where channel_address = '%s'",
@ -62,27 +59,26 @@ class Editblock extends \Zotlabs\Web\Controller {
$owner = intval($r[0]['channel_id']); $owner = intval($r[0]['channel_id']);
} }
} }
$ob_hash = (($observer) ? $observer['xchan_hash'] : ''); $ob_hash = (($observer) ? $observer['xchan_hash'] : '');
if(! perm_is_allowed($owner,$ob_hash,'write_pages')) { if(! perm_is_allowed($owner,$ob_hash,'write_pages')) {
notice( t('Permission denied.') . EOL); notice( t('Permission denied.') . EOL);
return; return;
} }
$is_owner = (($uid && $uid == $owner) ? true : false); $is_owner = (($uid && $uid == $owner) ? true : false);
$o = ''; $o = '';
// Figure out which post we're editing // Figure out which post we're editing
$post_id = ((argc() > 2) ? intval(argv(2)) : 0); $post_id = ((argc() > 2) ? intval(argv(2)) : 0);
if(! ($post_id && $owner)) { if(! ($post_id && $owner)) {
notice( t('Item not found') . EOL); notice( t('Item not found') . EOL);
return; return;
} }
$itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1", $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1",
intval($post_id), intval($post_id),
intval($owner) intval($owner)
@ -98,20 +94,20 @@ class Editblock extends \Zotlabs\Web\Controller {
notice( t('Item not found') . EOL); notice( t('Item not found') . EOL);
return; return;
} }
$plaintext = true; $plaintext = true;
$mimeselect = ''; $mimeselect = '';
$mimetype = $itm[0]['mimetype']; $mimetype = $itm[0]['mimetype'];
if($mimetype != 'text/bbcode') if($mimetype != 'text/bbcode')
$plaintext = true; $plaintext = true;
if(get_config('system','page_mimetype')) if(get_config('system','page_mimetype'))
$mimeselect = '<input type="hidden" name="mimetype" value="' . $mimetype . '" />'; $mimeselect = '<input type="hidden" name="mimetype" value="' . $mimetype . '" />';
else else
$mimeselect = mimetype_select($itm[0]['uid'],$mimetype); $mimeselect = mimetype_select($itm[0]['uid'],$mimetype);
\App::$page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array( \App::$page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array(
'$baseurl' => z_root(), '$baseurl' => z_root(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
@ -122,17 +118,17 @@ class Editblock extends \Zotlabs\Web\Controller {
'$confirmdelete' => t('Delete block?'), '$confirmdelete' => t('Delete block?'),
'$bbco_autocomplete'=> (($mimetype == 'text/bbcode') ? 'bbcode' : 'comanche-block') '$bbco_autocomplete'=> (($mimetype == 'text/bbcode') ? 'bbcode' : 'comanche-block')
)); ));
$tpl = get_markup_template("jot.tpl"); $tpl = get_markup_template("jot.tpl");
$jotplugins = ''; $jotplugins = '';
$jotnets = ''; $jotnets = '';
call_hooks('jot_tool', $jotplugins); call_hooks('jot_tool', $jotplugins);
call_hooks('jot_networks', $jotnets); call_hooks('jot_networks', $jotnets);
$rp = 'blocks/' . $channel['channel_address']; $rp = 'blocks/' . $channel['channel_address'];
$editor = replace_macros($tpl,array( $editor = replace_macros($tpl,array(
'$return_path' => $rp, '$return_path' => $rp,
'$action' => 'item', '$action' => 'item',
@ -174,18 +170,16 @@ class Editblock extends \Zotlabs\Web\Controller {
'$defexpire' => '', '$defexpire' => '',
'$bbcode' => (($mimetype == 'text/bbcode') ? true : false) '$bbcode' => (($mimetype == 'text/bbcode') ? true : false)
)); ));
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array( $o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
'$title' => t('Edit Block'), '$title' => t('Edit Block'),
'$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false), '$delete' => ((($itm[0]['author_xchan'] === $ob_hash) || ($itm[0]['owner_xchan'] === $ob_hash)) ? t('Delete') : false),
'$id' => $itm[0]['id'], '$id' => $itm[0]['id'],
'$editor' => $editor '$editor' => $editor
)); ));
return $o; return $o;
} }
}
}