aboutsummaryrefslogblamecommitdiffstats
path: root/mod/manage.php
blob: d29830f904e6c3df2b4859b3093260b40ff1ba09 (plain) (tree)
1
2
3
4
5
6
7
8
9

     

                              
                                



                                                       

                                             
                                                               
 










                                                                                                                     
                             

                                                     

                                                                         
                                 

         
                         
 
                          
                                                                                                                                                                  
                                                
                  
 


                                                                 
                                                                                                        
                 

         
                       
                                                                                  

          
 
                                                                       





                                                                                            

           


                  
 
<?php

function manage_content(&$a) {

	if(! get_account_id()) {
		notice( t('Permission denied.') . EOL);
		return;
	}

	require_once('include/security.php');

	$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",
			intval($change_channel),
			intval(get_account_id())
		);
		goaway(z_root() . '/manage');
	}

	if($change_channel) {
		$r = change_channel($change_channel);

		if($r && $r['channel_startpage'])
			goaway(z_root() . '/' . $r['channel_startpage']);
		goaway(z_root());
	}

	$channels = null;

	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 ",
			intval(get_account_id())
		);

		if($r && count($r)) {
			$channels = $r;
			for($x = 0; $x < count($channels); $x ++)
				$channels[$x]['link'] = 'manage/' . intval($channels[$x]['channel_id']);
		}
	}

	$links = array(
		array( 'new_channel', t('Create a new channel'), t('New Channel'))
	);


	$o = replace_macros(get_markup_template('channels.tpl'), array(
		'$header'           => t('Channel Manager'),
		'$desc'             => t('Attach to one of your channels by selecting it.'),
		'$msg_primary'      => t('Default Channel'),
		'$msg_make_primary' => t('Make Default'),
		'$links'            => $links,
		'$all_channels'     => $channels,
	));


	return $o;

}