public function join_room($room_id)
 {
     global $db;
     $sql = $db->prepare("INSERT INTO user_in_room(`user_id`, `room_id`) VALUES(?, ?)");
     $success = $sql->execute(array($this->user_id, $room_id));
     if ($success && $sql->rowCount()) {
         $new_room = Room::get($room_id);
         $this->rooms_list[] = $new_room;
         return $new_room;
     }
     return false;
 }
示例#2
0
$cal = new Calendar();
$book = new Booking();
$room = new Room();
$smartyType = "www";
$month = $request->GetVar('month', 'post');
$year = $request->GetVar('year', 'post');
$view = $request->GetVar('view', 'post');
$step = $request->GetVar('step', 'post');
//print "view:". $view ." year: ".$year ."month: " .$month;
$smarty->assign('tpl_navstep', $step);
$smarty->assign('tpl_navmonth', $month);
$smarty->assign('tpl_navyear', $year);
$smarty->assign('tpl_view', $view);
$smarty->assign('tpl_years', $cal->getdates());
// get rooms
$rooms = $room->get();
/*$monthName = $cal -> returnMonthName($month);
$prevMonth = $cal -> previous_month($month, $year, false, false);
$displayyear = $year;
*/
if ($step !== '') {
    if ($month == 12) {
        $nextmonth = 1;
        $tmpyear = $year + 1;
        $displayyear = $year . '/' . $tmpyear;
    } else {
        $nextmonth = $month + 1;
    }
    $monthName = $monthName . '/' . $cal->returnMonthName($nextmonth);
    $smarty->assign('tpl_step', 'false');
    $smarty->assign('tpl_cal', $cal->GetHalfMonth($year, $month, 0));
示例#3
0
*/
$smartyType = "www";
include_once "../includes/default.inc.php";
$auth->is_authenticated();
include_once 'roomclass.inc.php';
include_once 'roomcategoryclass.inc.php';
$room = new Room();
$roomcat = new RoomCategory();
$smarty->assign("tpl_title", "Zimmerverwaltung");
$smarty->assign('tpl_nav', 'settings');
$smarty->assign('tpl_subnav', 'syssettings');
$smarty->assign('tpl_subnav2', 'rooms');
if ($request->GetVar('frm_roomid', 'post') !== $request->undefined) {
    if ($request->GetVar('frm_action', 'post') == 'edit') {
        $smarty->assign('tpl_roomcat', $roomcat->Getall());
        $smarty->assign('tpl_editid', $request->GetVar('frm_roomid', 'post'));
    } else {
        if ($request->GetVar('frm_action', 'post') == 'addnew') {
            $smarty->assign('tpl_roomcat', $roomcat->Getall());
            $smarty->assign('tpl_addnew', 'true');
        } else {
            if ($request->GetVar('frm_action', 'post') == 'del') {
                $room->del($request->GetVar('frm_roomid', 'post'));
            } else {
                $check = $room->saveupdate();
            }
        }
    }
}
$smarty->assign('tpl_room', $room->get());
$smarty->display('rooms.tpl');
示例#4
0
/**
 * Save room open status, public or private, and the password.
 */
function room_open_status_save()
{
    $res = array();
    if ($_POST['id'] && ($_POST['open'] == 'true' || $_POST['open'] == 'false') && isset($_POST['password'])) {
        $db = sr_pdo();
        if ($room = Room::get($db, $_POST['id'])) {
            $room->is_open = $_POST['open'] == 'true' ? 1 : 0;
            $room->password = $_POST['password'];
            $room->save($db);
            $res['result'] = 0;
        } else {
            $res['result'] = 2;
            $res['msg'] = "Couldn't find the room";
        }
    } else {
        $res['result'] = 1;
        $res['msg'] = "Invalid request";
    }
    echo json_encode($res);
}
示例#5
0
                 exit_with_status_code(400);
             } else {
                 $room = Room::create($_REQUEST['name'], $_REQUEST['admin_id']);
                 if ($room) {
                     echo 'Room successfully created.';
                     exit_with_status_code(201);
                 } else {
                     echo 'Error creating room';
                     exit_with_status_code(400);
                 }
             }
         case 'PUT':
             echo 'Operation not supported';
             exit_with_status_code(405);
         case 'GET':
             $rooms = Room::get();
             if ($rooms) {
                 foreach ($rooms as $room) {
                     echo $room->to_json();
                 }
                 exit_with_status_code(200);
             } else {
                 echo 'Error getting rooms.';
                 exit_with_status_code(500);
             }
         case 'DELETE':
             echo 'Cannot delete all rooms at once.';
         default:
             exit_with_status_code(405);
     }
 }
示例#6
0
 /**
  * GET /rooms/{room_id}/files/{file_id}
  * ファイル情報を取得.
  *
  * 引数0:room_id
  * 引数1:file_id
  * 引数2:create_download_url ダウンロードする為のURLを生成するか 30 秒間だけダウンロード可能なURLを生成します.
  */
 public function fetchRoomFile()
 {
     $query_parameters = array('create_download_url' => isset($this->args[2]) ? $this->args[2] : null);
     $query_parameters = self::filteringParameters($query_parameters);
     $this->loadModel('Chatwork.Room');
     $results = Room::get(array('room_id' => $this->args[0], 'action' => 'files', 'file_id' => $this->args[1], 'query_parameters' => $query_parameters));
     $this->out(print_r($results, true));
 }