private function showCreateRoomPage() { if (WebRequest::wasPosted()) { try { // get variables $rname = WebRequest::post("rname"); $rtype = WebRequest::postInt("rtype"); $rmin = WebRequest::postInt("rmin"); $rmax = WebRequest::postInt("rmax"); $rprice = WebRequest::postFloat("rprice"); // data validation if ($rname == "") { throw new CreateRoomException("blank-roomname"); } if ($rtype == 0) { throw new CreateRoomException("blank-roomtype"); } if ($rmax < 1 || $rmin < 0) { throw new CreateRoomException("room-capacity-too-small"); } if ($rmin > $rmax) { throw new CreateRoomException("room-capacity-min-gt-max"); } if ($rprice != abs($rprice)) { throw new CreateRoomException("room-price-negative"); } $room = new Room(); // set values $room->setName($rname); $room->setType($rtype); $room->setMinPeople($rmin); $room->setMaxPeople($rmax); $room->setPrice($rprice); $room->save(); global $cScriptPath; $this->mHeaders[] = "Location: {$cScriptPath}/Rooms"; } catch (CreateRoomException $ex) { $this->mBasePage = "mgmt/roomCreate.tpl"; $this->error($ex->getMessage()); } } else { $this->mBasePage = "mgmt/roomCreate.tpl"; } $this->mSmarty->assign("rtlist", RoomType::$data); }
$s1->setLabel('kodi'); $s1->save(); $r1 = new Right(); $r1->setSection($s1->getId()); $r1->setRead('1'); $r1->setDelete('1'); $r1->setCreate('1'); $r1->setUpdate('1'); $r1->setRank('1'); $r1->save(); $conf = new Configuration(); $conf->put('plugin_kodiCmd_api_url_kodi', 'http://192.168.1.107:85/jsonrpc'); $conf->put('plugin_kodiCmd_api_timeout_kodi', 5); $conf->put('plugin_kodiCmd_api_recognition_status', ''); $ro = new Room(); $ro->setName('KODI'); $ro->setDescription('De la bonne zic, un bon p\'tit film....'); $ro->save(); $roomManager = new Room(); $rooms = $roomManager->populate(); foreach ($rooms as $room) { if ($room->getName() == "KODI") { $kodiRoomId = $room->getId(); } } $id = 0; $kodi = new KodiCmd(); $kodi->setName('à droite'); $kodi->setDescription('se déplacer à droite'); $kodi->setJson('"method":"Input.Right","id":"1"'); $kodi->setConfidence('0.8');
/** * Save room. */ function execute() { $roomDao = DAORegistry::getDAO('RoomDAO'); $schedConf =& Request::getSchedConf(); if (isset($this->roomId)) { $room =& $roomDao->getRoom($this->roomId); } if (!isset($room)) { $room = new Room(); } $room->setBuildingId($this->buildingId); $room->setName($this->getData('name'), null); // Localized $room->setAbbrev($this->getData('abbrev'), null); // Localized $room->setDescription($this->getData('description'), null); // Localized // Update or insert room if ($room->getId() != null) { $roomDao->updateRoom($room); } else { $roomDao->insertRoom($room); } }
/** * For upgrade to 2.1.0: Migrate paper locations into scheduler * @return boolean */ function migratePaperLocations() { $paperDao = DAORegistry::getDAO('PaperDAO'); $buildingDao = DAORegistry::getDAO('BuildingDAO'); $roomDao = DAORegistry::getDAO('RoomDAO'); $lastSchedConfId = null; $buildingId = null; $result =& $paperDao->retrieve("SELECT p.paper_id, c.primary_locale, sc.sched_conf_id, p.location FROM papers p, published_papers pp, sched_confs sc, conferences c WHERE p.paper_id = pp.paper_id AND p.sched_conf_id = sc.sched_conf_id AND sc.conference_id = c.conference_id AND location IS NOT NULL AND location <> '' ORDER BY sched_conf_id"); while (!$result->EOF) { $row = $result->GetRowAssoc(false); $paperId = $row['paper_id']; $schedConfId = $row['sched_conf_id']; $locale = $row['primary_locale']; $location = $row['location']; if ($schedConfId !== $lastSchedConfId) { // Create a default building $defaultText = __('common.default'); $building = new Building(); $building->setSchedConfId($schedConfId); $building->setName($defaultText, $locale); $building->setAbbrev($defaultText, $locale); $building->setDescription($defaultText, $locale); $buildingId = $buildingDao->insertBuilding($building); unset($building); $rooms = array(); } if (!isset($rooms[$location])) { $room = new Room(); $room->setBuildingId($buildingId); $room->setName($location, $locale); $room->setAbbrev($location, $locale); $room->setDescription($location, $locale); $roomId = $roomDao->insertRoom($room); $rooms[$location] =& $room; unset($room); } else { $room =& $rooms[$location]; $roomId = $room->getId(); unset($room); } $paperDao->update('UPDATE published_papers SET room_id = ? WHERE paper_id = ?', array($roomId, $paperId)); $result->MoveNext(); $lastSchedConfId = $schedConfId; } $result->Close(); unset($result); return true; }
public function execute($action) { $msgs = Localization::getInstance(); $forwards = $action->getForwards(); // Recebe os valores enviados $roomCourse = $_POST["group"]; $roomManager = $_POST['manager']; $userName = utf8_decode($_POST["name"]); $userEmail = $_POST["email"]; $userPasswordPlataform = "mude"; if (!empty($roomCourse) && !empty($roomManager) && !empty($userName) && !empty($userEmail)) { /** * Routine that checks which the browser used * If an error occurs during the login, the system should return to the previous page * If the browser used is Firefox, the system must go back two pages * If is Chrome should back 1 page * TODO Test with Internet Explorer */ $useragent = $_SERVER['HTTP_USER_AGENT']; if (preg_match('|Firefox/([0-9\\.]+)|', $useragent, $matched)) { $browser_version = $matched[1]; $browser = 'Firefox'; $numReturnPages = 2; } else { $numReturnPages = 1; } /** * Via rest, it checks if this tool (in this case the Whiteboard) * have permission to use information from the Core */ $host = $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]; $pass = md5(date("d/m/Y") . $host); $server = "http://code.inf.poa.ifrs.edu.br/core/index.php/rest"; $action = str_replace("%40", "@", $userEmail); $rest = new RESTClient(); $rest->initialize(array('server' => $server, 'http_user' => $host, 'http_pass' => $pass)); $granted = $rest->get($action); if ($granted == 1) { // Caso o usuário esteja cadastrado na Plataform // CHECKING USER IN WHITEBOARD $user = $this->dao->login($userEmail, $userPasswordPlataform); if (count($user) <= 0) { // Not in database, create new user if (!empty($userEmail) && !empty($userName)) { // Instantiates a new user; $user = new User(); $user->setName($userName); $user->setEmail($userEmail); $user->setPassword($userPasswordPlataform); $user->setRoomcreator(0); $resultUser = $this->dao->saveNewUser($user); $user = $this->dao->login($userEmail, $userPasswordPlataform); } } if ($user->getName() != $userName) { // Upadate user; $resultUser = $this->dao->updateUserName($user->getUserId(), $userName); } // User contained in the database, loggin $_SESSION['id'] = $user->getUserId(); $_SESSION['name'] = $user->getName(); $_SESSION['roomCreator'] = $user->getRoomcreator(); $_SESSION['email'] = $user->getEmail(); $_SESSION['user'] = $user; // Verifies and creates, if necessary, the room of course $roomPlataform = $this->dao->getRoomByCourse($roomCourse); if (count($roomPlataform) <= 0) { $roomName = "Turma: " . $roomCourse; if ($user->getEmail() == $roomManager) { $managerId = $user->getUserId(); } else { $manager = $this->dao->login($roomManager, $userPasswordPlataform); if (count($manager) <= 0) { // Not in database, create new user coordinator $manager = new User(); $manager->setName("Professor " . $roomCourse); $manager->setEmail($roomManager); $manager->setPassword($userPasswordPlataform); $manager->setRoomcreator(1); $resultManager = $this->dao->saveNewUser($manager); $manager = $this->dao->login($manager->getEmail(), $userPasswordPlataform); } $managerId = $manager->getUserId(); } // Instantiates a new room; $roomPlataform = new Room(); $roomPlataform->setName($roomName); $roomPlataform->setUserId($managerId); $roomPlataform->setActive(0); $roomPlataform->setActiveProduction(0); $roomPlataform->setCourse($roomCourse); $resultRoom = $this->dao->saveNewRoom($roomPlataform); $roomPlataform = $this->dao->getRoomByCourse($roomCourse); // Set manager permission of room $permission = new Permission(); $permission->setUserId($managerId); $permission->setRoomId($roomPlataform->getRoomId()); $resultPermission = $this->dao->savePermission($permission); } // Checks permissions $permissions = $this->dao->listPermissions($roomPlataform->getRoomId()); $havePermission = false; foreach ($permissions as $permission) { if ($permission->getUserId() == $user->getUserId()) { $havePermission = true; } } if (!$havePermission) { $permission = new Permission(); $permission->setUserId($user->getUserId()); $permission->setRoomId($roomPlataform->getRoomId()); $resultPermission = $this->dao->savePermission($permission); } $roomPlataform = $this->dao->getRoomByCourse($roomCourse); $_SESSION['plataform'] = true; unset($_POST["group"]); unset($_POST['manager']); unset($_POST["name"]); unset($_POST["email"]); // If the room is active, will be given a join if ($roomPlataform->getActive() == 1) { $_SESSION["idRoom"] = $roomPlataform->getRoomId(); $room = $this->dao->getRoom($roomPlataform->getRoomId()); // put the production in the session $idProduction = $room->getActiveProduction(); $_SESSION['idProduction'] = $idProduction; $history = new History(); $history->setUserId($_SESSION["id"]); $history->setProductionId($idProduction); $history->setDate(date('Y-m-d')); $resultHistory = $this->dao->saveHistory($history); // Retrieving the users in the room $_REQUEST["users"] = $this->dao->getRoomUsers($_SESSION['idProduction']); // Showing the page $this->pageController->run($forwards['success']); } else { if ($user->getUserId() == $roomPlataform->getUserId()) { // If it is not active and the user is the owner of the room, will be given a start in the room $production = new Production(); $production->setCreationDate(date('Y-m-d')); $production->setUpdateDate(date('Y-m-d')); $production->setRoomId($roomPlataform->getRoomId()); $resultProduction = $this->dao->createProduction($production); if ($resultProduction) { $_SESSION['idProduction'] = $production->getProductionId(); } $resultUpdateRoom = $this->dao->updateRoomState($roomPlataform->getRoomId(), true, $_SESSION['idProduction']); if ($resultUpdateRoom) { $_SESSION["idRoom"] = $roomPlataform->getRoomId(); } $resultRoom = $this->dao->getRoom($roomPlataform->getRoomId()); if ($resultRoom) { $_SESSION["currentRoomManager"] = $resultRoom->getUserId(); } $history = new History(); $history->setUserId($_SESSION["id"]); $history->setProductionId($_SESSION['idProduction']); $history->setDate(date('Y-m-d')); $resultHistory = $this->dao->saveHistory($history); // Retrieving the users in the room $_REQUEST["users"] = $this->dao->getRoomUsers($_SESSION['idProduction']); $this->pageController->run($forwards['success']); } else { // Otherwise, the room is closed and the user must wait until she opens unset($_SESSION['id']); unset($_SESSION['name']); unset($_SESSION['roomCreator']); unset($_SESSION['email']); unset($_SESSION['user']); // Closed room echo "<script type='text/javascript'>"; echo "alert('" . $msgs->getText('error.plataform.closeRoom') . "');"; // Without permission echo "history.go(-{$numReturnPages});"; echo "</script>"; } } } else { // Without permission echo "<script type='text/javascript'>"; echo "alert('" . $msgs->getText('error.plataform.withoutPermission') . "');"; echo "history.go(-{$numReturnPages});"; echo "</script>"; } } else { // Insufficient data echo "<script type='text/javascript'>"; echo "alert('" . $msgs->getText('error.plataform.insufficientData') . "');"; echo "history.go(-{$numReturnPages});"; echo "</script>"; } }
public function execute($action) { $forwards = $action->getForwards(); $roomName = $_POST['name']; $user = $_SESSION['id']; $listUsers = explode("-", $_POST['idsSelecteds']); // Checks if all fields were provided if (!empty($_POST['name']) && !empty($_SESSION['id'])) { // Instantiates a new room; $room = new Room(); $room->setName($_POST['name']); $room->setUserId($_SESSION['id']); $room->setActive(0); $room->setActiveProduction(0); $room->setCourse($_POST['course']); $resultRoom = $this->dao->saveNewRoom($room); // List Rooms $listRoonsAction = new ListRoonsAction(); $listRoonsAction->execute($action); $roons = $_REQUEST["roons"]; foreach ($roons as $srcRoom) { if (is_null($srcRoom->getCode())) { $newRoomId = $srcRoom->getRoomId(); } } // Generates the secret code of the room $room = $this->dao->getRoom($newRoomId); $code = md5($newRoomId); $room->setCode($code); $room->save(); // Gives permission to the user who created the room $listUsers[] = $_SESSION['id']; // Instantiates a new room permission; foreach ($listUsers as $allowedUserId) { if ($allowedUserId != 0) { $permission = new Permission(); $permission->setUserId($allowedUserId); $permission->setRoomId($newRoomId); $resultPermission = $this->dao->savePermission($permission); } } // Showing the page $this->pageController->run($forwards['success']); } else { // It will set a variable with the id of the button // that opens the modal window that was active $_SESSION['openModalWindow'] = "#btnOpenNewRoomForm"; // Error if there are blank fields $_REQUEST["errorMsg"] = $this->message->getText("error.blankField"); $this->pageController->run($forwards['error']); } }