本文整理汇总了PHP中User::Load方法的典型用法代码示例。如果您正苦于以下问题:PHP User::Load方法的具体用法?PHP User::Load怎么用?PHP User::Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::Load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: LoadNewest
public static function LoadNewest($amount, $page)
{
$result = array();
$page = $amount * $page;
if ($stmt = Database::GetLink()->prepare('SELECT `recipe_id`, `picture_id`, `user_id`, `type_id`, `recipe_title`, `recipe_description`, `disabled` FROM `Recipe` LIMIT ?,?;')) {
$stmt->bindParam(1, $page, PDO::PARAM_INT);
$stmt->bindParam(2, $amount, PDO::PARAM_INT);
$stmt->execute();
$stmt->bindColumn(1, $recipeId);
$stmt->bindColumn(2, $pictureId);
$stmt->bindColumn(3, $userId);
$stmt->bindColumn(4, $typeId);
$stmt->bindColumn(5, $title);
$stmt->bindColumn(6, $description);
$stmt->bindColumn(7, $disabled);
while ($stmt->fetch()) {
$recipe = new Recipe($recipeId);
$recipe->_user = User::Load($userId);
//if ($pictureId != null) { $recipe->_picture = Image::Load($pictureId); }
//if ($typeId != null) { $recipe->_type = Recipe::GetTypeName($typeId); }
$recipe->_title = $title;
$recipe->_description = $description;
$recipe->_disabled = $disabled;
$result[] = $recipe;
}
$stmt->closeCursor();
}
if (empty($result)) {
$result = false;
}
return $result;
}
示例2: sendResetPasswordEmail
public function sendResetPasswordEmail($emailOrUserId)
{
$user = new User();
$user->Load("email = ?", array($emailOrUserId));
if (empty($user->id)) {
$user = new User();
$user->Load("username = ?", array($emailOrUserId));
if (empty($user->id)) {
return false;
}
}
$params = array();
//$params['user'] = $user->first_name." ".$user->last_name;
$params['url'] = CLIENT_BASE_URL;
$newPassHash = array();
$newPassHash["CLIENT_NAME"] = CLIENT_NAME;
$newPassHash["oldpass"] = $user->password;
$newPassHash["email"] = $user->email;
$newPassHash["time"] = time();
$json = json_encode($newPassHash);
$encJson = AesCtr::encrypt($json, $user->password, 256);
$encJson = urlencode($user->id . "-" . $encJson);
$params['passurl'] = CLIENT_BASE_URL . "service.php?a=rsp&key=" . $encJson;
$emailBody = file_get_contents(APP_BASE_PATH . '/templates/email/passwordReset.html');
$this->sendEmail("[" . APP_NAME . "] Password Change Request", $user->email, $emailBody, $params);
return true;
}
示例3: getLeaveDaysReadonly
public function getLeaveDaysReadonly($req)
{
$leaveId = $req->leave_id;
$leaveLogs = array();
$employeeLeave = new EmployeeLeave();
$employeeLeave->Load("id = ?", array($leaveId));
$employee = $this->baseService->getElement('Employee', $employeeLeave->employee, null, true);
//$rule = $this->getLeaveRule($employee, $employeeLeave->leave_type);
$currentLeavePeriodResp = $this->getCurrentLeavePeriod($employeeLeave->date_start, $employeeLeave->date_end);
if ($currentLeavePeriodResp->getStatus() != IceResponse::SUCCESS) {
return new IceResponse(IceResponse::ERROR, $currentLeavePeriodResp->getData());
} else {
$currentLeavePeriod = $currentLeavePeriodResp->getData();
}
$leaveMatrix = $this->getAvailableLeaveMatrixForEmployeeLeaveType($employee, $currentLeavePeriod, $employeeLeave->leave_type);
$leaves = array();
$leaves['totalLeaves'] = floatval($leaveMatrix[0]);
$leaves['pendingLeaves'] = floatval($leaveMatrix[1]);
$leaves['approvedLeaves'] = floatval($leaveMatrix[2]);
$leaves['rejectedLeaves'] = floatval($leaveMatrix[3]);
$leaves['cancelRequestedLeaves'] = floatval($leaveMatrix[4]);
$leaves['cancelledLeaves'] = floatval($leaveMatrix[5]);
$leaves['availableLeaves'] = $leaves['totalLeaves'] - $leaves['pendingLeaves'] - $leaves['approvedLeaves'] - $leaves['cancelRequestedLeaves'];
$leaves['attachment'] = $employeeLeave->attachment;
$employeeLeaveDay = new EmployeeLeaveDay();
$days = $employeeLeaveDay->Find("employee_leave = ?", array($leaveId));
$employeeLeaveLog = new EmployeeLeaveLog();
$logsTemp = $employeeLeaveLog->Find("employee_leave = ? order by created", array($leaveId));
foreach ($logsTemp as $empLeaveLog) {
$t = array();
$t['time'] = $empLeaveLog->created;
$t['status_from'] = $empLeaveLog->status_from;
$t['status_to'] = $empLeaveLog->status_to;
$t['time'] = $empLeaveLog->created;
$userName = null;
if (!empty($empLeaveLog->user_id)) {
$lgUser = new User();
$lgUser->Load("id = ?", array($empLeaveLog->user_id));
if ($lgUser->id == $empLeaveLog->user_id) {
if (!empty($lgUser->employee)) {
$lgEmployee = new Employee();
$lgEmployee->Load("id = ?", array($lgUser->employee));
$userName = $lgEmployee->first_name . " " . $lgEmployee->last_name;
} else {
$userName = $lgUser->userName;
}
}
}
if (!empty($userName)) {
$t['note'] = $empLeaveLog->data . " (by: " . $userName . ")";
} else {
$t['note'] = $empLeaveLog->data;
}
$leaveLogs[] = $t;
}
return new IceResponse(IceResponse::SUCCESS, array($days, $leaves, $leaveId, $employeeLeave, $leaveLogs));
}
示例4: saveUser
public function saveUser($req)
{
$profileVar = SIGN_IN_ELEMENT_MAPPING_FIELD_NAME;
$profileClass = ucfirst(SIGN_IN_ELEMENT_MAPPING_FIELD_NAME);
if ($this->user->user_level == 'Admin') {
$user = new User();
$user->Load("email = ?", array($req->email));
if ($user->email == $req->email) {
return new IceResponse(IceResponse::ERROR, "User with same email already exists");
}
$user->Load("username = ?", array($req->username));
if ($user->username == $req->username) {
return new IceResponse(IceResponse::ERROR, "User with same username already exists");
}
$user = new User();
$user->email = $req->email;
$user->username = $req->username;
$password = $this->generateRandomString(6);
$user->password = md5($password);
$user->profile = empty($req->profile) || $req->profile == "NULL" ? NULL : $req->profile;
$user->user_level = $req->user_level;
$user->last_login = date("Y-m-d H:i:s");
$user->last_update = date("Y-m-d H:i:s");
$user->created = date("Y-m-d H:i:s");
$profile = null;
if (!empty($user->profile)) {
$profile = $this->baseService->getElement($profileClass, $user->profile, null, true);
}
$ok = $user->Save();
if (!$ok) {
LogManager::getInstance()->info($user->ErrorMsg() . "|" . json_encode($user));
return new IceResponse(IceResponse::ERROR, "Error occured while saving the user");
}
$user->password = "";
$user = $this->baseService->cleanUpAdoDB($user);
if (!empty($this->emailSender)) {
$usersEmailSender = new UsersEmailSender($this->emailSender, $this);
$usersEmailSender->sendWelcomeUserEmail($user, $password, $profile);
}
return new IceResponse(IceResponse::SUCCESS, $user);
}
return new IceResponse(IceResponse::ERROR, "Not Allowed");
}
示例5: saveUser
public function saveUser($req)
{
if ($this->user->user_level == 'Admin') {
$user = new User();
$user->Load("email = ?", array($req->email));
if ($user->email == $req->email) {
return new IceResponse(IceResponse::ERROR, "User with same email already exists");
}
$user->Load("username = ?", array($req->username));
if ($user->username == $req->username) {
return new IceResponse(IceResponse::ERROR, "User with same username already exists");
}
$user = new User();
$user->email = $req->email;
$user->username = $req->username;
$password = $this->generateRandomString(6);
$user->password = md5($password);
$user->employee = empty($req->employee) || $req->employee == "NULL" ? NULL : $req->employee;
$user->user_level = $req->user_level;
$user->last_login = date("Y-m-d H:i:s");
$user->last_update = date("Y-m-d H:i:s");
$user->created = date("Y-m-d H:i:s");
$employee = null;
if (!empty($user->employee)) {
$employee = $this->baseService->getElement('Employee', $user->employee, null, true);
}
$ok = $user->Save();
if (!$ok) {
error_log($user->ErrorMsg() . "|" . json_encode($user));
return new IceResponse(IceResponse::ERROR, "Error occured while saving the user");
}
$user->password = "";
$user = $this->baseService->cleanUpAdoDB($user);
if (!empty($this->emailSender)) {
$usersEmailSender = new UsersEmailSender($this->emailSender, $this);
$usersEmailSender->sendWelcomeUserEmail($user, $password, $employee);
}
return new IceResponse(IceResponse::SUCCESS, $user);
}
return new IceResponse(IceResponse::ERROR, "Not Allowed");
}
示例6: init
public function init()
{
if (SettingsManager::getInstance()->getSetting("Api: REST Api Enabled") == "1") {
$user = BaseService::getInstance()->getCurrentUser();
$dbUser = new User();
$dbUser->Load("id = ?", array($user->id));
$resp = RestApiManager::getInstance()->getAccessTokenForUser($dbUser);
if ($resp->getStatus() != IceResponse::SUCCESS) {
LogManager::getInstance()->error("Error occured while creating REST Api acces token for " . $user->username);
}
}
}
示例7: validateAccessTokenInner
private function validateAccessTokenInner($accessToken)
{
$accessTokenTemp = AesCtr::decrypt($accessToken, APP_SEC, 256);
$parts = explode("|", $accessTokenTemp);
$user = new User();
$user->Load("id = ?", array($parts[0]));
if (empty($user->id) || $user->id != $parts[0] || empty($parts[0])) {
return new IceResponse(IceResponse::ERROR, -1);
}
$accessToken = AesCtr::decrypt($parts[1], $user->password, 256);
$data = json_decode($accessToken, true);
if ($data['userId'] == $user->id) {
return new IceResponse(IceResponse::SUCCESS, true);
}
return new IceResponse(IceResponse::ERROR, false);
}
示例8: Register
public function Register($params)
{
$user = User::Load($params['login']);
$saved = false;
if ($user) {
$user->Set($params);
$saved = $user->Save();
} else {
$user = User::Add($params);
if ($user) {
$saved = true;
}
}
if ($saved) {
header('Location: /Login/UserView/login/' . $user->login, TRUE, 307);
} else {
header('Location: /Login/RegisterForm/', TRUE, 307);
}
}
示例9: createNewUsers
protected function createNewUsers()
{
$profileVar = SIGN_IN_ELEMENT_MAPPING_FIELD_NAME;
$profileClass = ucfirst(SIGN_IN_ELEMENT_MAPPING_FIELD_NAME);
$user = new User();
$user->username = 'manager';
$user->email = 'manager@icehrm-test.com';
$user->password = '21232f297a57a5a743894a0e4a801fc3';
$user->user_level = 'Manager';
$user->Save();
$this->usersArray[$user->username] = $user;
$user = new User();
$user->username = 'profile';
$user->email = 'profile@icehrm-test.com';
$user->password = '21232f297a57a5a743894a0e4a801fc3';
$user->user_level = 'Profile';
$user->Save();
$this->usersArray[$user->username] = $user;
$user = new User();
$user->Load("username = ?", array('admin'));
$this->usersArray[$user->username] = $user;
}
示例10: trim
<?php
if (isset($_POST["txtUserName"])) {
$user_name = trim($_POST["txtUserName"]);
$password = $_POST["txtPassword"];
$user = null;
try {
DBConnection::Connect();
${$user} = User::Load($user_name, $password);
DBConnection::Close();
} catch (Exception $ex) {
}
if ($user != null) {
User::SetCookie();
header("Location: /");
exit;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/login.css?v=0.0.1" />
<script type="text/javascript" src="../js/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="js/login.js"></script>
</head>
<body>
<form name="frmLogin" method="post">
<?php
// TODO: Make sucide because of using tables to orgenize the page, instead of divs and css
示例11: Reload
/**
* Reload this User from the database.
* @return void
*/
public function Reload()
{
// Make sure we are actually Restored from the database
if (!$this->__blnRestored) {
throw new QCallerException('Cannot call Reload() on a new, unsaved User object.');
}
// Reload the Object
$objReloaded = User::Load($this->intId);
// Update $this's local variables to match
$this->strNick = $objReloaded->strNick;
$this->strPassword = $objReloaded->strPassword;
$this->strEmail = $objReloaded->strEmail;
$this->strStatus = $objReloaded->strStatus;
$this->dttCreatedAt = $objReloaded->dttCreatedAt;
$this->strActivationKey = $objReloaded->strActivationKey;
$this->dttActivatedAt = $objReloaded->dttActivatedAt;
$this->dttLastseenAt = $objReloaded->dttLastseenAt;
$this->strRealname = $objReloaded->strRealname;
$this->strAddress = $objReloaded->strAddress;
$this->strState = $objReloaded->strState;
$this->strZip = $objReloaded->strZip;
$this->intFbinCount = $objReloaded->intFbinCount;
$this->intFbinTotal = $objReloaded->intFbinTotal;
$this->intFboutCount = $objReloaded->intFboutCount;
$this->intFboutTotal = $objReloaded->intFboutTotal;
}
示例12: dirname
<?php
/**
This script creates a table named Users with following details
* HASH key = client
* RANGE Key = userId
* Global secondary index = email
*/
include dirname(__FILE__) . "/../include.inc.php";
include dirname(__FILE__) . "/models.php";
include dirname(__FILE__) . "/configure.php";
$user = new User();
$user->client = 'Vocanic';
$user->email = "user@vocanic.com";
$user->password = "Password";
$user->name = "User " . rand();
$user->location = "SL";
$user->time = 100;
$user->Save();
$user1 = new User();
$ok = $user1->Load(array($user->client, $user->userId), true);
echo "Newly created user = " . json_encode($user1) . "\r\n";
示例13: getName
<?php
interface IUser
{
function getName();
}
class User implements IUser
{
public static function Load($id)
{
return new User($id);
}
public static function Create()
{
return new User(null);
}
public function __construct($id)
{
}
public function getName()
{
return "Jack";
}
}
$uo = User::Load(1);
echo $uo->getName() . "\n";
示例14: loadFromUsername
public static function loadFromUsername($username)
{
$user = new User();
$user->Load("username ='" . $username . "'");
return $user;
}
示例15: readfile
readfile($fileName);
exit;
} else {
if ($action == 'rsp') {
// linked clicked from password change email
$user = new User();
if (!empty($_REQUEST['key'])) {
$arr = explode("-", $_REQUEST['key']);
$userId = $arr[0];
$keyArr = array_shift($arr);
if (count($keyArr) > 1) {
$key = implode("-", $arr);
} else {
$key = $arr[0];
}
$user->Load("id = ?", array($userId));
if (!empty($user->id)) {
LogManager::getInstance()->info("Key : " . $key);
$data = AesCtr::decrypt($key, $user->password, 256);
if (empty($data)) {
$ret['status'] = "ERROR";
$ret['message'] = "Invalid Key for changing password, error decrypting data";
} else {
$data = json_decode($data, true);
if ($data['CLIENT_NAME'] != CLIENT_NAME || $data['email'] != $user->email) {
$ret['status'] = "ERROR";
$ret['message'] = "Invalid Key for changing password, keys do not match";
} else {
if (empty($_REQUEST['now'])) {
LogManager::getInstance()->info("now not defined");
header("Location:" . CLIENT_BASE_URL . "login.php?cp=1&key=" . $_REQUEST['key']);