当前位置: 首页>>代码示例>>PHP>>正文


PHP user_is_anonymous函数代码示例

本文整理汇总了PHP中user_is_anonymous函数的典型用法代码示例。如果您正苦于以下问题:PHP user_is_anonymous函数的具体用法?PHP user_is_anonymous怎么用?PHP user_is_anonymous使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了user_is_anonymous函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buildEntityFieldQuery

 /**
  * Overrides OgSelectionHandler::buildEntityFieldQuery().
  */
 public function buildEntityFieldQuery($match = NULL, $match_operator = 'CONTAINS')
 {
     $group_type = $this->field['settings']['target_type'];
     // See if the Entity allows for non-member postings
     $user_access = FALSE;
     $event = NULL;
     if ($this->entity && isset($this->entity->og_group_ref[LANGUAGE_NONE][0]['target_id'])) {
         $event = $this->entity->og_group_ref[LANGUAGE_NONE][0]['target_id'];
     } elseif (module_exists('og_context') && isset($_SESSION)) {
         $event = isset($_SESSION['og_context']) ? $_SESSION['og_context'] : og_context('node');
         $event = isset($event['gid']) ? $event['gid'] : NULL;
     }
     if ($event) {
         $user_access = og_user_access('node', $event, "create " . $this->instance['bundle'] . " content") || og_user_access('node', $event, "update own " . $this->instance['bundle'] . " content") || og_user_access('node', $event, "edit any " . $this->instance['bundle'] . " content");
     }
     if (empty($this->instance['field_mode']) || $group_type != 'node' || user_is_anonymous() || !$user_access) {
         return parent::buildEntityFieldQuery($match, $match_operator);
     }
     $handler = EntityReference_SelectionHandler_Generic::getInstance($this->field, $this->instance, $this->entity_type, $this->entity);
     $query = $handler->buildEntityFieldQuery($match, $match_operator);
     // Show only the entities that are active groups.
     $query->fieldCondition(OG_GROUP_FIELD, 'value', 1);
     // Add this property to make sure we will have the {node} table later on in
     // OgCommonsSelectionHandler::entityFieldQueryAlter().
     $query->propertyCondition('nid', 0, '>');
     $query->addMetaData('entityreference_selection_handler', $this);
     // FIXME: http://drupal.org/node/1325628
     unset($query->tags['node_access']);
     $query->addTag('entity_field_access');
     $query->addTag('og');
     return $query;
 }
开发者ID:hguru,项目名称:224cod,代码行数:35,代码来源:OgEventsSelectionHandler.class.php

示例2: getLoggedInAccount

 public static function getLoggedInAccount()
 {
     if (isset(self::$logged_in_account)) {
         return self::$logged_in_account;
     }
     if (user_is_anonymous()) {
         return NULL;
     }
     global $user;
     self::$logged_in_account = user_load($user->uid);
     return self::$logged_in_account;
 }
开发者ID:cultuurnet,项目名称:culturefeed,代码行数:12,代码来源:DrupalCultureFeedBase.php

示例3: bootstrap_preprocess_page

/**
 * Implements template_preprocess_page().
 */
