本文整理汇总了PHP中User::Get方法的典型用法代码示例。如果您正苦于以下问题:PHP User::Get方法的具体用法?PHP User::Get怎么用?PHP User::Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetByToken
/**
* Get a user instance from a token
* @param int $token
* @return User|bool
*/
static function GetByToken($token)
{
$db = new DB();
$data = ["token" => $token];
if ($user_id = $db->fetch("SELECT user_id FROM Token WHERE token = :token", $data)) {
$user = User::Get($user_id);
return $user;
} else {
return false;
}
}
示例2: __construct
public function __construct()
{
$this->Infos['Title'] = Language::Get('com.sbb.page.profile');
// If logged in, redirect to start page
if (!User::LoggedIn()) {
header("Location: index.php");
}
$Message = '';
if (isset($_POST['Submit'])) {
if (User::CheckUpdate($_POST)) {
User::Update(array('Homepage' => $_POST['Homepage'], 'Signatur' => $_POST['Signature']));
$Message = Language::Get('com.sbb.profile.success');
} else {
$Message = '<b>' . Language::Get('com.sbb.error') . ':</b><ul><li>' . implode('</li><li>', Register::GetError()) . '</li></ul>';
}
}
// Füllt die Variablen im TPL
SBB::Template()->Assign(array('Homepage' => User::Get('Homepage'), 'Signature' => User::Get('Signatur'), 'Message' => $Message, 'Page' => 'Profile'));
}
示例3: tryLoginUser
public function tryLoginUser($suppliedUserName, $suppliedPassword)
{
$valid = $this->checkIfUserSuppliedInput($suppliedUserName, $suppliedPassword);
if ($valid != true) {
$valid = false;
return $valid;
}
$user = User::Get($this->suppliedUserName);
if ($user != NULL && $user->comparePassword($this->suppliedPassword)) {
if (!isset($_SESSION[self::$userLoginSession])) {
$valid = true;
$_SESSION[self::$userLoginSession] = true;
$this->messageKey = FeedbackStrings::LOGINSUCCESS;
}
} else {
$this->messageKey = FeedbackStrings::LOGINFAIL;
$valid = false;
}
return $valid;
}
示例4: die
<?php
if (!defined('ADMIN')) {
die("Access denied!");
}
$edit_user = new User();
if (isset($_GET['id']) && $edit_user->Load(array('id' => $_GET['id']))) {
?>
<form class="ajaxform" method="POST" action="">
<h2>Edit an user</h2>
<div class="message-box"></div>
Username:
<input type="text" name="username" value="<?php
echo $edit_user->Get('username');
?>
"><br>
Email:
<input type="text" name="email" value="<?php
echo $edit_user->Get('email');
?>
"><br>
User type:
<select name="user_type">
<option value="user" <?php
echo $edit_user->Get('user_type') == 'user' ? 'selected' : '';
?>
>user</option>
<option value="admin" <?php
echo $edit_user->Get('user_type') == 'admin' ? 'selected' : '';
?>
>admin</option>
示例5: ProjectUser
public function ProjectUser(User $oUser)
{
if (is_array($this->m_aUserProjections)) {
// Hit!
return $this->m_aUserProjections;
}
$sExpr = $this->Get('value');
if ($sExpr == '<user>') {
$sColumn = $this->Get('attribute');
if (empty($sColumn)) {
$aRes = array($oUser->GetKey());
} else {
$aRes = array($oUser->Get($sColumn));
}
} elseif ($sExpr == '<any>' || $sExpr == '') {
$aRes = null;
} elseif (strtolower(substr($sExpr, 0, 6)) == 'select') {
$sColumn = $this->Get('attribute');
// SELECT...
$oValueSetDef = new ValueSetObjects($sExpr, $sColumn, array(), true);
$aRes = $oValueSetDef->GetValues(array('user' => $oUser), '');
} else {
// Constant value(s)
$aRes = explode(';', trim($sExpr));
}
$this->m_aUserProjections = $aRes;
return $aRes;
}
示例6: do_updateUserMembers
function do_updateUserMembers()
{
$old_search = KTUtil::arrayGet($_REQUEST, 'old_search');
$group_id = KTUtil::arrayGet($_REQUEST, 'group_id');
$oGroup = Group::get($group_id);
if (PEAR::isError($oGroup) || $oGroup === false) {
$this->errorRedirectToMain(_kt('No such group.'));
}
$userAdded = KTUtil::arrayGet($_REQUEST, 'users_items_added', '');
$userRemoved = KTUtil::arrayGet($_REQUEST, 'users_items_removed', '');
$aUserToAddIDs = explode(",", $userAdded);
$aUserToRemoveIDs = explode(",", $userRemoved);
$this->startTransaction();
$usersAdded = array();
$usersRemoved = array();
$addWarnings = array();
$removeWarnings = array();
foreach ($aUserToAddIDs as $iUserId) {
if ($iUserId > 0) {
$oUser = User::Get($iUserId);
$memberReason = GroupUtil::getMembershipReason($oUser, $oGroup);
//var_dump($memberReason);
if (!(PEAR::isError($memberReason) || is_null($memberReason))) {
$addWarnings[] = $memberReason;
}
$res = $oGroup->addMember($oUser);
if (PEAR::isError($res) || $res == false) {
$this->errorRedirectToMain(sprintf(_kt('Unable to add user "%s" to group "%s"'), $oUser->getName(), $oGroup->getName()), sprintf("old_search=%s&do_search=1", $old_search));
} else {
$usersAdded[] = $oUser->getName();
}
}
}
// Remove groups
foreach ($aUserToRemoveIDs as $iUserId) {
if ($iUserId > 0) {
$oUser = User::get($iUserId);
$res = $oGroup->removeMember($oUser);
if (PEAR::isError($res) || $res == false) {
$this->errorRedirectToMain(sprintf(_kt('Unable to remove user "%s" from group "%s"'), $oUser->getName(), $oGroup->getName()), sprintf("old_search=%s&do_search=1", $old_search));
} else {
$usersRemoved[] = $oUser->getName();
$memberReason = GroupUtil::getMembershipReason($oUser, $oGroup);
//var_dump($memberReason);
if (!(PEAR::isError($memberReason) || is_null($memberReason))) {
$removeWarnings[] = $memberReason;
}
}
}
}
if (!empty($addWarnings)) {
$sWarnStr = _kt('Warning: some users were already members of some subgroups') . ' — ';
$sWarnStr .= implode(', ', $addWarnings);
$_SESSION['KTInfoMessage'][] = $sWarnStr;
}
if (!empty($removeWarnings)) {
$sWarnStr = _kt('Warning: some users are still members of some subgroups') . ' — ';
$sWarnStr .= implode(', ', $removeWarnings);
$_SESSION['KTInfoMessage'][] = $sWarnStr;
}
$msg = '';
if (!empty($usersAdded)) {
$msg .= ' ' . _kt('Added') . ': ' . implode(', ', $usersAdded) . '. ';
}
if (!empty($usersRemoved)) {
$msg .= ' ' . _kt('Removed') . ': ' . implode(', ', $usersRemoved) . '.';
}
if (!Permission::userIsSystemAdministrator($_SESSION['userID'])) {
$this->rollbackTransaction();
$this->errorRedirectTo('manageUsers', _kt('For security purposes, you cannot remove your own administration priviledges.'), sprintf('group_id=%d', $oGroup->getId()), sprintf("old_search=%s&do_search=1", $old_search));
exit(0);
}
$this->commitTransaction();
$this->successRedirectToMain($msg, sprintf("old_search=%s&do_search=1", $old_search));
}
示例7: TemplateAssign
private static function TemplateAssign()
{
global $GeneratingTime;
self::Template()->Assign(array('DIR_STYLE' => DIR_STYLE, 'DIR_JS' => DIR_JS, 'User' => User::Get(), 'Load' => '~Load: ' . round((microtime(true) - $GeneratingTime) * 1000, 2) . 'ms'));
self::Template()->AssignLanguage(Language::Assign());
}
示例8:
<?php
include_once '../Models/User.php';
$user = User::Get();
my_print($user);
示例9: Exception
if (!Mail::send($email, $name, "Account created", $message)) {
throw new Exception("Error sending email", 500);
}
$app->render_json(["id" => $user_id]);
// Create the user token for the first time
Token::Update($user_id);
} else {
throw new Exception("Something went wrong!", 500);
}
}
}
});
/* Delete User
**********************************************************************************************************************/
$app->delete('/users/:id', function ($id) use($app) {
if ($user = User::Get($id)) {
// Set the user status to disabled instead of deleting it
$user->setStatus('disabled');
$app->render_json(["success" => true]);
} else {
throw new Exception("User not found", 404);
}
});
/* Get stats by user
**********************************************************************************************************************/
$app->get('/users/:id/stats', function ($id) use($app) {
$stats = Stats::GetByUser($id);
$app->render_json($stats);
});
/* Get all teams
**********************************************************************************************************************/
示例10: dirname
<?php
require dirname(__FILE__) . '/../../fx.php';
// Are we logged in?
if (strlen(User::cGet('id')) == 0 or strlen(User::cGet('oat')) == 0 or strlen(User::cGet('oats')) == 0) {
Redirect('/account/signin');
}
$data = array();
$data['user'] = User::Get();
$data['services'] = User::GetServices($data['user']);
Layout('Your Account', 'account');
TPL('account/index', $data);
示例11: DisplayDefaultData
function DisplayDefaultData()
{
global $smarty;
$session = new session();
require_once 'objects/class.user.php';
$user = new User();
$user->Get($session->get('currentuserid'));
$smarty->assign('currentuserid', $user->userId);
$smarty->assign('currentusername', $user->username);
$smarty->assign('currentfirst', $user->firstname);
$smarty->assign('currentlast', $user->lastname);
}
示例12: Login
static function Login($fields, $encrypted = false)
{
$username = $fields['username'];
$password = $fields['password'];
$validator = new Validate();
$result = $validator->AddValue('usernameoremail', $username)->AddRule('required', true)->AddValue('password', $password)->AddRule('required', true)->Check();
if (!$encrypted) {
$password = Validate::Encrypt($password);
}
if ($result) {
if (strpos($username, '@') !== false) {
$type = "email";
} else {
$type = "username";
$username = Validate::Escape($username);
}
$user = new User();
$result = $user->Load(array($type => $username, 'password' => $password));
if ($result) {
if ($user->Get('activation_state') == '0') {
Error::Set("email", "notactivated");
} else {
if (isset($fields['rememberme'])) {
Cookie::Set($username, $password);
}
Session::Set("current_user", $user);
return true;
}
} else {
Error::Set("username", "usernotfound");
}
}
return false;
}
示例13: intval
$userid = intval($_SESSION['user_id']);
$the_comment = Utils::secure($_POST['comment']);
$id = intval($_POST['id']);
if (User::login_check(Query::$mysqli) == true) {
$date = date("Y-m-d H:i:s");
Query::query("INSERT INTO tbl_comments (user, comment, link_id, date, ip) VALUES ('{$userid}', '{$the_comment}', '{$id}', '{$date}', '{$_SERVER['REMOTE_ADDR']}')");
$user_url = '';
//'uploads/avatars/' . User::Get('id') . User::Get('AvatarType');//ProfileUrl($user2['id'], $user2['seo_url']);
$content = stripslashes(nl2br(strip_tags($_POST['comment'])));
$username = User::Get('Username');
$report_button = '';
$delete = '';
if (User::Get('AvatarType') == '') {
$avatar_url = '/uploads/avatars/default.png';
} else {
$avatar_url = 'uploads/avatars/' . User::Get('id') . User::Get('AvatarType');
}
//$this->set('user_avatar', 'uploads/avatars/' . User::Get('id') . User::Get('AvatarType'));
include '../../../app/templates/sections/CommentsAJAX.tpl';
//$comment = array('username' => $user2['username'], 'content' => stripslashes(nl2br(strip_tags($_POST['comment']))), 'user_points' => $user2['points'], 'date' => FormatDate($date, 'time'));
//$comment['delete'] = '';
//$seo_username = seoname($user2['username']);
//$comment['user_url'] = ProfileUrl($user2['id'], $user2['seo_url']);
//if ($user2['admin'] == 1) {
// $comment['delete'] = '<a href="#" onclick="DeleteNewsComment(' . mysql_insert_id() . ', ' . "'" . $setting['site_url'] . "'" . '); return false">Delete</a>';
// $comment['report_button'] = '<a href="' . $setting['site_url'] . '/admin/?task=manage_users#page=1&ip=' . $_SERVER['REMOTE_ADDR'] . '"><img src="' . $setting['site_url'] . '/images/report.png" title="' . $_SERVER['REMOTE_ADDR'] . '" style="vertical-align:middle;"/></a>';
//} else {
// if ($setting['report_permissions'] == "1" || $setting['report_permissions'] == "2" && $user['login_status'] == 1) {
// $comment['report_button'] = '<a href="#" onclick="ShowPopup(\'ava-popup\', \'' . $setting['site_url'] . '/includes/forms/comment_report_form.php?id=' . mysql_insert_id() . '&type=2\', \'Report comment\'); return false"><img src="' . $setting['site_url'] . '/images/report.png" title="' . REPORT . '" style="vertical-align:middle;"/></a>';
// } else {
// $comment['report_button'] = '';
示例14: GetList
/**
* Returns a sorted array of objects that match given conditions
* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
* @param string $sortBy
* @param boolean $ascending
* @param int limit
* @return array $userList
*/
static function GetList($fcv_array, $sortBy = '', $ascending = true, $limit = '')
{
$sqlLimit = $limit != '' && $sortBy == '' ? "LIMIT {$limit}" : '';
if (sizeof($fcv_array) > 0) {
$userList = array();
$Database = new DatabaseConnection();
$pog_query = "select userid from `user` where ";
for ($i = 0, $c = sizeof($fcv_array) - 1; $i < $c; $i++) {
$pog_query .= "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " '" . $Database->Escape($fcv_array[$i][2]) . "' AND";
}
$pog_query .= "`" . $fcv_array[$i][0] . "` " . $fcv_array[$i][1] . " '" . $Database->Escape($fcv_array[$i][2]) . "' order by userid asc {$sqlLimit}";
$Database->Query($pog_query);
for ($i = 0; $i < $Database->Rows(); $i++) {
$user = new User();
$user->Get($Database->Result($i, "userid"));
$userList[] = $user;
}
if ($sortBy != '') {
$f = '';
$user = new User();
if (isset($user->pog_attribute_type[strtolower($sortBy)]) && $user->pog_attribute_type[strtolower($sortBy)][0] == "NUMERIC") {
$f = 'return $user1->' . $sortBy . ' > $user2->' . $sortBy . ';';
} else {
if (isset($user->pog_attribute_type[strtolower($sortBy)])) {
$f = 'return strcmp(strtolower($user1->' . $sortBy . '), strtolower($user2->' . $sortBy . '));';
}
}
usort($userList, create_function('$user1, $user2', $f));
if (!$ascending) {
$userList = array_reverse($userList);
}
if ($limit != '') {
$limitParts = explode(',', $limit);
if (sizeof($limitParts) > 1) {
return array_slice($userList, $limitParts[0], $limitParts[1]);
} else {
return array_slice($userList, 0, $limit);
}
}
}
return $userList;
}
return null;
}
示例15: dirname
<?php
require dirname(__FILE__) . '/../../../fx.php';
// Are we logged in?
if (strlen(User::cGet('id')) == 0 or strlen(User::cGet('oat')) == 0 or strlen(User::cGet('oats')) == 0) {
Redirect('/account/signin');
}
$data = array('user' => User::Get());
$follows = array('status' => 'active', 'email' => !empty($_POST['email']) ? trim($_POST['email']) : '', 'frequency' => 'daily', 'hour' => date('H'), 'when' => '', 'post_url' => '', 'post_format' => '');
$result = User::InstallService('follows', $data['user'], $follows);
if ($result === true) {
Redirect('/account/follows/');
}
$data['message'] = 'Installation failed; ' . $result;
Layout('Follows', 'account');
TPL('account/follows/install', $data);