fix default channel

This commit is contained in:
friendica 2012-11-02 18:55:40 +11:00
parent 83cf11dd95
commit 9bb1b7e3ed
3 changed files with 18 additions and 13 deletions

View file

@ -11,14 +11,17 @@ function manage_content(&$a) {
$change_channel = ((argc() > 1) ? intval(argv(1)) : 0);
if((argc() > 2) && (argv(2) === 'primary')) {
q("update channel set channel_primary = 0 where channel_account_id = %d",
intval(get_account_id())
);
q("update channel set channel_primary = 1 where channel_id = %d and channel_account_id = %d limit 1",
if((argc() > 2) && (argv(2) === 'default')) {
$r = q("select channel_id from channel where channel_id = %d and channel_account_id = %d limit 1",
intval($change_channel),
intval(get_account_id())
);
if($r) {
q("update account set account_default_channel = %d where account_id = %d limit 1",
intval($change_channel),
intval(get_account_id())
);
}
goaway(z_root() . '/manage');
}
@ -38,6 +41,7 @@ function manage_content(&$a) {
);
$selected_channel = null;
$account = get_app()->get_account();
if($r && count($r)) {
$channels = $r;
@ -45,7 +49,8 @@ function manage_content(&$a) {
$channels[$x]['link'] = 'manage/' . intval($channels[$x]['channel_id']);
if($channels[$x]['channel_id'] == local_user())
$selected_channel = $channels[$x];
$channels[$x]['primary_links'] = '1';
$channels[$x]['default'] = (($channels[$x]['channel_id'] == $account['account_default_channel']) ? "1" : '');
$channels[$x]['default_links'] = '1';
}
}
}
@ -60,8 +65,8 @@ function manage_content(&$a) {
'$msg_selected' => t('Current Channel'),
'$selected' => $selected_channel,
'$desc' => t('Attach to one of your channels by selecting it.'),
'$msg_primary' => t('Default Channel'),
'$msg_make_primary' => t('Make Default'),
'$msg_default' => t('Default Channel'),
'$msg_make_default' => t('Make Default'),
'$links' => $links,
'$all_channels' => $channels,
));

View file

@ -12,7 +12,7 @@
margin-bottom: 20px;
}
.channel-selection-primary {
.channel-selection-default {
font-size: 0.8em;
margin-bottom: 10px;
}

View file

@ -1,9 +1,9 @@
<div class="channel-selection">
{{ if $channel.primary_links }}
{{ if $channel.channel_primary }}
<div class="channel-selection-primary primary">$msg_primary</div>
{{ if $channel.default_links }}
{{ if $channel.default }}
<div class="channel-selection-default default">$msg_default</div>
{{ else }}
<div class="channel-selection-primary"><a href="manage/$channel.channel_id/primary">$msg_make_primary</a></div>
<div class="channel-selection-default"><a href="manage/$channel.channel_id/default">$msg_make_default</a></div>
{{ endif }}
{{ endif }}
<a href="$channel.link" class="channel-selection-photo-link" title="$channel.channel_name"><img class="channel-photo" src="$channel.xchan_photo_m" alt="$channel.channel_name" /></a>