function bootstrap_preprocess_page(&$variables)
{
    $left_col = array('col-xs-12', 'col-sm-12', 'col-md-12');
    if (isset($variables['page']['sidebar']) && $variables['page']['sidebar']) {
        $left_col = array('col-xs-12', 'col-sm-8', 'col-md-8');
    }
    $breadcrumb_attr = array('id' => 'breadcrumbs', 'class' => array('col-xs-12', 'col-sm-12', 'col-md-12'));
    $left_col_attr = array('id' => 'left-content', 'class' => $left_col, 'role' => 'main');
    $right_col_attr = array('id' => 'right-content', 'class' => array('col-xs-12', 'col-sm-4', 'col-md-3'), 'role' => 'complementary');
    $variables['breadcrumb_attributes_array'] = $breadcrumb_attr;
    $variables['breadcrumb_attributes'] = drupal_attributes($breadcrumb_attr);
    $variables['left_col_attributes'] = drupal_attributes($left_col_attr);
    $variables['right_col_attributes'] = drupal_attributes($right_col_attr);
    global $user;
    $path = current_path();
    if (user_is_anonymous()) {
        switch ($path) {
            case 'user':
            case 'user/login':
                drupal_set_title(t('Log in'));
                $variables['title'] = t('Log in');
                break;
            case 'user/register':
                drupal_set_title(t('Create new account'));
                $variables['title'] = t('Create new account');
                break;
            case 'user/password':
                drupal_set_title(t('Request new password'));
                $variables['title'] = t('Request new password');
                break;
        }
    } else {
        switch ($path) {
            case 'user':
            case 'user/' . $user->uid . '/edit':
                drupal_set_title('My profile');
                break;
            case 'user/' . $user->uid . '/shortcuts':
                drupal_set_title('My shortcuts');
                break;
            case 'user/' . $user->uid . '/devel':
            case 'user/' . $user->uid . '/devel/load':
                drupal_set_title('User devel load');
                break;
            case 'user/' . $user->uid . '/devel/render':
                drupal_set_title('User devel render');
                break;
        }
    }
}
开发者ID:richardbuchanan,项目名称:bootstrap,代码行数:53,代码来源:template.php

示例4: buildEntityFieldQuery

 /**
  * Overrides TicketStateSelectionHandler::buildEntityFieldQuery().
  */
 public function buildEntityFieldQuery($match = NULL, $match_operator = 'CONTAINS')
 {
     $group_type = $this->field['settings']['target_type'];
     if (empty($this->instance['field_mode']) || $group_type != 'node' || user_is_anonymous()) {
         return parent::buildEntityFieldQuery($match, $match_operator);
     }
     $handler = EntityReference_SelectionHandler_Generic::getInstance($this->field, $this->instance, $this->entity_type, $this->entity);
     $query = $handler->buildEntityFieldQuery($match, $match_operator);
     // Show only the entities that are active groups.
     $query->propertyCondition('active', 1);
     $query->addMetaData('entityreference_selection_handler', $this);
     $query->addTag('entity_field_access');
     return $query;
 }
开发者ID:hguru,项目名称:224cod,代码行数:17,代码来源:TicketStateSelectionHandler.class.php

示例5: nesi_bootstrap_menu_link__main_menu

