本文整理汇总了PHP中UserDAO类的典型用法代码示例。如果您正苦于以下问题:PHP UserDAO类的具体用法?PHP UserDAO怎么用?PHP UserDAO使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UserDAO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertBestelling
public function insertBestelling($id, $keuze)
{
$userDAO = new UserDAO();
$id = $userDAO->getByUserId($id);
$bestregDAO = new BestregDAO();
$bestel = $BestregDAO->insertBestreg($keuze);
}
示例2: executeChange
function executeChange($currUser, $userid, $newrole)
{
if ($newrole !== "1" && $newrole !== "2" && $newrole !== "3" && $newrole !== "4") {
return "Invalid status!";
}
$userDAO = new UserDAO();
$userChan = $userDAO->getUserByID($userid);
$userCurr = $userDAO->getUserByID($currUser);
//get current session user
if ($userCurr->getRole()->getRoleID() !== "1" && $userCurr->getRole()->getRoleID() !== "2") {
return "You have no right to change user status!";
}
if ($userChan === null) {
//database
return "Could not find this user!";
}
if ($userChan->getRole()->getRoleID() === $newrole) {
//type
return "Old status is equal to new status, don't need to change!";
}
if ($userCurr->getRole()->getRoleID() === "2") {
if ($newrole === "1" || $newrole === "2") {
return "You have no right to set an advanced user.";
}
}
$roleDAO = new RoleDAO();
$newroleObj = $roleDAO->getRoleByID($newrole);
$userChan->setRole($newroleObj);
$userDAO->updateUser($userChan);
return true;
}
示例3: execChangeProfile
function execChangeProfile($firstname, $lastname, $sex, $departmentID)
{
if (!isValidName($firstname) || !isValidName($lastname)) {
return "Please enter valid names!";
}
if (!isValidID($departmentID)) {
return "Invalid department id!";
}
$departDAO = new DepartmentDAO();
$depart = $departDAO->getDepartmentByID($departmentID);
if ($depart === null) {
return "Could not find the depart!";
}
$userDAO = new UserDAO();
$user = $userDAO->getUserByID($_SESSION["userID"]);
$user->setDepartment($depart);
if ($user->getFirstName() != $firstname) {
$user->setFirstName($firstname);
}
if ($user->getLastName() != $lastname) {
$user->setLastName($lastname);
}
if ($user->getGender() != $sex) {
$user->setGender($sex);
}
if (isset($_FILES["uploadphoto"])) {
$ans = uploadPhoto($user, $_FILES["uploadphoto"]);
if ($ans !== true) {
return $ans;
}
}
$userDAO->updateUser($user);
return true;
}
示例4: execute
function execute()
{
$user = json_decode($_GET['user']);
$dao = new UserDAO();
$user->id = $dao->create($user);
echo json_encode($user);
}
示例5: executeChange
function executeChange($userID, $recordID, $newRecordStatus)
{
if ($newRecordStatus !== "1" && $newRecordStatus !== "2" && $newRecordStatus !== "3") {
return "Invalid status!";
}
$userDAO = new UserDAO();
$user = $userDAO->getUserByID($userID);
$recordDAO = new RecordDAO();
$record = $recordDAO->getRecordByID($recordID);
if ($record === null) {
return "Could not find this record!";
}
if ($record->getDisplayStatus() === $newRecordStatus) {
return "Old status is equal to new status, don't need to change!";
}
if ($user->getRole()->getRoleID() === "3") {
if ($record->getUser()->getUserID() !== $userID) {
return "You have no right to change group status!";
}
if ($newStatus === "3") {
return "You have no right to delete this record!";
}
}
if ($newRecordStatus !== "3") {
$record->setDisplayStatus($newRecordStatus);
$recordDAO->updateRecord($record);
// Do not have updateRecord function
} else {
$recordDAO->deleteRecord($record);
//Do not have this function
}
return true;
}
示例6: verify
function verify()
{
if (isset($_GET["groupid"]) && isset($_GET["accept"])) {
$groupID = $_GET["groupid"];
if (!isValidID($groupID)) {
return;
}
$groupDAO = new GroupDAO();
$group = $groupDAO->getGroupByID($groupID);
if ($group === null) {
return;
}
$userDAO = new UserDAO();
$user = $userDAO->getUserByID($_SESSION["userID"]);
$gmDAO = new GroupMemberDAO();
$gm = $gmDAO->getGroupMember($group, $user);
if ($gm === null) {
return;
}
$status = $gm->getAcceptStatus();
if ($status == "1") {
return;
}
if ($_GET["accept"] == "1") {
$gm->setAcceptStatus("1");
$gmDAO->updateGroupMember($gm);
} elseif ($_GET["accept"] == "3") {
$gmDAO->deleteGroupMember($gm);
}
}
}
示例7: execEditGroup
function execEditGroup($userID, $groupID, $checkedUser)
{
if (gettype($checkedUser) != "array") {
return "Wrong type of group member!";
}
$checkedUser[] = $userID;
$userDAO = new UserDAO();
$user = $userDAO->getUserByID($userID);
if (!isValidID($groupID)) {
return "Invalid group ID!";
}
$groupDAO = new GroupDAO();
$group = $groupDAO->getGroupByID($groupID);
if ($group === null) {
return "Group doesn't exist!";
}
if ($group->getOwner()->getUserID() !== $userID) {
return "You are not the owner of this group!";
}
$gmDAO = new GroupMemberDAO();
$gms = $gmDAO->getGroupMembersByGroup($group);
foreach ($gms as $gm) {
$alreadyUser = $gm->getUser();
if (in_array($alreadyUser->getUserID(), $checkedUser)) {
continue;
}
$gmDAO->deleteGroupMember($gm);
}
return true;
}
示例8: testIsUserInDB
function testIsUserInDB()
{
$conn = $this->db->getConnection();
$udao = new UserDAO($this->logger, $this->db);
$this->assertTrue($udao->isUserInDB(930061));
$this->assertTrue(!$udao->isUserInDB(9.345465465465006E+16));
$this->db->closeConnection($conn);
}
示例9: uploadFile
function uploadFile($userID, $groupID, $file)
{
$userDAO = new UserDAO();
$user = $userDAO->getUserByID($userID);
if ($user->getRole()->getRoleID() == "4") {
return "This user was forbidden to upload file!";
}
if (!isValidID($groupID)) {
return "Group id is not valid!";
}
$groupDAO = new GroupDAO();
$group = $groupDAO->getGroupByID($groupID);
if ($group === null) {
return "Can not find this group!";
}
if ($group->getActivateStatus() === "2") {
return "Group is not activated!";
}
$groupMemberDAO = new GroupMemberDAO();
$groupMember = $groupMemberDAO->getGroupMember($group, $user);
if ($groupMember === null) {
return "User didn't belong to this group!";
}
if (gettype($file["error"]) == "array") {
return "Only accept one file!";
}
$res = isValidUploadFile($file["error"]);
if ($res !== true) {
return $res;
}
$fileType = -1;
$res = isValidImage($file["name"]);
if ($res === true) {
$fileType = "2";
}
$res = isValidFile($file["name"]);
if ($res === true) {
$fileType = "3";
}
if ($fileType === -1) {
return "Only accepts jpeg/jpg/gif/png/zip file!";
}
$record = new Record($group, $user, $fileType, "temp", "1");
$recordDAO = new RecordDAO();
$recordDAO->insertRecord($record);
$fileDir = "upload/";
$filePath = $fileDir . $record->getRecordID() . "_" . $file["name"];
$record->setContent($filePath);
$recordDAO->updateRecord($record);
if (file_exists($filePath)) {
unlink($filePath);
}
if (!move_uploaded_file($file['tmp_name'], $filePath)) {
return "Fail to move file, please contact administrator!";
}
return true;
}
示例10: validate
public function validate($messageManager)
{
$field = $this->form->getField($this->fieldName);
$fieldValue = $field->getValue();
$userDAO = new UserDAO();
$userRecord = $userDAO->getRecordById($this->userId);
if ($userRecord['userPassword'] != $fieldValue) {
$messageManager->addMessage('invalidPassword', array($this->fieldName => $field->getCaption()));
}
}
示例11: controlUser
public function controlUser($userName, $password)
{
$dao = new UserDAO();
$user = $dao->getByGebruikersnaam($userName);
if (isset($user) && $user->getWachtwoord() == $password) {
return true;
} else {
return false;
}
}
示例12: testFetchInstanceUserInfo
function testFetchInstanceUserInfo()
{
$tc = new TwitterCrawler($this->instance, $this->logger, $this->api, $this->db);
$tc->fetchInstanceUserInfo();
$udao = new UserDAO($this->db, $this->logger);
$user = $udao->getDetails(36823);
$this->assertTrue($user->id == 1);
$this->assertTrue($user->user_id == 36823);
$this->assertTrue($user->username == 'anildash');
$this->assertTrue($user->found_in == 'Owner Status');
}
示例13: validate
public function validate($messageManager)
{
$field = $this->form->getField($this->fieldName);
$fieldValue = $field->getValue();
if ($fieldValue) {
$dao = new UserDAO();
if (!$dao->isActiveUser($fieldValue)) {
$messageManager->addMessage('userDoesNotExist', array($this->fieldName => $field->getCaption()));
}
}
}
示例14: create
function create()
{
$usr = new UserDAO();
$usr->setName($_POST['name']);
$usr->setAge($_POST['age']);
$model = new UserModel();
$res = $model->create($usr);
if ($res == 1) {
header("Location: " . SITE_URL . "/user/addnew/?e=1");
}
}
示例15: __construct
function __construct()
{
session_start();
if (isset($_SESSION[AppConstants::SESSION_USER]) === false) {
$_SESSION[AppConstants::SESSION_USER] = '';
$_SESSION[AppConstants::SESSION_PASSWORD] = '';
}
$user = $_SESSION[AppConstants::SESSION_USER];
$pass = $_SESSION[AppConstants::SESSION_PASSWORD];
$userDao = new UserDAO();
$this->_user_USR = $userDao->getUser($user, $pass);
}