Example #1
0
function chat_post(&$a)
{
    if ($_POST['room_name']) {
        $room = strip_tags(trim($_POST['room_name']));
    }
    if (!$room || !local_channel()) {
        return;
    }
    $channel = $a->get_channel();
    if ($_POST['action'] === 'drop') {
        logger('delete chatroom');
        chatroom_destroy($channel, array('cr_name' => $room));
        goaway(z_root() . '/chat/' . $channel['channel_address']);
    }
    $acl = new AccessList($channel);
    $acl->set_from_array($_REQUEST);
    $arr = $acl->get();
    $arr['name'] = $room;
    $arr['expire'] = intval($_POST['chat_expire']);
    if (intval($arr['expire']) < 0) {
        $arr['expire'] = 0;
    }
    chatroom_create($channel, $arr);
    $x = q("select * from chatroom where cr_name = '%s' and cr_uid = %d limit 1", dbesc($room), intval(local_channel()));
    build_sync_packet(0, array('chatroom' => $x));
    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');
}
Example #2
0
function chat_post(&$a)
{
    if ($_POST['room_name']) {
        $room = strip_tags(trim($_POST['room_name']));
    }
    if (!$room || !local_channel()) {
        return;
    }
    $channel = $a->get_channel();
    if ($_POST['action'] === 'drop') {
        logger('delete chatroom');
        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_channel()));
    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');
}