function nesi_bootstrap_menu_link__main_menu(array $variables)
{
    $element = $variables['element'];
    $sub_menu = '';
    if ($element['#below']) {
        $sub_menu = drupal_render($element['#below']);
    }
    if ($element['#href'] == 'apply/nojs/create-proposal') {
        if (user_is_anonymous()) {
            $element['#localized_options']['attributes']['data-toggle'] = 'modal';
            $element['#localized_options']['attributes']['data-target'] = '#nesiLoginModal';
            $element['#localized_options']['attributes']['data-remote'] = 'false';
        }
    }
    $element['#attributes']['class'][] = 'menu-' . $element['#original_link']['mlid'];
    $element['#localized_options']['html'] = TRUE;
    $output = l($element['#title'] . '<span>' . $element['#localized_options']['attributes']['title'] . '</span>', $element['#href'], $element['#localized_options']);
    return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
开发者ID:nesi,项目名称:nesi-webportal,代码行数:19,代码来源:template.php

示例6: buildEntityFieldQuery

 /**
  * Overrides OgSelectionHandler::buildEntityFieldQuery().
  */
 public function buildEntityFieldQuery($match = NULL, $match_operator = 'CONTAINS')
 {
     $group_type = $this->field['settings']['target_type'];
     if (empty($this->instance['field_mode']) || $group_type != 'node' || user_is_anonymous()) {
         return parent::buildEntityFieldQuery($match, $match_operator);
     }
     $handler = EntityReference_SelectionHandler_Generic::getInstance($this->field, $this->instance, $this->entity_type, $this->entity);
     $query = $handler->buildEntityFieldQuery($match, $match_operator);
     // Show only the entities that are active groups.
     $query->fieldCondition(OG_GROUP_FIELD, 'value', 1);
     $query->fieldCondition('field_og_subscribe_settings', 'value', 'anyone');
     // Add this property to make sure we will have the {node} table later on in
     // OgCommonsSelectionHandler::entityFieldQueryAlter().
     $query->propertyCondition('nid', 0, '>');
     $query->addMetaData('entityreference_selection_handler', $this);
     // FIXME: http://drupal.org/node/1325628
     unset($query->tags['node_access']);
     $query->addTag('entity_field_access');
     $query->addTag('og');
     return $query;
 }
开发者ID:drupalicus,项目名称:drupal-commons,代码行数:24,代码来源:OgCommonsSelectionHandler.class.php

示例7: buildEntityFieldQuery

 /**
  * Overrides OgSelectionHandler::buildEntityFieldQuery().
  */
 public function buildEntityFieldQuery($match = NULL, $match_operator = 'CONTAINS')
 {
     $group_type = $this->field['settings']['target_type'];
     // See if the Entity allows for non-member postings
     $event_entity_types = cod_events_get_group_content_entity_types();
     if (empty($this->instance['field_mode']) || $group_type != 'node' || user_is_anonymous() || isset($this->instance['bundle']) && !(isset($event_entity_types['node'][$this->instance['bundle']]['non_member']) && user_access("create " . $this->instance['bundle'] . " content"))) {
         return parent::buildEntityFieldQuery($match, $match_operator);
     }
     $handler = EntityReference_SelectionHandler_Generic::getInstance($this->field, $this->instance, $this->entity_type, $this->entity);
     $query = $handler->buildEntityFieldQuery($match, $match_operator);
     // Show only the entities that are active groups.
     $query->fieldCondition(OG_GROUP_FIELD, 'value', 1);
     // Add this property to make sure we will have the {node} table later on in
     // OgCommonsSelectionHandler::entityFieldQueryAlter().
     $query->propertyCondition('nid', 0, '>');
     $query->addMetaData('entityreference_selection_handler', $this);
     // FIXME: http://drupal.org/node/1325628
     unset($query->tags['node_access']);
     $query->addTag('entity_field_access');
     $query->addTag('og');
     return $query;
 }
开发者ID:joshirohit100,项目名称:dcd2,代码行数:25,代码来源:OgEventsSelectionHandler.class.php

示例8: apigee_devconnect_preprocess_page

/**
 * Preprocessor for theme('page').
 */
function apigee_devconnect_preprocess_page(&$variables)
{
    $variables['user_reg_setting'] = variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
    $menu_tree = menu_tree_output(menu_tree_all_data('main-menu', NULL, 2));
    $variables['primary_nav'] = drupal_render($menu_tree);
    // Custom Search
    $variables['search'] = FALSE;
    if (theme_get_setting('toggle_search') && module_exists('search')) {
        $variables['search'] = drupal_get_form('search_form');
    }
    if (!user_is_anonymous()) {
        # Fix for long user names
        global $user;
        $user_email = $user->mail;
        if (strlen($user_email) > 22) {
            $tmp = str_split($user_email, 16);
            $user_email = $tmp[0] . '&hellip;';
        }
        $variables['truncated_user_email'] = $user_email;
    } else {
        $variables['truncated_user_email'] = '';
    }
}
开发者ID:nevetS,项目名称:flame,代码行数:26,代码来源:template.php

示例9: onelogin_saml_acs

function onelogin_saml_acs()
{
    global $user;
    // If a user initiates a login while they are already logged in, simply send them to their profile.
    if (user_is_logged_in() && !user_is_anonymous()) {
        drupal_goto('user/' . $user->uid);
    } else {
        if (isset($_POST['SAMLResponse']) && !empty($_POST['SAMLResponse'])) {
            $auth = initialize_saml();
            $auth->processResponse();
            $errors = $auth->getErrors();
            if (!empty($errors)) {
                drupal_set_message("There was at least one error processing the SAML Response" . implode("<br>", $errors), 'error', FALSE);
                drupal_goto('');
            }
            onelogin_saml_auth($auth);
        } else {
            drupal_set_message("No SAML Response found.", 'error', FALSE);
            drupal_goto('');
        }
    }
    drupal_goto('user/' . $user->uid);
}
开发者ID:bessonette,项目名称:drupal-saml,代码行数:23,代码来源:functions.php

示例10: rss_get_news_feed_url

/**
 * return rss news feed url
 * @param int $p_project_id
 * @param string $p_username
 * @param bool $p_relative
 * @return string
 */
function rss_get_news_feed_url($p_project_id = null, $p_username = null, $p_relative = true)
{
    if ($p_username === null) {
        $t_username = current_user_get_field('username');
    } else {
        $t_username = $p_username;
    }
    if ($p_project_id === null) {
        $t_project_id = helper_get_current_project();
    } else {
        $t_project_id = (int) $p_project_id;
    }
    if ($p_relative) {
        $t_rss_link = '';
    } else {
        $t_rss_link = config_get('path');
    }
    $t_user_id = user_get_id_by_name($t_username);
    // If we have a logged in user then they can be given a 'proper' feed, complete with auth string.
    if (user_is_anonymous($t_user_id)) {
        $t_rss_link .= "news_rss.php";
        if ($t_project_id != ALL_PROJECTS) {
            $t_rss_link .= "?project_id={$t_project_id}";
        }
    } else {
        $t_rss_link .= "news_rss.php?username={$t_username}&key=" . rss_calculate_key($t_user_id);
        if ($t_project_id != ALL_PROJECTS) {
            $t_rss_link .= "&project_id={$t_project_id}";
        }
    }
    return $t_rss_link;
}
开发者ID:fur81,项目名称:zofaxiopeu,代码行数:39,代码来源:rss_api.php

示例11: auth_attempt_login

/**
 * Attempt to login the user with the given password
 * If the user fails validation, false is returned
 * If the user passes validation, the cookies are set and
 * true is returned.  If $p_perm_login is true, the long-term
 * cookie is created.
 * @param string $p_username a prepared username
 * @param string $p_password a prepared password
 * @param bool $p_perm_login whether to create a long-term cookie
 * @return bool indicates if authentication was successful
 * @access public
 */
function auth_attempt_login($p_username, $p_password, $p_perm_login = false)
{
    $t_user_id = user_get_id_by_name($p_username);
    $t_login_method = config_get('login_method');
    if (false === $t_user_id) {
        if (BASIC_AUTH == $t_login_method) {
            $t_auto_create = true;
        } else {
            if (LDAP == $t_login_method && ldap_authenticate_by_username($p_username, $p_password)) {
                $t_auto_create = true;
            } else {
                $t_auto_create = false;
            }
        }
        if ($t_auto_create) {
            # attempt to create the user
            $t_cookie_string = user_create($p_username, md5($p_password));
            if (false === $t_cookie_string) {
                # it didn't work
                return false;
            }
            # ok, we created the user, get the row again
            $t_user_id = user_get_id_by_name($p_username);
            if (false === $t_user_id) {
                # uh oh, something must be really wrong
                # @@@ trigger an error here?
                return false;
            }
        } else {
            return false;
        }
    }
    # check for disabled account
    if (!user_is_enabled($t_user_id)) {
        return false;
    }
    # max. failed login attempts achieved...
    if (!user_is_login_request_allowed($t_user_id)) {
        return false;
    }
    # check for anonymous login
    if (!user_is_anonymous($t_user_id)) {
        # anonymous login didn't work, so check the password
        if (!auth_does_password_match($t_user_id, $p_password)) {
            user_increment_failed_login_count($t_user_id);
            return false;
        }
    }
    # ok, we're good to login now
    # increment login count
    user_increment_login_count($t_user_id);
    user_reset_failed_login_count_to_zero($t_user_id);
    user_reset_lost_password_in_progress_count_to_zero($t_user_id);
    # set the cookies
    auth_set_cookies($t_user_id, $p_perm_login);
    auth_set_tokens($t_user_id);
    return true;
}
开发者ID:kaos,项目名称:mantisbt,代码行数:70,代码来源:authentication_api.php

示例12: bug_monitor

/**
 * enable monitoring of this bug for the user
 * @param int p_bug_id integer representing bug ids
 * @param int p_user_id integer representing user ids
 * @return true if successful, false if unsuccessful
 * @access public
 * @uses database_api.php
 * @uses history_api.php
 * @uses user_api.php
 */
function bug_monitor($p_bug_id, $p_user_id)
{
    $c_bug_id = (int) $p_bug_id;
    $c_user_id = (int) $p_user_id;
    # Make sure we aren't already monitoring this bug
    if (user_is_monitoring_bug($c_user_id, $c_bug_id)) {
        return true;
    }
    # Don't let the anonymous user monitor bugs
    if (user_is_anonymous($c_user_id)) {
        return false;
    }
    $t_bug_monitor_table = db_get_table('mantis_bug_monitor_table');
    # Insert monitoring record
    $query = 'INSERT INTO ' . $t_bug_monitor_table . '( user_id, bug_id ) VALUES (' . db_param() . ',' . db_param() . ')';
    db_query_bound($query, array($c_user_id, $c_bug_id));
    # log new monitoring action
    history_log_event_special($c_bug_id, BUG_MONITOR, $c_user_id);
    # updated the last_updated date
    bug_update_date($p_bug_id);
    email_monitor_added($p_bug_id, $p_user_id);
    return true;
}
开发者ID:rahmanjis,项目名称:dipstart-development,代码行数:33,代码来源:bug_api.php

示例13: humanitarianresponse_preprocess_page

/**
 * Implements template_preprocess_page().
 */
function humanitarianresponse_preprocess_page(&$variables) {
  global $theme_path;
  $tree = menu_tree_page_data('main-menu', 1);
  $main_menu_dropdown = menu_tree_output($tree);
  $main_menu_dropdown['#theme_wrappers'] = array();
  $variables['main_menu_dropdown'] = $main_menu_dropdown;
  $variables['hr_tabs'] = array();
  $header_img_path = $theme_path.'/assets/images/headers/general.png';
  if (module_exists('og_context')) {
    $gid = og_context_determine_context('node');
    if (!empty($gid)) {
        $og_group = entity_load('node', array($gid));
        $og_group = $og_group[$gid];
        if ($og_group->type == 'hr_operation') {
          // Salahumanitaria logo
          if ($og_group->nid == 77) { // Nid of the Colombia operation
            $variables['logo'] = '/sites/all/themes/humanitarianresponse/assets/images/salahumanitaria_logo.png';
          }
          if (!empty($og_group->field_operation_type) && !empty($og_group->field_operation_region) && $og_group->field_operation_type[LANGUAGE_NONE][0]['value'] == 'country') {
            // Determine the region of the operation
            $region_id = $og_group->field_operation_region[LANGUAGE_NONE][0]['target_id'];
            $region = entity_load_single('node', $region_id);
            $region_uri = entity_uri('node', $region);
            $region_status = $region->field_operation_status[LANGUAGE_NONE][0]['value'];
            switch ($region_status) {
              case 'active':
                // Add the region to the tabs
                $variables['hr_tabs'][] = l($region->title, $region_uri['path'], $region_uri['options']);
                break;
              case 'inactive':
                break;
              case 'archived':
                break;
            }
          }
        }
        elseif ($og_group->type == 'hr_disaster') {
          $glide = $og_group->field_glide_number[LANGUAGE_NONE][0]['value'];
          if ($glide == 'EP-2014-000041-GIN') {
            $variables['logo'] = '/sites/all/themes/humanitarianresponse/assets/images/unmeer_logo.png';
          }
        }
        elseif ($og_group->type == 'hr_bundle') {
          // Get operation from bundle
          $op_gid = _hr_bundles_get_operation($og_group->nid);
          if (!empty($op_gid)) {
            $operation = entity_load_single('node', $op_gid);
            $op_uri = entity_uri('node', $operation);
            $variables['hr_tabs'][] = l($operation->title, $op_uri['path'], $op_uri['options']);
          }
        }
        $uri = entity_uri('node', $og_group);
        if ($og_group->status) { // Group is published
          $variables['hr_tabs'][] = l($og_group->title, $uri['path'], $uri['options']);
        }
        else {
          $variables['hr_tabs'][] = '<a href="#">'.$og_group->title.'</a>';
        }
        $group_img_path = '/assets/images/headers/'.$og_group->type.'/'.strtolower(str_replace(array(' ','/'), '-', $og_group->title)).'.png';
        if (file_exists(dirname(__FILE__).$group_img_path)) {
          $header_img_path = $theme_path.$group_img_path;
        }
      }
  }

  $variables['og_group_header_image'] = theme('image', array(
    'path' => $header_img_path,
    'alt' => 'Header image',
  ));

  if (user_is_anonymous()) {
    $variables['follow_us_link_href'] = 'user/login';
    $variables['follow_us_link_title'] = t('Login to follow us');
    $variables['follow_us_link_status'] = 'flag';
  }
  else {
    $temp = _humanitarianresponse_flag_follow_us();
    $variables['follow_us_link_href'] = $temp['link_href'];
    $variables['follow_us_link_title'] = $temp['link_title'];
    $variables['follow_us_link_status'] = $temp['link_status'];
  }

  $variables['hr_favorite_spaces'] = _humanitarianresponse_block_render('hr_bookmarks', 'hr_favorite_spaces');
}
开发者ID:pcambra,项目名称:site,代码行数:87,代码来源:template.php

示例14: list

		<div id="node-<?php 
    echo $entity->nid;
    ?>
" class="col-xs-12 col-md-6 media posdcast">
			<div class="pull-left"><?php 
    list($field) = field_get_items('node', $entity, 'field_image');
    $style = array('path' => $field['uri'], 'style_name' => 'posdcast_cover_image', 'attributes' => array('class' => array('media-object img-thumbnail')));
    echo theme('image_style', $style);
    ?>
<!-- <img class="media-object img-thumbnail" src="<?php 
    echo base_path() . drupal_get_path('theme', 'zdigital') . '/images/podcats_14.jpg';
    ?>
" /> --></div>
			<div class="media-body">
				<h3 class="media-heading"><a href="<?php 
    echo user_is_anonymous() ? url('user/login', array('query' => array('destination' => 'podcasts/' . $entity->nid))) : url('podcasts/' . $entity->nid);
    ?>
"><?php 
    echo $entity->title;
    ?>
</a></h3><?php 
    list($field) = field_get_items('node', $entity, 'body');
    echo text_summary($field['safe_value'], 1, 250);
    ?>
<div class="submitted">
					<span class="date"><span class="icon glyphicon glyphicon-calendar"></span><?php 
    list($field) = field_get_items('node', $entity, 'field_post_date');
    if (!empty($field['value'])) {
        $datetime = strtotime($field['value']);
        echo format_date($datetime, 'custom', 'F d, Y');
    }
开发者ID:arjun0819,项目名称:zdigital.com,代码行数:31,代码来源:podcasts.tpl.php

示例15: require_api

require_api('gpc_api.php');
require_api('helper_api.php');
require_api('print_api.php');
require_api('user_api.php');
form_security_validate('bug_monitor_delete');
$f_bug_id = gpc_get_int('bug_id');
$t_bug = bug_get($f_bug_id, true);
$f_user_id = gpc_get_int('user_id', NO_USER);
$t_logged_in_user_id = auth_get_current_user_id();
if ($f_user_id === NO_USER) {
    $t_user_id = $t_logged_in_user_id;
} else {
    user_ensure_exists($f_user_id);
    $t_user_id = $f_user_id;
}
if (user_is_anonymous($t_user_id)) {
    trigger_error(ERROR_PROTECTED_ACCOUNT, E_USER_ERROR);
}
bug_ensure_exists($f_bug_id);
if ($t_bug->project_id != helper_get_current_project()) {
    # in case the current project is not the same project of the bug we are viewing...
    # ... override the current project. This to avoid problems with categories and handlers lists etc.
    $g_project_override = $t_bug->project_id;
}
if ($t_logged_in_user_id == $t_user_id) {
    access_ensure_bug_level(config_get('monitor_bug_threshold'), $f_bug_id);
} else {
    access_ensure_bug_level(config_get('monitor_delete_others_bug_threshold'), $f_bug_id);
}
bug_unmonitor($f_bug_id, $t_user_id);
form_security_purge('bug_monitor_delete');
开发者ID:nextgens,项目名称:mantisbt,代码行数:31,代码来源:bug_monitor_delete.php


注:本文中的user_is_anonymous函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。