示例#1
0
function generatePrivateAudiences($roomId, $withToken)
{
    $roomMembers = getRoomMembers($roomId, $withToken);
    foreach ($roomMembers as $roomMember) {
        $privateAudienceName = "Private Yoda Audience - " . $roomMember['name'];
        if (($response = roomExists($privateAudienceName, $withToken)) === true) {
            passOwnershipRoom($privateAudienceName, $roomMember, $withToken);
        } else {
            switch ($response['code']) {
                case '403':
                    //Room exists and has an other owner! (Good!)
                    break;
                case '404':
                    //Room does not exist..
                    $room = createRoom($privateAudienceName, $withToken);
                    createWebhook($room['id'], '.*', 'room_message', $withToken);
                    createWebhook($room['id'], '.*', 'room_enter', $withToken);
                    createWebhook($room['id'], '.*', 'room_exit', $withToken);
                    inviteUser($room['id'], $roomMember['id'], $withToken);
                    passOwnershipRoom($privateAudienceName, $roomMember, $withToken);
                    break;
            }
        }
    }
}
示例#2
0
         }
     }
     $query = DBi::$conn->query($sql) or die(DBi::$conn->error . " " . __FILE__ . " line " . __LINE__ . $sql);
     while ($row = $query->fetch_assoc()) {
         $continue = true;
         if (strcmp($joined_only, "1") == 0) {
             $sql2 = "SELECT* FROM roommembers WHERE (member_id=" . $owner_user_id . ") AND (origin_room_id=" . $row['r_id'] . ")";
             $query2 = DBi::$conn->query($sql2) or die(DBi::$conn->error . " " . __FILE__ . " line " . __LINE__ . $sql2);
             if ($row2 = $query2->fetch_assoc()) {
             } else {
                 $continue = false;
             }
         }
         if ($continue) {
             $member_ids = getRoomMembers($row['r_id'], false);
             $members = getRoomMembers($row['r_id'], true);
             $array = array("name" => $row['name'], "room_id" => $row['r_id'], "member_ids" => $member_ids, "members" => $members, "owner_user_id" => $row['owner_user_id'], "user_id" => $row['u_id'], "email" => $row['email'], "title" => $row['title'], "first_name" => $row['first_name'], "last_name" => $row['last_name']);
             $roomlist[] = $array;
             $counter++;
         }
     }
     echo json_encode(array("status" => 1, "roomlist" => $roomlist));
 } else {
     if (strcmp($action, "delete_room") == 0) {
         $roomid = "";
         if (isset($_GET['roomid'])) {
             $roomid = $_GET['roomid'];
         }
         if (strlen($roomid) == 0) {
             die(json_encode(array("status" => 0, "msg" => "No roomid set")));
         }