本文整理汇总了PHP中user_is_anonymous函数的典型用法代码示例。如果您正苦于以下问题:PHP user_is_anonymous函数的具体用法?PHP user_is_anonymous怎么用?PHP user_is_anonymous使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_is_anonymous函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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] . '…';
}
$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
示例16: user_is_protected
/**
* Check if a user has a protected user account.
* Protected user accounts cannot be updated without manage_user_threshold
* permission. If the user ID supplied is that of the anonymous user, this
* function will always return true. The anonymous user account is always
* considered to be protected.
*
* @param integer $p_user_id A valid user identifier.
* @return boolean true: user is protected; false: user is not protected.
* @access public
*/
function user_is_protected($p_user_id)
{
if (user_is_anonymous($p_user_id) || ON == user_get_field($p_user_id, 'protected')) {
return true;
}
return false;
}
开发者ID:pkdevboxy,项目名称:mantisbt,代码行数:18,代码来源:user_api.php
示例17: ciclo20v2_preprocess_page
/**
* Page preprocessing
*/
function ciclo20v2_preprocess_page(&$vars)
{
if ($_GET['q'] != 'user' && strpos($_GET['q'], 'sites') !== 0 && strpos($_GET['q'], 'JQUERY') !== 0) {
if (user_is_anonymous()) {
unset($_REQUEST['destination']);
drupal_goto('user');
}
}
// Format the footer message
// We do this here instead of in page.tpl.php because
// we need a formatted message to pass along to the
// same theme function as the $footer in order to have
// them nested together
if (isset($vars['footer_message']) && strlen($vars['footer_message'])) {
$markup = '';
$markup .= '<div id="footer-message" class="footer-message">';
$markup .= '<div id="footer-message-inner" class="footer-message-inner inner">';
$markup .= $vars['footer_message'];
$markup .= '</div><!-- /footer-message-inner -->';
$markup .= '</div><!-- /footer-message -->';
$vars['footer_message'] = $markup;
}
if (isset($vars['node']) && $vars['node']->type === 'group') {
$vars['tabs'] = '';
if ($vars['body_id'] === 'pid-node-' . $vars['node']->nid . '-edit') {
$vars['is_edit'] = TRUE;
} else {
$vars['is_edit'] = FALSE;
}
}
if (isset($vars['node'])) {
// If the node type is "blog" the template suggestion will be "page-blog.tpl.php".
$vars['template_files'][] = 'page-' . str_replace('_', '-', $vars['node']->type);
}
if (isset($vars['template_files'])) {
foreach ($vars['template_files'] as $tpl) {
if (strpos($tpl, 'page-user-') !== FALSE) {
$arr = explode('-', $tpl);
if (count($arr) > 2 && is_numeric($arr[2])) {
$cuid = intval($arr[2]);
$cuser = user_load($cuid);
if (empty($cuser->profile_name) || empty($cuser->profile_last_name)) {
profile_load_profile($cuser);
}
if (!empty($cuser->profile_name) && !empty($cuser->profile_last_name)) {
$vars['title'] = $cuser->profile_name . ' ' . $cuser->profile_last_name;
}
break;
}
}
}
}
// Include language switcher
$block = module_invoke('locale', 'block', 'view', 0);
$vars['language_switcher'] = $block['content'];
// Add a class of "CONTENT-TYPE-node-form" to the <body> tag of each node form.
// Identify the page as a node form.
if (arg(0) == 'node' && arg(1) == 'add' || arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'edit') {
// Retrieve the node type for...
// The node creation form
if (arg(0) == 'node' && arg(1) == 'add') {
$node_type = arg(2);
// The node edit form
} else {
$node_type = $vars['node']->type;
}
// Store the current body_classes in an array.
$body_classes = explode(' ', $vars['body_classes']);
// Add "content-type-node-form to the array.
$body_classes[] = $node_type . '-node-form';
$body_classes[] = 'node-edit';
// Turn the array back into a string and place it back in the correct key of the $vars array.
$vars['body_classes'] = implode(' ', $body_classes);
}
}
开发者ID:nivaria,项目名称:ciclo20v2,代码行数:78,代码来源:template.php
示例18: druio_theme_preprocess_flag
/**
* Imlements hook_preprocess_hook().
*
* @param $variables
*/
function druio_theme_preprocess_flag(&$variables)
{
global $user;
$user_wrapper = entity_metadata_wrapper('user', $user);
if ($variables['flag']->name == 'ready2work' && !user_is_anonymous()) {
$field_user_contacts = $user_wrapper->field_user_contacts->value();
if ($field_user_contacts) {
$variables['has_contacts'] = TRUE;
} else {
$variables['has_contacts'] = FALSE;
}
$node = menu_get_object();
$variables['is_active'] = FALSE;
if (isset($node) && ($node->type = 'order')) {
$node_wrapper = entity_metadata_wrapper('node', $node);
$field_order_status_term = $node_wrapper->field_order_status_term->getIdentifier();
if ($field_order_status_term == 3420) {
$variables['is_active'] = TRUE;
}
}
$variables['no_contacts_message'] = format_string('<div class="no-contacts-warning">@text !link</div>', array('@text' => 'Для того чтобы отозваться на заявку, вам необходимо указать личные контактные данные в своём профиле.', '!link' => l('Добавить контактную информацию.', '/user/' . $user->uid . '/edit', array('fragment' => 'edit-field-user-contacts', 'query' => array('destination' => current_path())))));
}
}
开发者ID:isaenkov,项目名称:Dru.io,代码行数:28,代码来源:template.php
示例19: _unl_get_user_audit_content
/**
* Returns an array that can be passed to drupal_render() of the given user's sites/roles.
* @param string $username
*/
function _unl_get_user_audit_content($username)
{
if (user_is_anonymous()) {
return array();
}
$audit_map = array();
foreach (unl_get_site_user_map('username', $username) as $site_id => $site) {
$audit_map[$site_id] = array('uri' => l($site['uri'], $site['uri']), 'roles' => '', 'last_update' => $site['last_update']);
foreach ($site['roles'] as $role => $user) {
$audit_map[$site_id]['roles'] .= "{$role} ";
$audit_map[$site_id]['roles'] .= $GLOBALS['user']->name != $username ? "({$user})" : '';
$audit_map[$site_id]['roles'] .= "<br />";
}
}
if (count($audit_map) > 0) {
$header = array('uri' => array('data' => t('Site'), 'field' => 'uri'), 'role' => array('data' => t('Role') . ($GLOBALS['user']->name != $username ? ' (' . t('User') . ')' : '')), 'last_update' => array('data' => t('Last Updated'), 'field' => 'last_update'));
// Sort the table data accordingly with a custom sort function.
$order = tablesort_get_order($header);
$sort = tablesort_get_sort($header);
$rows = unl_sites_sort($audit_map, $order, $sort);
// Now that the access timestamp has been used to sort, convert it to something readable.
foreach ($rows as $key => $row) {
$rows[$key]['last_update'] = isset($rows[$key]['last_update']) ? format_date($rows[$key]['last_update'], 'short') : t('never');
}
$content = array('#theme' => 'table', '#header' => $header, '#rows' => $rows);
if ($username == $GLOBALS['user']->name) {
$content['#caption'] = t('You belong to the following sites as a member of the listed roles.');
} else {
$content['#caption'] = t('Users matching "@user" belong to the following sites as a member of the listed roles.', array('@user' => $username));
}
} else {
$content = array('#type' => 'item');
if ($username == $GLOBALS['user']->name) {
$content['#title'] = t('You do not belong to any roles on any sites.');
} else {
$content['#title'] = t('User matching "@user" does not belong to any roles on any sites.', array('@user' => $username));
}
}
return $content;
}
开发者ID:rgamb,项目名称:UNL-CMS,代码行数:44,代码来源:unl_site_creation.php
示例20: view
/**
* Displays the bean.
*/
public function view($bean, $content, $view_mode = 'default', $langcode = NULL)
{
// Return the active entity information.
$active_entity = bean_tax_active_entity_array($bean->settings['related']);
// Create a unique id to be used by the cache.
if (isset($active_entity['type']) && !empty($active_entity['ids'])) {
// Determine user role and append to cache.
if ($active_entity['type'] != 'user') {
// Grab the highest rid attached to the user.
global $user;
$key = max(array_keys($user->roles));
// Use active entity type, entity id and max role to determine cache id.
$cid = $active_entity['type'] . ':' . $active_entity['ids'][0] . ':' . $key;
} else {
// Use active entity type and entity id to determine cache id.
$cid = $active_entity['type'] . ':' . $active_entity['ids'][0];
}
} else {
// Create a generic cache id for use otherwise.
$cid = date('Y:m:d:i');
}
// Append language prefix to end of cache id.
global $language;
if ($language->prefix != '') {
$cid = $cid . ':' . $language->prefix;
}
// Set the cache name.
$cache_name = 'bean_tax:related:' . $bean->delta . ':' . $cid;
// Check for cached content.
if ($cache = cache_get($cache_name)) {
$content = $cache->data;
} else {
// We need to make sure that the bean is configured correctly.
if (!empty($active_entity) && !empty($bean->filters['vocabulary']) && !empty($bean->settings['bundle_types'])) {
// Determine a list of possible terms based on the set vocabulary.
$possible_tid = $this->getPossibleTerms($bean);
// Return a list of valid term ids based on the terms attached to the
// active entity object.
$valid_tid = array();
if (isset($active_entity['terms'])) {
$this->getValidTerms($active_entity['terms'], $possible_tid, $valid_tid);
}
// Use EFQ to return all possible related entites.
$aggregate = $this->getAggregate($bean);
// Score and sort any valid results.
$result = $this->scoreResults($bean, $aggregate, $valid_tid);
// Related entities initially set to none.
if (empty($result)) {
// Hide block when result is empty and 'hide_empty' option is checked.
if (isset($bean->settings['hide_empty']) || !$active_entity['object']) {
return;
}
// There are no related nodes. Set Empty array for theme output.
$content['#markup'] = t('No Results');
} elseif (isset($active_entity['type']) && $active_entity['type'] == 'bean' && $bean->bid === $active_entity['object']->bid) {
$content['#markup'] = '';
} else {
// If all else fails, we really must have something to show people.
$content['#markup'] = $this->returnMarkup($bean, $result);
// Cache the bean where appropriate.
if (isset($bean->settings['cache_duration']) && isset($bean->settings['cache_auth_user']) && isset($bean->settings['cache_anon_user'])) {
$cache_bean = TRUE;
// Check if authenticated user caching is turned off.
if ($bean->settings['related'] == 'user' && !$bean->settings['cache_auth_user']) {
$cache_bean = FALSE;
}
// Anonymous user check.
$anon = user_is_anonymous();
// Check if anonymous user caching is turned off.
if ($bean->settings['related'] == 'user' && !$bean->settings['cache_anon_user'] && $anon == TRUE) {
$cache_bean = FALSE;
}
// Check if anonymous user caching is turned on.
if ($bean->settings['related'] == 'user' && $bean->settings['cache_anon_user'] && $anon == TRUE) {
$cache_bean = TRUE;
}
// Finally, set the cache after all checks pass.
if ($cache_bean) {
cache_set($cache_name, $content, 'cache', time() + 60 * $bean->settings['cache_duration']);
}
}
}
}
// Render the optional "more link" if provided.
if (!empty($bean->more_link['text']) && !empty($bean->more_link['path'])) {
$content['#markup'] .= theme('bean_tax_more_link', array('text' => $bean->more_link['text'], 'path' => $bean->more_link['path']));
}
}
return $content;
}
开发者ID: |
请发表评论