aboutsummaryrefslogtreecommitdiffstats
path: root/include/Contact.php
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-07-14 09:01:02 +1000
committerredmatrix <redmatrix@redmatrix.me>2015-07-14 09:01:02 +1000
commit86633bda48af77483a082d79c1bec7abc3febab3 (patch)
tree705e517804aa881d64d1830d04568b9cfc7e0b47 /include/Contact.php
parentb7d3eb16056d4c91f60f3ae1e3b0085fdd6331b6 (diff)
parenta07be48017fd4b9a83c14153674386f2bcdc016c (diff)
downloadvolse-hubzilla-86633bda48af77483a082d79c1bec7abc3febab3.tar.gz
volse-hubzilla-86633bda48af77483a082d79c1bec7abc3febab3.tar.bz2
volse-hubzilla-86633bda48af77483a082d79c1bec7abc3febab3.zip
Merge pull request #373 from zzottel/master
change account_default_channel if default channel is removed
Diffstat (limited to 'include/Contact.php')
-rw-r--r--include/Contact.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/Contact.php b/include/Contact.php
index 9490fd2da..035e83a82 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -311,6 +311,24 @@ function channel_remove($channel_id, $local = true, $unset_session=true) {
intval(PAGE_REMOVED),
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_flags = (hubloc_flags | %d) where hubloc_hash = '%s' and hubloc_url = '%s' ",
intval(HUBLOC_FLAGS_DELETED),