本文整理汇总了PHP中Session::getUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::getUserId方法的具体用法?PHP Session::getUserId怎么用?PHP Session::getUserId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Session
的用法示例。
在下文中一共展示了Session::getUserId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetCurrentUser
public function testSetCurrentUser()
{
$this->assertEmpty($this->object->getGroups());
$this->assertEmpty($this->object->getUserId());
$this->assertEmpty($this->object->getUserName());
$this->object->setCurrentUser(1, 'test', array('x1', 'x2'));
$this->assertEquals(1, $this->object->getUserId());
$this->assertEquals('test', $this->object->getUserName());
$this->assertEquals(array('x1', 'x2'), $this->object->getGroups());
$this->object->setCurrentUser(2, 'other test', array('a', 'b', 'c'));
$this->assertEquals(2, $this->object->getUserId());
$this->assertEquals('other test', $this->object->getUserName());
$this->assertEquals(array('a', 'b', 'c'), $this->object->getGroups());
}
示例2: Create
public static function Create($p_sessionId, &$p_objectId, $p_objectTypeId = null, $p_userId = null, $p_updateStats = false)
{
if (empty($p_sessionId)) {
throw new SessionIdNotSet();
}
$session = new Session($p_sessionId);
if (!$session->exists()) {
$sessionParams = array('start_time' => strftime("%Y-%m-%d %T"));
if (!empty($p_userId)) {
$sessionParams['user_id'] = $p_userId;
}
$session->create($sessionParams);
}
$sessionUserId = $session->getUserId();
if (!empty($p_userId) && !empty($sessionUserId) && $sessionUserId != $p_userId) {
throw new InvalidUserId();
}
$requestObject = new RequestObject($p_objectId);
if (!$requestObject->exists()) {
if (empty($p_objectTypeId)) {
throw new ObjectTypeIdNotSet();
}
$requestObject->create(array('object_type_id' => $p_objectTypeId));
$p_objectId = $requestObject->getObjectId();
} elseif (empty($p_objectId)) {
throw new ObjectIdNotSet();
}
if ($p_updateStats) {
self::UpdateStats($p_sessionId, $p_objectId);
}
}
示例3: new_form
function new_form($params)
{
if (!$params['project_id']) {
bail('Required parameter "project_id" is missing.');
}
$project = new Project($params['project_id']);
$this->options = array('project_id' => $project->id, 'title' => $project->getName());
$this->data = new Hour();
$this->data->set(array('staff_id' => Session::getUserId(), 'date' => date('Y-m-d')));
}
示例4: show
function show($params)
{
$params['id'] ? $this->data->contract = new SupportContract($params['id']) : Bail('required parameter $params["id"] missing.');
$this->data->new_hour = new Hour();
$this->data->new_hour->set(array('staff_id' => Session::getUserId(), 'date' => date('Y-m-d'), 'support_contract_id' => $params['id']));
$this->data->new_charge = new Charge();
$this->data->new_charge->set(array('date' => date('Y-m-d'), 'company_id' => $this->data->contract->get('company_id')));
$this->data->hours = $this->data->contract->getHours(array_merge(array('sort' => 'date DESC'), $this->search_params('hour_search')));
$this->data->total_hours_this_month = $this->data->contract->getTotalHours(array('date_range' => array('start_date' => Util::start_date_of_current_month(), 'end_date' => Util::end_date_of_current_month())));
$this->data->billable_hours_this_month = $this->data->contract->getBillableHours(array('date_range' => array('start_date' => Util::start_date_of_current_month(), 'end_date' => Util::end_date_of_current_month())));
}
示例5: show
function show($params)
{
if (!$params['id']) {
bail('Required $params["id"] not present.');
}
$d = $this->data;
$d->hour = new Hour($params['id']);
$d->support_contract = new SupportContract($d->hour->get('support_contract_id'));
$d->support_hours = Hour::getMany(array('support_contract_id' => $d->support_contract->id, 'sort' => 'date DESC'));
$d->new_hour = new Hour();
$d->new_hour->set(array('support_contract_id' => $d->support_contract->id, 'staff_id' => Session::getUserId(), 'date' => date('Y-m-d')));
}
示例6: isAuthorized
public function isAuthorized()
{
$action = $this->request->param('action');
$role = Session::getUserRole();
$resource = "files";
//only for admins
Permission::allow('admin', $resource, ['*']);
//only for normal users
Permission::allow('user', $resource, ['index', 'getAll', 'create']);
Permission::allow('user', $resource, ['delete'], 'owner');
$fileId = Encryption::decryptIdWithDash($this->request->data("file_id"));
$config = ["user_id" => Session::getUserId(), "table" => "files", "id" => $fileId];
return Permission::check($role, $resource, $action, $config);
}
示例7: show
function show($params)
{
if (!$params['id']) {
bail('Required parameter "id" is not present.');
}
$d = $this->data;
$d->estimate = new Estimate($params['id']);
$d->project = new Project($d->estimate->get('project_id'));
$d->new_hour = new Hour();
$d->new_hour->set(array('estimate_id' => $params['id'], 'staff_id' => Session::getUserId(), 'date' => date('Y-m-d')));
$d->new_estimate = new Estimate();
$d->new_estimate->set(array('project_id' => $d->project->id));
$d->estimates = $d->project->getEstimates();
$d->hours = getMany('Hour', array('estimate_id' => $params['id'], 'sort' => 'date DESC'));
}
示例8: checkUserUpdateMPass
/**
* Comprobar si el usuario tiene actualizada la clave maestra actual.
*
* @param string $login opcional con el login del usuario
* @return bool
*/
public static function checkUserUpdateMPass($login = null)
{
$userId = !is_null($login) ? UserUtil::getUserIdByLogin($login) : Session::getUserId();
if ($userId === 0) {
return false;
}
$configMPassTime = ConfigDB::getValue('lastupdatempass');
if ($configMPassTime === false) {
return false;
}
$query = 'SELECT user_lastUpdateMPass FROM usrData WHERE user_id = :id LIMIT 1';
$data['id'] = $userId;
$queryRes = DB::getResults($query, __FUNCTION__, $data);
$ret = $queryRes !== false && $queryRes->user_lastUpdateMPass > $configMPassTime;
return $ret;
}
示例9: isAuthorized
public function isAuthorized()
{
$action = $this->request->param('action');
$role = Session::getUserRole();
$resource = "todo";
// only for admins
Permission::allow('admin', $resource, ['*']);
// only for normal users
Permission::allow('user', $resource, ['delete'], 'owner');
$todoId = $this->request->data("todo_id");
if (!empty($todoId)) {
$todoId = Encryption::decryptIdWithDash($todoId);
}
$config = ["user_id" => Session::getUserId(), "table" => "todo", "id" => $todoId];
return Permission::check($role, $resource, $action, $config);
}
示例10: show
function show($params = array())
{
if (!isset($params['id']) || !$params['id']) {
$staff_members = getAll('Staff');
if (!isset($params['start_date']) || !isset($params['end_date'])) {
$hours_criteria = array('current_week' => true);
$this->data->dates = array('start_date' => date('Y-m-d', strtotime('last Sunday')), 'end_date' => date('Y-m-d', strtotime('next Sunday')));
} else {
$hours_criteria = array('hour_search' => array('start_date' => $params['start_date'], 'end_date' => $params['end_date']));
$this->data->dates = array('start_date' => $params['start_date'], 'end_date' => $params['end_date']);
}
foreach ($staff_members as $staff) {
if (!$staff->get('active')) {
continue;
}
if (!isset($this->data->billable_hours_this_week)) {
$this->data->staff = array();
$this->data->billable_hours_this_week = array();
}
if (!isset($this->data->total_hours_this_week)) {
$this->data->staff = array();
$this->data->total_hours_this_week = array();
}
$this->data->staff[$staff->get('id')] = $staff->getName();
$this->data->billable_hours_this_week[$staff->get('id')] = $staff->getBillableHoursTotal($hours_criteria);
$this->data->total_hours_this_week[$staff->get('id')] = $staff->getHoursTotal($hours_criteria);
}
} else {
$this->data->active_projects = getMany('Project', array('active' => true));
$staff = new Staff($params['id']);
$this->data->staff = $staff;
$this->data->staff_hours = $staff->getHours();
$hours_criteria = array('current_month' => true);
$this->data->hours_this_month = $staff->getHoursTotal($hours_criteria);
$this->data->billable_hours_this_month = $staff->getBillableHoursTotal($hours_criteria);
$hours_criteria = array('current_week' => true);
$this->data->hours_this_week = $staff->getHoursTotal($hours_criteria);
$this->data->billable_hours_this_week = $staff->getBillableHoursTotal($hours_criteria);
$this->data->new_project = new Project();
$this->data->new_project->set(array('staff_id' => Session::getUserId()));
$this->data->new_support_hour = new Hour();
$this->data->new_support_hour->set(array('staff_id' => Session::getUserId(), 'date' => date('Y-m-d')));
$this->data->graph = array('staff' => $staff->id, 'call' => 'overview');
}
}
示例11: show
function show($params)
{
if (empty($params['id'])) {
bail('No company selected.');
}
$this->data->company = new Company($params['id']);
$user_id = Session::getUserId();
$p = new Project();
$p->set(array('company_id' => $params['id'], 'staff_id' => $user_id));
$this->data->new_project = $p;
$this->data->new_note = new Note();
$this->data->new_note->set(array('date' => date('Y-m-d'), 'staff_id' => Session::getUserId(), 'company_id' => $params['id']));
$this->data->new_charge = new Charge();
$this->data->new_charge->set(array('date' => date('Y-m-d'), 'company_id' => $params['id']));
$this->data->new_payment = new Payment();
$this->data->new_payment->set(array('date' => date('Y-m-d'), 'company_id' => $params['id']));
$this->data->new_invoice = new Invoice();
$this->data->new_invoice->set(array('company_id' => $params['id']));
$this->data->new_contact = new Contact();
$this->data->new_contact->set(array('company_id' => $params['id']));
}
示例12: __construct
/**
* Private constructor. Ensures there is always a owner group and user.
*
* @internal
*
* @param string $environment (optional)
* @param array $context
*/
private function __construct($environment = '', array $context = [])
{
$this->setEnvironment($environment, $context);
$this->handlers = Application::getAuthorizationHandlers();
foreach ($this->handlers as $handler) {
$handler->handleContext($this->context);
}
// make sure, we always have user and group id of the owner
if (!isset($this->context['request_user_id'])) {
$this->context['request_user_id'] = Session::getUserId();
}
if (isset($this->context['request_user_id'])) {
$this->isLoggedIn = $this->context['request_user_id'] > 0;
}
if (!isset($this->context['owner_user_id'])) {
$this->context['owner_user_id'] = -1;
}
if (!isset($this->context['owner_group_id'])) {
$this->context['owner_group_id'] = -1;
}
}
示例13: foreach
<?php
$notifications = $this->controller->user->getNotifications(Session::getUserId());
$newsfeed = $posts = $files = "";
foreach ($notifications as $notification) {
if ($notification["count"] > 0) {
// $$notification["target"] = $notification["count"]; // DEPRECATED IN PHP 7
${$notification["target"]} = $notification["count"];
}
}
$info = $this->controller->user->getProfileInfo(Session::getUserId());
?>
<!-- Navigation -->
<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- /.navbar-header -->
<ul class="nav navbar-top-links navbar-right">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
Hello,<strong> <?php
echo $info["name"];
示例14: CsrfToken
/**
* validate CSRF token
* CSRF token can be passed with submitted forms and links associated with sensitive server-side operations.
*
* In case of GET request, you need to set 'validateCsrfToken' in $config to true.
*
* @param array $config configuration data
* @return boolean
*/
public function CsrfToken($config = [])
{
$userToken = null;
if ($this->request->isPost()) {
$userToken = $this->request->data('csrf_token');
} else {
$userToken = $this->request->query('csrf_token');
}
if (empty($userToken) || $userToken !== Session::getCsrfToken()) {
Logger::log("CSRF Attack", "User: " . Session::getUserId() . " provided invalid CSRF Token " . $userToken, __FILE__, __LINE__);
return false;
}
return $userToken === Session::getCsrfToken();
}
示例15: logOut
/**
* logout
*
*/
public function logOut()
{
$this->login->logOut(Session::getUserId());
Redirector::login();
}