本文整理汇总了PHP中User::findById方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findById方法的具体用法?PHP User::findById怎么用?PHP User::findById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User::findById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printDetail
public function printDetail($id)
{
$user = $this->userRepository->findById($id);
$pdf = PDF::loadView('admin.users.detail', compact('user'));
return $pdf->setPaper('a4')->setOrientation('landscape')->setWarnings(false)->stream(str_random(10) . '.pdf');
// return View::make('admin.users.detail',compact('user'));
}
示例2: indexAction
/**
* Show files generated by reports This action will be viewed by
*/
public function indexAction()
{
$user = User::findById($this->session->get("user-data")->getId());
if ($this->request->get('id')) {
$db = Db::findById($this->request->get('id'));
$user->setConfig('db', $db->getId());
}
if ($user->getConfig('db')) {
$db = isset($db) ? $db : Db::findById($user->getConfig('db'));
if (!$this->request->get('id')) {
return $this->response->redirect('report/index?id=' . $db->getId());
}
if (!$this->getUserSession()->hasPermission($db, 'view')) {
return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'error404'));
} else {
$this->view->dbm = $db;
$this->view->currentDbId = $db->getId();
}
} else {
return $this->response->redirect('report/default');
}
//if master show users
if ($this->getUserRole() == 'master') {
$this->view->users = User::find(['conditions' => ['type' => 'operator', 'status' => 1]]);
}
}
示例3: update
public function update()
{
$user = User::findById(1);
$user->permit(['email']);
$user->email = 'ale88andr@inbox.ru';
$user->login = 'blah';
$user->update();
}
示例4:
function admin_view_user($id = null)
{
if (!$id) {
$this->Session->setFlash('Wrong user ID!');
} else {
$user = $this->User->findById($id);
$this->set(compact('user'));
}
}
示例5: getFirstLastName
public function getFirstLastName($userData = null)
{
App::import("Model", "User");
$userObject = new User();
/* Get data from id */
$getUserData = $userObject->findById($userData);
/* Get Data */
$lastName = str_split($getUserData['User']['last_name']);
return ucfirst($getUserData['User']['first_name'] . ' ' . $lastName[0]);
}
示例6: home
function home()
{
$user = new User();
$usr = $user->findById($this->session->read('uid'));
$this->set('name', $this->session->read('name'));
$this->set('mail', $usr["mail"]);
$calendar = new Calendar();
$actualEvents = $calendar->getActualEvents();
$futureEvents = $calendar->getFutureEvents();
$this->set('actualEvents', $actualEvents);
$this->set('futureEvents', $futureEvents);
}
示例7: sendCourseAssignedMsg
public function sendCourseAssignedMsg($requirements)
{
$user = new User();
$garant = $this->controller->session->read("name");
$pract = $user->findById($requirements->cviciaci);
$teacher = $user->findById($requirements->prednasajuci);
$list = array(1 => array("mail" => $pract["mail"], "role" => "Cvičiaci", "url_part" => "/pract/requirements/edit/"), 2 => array("mail" => $teacher["mail"], "role" => "Prednášajúci", "url_part" => "/teacher/requirements/edit/"));
for ($i = 1; $i < 3; $i++) {
$mail = $list[$i]["mail"];
$toList = array($mail);
$toList = $this->__filterList($toList);
if (empty($toList)) {
continue;
}
$default = array('DATE' => date("d.m.Y H:i", time()), 'GARANT' => $garant, 'COURSE' => Subjects::getSubjectInfo($requirements->id), 'ROLE' => $list[$i]["role"], 'URL' => BASE_URL . $list[$i]["url_part"] . $requirements->id);
$message = $this->__createTemplate("messages/courseAssigned.tpl", $default);
$subject = "[" . Subjects::getSubjectInfo($requirements->id) . "]" . " - priradená zodpovednosť " . $list[$i]["role"];
$ref = $this->__createRef("garant.course", $requirements->id);
$this->sendNotifyMessage($toList, $message, $subject, $ref);
}
}
示例8: passAction
/**
* Change pass from a master user account
* @return mixed
*/
public function passAction()
{
if ($this->securePage(true)) {
$userSess = $this->session->get("user-data");
$user = User::findById($userSess->getId());
if ($this->processForm($user, 'PassForm')) {
$this->flash->success("Your account password was succesfully changed.");
return $this->response->redirect('user/edit');
}
$this->view->user = $user;
}
}
示例9: isAdmin
public static function isAdmin()
{
if (isset($_COOKIE['token']) && isset($_COOKIE['user_id'])) {
$user = User::findById($_COOKIE['user_id']);
//var_dump('User: (' . $user->token . ')');
//var_dump($_COOKIE['token']);
//var_dump($user->token);
if ($_COOKIE['token'] == $user->token && $user->is_admin) {
return true;
}
}
return false;
}
示例10: getAuthor
public function getAuthor()
{
if (empty($this->created_by_id)) {
return null;
} else {
$user = User::findById($this->created_by_id);
if ($user instanceof User) {
return $user->name;
} else {
return null;
}
}
}
示例11: editAction
public function editAction()
{
$id = $this->_request->getParam("id");
$data = User::findById($id);
$userAircrafts = App_Utils::toList($data['Aircraft'], "id", "id");
$form = new Form_UserEdit();
$form->role_id->addMultiOptions(App_Utils::toList(AclRole::findAll(), 'id', 'name'));
$form->aircraft->setMultiOptions(App_Utils::toList($data['Aircraft'], 'id', 'name'));
$form->aircraft_available->setMultiOptions(App_Utils::toList(Aircraft::findAll(array('exclude' => $userAircrafts)), 'id', 'name'));
$form->role_id->setValue($data['role_id']);
$form->user_id->setValue($id);
$form->populate($data);
$options = array('title' => "Edit User", 'url' => "/user/edit/format/json/subaction/submit", 'button' => "Edit", 'success' => array("button" => array("title" => "Close", "action" => "close"), "redirect" => "/user/list", "message" => "User {$form->first_name->getValue()} {$form->last_name->getValue()} modified correctly"), 'model' => array("class" => "User", "method" => "edit"));
$this->ajaxFormProcessor($form, $options);
}
示例12: checkAndAssignKickCampaignToUser
public static function checkAndAssignKickCampaignToUser($userId)
{
Log::user("checkAndAssignKickCampaignToUser");
$currentWeek = OBCampaign::getCurrentWeek($userId);
Log::user("current week is {$currentWeek}");
$lala = Campaign::doesUserHaveCampaign($userId, Campaign::$_KICK_TRACKER_CAMPAIGN);
Log::user("does this person already have this campaign? {$lala}");
$conditional = OBCampaign::getCurrentWeek($userId) >= 28 && !Campaign::doesUserHaveCampaign($userId, Campaign::$_KICK_TRACKER_CAMPAIGN);
$currentUser = User::findById($userId);
$hasLocation = $currentUser->location;
boldError("the conditional is: {$conditional}");
if (OBCampaign::getCurrentWeek($userId) >= 28 && $hasLocation) {
Campaign::assignCampaignToUser(Campaign::$_KICK_TRACKER_CAMPAIGN, $userId);
Action::assignActionItem($userId, KickCampaign::$_KICK_TRACKER_ACTION_ID);
boldError("ASSIGNED KICK CAMPAIGN");
}
}
示例13: beforeFilter
public function beforeFilter()
{
//check isset user logged update info
if ($this->Auth->loggedIn()) {
App::import('Model', 'User');
$user = new User();
$this->Session->write('Auth', $user->findById($this->Auth->User('id')));
}
//load setting
$this->loadModel('Settings');
$settings = $this->Settings->find('all');
$configs = array();
foreach ($settings as $key => $row) {
$configs[$row['Settings']['category']][$row['Settings']['param_name']] = $row['Settings']['param_value'];
}
Configure::write('Settings', $configs);
//set limit for paginate
if (isset($this->request->query['limit'])) {
$this->paginate['limit'] = $this->request->query['limit'];
}
//setting the timezone for all dates using TimeHelper
if ($this->Session->read('Auth.User.timezone')) {
Configure::write('Config.timezone', $this->Session->read('Auth.User.timezone'));
}
if ($this->name == 'Users') {
$this->Auth->allow('forgot', 'captcha');
}
if ($this->name == 'Enquiries') {
$this->Auth->allow('add_client');
}
if ($this->name == 'AdvertisingLinks') {
$this->Auth->allow('go');
}
if ($this->name == 'Briefs') {
$this->Auth->allow('visitor');
}
$this->Auth->loginAction = Configure::read('Core.LoginAction');
$this->Auth->loginRedirect = Configure::read('Core.LoginRedirect');
$this->Auth->logoutRedirect = Configure::read('Core.LogoutRedirect');
// prd($this->name);
if (!$this->Permissionable->checkModuleAccess($this) && $this->name != 'ToolbarAccess') {
die('denny');
}
}
示例14: providerRejects
public function providerRejects($id)
{
if ($this->isClosed()) {
return false;
}
$key = array_search($id, $this->providers);
if ($key !== false) {
unset($this->providers[$key]);
if (!$this->save()) {
return false;
}
if (count($this->providers) == 0) {
$user = User::findById((string) $this->user);
Push::send('Não foram encontradas pessoas disponíveis.', [$user->registrationId]);
}
return true;
}
return false;
}
示例15: loginWithCookie
/**
* Logs user in if cookie value matches database value
*
* @return bool
*/
public function loginWithCookie()
{
$cookie = isset($_COOKIE['rememberme']) ? $_COOKIE['rememberme'] : '';
if ($cookie) {
list($user_id, $token, $hash) = explode(':', base64_decode($cookie));
if ($hash !== hash('sha256', $user_id . ':' . $token)) {
return false;
}
// do not log in when token is empty
if (empty($token)) {
return false;
}
// @TODO: need to find a better way to tie this in without using global User
$user = \User::findById($user_id);
if ($user->rememberme_token == $token) {
$this->login($user);
return true;
} else {
$this->_response->setCookie(Cookie::create()->make('rememberme', false, time() - 3600 * 3650, '/'));
$this->logout();
}
}
return false;
}