本文整理匯總了PHP中models\User類的典型用法代碼示例。如果您正苦於以下問題:PHP User類的具體用法?PHP User怎麽用?PHP User使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了User類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: seedImage
public function seedImage(User $user)
{
$file = $this->faker->imageUrl(600, 400, 'people');
Debugger::debug($file, 'image url');
$image = new Image($file);
Debugger::debug($image, 'image class');
$filename = md5($file . $user->get('id')) . '.jpg';
$imageDir = 'assets/images/profile-pics/original/';
$imageDir .= substr($filename, 0, 1) . '/';
$imageDir .= substr($filename, 1, 1) . '/';
$imageDir .= substr($filename, 2, 1) . '/';
if (!is_dir(PUBLIC_ROOT . $imageDir)) {
mkdir(PUBLIC_ROOT . $imageDir, 0777, true);
}
$saveName = PUBLIC_ROOT . $imageDir . $filename;
Debugger::debug($saveName, 'save name');
$image->save($imageDir . $filename);
$thumbnail = $this->seedThumbnail($image, $imageDir, $user);
// update the database
$userImage = new UserImage();
$userImage->set('user_id', $user->get('id'));
$userImage->set('image_url', '/' . $imageDir . $filename);
$userImage->set('thumbnail', '/' . $thumbnail);
$userImage->set('main_image', 1);
$userImage->save();
}
示例2: signin
public function signin()
{
$userModel = new \Models\User();
$helper = $this->fb->getRedirectLoginHelper();
$permissions = ['email', 'user_likes'];
// optional
$callback_url = DIR . 'account/fblogin';
$this->data['loginUrl'] = $helper->getLoginUrl($callback_url, $permissions);
if (isset($_POST['email']) && !empty($_POST['email'])) {
$login = $userModel->login($_POST['email'], md5($_POST['password']));
if (!is_bool($login)) {
Session::set('user_id', $login->user_id);
Session::set('user', $login);
//redirects user to last visited page
$redirectUrl = Session::get('redirectLogin');
Session::destroy('redirectLogin');
if (isset($redirectUrl) && $redirectUrl != '') {
Url::redirect($redirectUrl);
} else {
Url::redirect('board');
}
} else {
Session::set('error', 'Login Fails!');
}
}
$this->data['title'] = 'Sign In';
View::rendertemplate('header', $this->data);
View::render('account/signin', $this->data);
View::rendertemplate('footer', $this->data);
}
示例3: actionEdit_status
public function actionEdit_status()
{
$user = new User();
$user->find()->where(['id' => $_POST['userID']])->one();
$user->status = $_POST['status'];
$user->save();
}
示例4: index
public function index()
{
$f3 = \Base::instance();
$this->_requireLogin();
$user = $f3->get('user');
$user_obj = $f3->get('user_obj');
$user_org_links = $f3->get('user_org_links');
$db = $f3->get('db.instance');
$tickets = $db->exec('SELECT * FROM support_tickets WHERE memberId = ? ORDER BY id DESC', $user['id']);
foreach ($tickets as $id => $ticket) {
$result = $db->exec('SELECT COUNT(*) AS `count` FROM support_tickets_msg WHERE ticketId = ?', $ticket['id']);
$tickets[$id]['messages_count'] = $result[0]['count'];
// Assigned or not ?
if ($ticket['assignedUserId'] != 0) {
$assignedUser = new User();
$assignedUser->load($ticket['assignedUserId']);
$tickets[$id]['assignedUser'] = $assignedUser->cast();
}
}
$f3->set('tickets', $tickets);
$active_tickets = $db->exec("SELECT * FROM support_tickets WHERE memberId = ? AND status != 'closed'", $user['id']);
$f3->set('active_tickets', $active_tickets);
$closed_tickets = $db->exec("SELECT * FROM support_tickets WHERE memberId = ? AND status = 'closed'", $user['id']);
$f3->set('closed_tickets', $closed_tickets);
$f3->set('target', 'support/index.html');
$this->_render('base.html');
}
示例5: index
public function index()
{
$userModel = new User();
$userModel->all();
$users = $userModel->all();
return view('index', compact('users'));
}
示例6: index
public function index()
{
$data['title'] = $this->language->get('title');
$user = new User();
var_dump($user->getData());
View::renderTemplate('header', $data);
View::render('welcome/welcome', $data);
View::renderTemplate('footer', $data);
}
示例7: register
public static function register($email, $nick, $password)
{
$user = new User();
$user->email = $email;
$user->nick = $nick;
$user->password = password_hash($password, PASSWORD_DEFAULT);
$user->save();
return $_SESSION['user'] = $user->id;
}
示例8: banUser
public function banUser($id)
{
if ($this->user->banUser($id) !== 1) {
Session::setError('something went wrong');
Redirect::back();
}
Session::setMessage('Done');
Redirect::to('/admin/users');
}
示例9: seedEmail
public function seedEmail(User $user)
{
Debugger::debug('Seeding email');
$userEmail = new Email();
$userEmail->set('user_id', $user->get('id'));
$userEmail->set('email', $this->faker->freeEmail);
$userEmail->set('primary', 1);
$userEmail->save();
}
示例10: actionReg
public function actionReg()
{
$vk_id = $this->app->cookie->get('vk_id');
$user = new User();
$user->find()->where(['vk_id' => $vk_id])->one();
$user->status = $_GET['status'] == 1 ? 2 : 1;
$user->save();
$this->app->parser->render('profile', ['user' => $user]);
}
示例11: create
protected function create()
{
$params = arrayKeysSnakeToCamel($_POST['user']);
$user = new User();
$user->fromArray($params);
$user->save();
$this->addFlash("success", "registered");
redirectTo("/");
}
示例12: start
public function start()
{
if ($this->user) {
return $this->app->parser->renderW('main_menu', ['user' => $this->user], false);
} else {
$user = new User();
$user->find()->where(['vk_id' => Cookie::get('vk_id')])->one();
return $this->app->parser->renderW('main_menu', ['user' => $user], false);
}
}
示例13: connect
public function connect(Application $app)
{
// creates a new controller based on the default route
$front = $app['controllers_factory'];
$front->get("/", 'FrontController\\Homepage::index')->bind("homepage");
$front->match("/final_test", 'FrontController\\FinalTest::index')->bind("final_test");
$front->match("/control_test", 'FrontController\\ControlTest::index')->bind("control_test");
$front->match("/{course_type}", 'FrontController\\CourseType::index')->bind("course_type");
//$front->post("/{course_type}", 'FrontController\Score::index')->bind("course_type");
$app->get('/logout', function (Request $request) use($app) {
$app['session']->set('username', '');
$app['session']->set('id', '');
$redirect = $app["url_generator"]->generate("homepage");
return $app->redirect($redirect);
})->bind("logout");
$app->post('/login-check', function (Request $request) use($app) {
$em = $app['orm.em'];
$qb = $em->createQueryBuilder();
if (null !== $request->get('username2')) {
$username = $request->get('username2');
$query = $qb->select('u')->from('models\\User', 'u')->where("u.username = '" . $username . "'")->getQuery();
$result = $query->getResult();
$result_count = count($result);
if ($result_count > 0) {
return 'Helaas, de gebruikersnaam die je hebt ingevoerd bestaat al, probeer eens een andere.';
} else {
$user = new User();
$user->setUsername($username);
$user->setRoles("ROLE_USER");
$em->persist($user);
$em->flush();
$id = $user->getId();
$app['session']->set('id', $id);
$app['session']->set('username', $username);
return 'succes';
}
} else {
if ($request->get('username') != '') {
$username = $request->get('username');
$query = $qb->select('u')->from('models\\User', 'u')->where("u.username = '" . $username . "'")->getQuery();
$result = $query->getResult();
$result_count = count($result);
if ($result_count < 1) {
return 'De gebruikersnaam die je hebt ingevoerd bestaat niet, probeer het eens opnieuw.';
} else {
$id = $result[0]->id;
$app['session']->set('id', $id);
$app['session']->set('username', $username);
return 'succes';
}
}
}
})->bind("login_check");
return $front;
}
示例14: users
function users()
{
if (Session::isSession('user')) {
$user = new User();
$usersData = $user->getAll();
$this->view->addUsers($usersData);
$this->view->forAjax('users');
} else {
Error::authFail();
}
}
示例15: actionMy
public function actionMy()
{
$vk_id = Cookie::get('vk_id');
$user = new User();
$user->find()->where(['vk_id' => $vk_id])->one();
$user->status = $_GET['status'] == 1 ? 2 : 1;
$user->save();
$region = new GeobaseRegion();
$city = new GeobaseCity();
$regionAll = $region->find()->orderBy('name', 'ASC')->all();
$this->app->parser->render('profile', ['user' => $user, 'regionAll' => $regionAll]);
}