本文整理汇总了PHP中user_is_logged_in函数的典型用法代码示例。如果您正苦于以下问题:PHP user_is_logged_in函数的具体用法?PHP user_is_logged_in怎么用?PHP user_is_logged_in使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_is_logged_in函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dynamic_menu_content
function dynamic_menu_content()
{
$cache_name = user_is_logged_in() ? 'logged_in_' . $_SESSION['class'] : 'guest';
if (cache_start($cache_name, CONFIG_CACHE_TIME_DYNAMIC, CONST_CACHE_DYNAMIC_MENU_GROUP)) {
$entries = db_query_fetch_all('SELECT
title,
internal_page,
permalink,
url,
visibility
FROM
dynamic_menu
WHERE
' . (user_is_logged_in() ? 'min_user_class <= ' . $_SESSION['class'] . ' AND (visibility = "private" OR visibility = "both")' : 'visibility = "public" OR visibility = "both"') . '
ORDER BY priority DESC');
foreach ($entries as $entry) {
echo '
<li>
<a href="', $entry['internal_page'] ? CONFIG_SITE_URL . 'content?show=' . $entry['permalink'] : htmlspecialchars($entry['url']), '">', htmlspecialchars($entry['title']), '</a>
</li>
';
}
cache_end($cache_name, CONST_CACHE_DYNAMIC_MENU_GROUP);
}
}
示例2: hasCategory
/**
* Decide whether block displays may include category information.
*
* @return int
* One of the BlockLatest::DISPLAY_* constants.
*/
public function hasCategory()
{
switch ($this->getDisplayPolicy()) {
// Display only for admin.
case static::DISPLAY_ADMIN:
$ret = $GLOBALS['user']->uid == 1;
break;
// Display for all authenticated users.
// Display for all authenticated users.
case static::DISPLAY_AUTH:
$ret = user_is_logged_in();
break;
// Always display.
// Always display.
case static::DISPLAY_ALWAYS:
$ret = TRUE;
break;
// BlockLatest::DISPLAY_NEVER and any other value.
// BlockLatest::DISPLAY_NEVER and any other value.
default:
$ret = FALSE;
break;
}
return $ret;
}
示例3: basetpl_process_page
/**
* Implements theme_process_page().
*/
function basetpl_process_page(&$variables)
{
global $base_path;
// show/hide breadcrumb
$variables['show_breadcrumb'] = TRUE;
// var theme_path
$variables['theme_path'] = $base_path . path_to_theme();
// var site_info
$variables['site_info'] = $variables['logo'] || $variables['site_name'] || $variables['site_slogan'] ? TRUE : FALSE;
// check if page is system page
$variables['system_page'] = isset($variables['node']) ? FALSE : TRUE;
// backend
if (user_is_logged_in() && path_is_admin(current_path())) {
$variables['site_info'] = FALSE;
$variables['system_page'] = TRUE;
foreach (element_children($variables['page']) as $region) {
if ($region != 'content') {
$variables['page'][$region] = FALSE;
}
}
}
// show/hide page title
$variables['title'] = $variables['system_page'] ? $variables['title'] : FALSE;
// add robots to head
if (theme_get_setting('robots') == 1) {
$robots = array('#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array('name' => 'robots', 'content' => 'noindex,nofollow'));
drupal_add_html_head($robots, 'robots');
}
}
示例4: blackberry_2016_status_messages
function blackberry_2016_status_messages($variables)
{
$display = $variables['display'];
$output = '';
$status_heading = array('status' => t('Status message'), 'error' => t('Error message'), 'warning' => t('Warning message'));
foreach (drupal_get_messages($display) as $type => $messages) {
// skip all error/warning messages for anonymous users
if (!user_is_logged_in() && $type == 'PHP') {
} else {
$output .= '<div class="alert alert-block alert-' . $type . '"><div class="container"><div class="row"><div class="col-xs-12">';
if (!empty($status_heading[$type])) {
$output .= '<h2 class="element-invisible">' . $status_heading[$type] . '</h2>';
}
if (count($messages) > 1) {
$output .= '<ul>';
foreach ($messages as $message) {
$output .= ' <li>' . $message . '</li>';
}
$output .= '</ul>';
} else {
$output .= $messages[0];
}
$output .= '</div></div></div><a class="close" data-dismiss="alert" href="#">×</a></div>';
}
}
return $output;
}
示例5: thearchivetheme_process_page
function thearchivetheme_process_page(&$vars)
{
$usernav = '';
if (user_is_logged_in()) {
global $user;
$node = menu_get_object();
$ar = array();
if ($node) {
$nid = $node->nid;
if (user_access('update collection')) {
$ar[] = '<a href="collection/edit/' . $nid . '">編輯</a>';
}
if (user_access('update collection')) {
$ar[] = '<a href="collection/update/file/' . $nid . '">更新數位檔</a>';
}
if (user_access('update collection') && editcol_is_video_collection($nid)) {
$ar[] = '<a href="collection/upload/video_icons/' . $nid . '">自定影片圖示</a>';
}
if (user_access('delete collection')) {
$ar[] = '<a href="collection/delete/' . $nid . '">刪除</a>';
}
}
if (user_access('control panel')) {
$ar[] = '<a href="/control_panel/1">Control Panel</a>';
}
$ar[] = 'Login as ' . $user->name;
$ar[] = '<a href="/user/logout">Log out</a>';
$usernav = '<div class="row">' . implode(' | ', $ar) . '</div>';
}
$vars['usernav'] = $usernav;
}
示例6: removeEvent
/**
* @function removeEvent
* Returns interface for removing an event
*/
public function removeEvent()
{
$explodedpath = explode("/", current_path());
$event_id = $this->clearContent($explodedpath[1]);
if (!user_is_logged_in() || !$this->event->isAuthorized($event_id, $this->user_id)) {
drupal_access_denied();
drupal_exit();
}
if (isset($_POST['submit'])) {
$this->event->removeEvent($event_id);
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
drupal_set_message(t('Das Event wurde gelöscht.'));
header("Location: " . $base_url . "/events");
// Und "Tschö mit ö..."!
} else {
$pathThisFile = $_SERVER['REQUEST_URI'];
return '<div class="callout row">
<h4><strong>' . t('Möchten Sie dieses Event wirklich löschen?') . '</strong></h4><br />
<form action=' . $pathThisFile . ' method="POST" enctype="multipart/form-data">
<input name="event_id" type="hidden" id="eventEIDInput" value="' . $event_id . '" />
<a class="secondary button" href="javascript:history.go(-1)">Abbrechen</a>
<input type="submit" class="button" id="eventSubmit" name="submit" value="Löschen">
</form></div>';
}
}
示例7: __construct
/**
* Constructor to generically set up the user id condition if
* there is a current user.
*
* @param $connection
*/
function __construct($connection)
{
parent::__construct($connection);
if (user_is_logged_in()) {
global $user;
$this->useridCondition($user->name);
}
}
示例8: hook_rest_server_execute_errors_alter
/**
* Alter error messages right before delivering.
*
* @param array $errors
* Array of following properties:
* 'code' -- error code
* 'header_message' -- message that will be returned in Status header
* 'body_data' -- data returned in the body of the response
* You can alter 'header_message' and 'body_data' in your hook implementations.
* @param type $controller
* Executed controller.
* @param type $arguments
* Arguments of the controller.
*/
function hook_rest_server_execute_errors_alter(&$error, $controller, $arguments)
{
$error_code = $error['code'];
if (user_is_logged_in() && $error_code == 401) {
global $user;
$error['header_message'] = '403 ' . t('Access denied for user @user', array('@user' => $user->name));
}
}
示例9: analytics_portal_preprocess_html
function analytics_portal_preprocess_html(&$vars, $hook)
{
if (drupal_is_front_page() && !user_is_logged_in()) {
// If the content type's machine name is "my_machine_name" the file
// name will be "page--my-machine-name.tpl.php".
$vars['theme_hook_suggestions'][] = 'html__custom';
}
}
示例10: __construct
public function __construct($uid)
{
if (user_is_logged_in() == FALSE && !defined('OS_POKER_SCRIPT')) {
throw new Exception('Forbidden (User must be logged in)');
}
if ($this->Load($uid) == FALSE) {
throw new Exception('Invalid UID');
}
}
示例11: dmi_preprocess_menu_link
function dmi_preprocess_menu_link(&$variables)
{
if ($variables['theme_hook_original'] == 'menu_link__menu_topmenu') {
$logged_in = user_is_logged_in();
if ($variables['element']['#title'] == "login" && $logged_in) {
$variables['element']['#title'] = t('Uw account');
}
}
}
示例12: hook_raven_user_alter
/**
* Provide user information for logging.
*
* @param array $user_info
* A reference to array of user account info.
*/
function hook_raven_user_alter(array &$user_info)
{
global $user;
if (user_is_logged_in()) {
$user_info['id'] = $user->uid;
$user_info['name'] = $user->name;
$user_info['email'] = $user->mail;
$user_info['roles'] = implode(', ', $user->roles);
}
}
示例13: hook_commons_utility_links
/**
* Define utility links.
*
* This hook allows modules to register utility links for the functionality that
* they provide. For example, a social integration module could use it to
* register a "Find Friends" utility link which points to a page where the
* current user can search for other site users that they have connected with on
* social networks such as Twitter or Facebook.
*
* @return
* An associative array of utility links whose keys are used as its CSS class.
* Each link should be itself an array, with the same elements used in
* theme_links(), except for the addition of a 'weight' element that is used
* for ordering the links.
*
* For a detailed usage example, see commons_utility_links.module.
*
* @see theme_links()
* @see hook_commons_utility_links_alter()
*/
function hook_commons_utility_links()
{
$links = array();
if (user_is_logged_in()) {
global $user;
$account = $user;
$links['find_fiends'] = array('href' => 'user/' . $account->uid . '/find_friends', 'title' => t('Find friends'));
}
return $links;
}
示例14: send_cache_headers
function send_cache_headers($identifier, $lifetime, $group = 'default')
{
header('Cache-Control: ' . (user_is_logged_in() ? 'private' : 'public') . ', max-age=' . $lifetime);
$path = CONST_PATH_CACHE . 'cache_' . $group . '_' . $identifier;
if (file_exists($path)) {
$time_modified = filemtime($path);
header('Last-Modified: ' . gmdate('D, d M Y H:i:s ', $time_modified) . 'GMT');
header('Expires: ' . gmdate('D, d M Y H:i:s ', $time_modified + $lifetime) . 'GMT');
}
}
示例15: adminlte_preprocess_page
/**
* Implement hook_preprocess_page()
*/
function adminlte_preprocess_page(&$vars, $hook)
{
global $user;
global $base_url;
$vars['front_page'] = $base_url;
$theme_path = drupal_get_path('theme', 'adminlte');
// Fontawesome 4.5.0
drupal_add_css('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css', array('type' => 'external', 'scope' => 'header'));
// Ionicons 2.0.1
drupal_add_css('https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css', array('type' => 'external', 'scope' => 'header'));
// jQuery 2.2.3
drupal_add_js($theme_path . '/plugins/jQuery/jQuery-2.2.3.min.js', array('type' => 'file', 'scope' => 'footer'));
// Bootstrap 3.3.5
drupal_add_js($theme_path . '/bootstrap/js/bootstrap.min.js', array('type' => 'file', 'scope' => 'footer'));
// jQuery UI
drupal_add_js('https://code.jquery.com/ui/1.11.4/jquery-ui.min.js', array('type' => 'external', 'scope' => 'footer'));
// FastClick
drupal_add_js($theme_path . '/plugins/fastclick/fastclick.min.js', array('type' => 'file', 'scope' => 'footer'));
// AdminLTE App
drupal_add_js($theme_path . '/dist/js/app.min.js', array('type' => 'file', 'scope' => 'footer'));
// Moment
drupal_add_js('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js', array('type' => 'external', 'scope' => 'footer'));
// Fullcalendar
drupal_add_js($theme_path . '/plugins/fullcalendar/fullcalendar.min.js', array('type' => 'file', 'scope' => 'footer'));
// Additional js for theme.
drupal_add_js($theme_path . '/assets/js/script.js', array('type' => 'file', 'scope' => 'footer'));
$vars['logout'] = '/user/logout';
$vars['profile'] = 'user/' . $user->uid;
$roles = end($user->roles);
$vars['role'] = ucfirst($roles);
reset($user->roles);
// Check if user is login
if (user_is_logged_in()) {
$account = user_load($user->uid);
$avatar_uri = drupal_get_path('theme', 'adminlte') . '/img/avatar.png';
$alt = t("@user's picture", array('@user' => format_username($user)));
// Display profile picture.
if (!empty($account->picture)) {
$user_picture = theme('image_style', array('style_name' => 'thumbnail', 'path' => $account->picture->uri, 'alt' => $alt, 'title' => $alt, 'attributes' => array('class' => 'img-circle')));
$user_picture_m = theme('image_style', array('style_name' => 'thumbnail', 'path' => $account->picture->uri, 'alt' => $alt, 'title' => $alt, 'attributes' => array('class' => 'user-image')));
} else {
$user_picture_config = array('style_name' => 'thumbnail', 'path' => $avatar_uri, 'alt' => $alt, 'title' => $alt, 'attributes' => array('class' => 'img-circle'));
$user_picture_m_config = array('style_name' => 'thumbnail', 'path' => $avatar_uri, 'alt' => $alt, 'title' => $alt, 'attributes' => array('class' => 'user-image'));
$user_picture = adminlte_image_style($user_picture_config);
$user_picture_m = adminlte_image_style($user_picture_m_config);
}
// Assign profile picture in variables.
$vars['avatar'] = $user_picture;
$vars['avatarsm'] = $user_picture_m;
// Display history of member.
$vars['history'] = 'Member for ' . format_interval(time() - $user->created);
// Display username or you can change this to set the fullname of user login.
$vars['fullname'] = $account->name;
}
}