2014-01-30 01:09:20 +00:00
|
|
|
<?php /** @file */
|
|
|
|
|
|
|
|
require_once('include/chat.php');
|
|
|
|
|
|
|
|
function chat_init(&$a) {
|
|
|
|
|
|
|
|
$which = null;
|
|
|
|
if(argc() > 1)
|
|
|
|
$which = argv(1);
|
|
|
|
if(! $which) {
|
|
|
|
if(local_user()) {
|
|
|
|
$channel = $a->get_channel();
|
|
|
|
if($channel && $channel['channel_address'])
|
|
|
|
$which = $channel['channel_address'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(! $which) {
|
|
|
|
notice( t('You must be logged in to see this page.') . EOL );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$profile = 0;
|
|
|
|
$channel = $a->get_channel();
|
|
|
|
|
|
|
|
if((local_user()) && (argc() > 2) && (argv(2) === 'view')) {
|
|
|
|
$which = $channel['channel_address'];
|
|
|
|
$profile = argv(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
$a->page['htmlhead'] .= '<link rel="alternate" type="application/atom+xml" href="' . $a->get_baseurl() . '/feed/' . $which .'" />' . "\r\n" ;
|
|
|
|
|
|
|
|
// Run profile_load() here to make sure the theme is set before
|
|
|
|
// we start loading content
|
|
|
|
|
|
|
|
profile_load($a,$which,$profile);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function chat_content(&$a) {
|
|
|
|
|
2014-01-30 02:19:19 +00:00
|
|
|
$observer = get_observer_hash();
|
|
|
|
if(! $observer) {
|
|
|
|
notice( t('Permission denied.') . EOL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(! perm_is_allowed($a->profile['profile_uid'],$observer,'chat')) {
|
2014-01-30 01:09:20 +00:00
|
|
|
notice( t('Permission denied.') . EOL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if((argc() > 3) && intval(argv(2)) && (argv(3) === 'leave')) {
|
2014-01-30 02:19:19 +00:00
|
|
|
chatroom_leave($observer,$room_id,$_SERVER['REMOTE_ADDR']);
|
2014-01-30 01:09:20 +00:00
|
|
|
goaway(z_root() . '/channel/' . argv(1));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(argc() > 2 && intval(argv(2))) {
|
|
|
|
$room_id = intval(argv(2));
|
2014-01-30 02:19:19 +00:00
|
|
|
$x = chatroom_enter($observer,$room_id,'online',$_SERVER['REMOTE_ADDR']);
|
2014-01-30 01:09:20 +00:00
|
|
|
if(! $x)
|
|
|
|
return;
|
2014-01-30 04:14:18 +00:00
|
|
|
$o = replace_macros(get_markup_template('chat.tpl'),array(
|
|
|
|
'$room_id' => $room_id,
|
|
|
|
'$submit' => t('Submit')
|
|
|
|
));
|
2014-01-30 01:09:20 +00:00
|
|
|
return $o;
|
|
|
|
}
|
2014-01-30 04:40:37 +00:00
|
|
|
require_once('include/widgets.php');
|
|
|
|
|
|
|
|
return widget_chatroom_list(array());
|
2014-01-30 01:09:20 +00:00
|
|
|
|
|
|
|
}
|