aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/channel.php86
-rw-r--r--include/conversation.php6
-rw-r--r--include/zot.php4
3 files changed, 91 insertions, 5 deletions
diff --git a/include/channel.php b/include/channel.php
index f6252f094..efa39dcac 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -554,6 +554,92 @@ function change_channel_keys($channel) {
return $ret;
}
+function channel_change_address($channel,$new_address) {
+
+ $ret = array('success' => false);
+
+ $old_address = $channel['channel_address'];
+
+ if($new_address === 'sys') {
+ $ret['message'] = t('Reserved nickname. Please choose another.');
+ return $ret;
+ }
+
+ if(check_webbie(array($new_address)) !== $new_address) {
+ $ret['message'] = t('Nickname has unsupported characters or is already being used on this site.');
+ return $ret;
+ }
+
+ $r = q("update channel set channel_address = '%s' where channel_id = %d",
+ dbesc($new_address),
+ intval($channel['channel_id'])
+ );
+ if(! $r) {
+ return $ret;
+ }
+
+ $r = q("select * from channel where channel_id = %d",
+ intval($channel['channel_id'])
+ );
+
+ if(! $r) {
+ $ret['message'] = t('Unable to retrieve modified identity');
+ return $ret;
+ }
+
+ $r = q("update xchan set xchan_addr = '%s' where xchan_hash = '%s'",
+ dbesc($new_address . '@' . App::get_hostname()),
+ dbesc($channel['channel_hash'])
+ );
+
+ $h = q("select * from hubloc where hubloc_hash = '%s' and hubloc_url = '%s' ",
+ dbesc($channel['channel_hash']),
+ dbesc(z_root())
+ );
+
+ if($h) {
+ foreach($h as $hv) {
+ if($hv['hubloc_primary']) {
+ q("update hubloc set hubloc_primary = 0 where hubloc_id = %d",
+ intval($hv['hubloc_id'])
+ );
+ }
+ q("update hubloc set hubloc_deleted = 1 where hubloc_id = %d",
+ intval($hv['hubloc_id'])
+ );
+
+ unset($hv['hubloc_id']);
+ $hv['hubloc_addr'] = $new_address . '@' . App::get_hostname();
+ hubloc_store_lowlevel($hv);
+ }
+ }
+
+ // fix apps which were stored with the actual name rather than a macro
+
+ $r = q("select * from app where app_channel = %d and app_system = 1",
+ intval($channel['channel_id'])
+ );
+ if($r) {
+ foreach($r as $rv) {
+ $replace = preg_replace('/([\=\/])(' . $old_address . ')($|[\%\/])/ism','$1' . $new_address . '$3',$rv['app_url']);
+ if($replace != $rv['app_url']) {
+ q("update app set app_url = '%s' where id = %d",
+ dbesc($replace),
+ intval($rv['id'])
+ );
+ }
+ }
+ }
+
+ Zotlabs\Daemon\Master::Summon(array('Notifier', 'refresh_all', $channel['channel_id']));
+
+ $ret['success'] = true;
+ return $ret;
+}
+
+
+
+
/**
diff --git a/include/conversation.php b/include/conversation.php
index 460c97efb..13ae571d6 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -1624,11 +1624,9 @@ function network_tabs() {
// tabs
$tabs = array();
- $d = get_config('system','disable_discover_tab');
- if($d === false)
- $d = 1;
+ $disable_discover_tab = get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false;
- if(! $d) {
+ if(! $disable_discover_tab) {
$tabs[] = array(
'label' => t('Discover'),
'url' => z_root() . '/' . $cmd . '?f=&fh=1' ,
diff --git a/include/zot.php b/include/zot.php
index 75c37836d..3e2a66734 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -1344,8 +1344,10 @@ function public_recips($msg) {
$include_sys = false;
if($msg['message']['type'] === 'activity') {
- if(! get_config('system','disable_discover_tab'))
+ $disable_discover_tab = get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false;
+ if(! $disable_discover_tab)
$include_sys = true;
+
$perm = 'send_stream';
if(array_key_exists('flags',$msg['message']) && in_array('thread_parent', $msg['message']['flags'])) {