本文整理汇总了PHP中currentUser函数的典型用法代码示例。如果您正苦于以下问题:PHP currentUser函数的具体用法?PHP currentUser怎么用?PHP currentUser使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了currentUser函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerMenu
/**
* Register a menu.
*
* @param \Caffeinated\Menus\Builder|\Caffeinated\Menus\Item $menuBuilder
* @param \Yajra\CMS\Entities\Menu $menu
* @return \Caffeinated\Menus\Builder|bool
* @throws \Laracasts\Presenter\Exceptions\PresenterException
*/
protected function registerMenu($menuBuilder, Menu $menu)
{
if (!$menuBuilder) {
return false;
}
if (!$menu->published) {
return false;
}
if ($menu->requiresAuthentication() && !auth()->check()) {
return false;
}
if (count($menu->permissions)) {
if ($menu->authorization === 'can') {
foreach ($menu->permissions as $permission) {
if (!currentUser()->can($permission->slug)) {
return false;
}
}
} else {
$permissions = $menu->permissions->pluck('slug')->toArray();
if (!currentUser()->canAtLeast($permissions)) {
return false;
}
}
}
$item = $menuBuilder->add($menu->title, url($menu->present()->url))->attribute('target', $menu->present()->target)->attribute('title', $menu->present()->linkTitle);
if ($menu->present()->linkStyle) {
$item->attribute('style', $menu->present()->linkStyle);
}
if ($menu->isActive()) {
session()->flash('active_menu', $menu);
}
return $item;
}
示例2: submit
public function submit($id, Request $request, Guard $auth)
{
$this->validate($request, ['comment' => 'required|max:250']);
$pattern = $this->findOrFail($id);
$this->create($pattern, currentUser(), $request->get('comment'));
session()->flash('success', 'Tu comentario fue guardado exitosamente');
return redirect()->back();
}
示例3: submit
public function submit($id, Request $request, Guard $auth)
{
$this->validate($request, ['comment' => 'required|max:250', 'link' => 'url']);
$ticket = $this->ticketRepository->findOrFail($id);
$this->commentsRepositories->create($ticket, currentUser(), $request->get('comment'), $request->get('link'));
session()->flash('success', 'Tu comentario fue guardado satiscatoriamente ');
return redirect()->back();
}
示例4: destroy
public function destroy($id, Request $request)
{
$ticket = $this->ticketRepository->findOrFail($id);
$success = $this->voteRepository->unvote(currentUser(), $ticket);
if ($request->ajax()) {
return response()->json(compact('success'));
}
return redirect()->back();
}
示例5: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (auth()->check() && $request->is('administrator*')) {
Menu::make('admin', function (Builder $menu) {
$menu->add('Dashboard', route('administrator.index'))->icon('home');
$navs = app('navigation')->getPublished();
if ($navs->count()) {
$nav = $menu->add('Navigation', '#')->icon('sitemap')->data('permission', 'navigation.view');
$nav->add('Manage', route('administrator.navigation.index'))->icon('cogs')->data(['permission' => 'navigation.view', 'append' => route('administrator.navigation.create')]);
$navs->each(function ($item) use($nav) {
$nav->add($item->title, route('administrator.navigation.menu.index', $item->id))->icon('link')->data(['permission' => 'navigation.view', 'append' => route('administrator.navigation.menu.create', $item->id)]);
});
} else {
$menu->add('Navigation', route('administrator.navigation.index'))->icon('link')->data(['permission' => 'navigation.view']);
}
$contents = $menu->add('Contents', '#')->icon('files-o');
$contents->add('Articles', route('administrator.articles.index'))->icon('files-o')->data(['permission' => 'article.view', 'append' => route('administrator.articles.create')]);
$contents->add('Categories', route('administrator.categories.index'))->icon('file-text')->data(['permission' => 'category.view', 'append' => route('administrator.categories.create')]);
$contents->add('Widgets', route('administrator.widgets.index'))->icon('plug')->data(['permission' => 'widget.view', 'append' => route('administrator.widgets.create')]);
$contents->add('Media', route('administrator.media.index'))->icon('image')->data('permission', 'media.view');
$modules = $menu->add('Modules', '#')->icon('plug')->data('permission', 'modules.view');
event('admin.menu.build', $modules);
$menu->add('Themes', route('administrator.themes.index'))->icon('windows')->data(['permission' => 'theme.view']);
$users = $menu->add('Users', '#')->icon('key')->data(['permission' => ['user.view', 'role.view', 'permission.view']]);
$users->add('Manage', route('administrator.users.index'))->icon('users')->data(['permission' => 'user.view', 'append' => route('administrator.users.create')]);
$users->add('Roles', route('administrator.roles.index'))->icon('shield')->data(['permission' => 'role.view', 'append' => route('administrator.roles.create')]);
$users->add('Permissions', route('administrator.permissions.index'))->icon('tag')->data(['permission' => 'permission.view', 'append' => route('administrator.permissions.create')]);
$config = $menu->add('Configurations', '#')->icon('gears')->data(['permission' => ['extension.view', 'utilities.config']]);
$config->add('Extensions', route('administrator.extension.index'))->icon('plug')->data('permission', 'extension.view');
$config->add('Global', route('administrator.configuration.index'))->icon('globe')->data('permission', 'utilities.config');
$menu->add('Utilities', route('administrator.utilities.index'))->icon('wrench')->data('permission', 'utilities.view');
$menu->add('Logout', route('administrator.logout'))->icon('power-off');
})->filter(function ($item) {
$permissions = (array) $item->data('permission');
if (!$permissions) {
return true;
}
return currentUser()->canAtLeast($permissions);
});
}
$response = $next($request);
return $response;
}
示例6: listSchools
public function listSchools()
{
$schools = currentUser()->schools;
return view('schools/list', compact('schools'));
}
示例7: hasPermission
/**
* Check users permission.
*
* @param string $action
* @param Project $project
*
* @return boolean
*/
function hasPermission($action, Project $project = null)
{
// Admins can do everything, regardless of permissions.
if (currentUser() && currentUser()->isAdmin()) {
return true;
}
$permissions = $project ? Permission::getPermissions(currentUser(), $project) : $GLOBALS['permissions'];
return isset($permissions[$action]) ? $permissions[$action] : null;
}
示例8: store
public function store(Request $request)
{
$this->validate($request, ['title' => 'required|max:120', 'link' => 'url']);
$ticket = $this->ticketRepository->openNew(currentUser(), $request->get('title'), $request->get('link'));
return Redirect::route('tickets.details', $ticket->id);
}
示例9: currentUser
<?php
include "includes/functions.php";
$currentUser = currentUser();
if (!isset($currentUser->id)) {
/* Redirect if the user is not signed in */
$_SESSION['error'] = "Sorry! You have to be logged in to access this page";
header("location: index.php");
die;
}
if (!$currentUser->isConfirmed()) {
/* Redirect if the user has not confirmed their email address */
header("location: reconfirm.php");
die;
}
if ($currentUser->membership == 0) {
$_SESSION['error'] = "We're Sorry! You have to sign up for a membership in order to acccess the page.";
header("location: index.php");
die;
}
include "includes/userinfo.php";
示例10: currentUser
<?php
require_once "../template/header.php";
require_once "../template/wrapper.php";
if (isset($_SESSION['USERID'])) {
$currentUserProfile = $_SESSION['USERID'];
$profile_info2 = currentUser($_SESSION['USERID']);
?>
<div class="container-fluid card" style="width:50%; min-width:500px; margin:0 auto; padding-bottom:30px; min-height:500px;">
<legend><h2><?php
echo ucwords($profile_info2['firstName'] . " " . $profile_info2['lastName']);
?>
</h2></legend>
<?php
if ($profile_info2['userRoleID'] == 1) {
?>
Want to become a tutor?
<a href="../profile-setup/?u=2"> <button name="upgradeAccount" type="button" class="btn btn-info" style="margin-left:20px;">Upgrade your account</button></a>
<?php
} else {
if ($profile_info2['pstatus'] < 5) {
?>
Complete your tutor profile
<a href="../profile-setup/"> <button name="completeProfile" type="button" class="btn btn-info" style="margin-left:20px;">Go</button></a>
<?php
} else {
$profile_info3 = mysql_fetch_array(mysql_query("SELECT * FROM users LEFT JOIN profile6 ON users.username = profile6.username WHERE users.ID = '{$currentUserProfile}'"));
?>
Your account was created on: <?php
echo dateInUS($profile_info3['date']);
示例11: renderBlock
<script src="/assets/vendor/jquery/dist/jquery.min.js"></script>
<?php
renderBlock('javascripts', $container);
?>
<?php
renderBlock('styles', $container);
?>
</head>
<body>
<div class="header menu">
<div class="container">
<a href="/index.php/" class="item logo"></a>
<?php
if ($user = currentUser()) {
?>
<div class="right floated">
<div class="user item" data-timestamp="<?php
echo time();
?>
" data-user-id="<?php
echo $user['id'];
?>
">
<div class="name"><?php
echo $user['name'];
?>
</div>
<div class="balance">Баланс: <span
class="cash"><?php
示例12: get
});
// Show version
get('/roadmap/(.*)', function ($slug) {
$version = Version::find('slug', $slug);
echo json_encode($version);
});
post('/roadmap/(.*)', function ($slug) {
// Check if logged in and is admin
if (!currentUser() || currentUser()['role'] != 'admin') {
return http_response_code(currentUser() ? 401 : 403);
}
if (ng('id') && ($version = Version::find(ng('id')))) {
$version->set(['name' => ng('name'), 'slug' => ng('slug'), 'description' => ng('description'), 'display_order' => ng('display_order'), 'is_completed' => ng('is_completed')]);
if ($version->save()) {
echo json_encode($version);
} else {
http_response_code(400);
echo json_encode($version->errors());
}
} else {
http_response_code(400);
}
});
// Delete version
delete('/roadmap/(.*)', function ($slug) {
// Check if logged in and is admin
if (!currentUser() || currentUser()['role'] != 'admin') {
return http_response_code(currentUser() ? 401 : 403);
}
$version = Version::find('slug', $slug)->delete();
});
示例13: function
if (time() - $timer >= 5) {
return [];
}
}
return $events;
}
return function (array $request) {
$query = $request['query'];
if (array_key_exists('t', $query)) {
$id = (int) $query['t'];
if (!eventExists($id)) {
return createResponse('', 400);
}
} else {
$id = getLastId();
}
session_write_close();
$events = waitForEvent($id);
session_start();
if (0 === count($events)) {
$response = ['t' => $id];
} else {
$currentUser = currentUser();
if ($currentUser) {
$response = ['events' => $events, 'cash' => getCashById(currentUser()['id']) / 100, 't' => $events[0]['id']];
} else {
return createResponse('', 401);
}
}
return createResponse(json_encode($response), 200, ['content-type' => 'application/json']);
};
示例14: currentUser
<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>
<a class="navbar-brand" href="index.php">Windsor Centre for Film</a>
</div>
<?php
if (isset($_SESSION['id'])) {
?>
<div class="navbar-collapse collapse">
<div class="navbar-right">
<span class='navtext'>Welcome <?php
echo currentUser()->name;
?>
!</span>
<a href="home.php"><button class="btn btn-primary">My Profile</button></a>
<button class="btn btn-primary" data-toggle="modal" data-target="#search">Search</button>
<a href="logout.php"><button class="btn btn-primary">Logout</button></a>
<a href="profileform.php"><button class="btn btn-primary">Edit Profile</button></a>
</div>
</div>
<?php
} else {
?>
<div class="navbar-collapse collapse">
<div class="navbar-right">
<button class="btn btn-primary" data-toggle="modal" data-target="#search">Search</button>
<button class="btn btn-primary" data-toggle="modal" data-target="#signin">Sign In</button>
示例15: submit
/**
* Submit the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function submit($id, Guard $auth)
{
$ticket = Ticket::findOrFail($id);
//$data = auth()->user()->vote($ticket);
currentUser()->vote($ticket);
return redirect()->back();
}