aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/Contact.php18
-rw-r--r--include/bbcode.php6
-rw-r--r--mod/menu.php2
-rw-r--r--mod/mitem.php9
-rw-r--r--view/tpl/menuedit.tpl4
-rw-r--r--view/tpl/mitemedit.tpl2
6 files changed, 30 insertions, 11 deletions
diff --git a/include/Contact.php b/include/Contact.php
index e7aa4f861..ad3580f42 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -331,6 +331,24 @@ function channel_remove($channel_id, $local = true, $unset_session=true) {
dbesc(datetime_convert()),
intval($channel_id)
);
+ // if this was the default channel, set another one as default
+ if($a->account['account_default_channel'] == $channel_id) {
+ $r = q("select channel_id from channel where channel_account_id = %d and not ( channel_pageflags & %d)>0 limit 1",
+ intval($a->account['account_id']),
+ intval(PAGE_REMOVED));
+ if ($r) {
+ $rr = q("update account set account_default_channel = %d where account_id = %d",
+ intval($r[0]['channel_id']),
+ intval($a->account['account_id']));
+ logger("Default channel deleted, changing default to channel_id " . $r[0]['channel_id']);
+ }
+ else {
+ $rr = q("update account set account_default_channel = 0 where account_id = %d",
+ intval($r[0]['channel_id']),
+ intval($a->account['account_id']));
+ }
+ }
+
$r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s' and hubloc_url = '%s' ",
dbesc($channel['channel_hash']),
diff --git a/include/bbcode.php b/include/bbcode.php
index aa2562d62..2e201344c 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -174,10 +174,14 @@ function bb_parse_app($match) {
function bb_parse_element($match) {
$j = json_decode(base64url_decode($match[1]),true);
- if ($j) {
+ if ($j && local_channel()) {
$text = sprintf( t('Install %s element: '), translate_design_element($j['type'])) . $j['pagetitle'];
$o = EOL . '<a href="#" onclick="importElement(\'' . $match[1] . '\'); return false;" >' . $text . '</a>' . EOL;
}
+ else {
+ $text = sprintf( t('This post contains an installable %s element, however you lack permissions to install it on this site.' ), translate_design_element($j['type'])) . $j['pagetitle'];
+ $o = EOL . $text . EOL;
+ }
return $o;
}
diff --git a/mod/menu.php b/mod/menu.php
index f46dc9471..7763c4ed1 100644
--- a/mod/menu.php
+++ b/mod/menu.php
@@ -137,7 +137,9 @@ function menu_content(&$a) {
$o = replace_macros(get_markup_template('menuedit.tpl'), array(
'$header' => t('Edit Menu'),
+ '$sys' => $a->is_sys,
'$menu_id' => intval(argv(1)),
+ '$menu_edit_link' => 'mitem/' . intval(argv(1)) . (($a->is_sys) ? '?f=&sys=1' : ''),
'$hintedit' => t('Add or remove entries to this menu'),
'$editcontents' => t('Edit menu contents'),
'$menu_name' => array('menu_name', t('Menu name'), $m['menu_name'], t('Must be unique, only seen by you'), '*'),
diff --git a/mod/mitem.php b/mod/mitem.php
index c4c293d1e..bc93165ac 100644
--- a/mod/mitem.php
+++ b/mod/mitem.php
@@ -44,9 +44,6 @@ function mitem_post(&$a) {
if(! $a->data['menu'])
return;
-
- $channel = $a->get_channel();
-
if(!$_REQUEST['mitem_desc'] || !$_REQUEST['mitem_link']) {
notice( t('Unable to create element.') . EOL);
return;
@@ -90,9 +87,6 @@ function mitem_post(&$a) {
}
-
-
-
}
@@ -167,7 +161,8 @@ function mitem_content(&$a) {
'$submit_more' => t('Submit and continue'),
'$display' => $display,
'$lockstate' => $lockstate,
- '$menu_names' => $menu_names
+ '$menu_names' => $menu_names,
+ '$sys' => $a->is_sys
));
$o .= replace_macros(get_markup_template('mitemlist.tpl'),array(
diff --git a/view/tpl/menuedit.tpl b/view/tpl/menuedit.tpl
index 0e5df2c47..5c8734ef7 100644
--- a/view/tpl/menuedit.tpl
+++ b/view/tpl/menuedit.tpl
@@ -1,9 +1,9 @@
{{if $header}}
<div class="generic-content-wrapper">
<div class="section-title-wrapper">
- {{if $menu_id}}
+ {{if $menu_edit_link}}
<div class="pull-right">
- <a href="mitem/{{$menu_id}}" title="{{$hintedit}}" class="btn btn-xs btn-success"><i class="icon-edit"></i>&nbsp;{{$editcontents}}</a>
+ <a href="{{$menu_edit_link}}" title="{{$hintedit}}" class="btn btn-xs btn-success"><i class="icon-edit"></i>&nbsp;{{$editcontents}}</a>
</div>
{{/if}}
<h2>{{$header}}</h2>
diff --git a/view/tpl/mitemedit.tpl b/view/tpl/mitemedit.tpl
index 8715d6391..f9dc4e2cc 100644
--- a/view/tpl/mitemedit.tpl
+++ b/view/tpl/mitemedit.tpl
@@ -5,7 +5,7 @@
</div>
{{/if}}
<div id="menu-element-creator" class="section-content-tools-wrapper" style="display: {{$display}};">
- <form id="mitemedit" action="mitem/{{$menu_id}}{{if $mitem_id}}/{{$mitem_id}}{{/if}}" method="post" >
+ <form id="mitemedit" action="mitem/{{$menu_id}}{{if $mitem_id}}/{{$mitem_id}}{{/if}}{{if $sys}}?f=&sys=1{{/if}}" method="post" >
<input type="hidden" name="menu_id" value="{{$menu_id}}" />
{{if $mitem_id}}
<input type="hidden" name="mitem_id" value="{{$mitem_id}}" />