streams/mod/manage.php

92 lines
2.6 KiB
PHP
Raw Normal View History

2011-03-02 04:36:24 +00:00
<?php
function manage_content(&$a) {
if(! get_account_id()) {
2011-03-02 04:36:24 +00:00
notice( t('Permission denied.') . EOL);
return;
}
2012-10-02 02:04:21 +00:00
require_once('include/security.php');
2012-09-03 03:57:44 +00:00
$change_channel = ((argc() > 1) ? intval(argv(1)) : 0);
2012-10-02 02:04:21 +00:00
2012-11-02 07:55:40 +00:00
if((argc() > 2) && (argv(2) === 'default')) {
$r = q("select channel_id from channel where channel_id = %d and channel_account_id = %d limit 1",
2012-11-01 22:45:02 +00:00
intval($change_channel),
intval(get_account_id())
);
2012-11-02 07:55:40 +00:00
if($r) {
q("update account set account_default_channel = %d where account_id = %d limit 1",
intval($change_channel),
intval(get_account_id())
);
}
2012-11-01 22:45:02 +00:00
goaway(z_root() . '/manage');
}
2012-09-03 03:30:47 +00:00
if($change_channel) {
2012-10-02 02:04:21 +00:00
$r = change_channel($change_channel);
if($r && $r['channel_startpage'])
goaway(z_root() . '/' . $r['channel_startpage']);
2012-09-03 03:57:44 +00:00
goaway(z_root());
2012-09-03 03:30:47 +00:00
}
$channels = null;
2011-03-02 04:36:24 +00:00
if(local_user()) {
$r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and not ( channel_pageflags & %d ) order by channel_name ",
intval(get_account_id()),
intval(PAGE_REMOVED)
);
2011-03-02 04:36:24 +00:00
$selected_channel = null;
2012-11-02 07:55:40 +00:00
$account = get_app()->get_account();
2012-09-03 03:30:47 +00:00
if($r && count($r)) {
$channels = $r;
for($x = 0; $x < count($channels); $x ++) {
$channels[$x]['link'] = 'manage/' . intval($channels[$x]['channel_id']);
if($channels[$x]['channel_id'] == local_user())
$selected_channel = $channels[$x];
2012-11-02 07:55:40 +00:00
$channels[$x]['default'] = (($channels[$x]['channel_id'] == $account['account_default_channel']) ? "1" : '');
$channels[$x]['default_links'] = '1';
}
2012-09-03 03:30:47 +00:00
}
$r = q("select count(channel_id) as total from channel where channel_account_id = %d and not ( channel_pageflags & %d )",
intval(get_account_id()),
intval(PAGE_REMOVED)
);
$limit = service_class_fetch(local_user(),'total_identities');
if($limit !== false) {
$channel_usage_message = sprintf( t("You have created %1$.0f of %2$.0f allowed channels."), $r[0]['total'], $limit);
}
else {
$channel_usage_message = '';
}
2011-03-02 04:36:24 +00:00
}
2012-09-03 03:30:47 +00:00
$links = array(
array( 'new_channel', t('Create a new channel'), t('Create a new channel'))
2012-09-03 03:30:47 +00:00
);
2011-03-02 04:36:24 +00:00
$o = replace_macros(get_markup_template('channels.tpl'), array(
2012-11-01 22:45:02 +00:00
'$header' => t('Channel Manager'),
'$msg_selected' => t('Current Channel'),
'$selected' => $selected_channel,
2012-11-01 22:45:02 +00:00
'$desc' => t('Attach to one of your channels by selecting it.'),
2012-11-02 07:55:40 +00:00
'$msg_default' => t('Default Channel'),
'$msg_make_default' => t('Make Default'),
2012-11-01 22:45:02 +00:00
'$links' => $links,
'$all_channels' => $channels,
'$channel_usage_message' => $channel_usage_message,
));
2011-03-02 04:36:24 +00:00
return $o;
}