本文整理汇总了PHP中UserDAO::getUserByUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP UserDAO::getUserByUsername方法的具体用法?PHP UserDAO::getUserByUsername怎么用?PHP UserDAO::getUserByUsername使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserDAO
的用法示例。
在下文中一共展示了UserDAO::getUserByUsername方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execSignup
function execSignup($username, $password, $confirmpw, $firstname, $lastname, $gender)
{
if ($username == "" || !isValidUsername($username)) {
return "Username is empty or invalid!";
}
if ($password == "" || !isValidPassword($password)) {
return "Password is empty or invalid!";
}
if ($confirmpw == "" || !isValidPassword($confirmpw)) {
return "Confirm Password is empty or invalid!";
}
if ($firstname == "" || !isValidName($firstname)) {
return "First Name is empty or invalid!";
}
if ($lastname == "" || !isValidName($lastname)) {
return "Last Name is empty or invalid!";
}
if ($gender == "" || !isValidGender($gender)) {
return "Gender is empty or invalid!";
}
$userDAO = new UserDAO();
//verify username exist
$result = $userDAO->getUserByUsername($username);
if ($result !== null) {
return "Username exists, please change to another one!";
}
//verify $password == $confirmpw
if ($password != $confirmpw) {
return "Password and Confirm Password must be same!";
}
$roleDAO = new RoleDAO();
$role = $roleDAO->getRoleByID(3);
//normal user
$departmentDAO = new DepartmentDAO();
$depart = $departmentDAO->getDepartmentByID(1);
//root department
$encryptPW = encryptPassword($password);
$photoURL = "photo/default.png";
$user = new User($role, $depart, $username, $encryptPW, $firstname, $lastname, $gender, $photoURL);
if ($userDAO->insertUser($user) === true) {
return true;
} else {
return "Insert user into table error, please contact administrator!";
}
}
示例2: execLogin
function execLogin($username, $password)
{
$username = (string) $username;
$password = (string) $password;
if ($username == "" || $password == "") {
return "Username or password can not be empty!";
}
if (!isValidUsername($username) || !isValidPassword($password)) {
return "Username or password is invalid!";
}
$userDAO = new UserDAO();
$user = $userDAO->getUserByUsername($username);
if ($user === null || !verifyPassword($password, $user->getPassword())) {
return "There is no user account matching the Username and Password provided.";
}
if ($user->getRole()->getRoleID() == "4") {
return "This user was forbidden to login!";
}
login($user->getUserID());
return true;
}
示例3: array
/**
* Get all public annotations for a particular point in the text of a particular URL.
*
* @param $url string
* @param $username string
* @param $block string
* @return array Annotations
*/
function &getVisibleAnnotationsByUrlUserBlock($url, $username, $block, $all)
{
$annotations = array();
$currentUser = Request::getUser();
$query = 'SELECT a.*' . ', u.username AS userlogin' . ", concat(u.first_name,' ',u.middle_name,' ',u.last_name) AS username" . ' FROM annotations a' . ' JOIN users u ON u.user_id=a.userid' . ' WHERE ';
$queryParams = array();
if ($url) {
array_push($queryParams, $url);
$query .= "a.url=?";
} else {
$query .= '1=1';
}
// Only fetch annotations visible to the current user
$findUserId = 0;
if ($username) {
$userdao = new UserDAO();
$tuser = $userdao->getUserByUsername($username);
if ($tuser) {
if ($currentUser && ($currentUser->getUsername() == $username || $all)) {
$query .= " AND a.userid=?";
} elseif ($username) {
$query .= ' AND a.access_perms&' . AN_ACCESS_PUBLIC . ' AND a.userid=?';
}
array_push($queryParams, $tuser->getUserId());
} else {
$query .= ' AND 1=0';
}
} elseif (!$all) {
$query .= ' AND a.access_perms&' . AN_ACCESS_PUBLIC;
}
if ($block) {
// This implementation ignores the word and char fields of point
$testBlockStr = $block->getPaddedPathStr();
$query .= " AND a.start_block <= ? AND a.end_block >= ?";
array_push($queryParams, $testBlockStr, $testBlockStr);
}
$query .= " ORDER BY a.start_block, a.start_line, a.start_word, a.start_char";
$result =& $this->retrieve($query, $queryParams);
if (DEBUG_ANNOTATION_QUERY) {
echo "\n<p>" . htmlspecialchars($query) . "</p>\n";
echo "<p>";
for ($i = 0; $i < count($queryParams); ++$i) {
echo ($i > 0 ? ' , ' : '') . $queryParams[$i];
}
echo "</p>\n";
}
$annotations = array();
while (!$result->EOF) {
$annotations[] =& $this->_returnAnnotationfromRow($result->GetRowAssoc(false));
$result->MoveNext();
}
$result->Close();
unset($result);
return $annotations;
}