本文整理汇总了PHP中UserMapper::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP UserMapper::findById方法的具体用法?PHP UserMapper::findById怎么用?PHP UserMapper::findById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserMapper
的用法示例。
在下文中一共展示了UserMapper::findById方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update()
{
$userid = $_REQUEST["usuario"];
$user = $this->userMapper->findById($userid);
$errors = array();
$pass = md5($_POST["passActual"]);
if ($this->userMapper->isValidUser($_POST["usuario"], $pass)) {
if (isset($_POST["usuario"])) {
$user->setNombre($_POST["nombre"]);
$user->setApellidos($_POST["apellidos"]);
$user->setCorreo($_POST["correo"]);
if (isset($_FILES['img'])) {
$img = $_FILES['img']['name'];
$ext = strrchr($img, '.');
$ruta = 'imagenes/user_' . $user->getId() . $ext;
if (move_uploaded_file($_FILES['img']['tmp_name'], $ruta)) {
$user->setImagen($user->getId() . $ext);
}
}
if (!(strlen(trim($_POST["passNew"])) == 0)) {
if ($_POST["passNew"] == $_POST["passNueva"]) {
$passNew = md5($_POST["passNew"]);
$user->setPassword($passNew);
} else {
$errors["pass"] = i18n("Passwords must be equal");
$this->view->setVariable("errors", $errors);
$this->view->setVariable("user", $user);
$this->view->render("users", "modificar");
return false;
}
}
try {
$this->userMapper->update($user);
$this->view->setFlash(i18n("Modified user correctly"));
$this->view->redirect("users", "perfil");
} catch (ValidationException $ex) {
$errors = $ex->getErrors();
$this->view->setVariable("errors", $errors);
}
}
} else {
$errors["passActual"] = i18n("Incorrect password");
$this->view->setVariable("errors", $errors);
$this->view->setVariable("user", $user);
$this->view->render("users", "modificar");
}
}
示例2: header
session_start();
if (!isset($_SESSION['userID'])) {
$tpl_engine = $GLOBALS['tpl_engine'];
$tpl_engine->__set_filetpl('index.html', NULL);
$tpl_engine->render();
}
header("Location:" . $GLOBALS["url"] . "/control-panel/");
});
$rout_r->map('GET', '/control-panel/', function () {
session_start();
if (isset($_SESSION['userID'])) {
global $GLOBALS;
$tpl_engine = $GLOBALS['tpl_engine'];
$db = new MySqlDAO();
$userMapper = new UserMapper($db);
$user = $userMapper->findById($_SESSION['userID']);
$tpl_engine->__set_filetpl('main.html', array('user' => $user->getUserName()));
$tpl_engine->render();
} else {
(new ReportingFramework())->report(['condition' => "failure", 'message' => "This is a restricted area! Please login"]);
}
});
$rout_r->map('GET', '/api/user/register/', function () {
global $GLOBALS;
$query = $GLOBALS['query'];
if (isset($query["username"]) || isset($query["name"]) || isset($query["password"]) || isset($query["email"]) || isset($query["key"])) {
$user = new User(null, $query["username"], $query["name"], $query["password"], false, $query["email"], $query["key"]);
$db = new MySqlDAO();
$userMapper = new UserMapper($db);
$userMapper->insert($user);
die("User registration was successful!");
示例3: modifyAction
public function modifyAction($I_id)
{
$this->isAdmin();
$S_login = $_POST['login'];
if (isset($_POST['sendPassword'])) {
$B_password = $_POST['sendPassword'];
}
$S_name = $_POST['name'];
$S_firstName = $_POST['firstName'];
if (isset($_POST['sizeHarness'])) {
$I_sizeHarness = $_POST['sizeHarness'];
}
$S_email = $_POST['email'];
if (isset($_POST['company_id'])) {
$I_company_id = $_POST['company_id'];
}
if (isset($_POST['subgroup_id'])) {
$I_subgroup_id = $_POST['subgroup_id'];
}
if (isset($_POST['staff_id'])) {
$I_staff_id = $_POST['staff_id'];
}
if (isset($_POST['profile'])) {
$S_profile = $_POST['profile'];
}
$O_userMapper = new UserMapper();
$O_user = $O_userMapper->findById($I_id);
if (isset($_SESSION['token'])) {
if ($_POST['token'] == $_SESSION['token']) {
// OK - Je peux faire le traitement
// avons nous un operator ?
if (isset($_POST['operator']) && !isset($_POST['inspector'])) {
// si aucune modification de faite pas la peine de le lancer une requete
if ($S_login != $O_user->getLogin() || $S_name != $O_user->getOperator()->getName() || $S_firstName != $O_user->getOperator()->getFirstName() || $I_sizeHarness != $O_user->getOperator()->getSizeHarness() || $S_email != $O_user->getOperator()->getEmail() || $I_company_id != $O_user->getOperator()->getTeam()->getSubgroup()->getCompany()->getId() || $I_subgroup_id != $O_user->getOperator()->getTeam()->getSubgroup()->getId() || $I_staff_id != $O_user->getOperator()->getTeam()->getstaff()->getId() || isset($S_profile) && $S_profile != $O_user->getProfile()->getName()) {
// je mets à jour le login du user:
$O_user->setLogin($S_login);
// Pour mettre à jour la variable $profile_id et l'objet profile contenu dans l'objet user :
$O_profileMapper = new ProfileMapper();
$O_profile = $O_profileMapper->findByName($S_profile);
$O_user->setProfile($O_profile);
$O_user->setProfileId($O_user->getProfile()->getId());
// Pour mettre à jour l'operateur lié à l'utilisateur
$O_operatorMapper = new OperatorMapper();
$O_operator = $O_operatorMapper->findById($O_user->getOperatorId());
$O_operator->setName($S_name);
$O_operator->setFirstName($S_firstName);
$O_operator->setSizeHarness($I_sizeHarness);
$O_operator->setEmail($S_email);
// Pour cherché la team concerné par le subgroup et le staff
$O_teamMapper = new TeamMapper();
$O_team = $O_teamMapper->findByTwoIds($I_staff_id, $I_subgroup_id);
// Pour cherché le sous groupe concerné
$O_subgroupMapper = new SubgroupMapper();
$O_subgroup = $O_subgroupMapper->findById($I_subgroup_id);
// Pour cherché le staff
$O_staffMapper = new StaffMapper();
$O_staff = $O_staffMapper->findById($I_staff_id);
// On donne à l'objet Team son objet Staff et Subgroup
$O_team->setStaff($O_staff);
$O_team->setSubgroup($O_subgroup);
// On donne à l'opérateur sa team
$O_operator->setTeamId($O_team->getId());
$O_operator->setTeam($O_team);
// On donne à l'utilisateur son opérateur
$O_user->setOperator($O_operator);
try {
// on donne l'objet user pour la mise à jour
$O_userMapper->update($O_user);
// on donne l'objet operator pour la mise à jour
$O_operatorMapper->update($O_operator);
die(header('Location:/user/default/'));
} catch (Exception $e) {
Session::setSession('error', $e->getMessage());
}
} elseif ($B_password == true) {
$this->sendPasswordAction($S_email);
$O_userMapper->changePassword($O_user, $this->S_password);
die(header('Location:/user/default/'));
} else {
die(header('Location:/user/edit/' . $I_id));
}
} elseif (!isset($_POST['operator']) && isset($_POST['inspector'])) {
// si aucune modification de faite pas la peine de le lancer une requete
if ($S_login != $O_user->getLogin() || $S_name != $O_user->getInspector()->getName() || $S_firstName != $O_user->getInspector()->getFirstName() || $S_email != $O_user->getInspector()->getEmail() || isset($S_profile) && $S_profile != $O_user->getProfile()->getName()) {
// je mets à jour le login du user:
$O_user->setLogin($S_login);
// Pour mettre à jour la variable $profile_id et l'objet profile contenu dans l'objet user :
$O_profileMapper = new ProfileMapper();
$O_profile = $O_profileMapper->findByName($S_profile);
$O_user->setProfile($O_profile);
$O_user->setProfileId($O_user->getProfile()->getId());
// Pour mettre à jour l'inspecteur lié à l'utilisateur
$O_inspectorMapper = new InspectorMapper();
$O_inspector = $O_inspectorMapper->findById($O_user->getinspectorId());
$O_inspector->setName($S_name);
$O_inspector->setFirstName($S_firstName);
$O_inspector->setEmail($S_email);
// On donne à l'utilisateur son inspecteur
$O_user->setInspector($O_inspector);
try {
//.........这里部分代码省略.........