In the rare case where a default channel is not selected but channels actually exist, you should be able to visit /manage and set a default channel. Originally I believe this may have been possible but the ability was lost when delegation was added to the interface - which requires an active channel. Remove the active channel restriction so that the rest of the interface works (channel selections can be made and the ability to set a default is provided) however delegation info isn't presented unless there is an active channel.

This commit is contained in:
zotlabs 2017-04-20 19:52:50 -07:00
parent f52c670c05
commit 2d90b831f0

View File

@ -46,107 +46,111 @@ class Manage extends \Zotlabs\Web\Controller {
$channels = null; $channels = null;
if(local_channel()) { $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and channel_removed = 0 order by channel_name ",
$r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and channel_removed = 0 order by channel_name ", intval(get_account_id())
intval(get_account_id()) );
);
$account = \App::get_account(); $account = \App::get_account();
if($r && count($r)) { if($r && count($r)) {
$channels = $r; $channels = $r;
for($x = 0; $x < count($channels); $x ++) { for($x = 0; $x < count($channels); $x ++) {
$channels[$x]['link'] = 'manage/' . intval($channels[$x]['channel_id']); $channels[$x]['link'] = 'manage/' . intval($channels[$x]['channel_id']);
$channels[$x]['default'] = (($channels[$x]['channel_id'] == $account['account_default_channel']) ? "1" : ''); $channels[$x]['default'] = (($channels[$x]['channel_id'] == $account['account_default_channel']) ? "1" : '');
$channels[$x]['default_links'] = '1'; $channels[$x]['default_links'] = '1';
$c = q("SELECT id, item_wall FROM item $c = q("SELECT id, item_wall FROM item
WHERE item_unseen = 1 and uid = %d " . item_normal(), WHERE item_unseen = 1 and uid = %d " . item_normal(),
intval($channels[$x]['channel_id']) intval($channels[$x]['channel_id'])
); );
if($c) { if($c) {
foreach ($c as $it) { foreach ($c as $it) {
if(intval($it['item_wall'])) if(intval($it['item_wall']))
$channels[$x]['home'] ++; $channels[$x]['home'] ++;
else else
$channels[$x]['network'] ++; $channels[$x]['network'] ++;
}
} }
}
$intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ", $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ",
intval($channels[$x]['channel_id']) intval($channels[$x]['channel_id'])
); );
if($intr) if($intr)
$channels[$x]['intros'] = intval($intr[0]['total']); $channels[$x]['intros'] = intval($intr[0]['total']);
$mails = q("SELECT count(id) as total from mail WHERE channel_id = %d AND mail_seen = 0 and from_xchan != '%s' ", $mails = q("SELECT count(id) as total from mail WHERE channel_id = %d AND mail_seen = 0 and from_xchan != '%s' ",
intval($channels[$x]['channel_id']), intval($channels[$x]['channel_id']),
dbesc($channels[$x]['channel_hash']) dbesc($channels[$x]['channel_hash'])
); );
if($mails) if($mails)
$channels[$x]['mail'] = intval($mails[0]['total']); $channels[$x]['mail'] = intval($mails[0]['total']);
$events = q("SELECT etype, dtstart, adjust FROM event $events = q("SELECT etype, dtstart, adjust FROM event
WHERE event.uid = %d AND dtstart < '%s' AND dtstart > '%s' and dismissed = 0 WHERE event.uid = %d AND dtstart < '%s' AND dtstart > '%s' and dismissed = 0
ORDER BY dtstart ASC ", ORDER BY dtstart ASC ",
intval($channels[$x]['channel_id']), intval($channels[$x]['channel_id']),
dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + 7 days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + 7 days')),
dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days'))
); );
if($events) { if($events) {
$channels[$x]['all_events'] = count($events); $channels[$x]['all_events'] = count($events);
if($channels[$x]['all_events']) { if($channels[$x]['all_events']) {
$str_now = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d'); $str_now = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d');
foreach($events as $e) { foreach($events as $e) {
$bd = false; $bd = false;
if($e['etype'] === 'birthday') { if($e['etype'] === 'birthday') {
$channels[$x]['birthdays'] ++; $channels[$x]['birthdays'] ++;
$bd = true; $bd = true;
} }
else { else {
$channels[$x]['events'] ++; $channels[$x]['events'] ++;
} }
if(datetime_convert('UTC', ((intval($e['adjust'])) ? date_default_timezone_get() : 'UTC'), $e['dtstart'], 'Y-m-d') === $str_now) { if(datetime_convert('UTC', ((intval($e['adjust'])) ? date_default_timezone_get() : 'UTC'), $e['dtstart'], 'Y-m-d') === $str_now) {
$channels[$x]['all_events_today'] ++; $channels[$x]['all_events_today'] ++;
if($bd) if($bd)
$channels[$x]['birthdays_today'] ++; $channels[$x]['birthdays_today'] ++;
else else
$channels[$x]['events_today'] ++; $channels[$x]['events_today'] ++;
}
} }
} }
} }
} }
} }
$r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0", }
intval(get_account_id())
); $r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0",
$limit = account_service_class_fetch(get_account_id(),'total_identities'); intval(get_account_id())
if($limit !== false) { );
$channel_usage_message = sprintf( t("You have created %1$.0f of %2$.0f allowed channels."), $r[0]['total'], $limit); $limit = account_service_class_fetch(get_account_id(),'total_identities');
} if($limit !== false) {
else { $channel_usage_message = sprintf( t("You have created %1$.0f of %2$.0f allowed channels."), $r[0]['total'], $limit);
$channel_usage_message = '';
}
} }
else {
$channel_usage_message = '';
}
$create = array( 'new_channel', t('Create a new channel'), t('Create New')); $create = array( 'new_channel', t('Create a new channel'), t('Create New'));
$delegates = q("select * from abook left join xchan on abook_xchan = xchan_hash where $delegates = null;
abook_channel = %d and abook_xchan in ( select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'delegate' and v = '1' )",
intval(local_channel()), if(local_channel()) {
intval(local_channel()) $delegates = q("select * from abook left join xchan on abook_xchan = xchan_hash where
); abook_channel = %d and abook_xchan in ( select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'delegate' and v = '1' )",
intval(local_channel()),
intval(local_channel())
);
}
if($delegates) { if($delegates) {
for($x = 0; $x < count($delegates); $x ++) { for($x = 0; $x < count($delegates); $x ++) {