diff options
author | Michael Meer <michael@meer.name> | 2014-01-30 10:21:21 +0100 |
---|---|---|
committer | Michael Meer <michael@meer.name> | 2014-01-30 10:21:21 +0100 |
commit | e5d1e20ff50f49909e7df6fe7efe0d7488e58eaa (patch) | |
tree | a3e0b7d7e1f9a4a8a2af39d5c8fad8d62f0411a3 /mod/chat.php | |
parent | ef97a454bbccbd9f7e0e63180c365ed3227fe42c (diff) | |
parent | 6c6a9b963a925d33b2cc436d877a4edc5f0d59b1 (diff) | |
download | volse-hubzilla-e5d1e20ff50f49909e7df6fe7efe0d7488e58eaa.tar.gz volse-hubzilla-e5d1e20ff50f49909e7df6fe7efe0d7488e58eaa.tar.bz2 volse-hubzilla-e5d1e20ff50f49909e7df6fe7efe0d7488e58eaa.zip |
Merge branch 'master' of https://github.com/friendica/red
to be in sync with master repro
Diffstat (limited to 'mod/chat.php')
-rw-r--r-- | mod/chat.php | 147 |
1 files changed, 147 insertions, 0 deletions
diff --git a/mod/chat.php b/mod/chat.php new file mode 100644 index 000000000..54fa58092 --- /dev/null +++ b/mod/chat.php @@ -0,0 +1,147 @@ +<?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_post(&$a) { + + if($_POST['room_name']) + $room = strip_tags(trim($_POST['room_name'])); + + if((! $room) || (! local_user())) + return; + + $channel = $a->get_channel(); + + + if($_POST['action'] === 'drop') { + chatroom_destroy($channel,array('cr_name' => $room)); + goaway(z_root() . '/chat/' . $channel['channel_address']); + } + + + $arr = array('name' => $room); + $arr['allow_gid'] = perms2str($_REQUEST['group_allow']); + $arr['allow_cid'] = perms2str($_REQUEST['contact_allow']); + $arr['deny_gid'] = perms2str($_REQUEST['group_deny']); + $arr['deny_cid'] = perms2str($_REQUEST['contact_deny']); + + chatroom_create($channel,$arr); + + $x = q("select cr_id from chatroom where cr_name = '%s' and cr_uid = %d limit 1", + dbesc($room), + intval(local_user()) + ); + + if($x) + goaway(z_root() . '/chat/' . $channel['channel_address'] . '/' . $x[0]['cr_id']); + + // that failed. Try again perhaps? + + goaway(z_root() . '/chat/' . $channel['channel_address'] . '/new'); + + +} + + +function chat_content(&$a) { + + $observer = get_observer_hash(); + if(! $observer) { + notice( t('Permission denied.') . EOL); + return; + } + + if(! perm_is_allowed($a->profile['profile_uid'],$observer,'chat')) { + notice( t('Permission denied.') . EOL); + return; + } + + if((argc() > 3) && intval(argv(2)) && (argv(3) === 'leave')) { + chatroom_leave($observer,$room_id,$_SERVER['REMOTE_ADDR']); + goaway(z_root() . '/channel/' . argv(1)); + } + + + if(argc() > 2 && intval(argv(2))) { + $room_id = intval(argv(2)); + $x = chatroom_enter($observer,$room_id,'online',$_SERVER['REMOTE_ADDR']); + if(! $x) + return; + $o = replace_macros(get_markup_template('chat.tpl'),array( + '$room_name' => '', // should we get this from the API? + '$room_id' => $room_id, + '$submit' => t('Submit') + )); + return $o; + } + + + + + + if(local_user() && argc() > 2 && argv(2) === 'new') { + + + $channel = $a->get_channel(); + $channel_acl = array( + 'allow_cid' => $channel['channel_allow_cid'], + 'allow_gid' => $channel['channel_allow_gid'], + 'deny_cid' => $channel['channel_deny_cid'], + 'deny_gid' => $channel['channel_deny_gid'] + ); + + require_once('include/acl_selectors.php'); + + $o = replace_macros(get_markup_template('chatroom_new.tpl'),array( + '$header' => t('New Chatroom'), + '$name' => array('room_name',t('Chatroom Name'),'', ''), + '$acl' => populate_acl($channel_acl), + '$submit' => t('Submit') + )); + return $o; + } + + + + + + + require_once('include/widgets.php'); + + return widget_chatroom_list(array()); + +}
\ No newline at end of file |