leaveChannel() 공개 정적인 메소드

public static leaveChannel ( $uid, $cid )
예제 #1
0
    }
    // add name64 to the ban list
    $opname = Container_users::getUserData($online_uid, 'name');
    $reason = $req->params('reason');
    $ok = Container_channels_ban::addBan($cid, $name64, array('opname' => $opname, 'reason' => $reason ? $reason : '', 'timestamp' => time()));
    if ($ok) {
        $name = base64_decode($name64);
        $banuid = Container_indexes::getIndex('users/name', $name);
        $iskickban = $req->params('kickban') && $banuid;
        // notification to other connected user of this ban
        Container_messages::postMsgToChannel($cid, $online_uid, array('opname' => $opname, 'name' => $name, 'reason' => $reason ? $reason : '', 'kickban' => $iskickban), 'ban');
        // kick the user from the channel
        // (warning: do it after the above notification
        //  or he will not receive the notification)
        if ($iskickban) {
            Container_users::leaveChannel($banuid, $cid);
        }
        $res->status(201);
    } else {
        $res->status(500);
    }
});
/**
 * Remove :name64 from the :cid channel banished list
 */
$app->delete('/channels/:cid/ban/:name64', function ($cid, $name64) use($app, $req, $res) {
    // check user acces
    session_start();
    if (!isset($_SESSION['userdata']) or !isset($_SESSION['userdata']['id'])) {
        $res->status(401);
        // Need to authenticate
예제 #2
0
        $res->status(401);
        // Need to authenticate
        return;
    }
    if ($uid !== $_SESSION['userdata']['id']) {
        $res->status(403);
        // Forbidden
        return;
    }
    // check this user is online
    if (!Container_users::checkUserExists($uid)) {
        $res->status(400);
        // User is not connected
        return;
    }
    if (!Container_users::leaveChannel($uid, $cid)) {
        $res->status(404);
        // $res['Content-Type'] = 'application/json; charset=utf-8';
        // $res->body(json_encode(Container_channels::getChannelUsers($cid, true)));
        return;
    } else {
        // post a leave message
        $msg = Container_messages::postMsgToChannel($cid, $uid, null, 'leave');
        $res->status(200);
        $res['Content-Type'] = 'application/json; charset=utf-8';
        $res->body(json_encode(Container_channels::getChannelUsers($cid, true)));
        return;
    }
});
/**
 * Post a message on a channel