本文整理汇总了PHP中Permission::setUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::setUserId方法的具体用法?PHP Permission::setUserId怎么用?PHP Permission::setUserId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permission
的用法示例。
在下文中一共展示了Permission::setUserId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
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
//.........这里部分代码省略.........
示例2: execute
//.........这里部分代码省略.........
$user = new User();
$user->setName($userName);
$user->setEmail($userEmail);
$user->setPassword($userPasswordEduquito);
$user->setRoomcreator(0);
$resultUser = $this->dao->saveNewUser($user);
$user = $this->dao->login($userEmail, $userPasswordEduquito);
}
}
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
$roomEduquito = $this->dao->getRoomByCourse($roomCourse);
if (count($roomEduquito) <= 0) {
$roomName = "Sala do curso " . $roomCourse;
$_POST["name"] = $roomName;
$_POST["course"] = $roomCourse;
$_POST['idsSelecteds'] = $user->getUserId();
if ($user->getEmail() == $roomManager) {
$_SESSION['id'] = $user->getUserId();
} else {
$manager = $this->dao->login($roomManager, $userPasswordEduquito);
if (count($manager) <= 0) {
// Not in database, create new user coordinator
$manager = new User();
$manager->setName("Coordenador do curso");
$manager->setEmail($roomManager);
$manager->setPassword($userPasswordEduquito);
$manager->setRoomcreator(0);
$resultManager = $this->dao->saveNewUser($manager);
$manager = $this->dao->login($manager->getEmail(), $userPasswordEduquito);
}
$_SESSION['id'] = $manager->getUserId();
}
$createRoomAction = new CreateRoomAction();
$createRoomAction->execute($action);
$roomEduquito = $this->dao->getRoomByCourse($roomCourse);
$_SESSION['id'] = $user->getUserId();
}
// Checks permissions
$permissions = $this->dao->listPermissions($roomEduquito->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($roomEduquito->getRoomId());
$resultPermission = $this->dao->savePermission($permission);
}
$roomEduquito = $this->dao->getRoomByCourse($roomCourse);
$_GET["idRoom"] = $roomEduquito->getRoomId();
$_SESSION['eduquito'] = true;
if ($roomEduquito->getActive() == 1) {
$joinRoomAction = new JoinRoomAction();
$joinRoomAction->execute($action);
} else {
if ($user->getUserId() == $roomEduquito->getUserId()) {
$startRoomAction = new StartRoomAction();
$startRoomAction->execute($action);
} else {
unset($_SESSION['id']);
unset($_SESSION['name']);
unset($_SESSION['roomCreator']);
unset($_SESSION['email']);
unset($_SESSION['user']);
session_destroy();
// Closed room
echo "<script type='text/javascript'>";
echo "alert('" . $msgs->getText('error.eduquitoCloseRoom') . "');";
echo "history.go(-1);";
echo "</script>";
}
}
} else {
// Without permission
echo "<script type='text/javascript'>";
echo "alert('" . $msgs->getText('error.eduquitoWithoutPermission') . "');";
echo "history.go(-1);";
echo "</script>";
}
} else {
// Without permission
echo "<script type='text/javascript'>";
echo "alert('" . $msgs->getText('error.eduquitoInsufficientData') . "');";
echo "history.go(-1);";
echo "</script>";
}
}
示例3: execute
public function execute($action)
{
$forwards = $action->getForwards();
// Checks if all fields were provided
if (!empty($_POST['roomId']) && !empty($_POST['roomName']) && !empty($_POST['idsSelecteds'])) {
$idRoom = $_POST['roomId'];
$roomName = $_POST['roomName'];
$listUsers = explode("-", $_POST['idsSelecteds']);
$listUsers[] = $_SESSION['id'];
$_POST['currentRoom'] = $idRoom;
// Upadate user;
$resultRoom = $this->dao->updateRoomData($idRoom, $roomName);
// Delete old permissions
$listPermissions = new ListPermissionsAction();
$listPermissions->execute($action);
$permissions = $_REQUEST["permissions"];
foreach ($permissions as $permission) {
$resultDeletePermissions = $this->dao->deletePermission($permission);
}
// Instantiates a new room permission;
foreach ($listUsers as $allowedUserId) {
if ($allowedUserId != 0) {
$permission = new Permission();
$permission->setUserId($allowedUserId);
$permission->setRoomId($idRoom);
$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'] = "#btnUptRoom";
// Error if there are blank fields
$_REQUEST["errorMsg"] = $this->message->getText("error.blankField");
$this->pageController->run($forwards['error']);
}
}