本文整理汇总了PHP中node_access函数的典型用法代码示例。如果您正苦于以下问题:PHP node_access函数的具体用法?PHP node_access怎么用?PHP node_access使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了node_access函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _groupadmin_user_has_role
/**
* Test if user has the specified groupadmin role, or return array of all roles.
*/
function _groupadmin_user_has_role($group_node = null, $user = null, $role = null)
{
// All posssible roles in order of decreasing access.
$all_roles = array('manager', 'admins', 'members', 'visitors');
// If no group was specified, return array of all possible roles.
if (!$group_node) {
return $all_roles;
}
// Check for explicit permission.
if (_groupadmin_user_access($role)) {
return TRUE;
}
// Test status...
switch ($role) {
case 'manager':
$has_role = $user->uid == $group_node->uid;
break;
case 'admins':
$has_role = og_is_group_admin($group_node, $user);
break;
case 'members':
$has_role = _groupadmin_is_group_member($group_node->nid, $user->uid);
break;
case 'visitors':
$has_role = node_access('view', $group_node, $user);
break;
default:
$has_role = FALSE;
}
return $has_role;
}
开发者ID:j573fan1s,项目名称:portal,代码行数:34,代码来源:groupadmin.access.inc.php
示例2: mooc_foundation_access_preprocess_page
/**
* Implements template_preprocess_page.
*/
function mooc_foundation_access_preprocess_page(&$variables)
{
// speedreader is enabled
if (module_exists('speedreader')) {
$variables['speedreader'] = TRUE;
}
// mespeak is enabled
if (module_exists('mespeak')) {
$variables['mespeak'] = TRUE;
}
// support for add child page shortcut
$node = menu_get_object();
if ($node && user_access('access printer-friendly version')) {
$variables['tabs_extras'][200][] = '<hr>';
$variables['tabs_extras'][200][] = l(t('Print'), 'book/export/html/' . arg(1));
}
$child_type = variable_get('book_child_type', 'book');
if ($node && !empty($node->book) && (user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && isset($node->book['depth']) && $node->book['depth'] < MENU_MAX_DEPTH) {
$variables['tabs_extras'][200][] = '<hr>';
$variables['tabs_extras'][200][] = l(t('Add child page'), 'node/add/' . str_replace('_', '-', $child_type), array('query' => array('parent' => $node->book['mlid'])));
}
if (user_access('access contextual links')) {
$variables['tabs_extras'][0][] = '<li class="cis_accessibility_check"></li>';
}
}
开发者ID:kreynen,项目名称:elmsln,代码行数:28,代码来源:template.php
示例3: _nodereferrer_create_add_reference_form_submit
/**
* Submit the form to add to an existing node
*/
function _nodereferrer_create_add_reference_form_submit($form, &$form_state)
{
if ($form_state['clicked_button']['#name'] != 'add') {
drupal_set_message(t('The operation was cancelled'));
drupal_goto('node/' . arg(1));
return;
}
$append_node = node_load($form_state['values']['referrence']);
$current_node = node_load(arg(1));
// Make sure the user is allowed to do this.
if (!node_access('update', $current_node)) {
drupal_set_message(t('You do not have rights to update this node'));
drupal_goto('node/' . arg(1));
return;
}
$field_name = $current_node->reference_fields[arg(3)]['field_name'];
$field_array =& $current_node->{$field_name};
$multiple = $current_node->reference_fields[arg(3)]['multiple'] == 1;
if ($field_array[0]['nid'] === null || !$multiple) {
$field_array[0]['nid'] = $append_node->nid;
} else {
$field_array[] = array('nid' => $append_node->nid);
}
// Save, and ensure the changes are noticed
node_save($current_node);
cache_clear_all();
drupal_set_message(t('The node was added'));
drupal_goto('node/' . arg(1));
}
开发者ID:e2thex,项目名称:hackunteers.org,代码行数:32,代码来源:add_reference.php
示例4: mooc_foundation_access_preprocess_page
/**
* Implements template_preprocess_page.
*/
function mooc_foundation_access_preprocess_page(&$variables)
{
// speedreader is enabled
if (module_exists('speedreader')) {
$variables['speedreader'] = TRUE;
}
// mespeak is enabled
if (module_exists('mespeak')) {
$variables['mespeak'] = TRUE;
}
// support for add child page shortcut
$node = menu_get_object();
if ($node && user_access('access printer-friendly version')) {
$variables['tabs_extras'][200][] = '<hr>';
$variables['tabs_extras'][200][] = l(t('Print'), 'book/export/html/' . arg(1));
}
$child_type = variable_get('book_child_type', 'book');
if ($node && !empty($node->book) && (user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && isset($node->book['depth']) && $node->book['depth'] < MENU_MAX_DEPTH) {
$variables['tabs_extras'][200][] = '<hr>';
$variables['tabs_extras'][200][] = l(t('Add child page'), 'node/add/' . str_replace('_', '-', $child_type), array('query' => array('parent' => $node->book['mlid'])));
}
if (user_access('access contextual links')) {
$variables['tabs_extras'][0][] = '<li class="cis_accessibility_check"></li>';
}
// remove the prefix that provides a link to the home page
// as MOOC is the thing that currently provides support directly for this
// and slightly overrides the behavior
$keys = array_keys($variables['page']['header']);
$keyname = array_shift($keys);
unset($variables['page']['header'][$keyname]['#prefix']);
}
开发者ID:ronaldmulero,项目名称:elmsln,代码行数:34,代码来源:template.php
示例5: hook_publishcontent_unpublish_access
/**
* Allow other modules the ability to modify access to the unpublish controls.
*
* Modules may implement this hook if they want to have a say in whether or not
* a given user has access to perform unpublish action on a node.
*
* @param node $node
* A node object being checked
* @param user $account
* The user wanting to unpublish the node.
*
* @return bool|NULL
* TRUE - if the user should access return TRUE
* FALSE - if the user definetley should not access return FALSE
* NULL - This module wan't change the outcome. It is typically
* better to return NULL than FALSE. If no module returns TRUE
* then the user will be denied access. If one module returns
* FALSE then the user will denied even if another module returns
* TRUE.
*/
function hook_publishcontent_unpublish_access($node, $account)
{
$access = $node->status && (user_access('administer nodes') || user_access('unpublish any content') || user_access('unpublish own content') && $user->uid == $node->uid || user_access('unpublish editable content') && node_access('update', $node) || user_access('unpublish own ' . check_plain($node->type) . ' content', $user) && $user->uid == $node->uid || user_access('unpublish any ' . check_plain($node->type) . ' content') || user_access('unpublish editable ' . check_plain($node->type) . ' content') && node_access('update', $node));
if ($access) {
return TRUE;
}
}
开发者ID:odsherred,项目名称:subsites.odsherred.dk,代码行数:27,代码来源:publishcontent.api.php
示例6: _nodereferrer_create_get_referrers
/**
* Helper function : given a node, return the list of referrers the
* current user is allowed to create as an array defining :
*
* 'name' : Name of the referrer field
* 'field' : Details of the referer field
* 'referrence' : Detail of the reference field
*
*/
function _nodereferrer_create_get_referrers($node)
{
$list = array();
if (!variable_get('nodereferrer_create_show_on_nodereferrer', 1)) {
return $list;
}
$type = content_types($node->type);
foreach ($type['fields'] as $name => $field) {
if ($field['type'] != 'nodereferrer' || !is_array($field['referrer_types'])) {
continue;
}
foreach (array_filter($field['referrer_types']) as $reftype) {
if (!node_access('create', $reftype)) {
continue;
}
$with_field = array();
foreach (array_filter($field['referrer_fields']) as $reffield) {
$cf = content_fields($reffield, $reftype);
if ($cf) {
$with_field[$reftype][] = $cf;
}
}
if (count($with_field) == 0) {
continue;
}
$list[] = array('name' => substr($name, strlen('field_')), 'field' => $field, 'referrence' => $with_field);
}
}
return $list;
}
开发者ID:e2thex,项目名称:hackunteers.org,代码行数:39,代码来源:helper.php
示例7: canEdit
private function canEdit()
{
$node = $this->getNode();
if ($node) {
return node_access('update', $node);
} else {
return node_access('create', $node);
}
}
开发者ID:chgk,项目名称:db.chgk.info,代码行数:9,代码来源:DbQuestionMeta.class.php
示例8: have_access
/**
* Check view and edit permissions.
*
* @param $op
* The type of operation. Either 'view' or 'edit'.
*/
function have_access($op)
{
global $user;
$db = DBConnection::instance();
$field_id = (int) _post('fid');
if (!$field_id) {
$field_id = (int) _get('fid');
}
$field = (object) $db->dq("SELECT entity_id, entity_type, delta FROM {mytinytodo_fields} WHERE id = ?", $field_id)->fetch_assoc();
$field_info = field_info_field_by_id($field->delta);
if ($field->entity_type == 'node') {
if (!($node = node_load($field->entity_id))) {
return false;
}
$node_access = $op == 'edit' ? 'update' : $op;
if (node_access($node_access, $node, $user) && field_access($op, $field_info, $field->entity_type, $node, $user)) {
return true;
}
} else {
if ($field->entity_type == 'user') {
if (!($account = user_load($field->entity_id))) {
return false;
}
if (field_access($op, $field_info, $field->entity_type, $account, $user)) {
return true;
}
} else {
if ($field->entity_type == 'comment') {
if (!($comment = comment_load($field->entity_id))) {
return false;
}
if ($op == 'view' && !user_access('access comments')) {
return false;
} else {
if ($op == 'edit' && !comment_access($op, $comment)) {
return false;
}
}
if (field_access($op, $field_info, $field->entity_type, $comment, $user)) {
return true;
}
} else {
if (module_exists('entity')) {
if (!($entity = entity_load($field_id))) {
return false;
}
$entity_access = $op == 'edit' ? 'update' : $op;
if (entity_access($entity_access, $field->entity_type, $entity, $user) && field_access($op, $field_info, $field->entity_type, $entity, $user)) {
return true;
}
}
}
}
}
return false;
}
开发者ID:drupalconnect,项目名称:finsearches,代码行数:62,代码来源:common.php
示例9: hook_workbench_block
/**
* Return Workbench status information in a block.
*
* To reduce clutter, modules are encouraged to use this hook
* to provide debugging and other relevant information.
*
* @return
* An array of message strings to print. The preferred format
* is a one line string in the format Title: <em>Message</em>.
* @see workbench_block_view().
*/
function hook_workbench_block()
{
// Add editing information to this page (if it's a node).
if ($node = menu_get_object()) {
if (node_access('update', $node)) {
return array(t('My Module: <em>You may not edit this content.</em>'));
} else {
return array(t('My Module: <em>You may edit this content.</em>'));
}
}
}
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:22,代码来源:workbench.api.php
示例10: hook_publishcontent_unpublish_access
/**
* Allow other modules the ability to modify access to the unpublish controls.
*
* Modules may implement this hook if they want to have a say in whether or not
* a given user has access to perform unpublish action on a node.
*
* @param node $node
* A node object being checked
* @param user $account
* The user wanting to unpublish the node.
*
* @return bool|NULL
* PUBLISHCONTENT_ACCESS_ALLOW - if the user can unpublish the node.
* PUBLISHCONTENT_ACCESS_DENY - if the user definetley cannot unpublish.
* PUBLISHCONTENT_ACCESS_IGNORE - This module wan't change the outcome.
* It is typically better to return IGNORE than DENY. If no module returns
* ALLOW then the user will be denied access. If one module returns
* DENY then the user will denied even if another module returns
* ALLOW.
*/
function hook_publishcontent_unpublish_access($node, $account)
{
$access = $node->status && (user_access('administer nodes') || user_access('unpublish any content') || user_access('unpublish own content') && $user->uid == $node->uid || user_access('unpublish editable content') && node_access('update', $node) || user_access('unpublish own ' . check_plain($node->type) . ' content', $user) && $user->uid == $node->uid || user_access('unpublish any ' . check_plain($node->type) . ' content') || user_access('unpublish editable ' . check_plain($node->type) . ' content') && node_access('update', $node));
if ($access) {
// The user is allowed to unpublish the node according to this hook.
// If another hook denys access they will be denied.
return PUBLISHCONTENT_ACCESS_ALLOW;
}
// This function does not believe they can publish but is
// not explicitly denying access to publish. If no other hooks
// allow it then the user will be denied.
return PUBLISHCONTENT_ACCESS_IGNORE;
}
开发者ID:adamstacey5,项目名称:drupal-7-training,代码行数:33,代码来源:publishcontent.api.php
示例11: setNodeValue
public static function setNodeValue()
{
// Gather URL parameters.
$nid = isset($_GET['nid']) ? intval($_GET['nid']) : null;
$field = isset($_GET['f']) ? $_GET['f'] : null;
$value = isset($_GET['v']) ? $_GET['v'] : null;
// Validate parameters and coerce types as needed.
switch ($field) {
case 'sharing':
switch ($value) {
case 'public':
$value = 1;
break;
case 'private':
$value = 0;
break;
default:
$value = null;
break;
}
break;
default:
$field = null;
break;
}
if (!isset($nid) || !isset($field) || !isset($value)) {
throw new Exception(t('Invalid method parameters.'));
}
// Load the node and perform update access check.
require_once DRUPAL_ROOT . '/includes/common.inc';
module_load_include('module', 'node');
module_load_include('inc', 'field', 'field.attach');
module_load_include('module', 'user');
$node = node_load($nid);
if (!node_access('update', $node)) {
throw new Exception('User does not have access to nid ' . $nid, 403);
}
// Set the appropriate node fields.
switch ($field) {
case 'sharing':
$node->status = $value;
break;
}
// Save the node.
node_save($node);
die('ok');
}
开发者ID:NeilBryant,项目名称:sufferhub,代码行数:47,代码来源:NodeAccessHandler.class.php
示例12: getReferencableEntities
/**
* Implements EntityReferenceHandler::getReferencableEntities().
*/
public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0)
{
$gid = oa_core_get_space_context();
$space = node_load($gid);
$type = variable_get_value('oa_worktracker_assigned_to_users');
if ($type === OA_WORKTRACKER_ASSIGN_TO_INHERITED_USERS && !module_exists('oa_subspaces')) {
$type = OA_WORKTRACKER_ASSIGN_TO_ONLY_LOCAL_USERS;
}
$uids = array();
switch ($type) {
case OA_WORKTRACKER_ASSIGN_TO_INHERITED_USERS:
$uids = og_subgroups_get_users_group('node', $space);
$uids = $uids['user'];
$inherited = _og_subgroups_get_inherited_users('node', $gid);
foreach ($inherited as $inherited_uid => $data) {
$uids[] = $inherited_uid;
}
break;
case OA_WORKTRACKER_ASSIGN_TO_ONLY_LOCAL_USERS:
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'og_membership')->propertyCondition('group_type', 'node', '=')->propertyCondition('gid', $gid, '=')->propertyCondition('entity_type', 'user', '=')->propertyCondition('state', OG_STATE_ACTIVE, '=');
$result = $query->execute();
if (!empty($result['og_membership'])) {
$og_memberships = og_membership_load_multiple(array_keys($result['og_membership']));
foreach ($og_memberships as $og_membership) {
$uids[] = $og_membership->etid;
}
}
break;
case OA_WORKTRACKER_ASSIGN_TO_ANY_USERS:
$query = db_select('users', 'u')->fields('u', array('uid'))->condition('status', 1);
$uids = $query->execute()->fetchCol();
break;
}
$options = array('user' => array());
if (!empty($uids)) {
// Get the user label and make sure that the user can access the space.
$users = user_load_multiple($uids);
foreach ($users as $uid => $account) {
if (node_access('view', $space, $account)) {
$options['user'][$uid] = check_plain($this->getLabel($account));
}
}
asort($options['user']);
}
return $options;
}
开发者ID:cesardmoro,项目名称:openatrium-2-quickstart,代码行数:50,代码来源:OaWorkTracker_SelectionHandler_Assigned.class.php
示例13: mooc_foundation_access_preprocess_page
/**
* Implements template_preprocess_page.
*/
function mooc_foundation_access_preprocess_page(&$variables)
{
// speedreader is enabled
if (module_exists('speedreader')) {
$variables['speedreader'] = TRUE;
}
// drop some tabs that don't seem to go away on their own
if (isset($variables['tabs']['#primary']) && !empty($variables['tabs']['#primary'])) {
foreach ($variables['tabs']['#primary'] as $key => $value) {
if (in_array($value['#link']['path'], array('node/%/display', 'node/%/outline', 'node/%/log'))) {
unset($variables['tabs']['#primary'][$key]);
}
}
// fornow drop secondary entirely for nodes
if (arg(0) == 'node' && isset($variables['tabs']['#secondary'])) {
unset($variables['tabs']['#secondary']);
}
}
$child_type = variable_get('book_child_type', 'book');
$node = menu_get_object();
if ($node && !empty($node->book) && (user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && isset($node->book['depth']) && $node->book['depth'] < MENU_MAX_DEPTH) {
$variables['tabs_extras'][200][] = '<div class="divider"></div>';
$variables['tabs_extras'][200][] = '<span class="nolink cis-lmsless-text">' . t('Operations') . '</strong>';
$variables['tabs_extras'][200][] = l(t('Edit child outline'), 'node/' . $node->book['nid'] . '/outline/children');
$variables['tabs_extras'][200][] = l(t('Edit course outline'), 'admin/content/book/' . $node->book['bid']);
}
// support hiding the accessibility check UI which is poorly located
if ($node && user_access('view accessibility tests')) {
$variables['tabs_extras'][200][] = '<span class="cis_accessibility_check"></span>';
}
// remove the prefix that provides a link to the home page
// as MOOC is the thing that currently provides support directly for this
// and slightly overrides the behavior
$keys = array_keys($variables['page']['header']);
$keyname = array_shift($keys);
unset($variables['page']['header'][$keyname]['#prefix']);
// Remove title from a page when a gitbook markdown filter is present.
if (isset($variables['page']['content']['system_main']['nodes'])) {
foreach ($variables['page']['content']['system_main']['nodes'] as $node) {
if (isset($node['body']['#object'])) {
if ($node['body']['#object']->body['und'][0]['format'] == "git_book_markdown") {
$variables['title'] = "";
}
}
}
}
}
开发者ID:mmilutinovic1313,项目名称:elmsln,代码行数:50,代码来源:template.php
示例14: hook_message_access_alter
/**
* Allow modules to alter access granted to a message entity.
* @param $access
* Boolean specifying whether the specifified account has the specified access.
* @param context
* Array containing relevant information for determining access to
* the message entity. Keys are op, entity, entity_type, and account.
*/
function hook_message_access_alter(&$access, $context)
{
// We're only interested in the 'view' operation.
if ($context['op'] != 'view') {
return;
}
$message = $context['entity'];
// Verify view access to nodes referenced in the message.
if (isset($message->field_target_nodes)) {
foreach ($message->field_target_nodes[LANGUAGE_NONE] as $key => $value) {
$node = node_load($value['target_id']);
if (!node_access('view', $node, $context['account'])) {
// If the user cannot view any nodes in the message,
// deny access to the entire message;
$access = FALSE;
return;
}
}
}
}
开发者ID:jayelless,项目名称:beehive,代码行数:28,代码来源:message.api.php
示例15: _nodereferrer_create_add_form_submit
/**
* Submit the form to add to an existing node
*/
function _nodereferrer_create_add_form_submit($form, &$form_state)
{
if ($form_state['clicked_button']['#name'] != 'add') {
drupal_set_message(t('The operation was cancelled'));
drupal_goto('node/' . arg(1));
}
$append_node = node_load($form_state['values']['referrence']);
// Make sure the user is allowed to do this
if (!node_access('update', $append_node)) {
drupal_set_message(t('You do not have rights to update this node'));
drupal_goto('node/' . arg(1));
return;
}
$current_node = node_load(arg(1));
$field = $current_node->referrers[arg(3)]['referrence'][arg(4)][arg(5)]['field_name'];
array_push($append_node->{$field}, array('nid' => $current_node->nid));
// Save, and ensure the changes are noticed
node_save($append_node);
cache_clear_all();
drupal_set_message(t('The node was added'));
drupal_goto('node/' . arg(1));
}
开发者ID:e2thex,项目名称:hackunteers.org,代码行数:25,代码来源:add_to_referrer.php
示例16: entityAccess
/**
* {@inheritdoc}
*/
public function entityAccess($operation = 'view')
{
global $user;
$node = $this->getEntity();
// Make sure we don't render a node inside itself, preventing infinite loop.
$object = menu_get_object('node');
if (is_object($object) && isset($object->nid) && $object->nid == $node->nid) {
drupal_set_message(t('Cannot render a node inside itself, remove any view mode token related to the current node.'));
return FALSE;
}
// Make sure current user can actually access the rendered node.
if (user_access('bypass node access') || user_access('administer nodes')) {
return TRUE;
}
if (!node_access($operation, $node)) {
return FALSE;
}
if ($node->status == 0) {
return $node->uid == $user->uid && user_access('view own unpublished content');
} else {
return TRUE;
}
}
开发者ID:ec-europa,项目名称:platform-dev,代码行数:26,代码来源:NodeViewModeType.php
示例17: getReferencableEntities
/**
* Implements EntityReferenceHandler::getReferencableEntities().
*/
public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 25)
{
$options = array();
$target_node_types = $this->field['settings']['handler_settings']['target_bundles'];
// No target node types means all issue types may be selected.
if (empty($target_node_types)) {
$target_node_types = project_issue_issue_node_types();
}
global $base_url;
// Early return if the short match string would generate too many results.
// @todo: Make this configurable? Return even if user has ebereted #nid.
// It's unlikely they're trying to reference a two digit nid issue.
if (strlen($match) < 4) {
return $options;
}
// If the given string begins with the site domain, try to match it to the
// URL of an issue node.
if (substr($match, 0, strlen($base_url)) == $base_url) {
$matches = array();
// Extract the node ID from the URL, allowing for an anchor tag.
preg_match("@^{$base_url}/node/(\\d+)(?:#\\S+)?\$@", $match, $matches);
if (isset($matches[1])) {
$nid = $matches[1];
$node = node_load($nid);
if ($node) {
// Only allow the node if it's of the right type and the user has
// access to view it.
if (in_array($node->type, $target_node_types) && node_access('view', $node)) {
$options[$node->type][$nid] = check_plain($this->getLabel($node));
// Don't return yet, as there is a slim chance that the URL is part
// of the title of an issue which starts with the domain name or
// even the full URL, as in 'http://example.com/node/1 is broken'.
}
}
}
}
// If the given string is of the form '#1234' then try to match that as a
// nid.
if (strpos($match, '#') === 0) {
if (preg_match("@^#(\\d+)\$@", $match)) {
$nid = substr($match, 1);
$node = node_load($nid);
if ($node) {
// Only allow the node if it's of the right type and the user has
// access to view it.
if (in_array($node->type, $target_node_types) && node_access('view', $node)) {
$options[$node->type][$nid] = check_plain($this->getLabel($node));
// Don't return, same reason as above.
}
}
}
}
// Build a query for the nodes. We can't use buildEntityFieldQuery() because
// we have to use a SelectQuery rather than an EntityFieldQuery to have an
// OR condition.
$query = db_select('node', 'n');
if (isset($match)) {
// Try to match on the title or nid.
$query->condition(db_or()->condition('n.title', '%' . db_like($match) . '%', 'LIKE')->condition('n.nid', $match));
}
// Set the node type.
$query->condition('type', $target_node_types);
if (!user_access('bypass node access')) {
// Restrict the query to published nodes.
$query->condition('n.status', NODE_PUBLISHED);
}
// Restrict the number of returned rows. jQuery UI autocomplete defaults to
// showing 10 only.
if (!empty($limit)) {
$query->range(0, $limit);
}
// Order the returned nodes by some sort of relevancy.
$query->orderBy('n.changed', 'DESC');
$node_data = $query->fields('n', array('nid', 'title', 'type'))->addTag('node_access')->execute()->fetchAll();
foreach ($node_data as $item) {
$options[$item->type][$item->nid] = check_plain($item->title);
}
return $options;
}
开发者ID:washim,项目名称:techsupport,代码行数:82,代码来源:ProjectIssue_SelectionHandler_Issues.class.php
示例18: get_visibility
/**
* Determines the visibility of a piece of content
* and returns that value
*
* Possible values are: 'draft', 'private', and NULL
*
* @param Object $node The content to determine its visibility
* @return String a string indicating its visibility
*/
public static function get_visibility($node)
{
$visibility = NULL;
// Check if it is a draft
if (isset($node->status) && $node->status == 0) {
$visibility = 'draft';
}
// Check if it should be excluded from recommendations
if (isset($node->shareaholic_options) && $node->shareaholic_options['shareaholic_exclude_from_recommendations']) {
$visibility = 'private';
}
// Check if a site visitor can see the content
try {
$anonymous_user = user_load(0);
if ($anonymous_user && !node_access('view', $node, $anonymous_user)) {
$visibility = 'private';
}
} catch (Exception $e) {
ShareaholicUtilities::log('Error in checking node_access: ' . $e->getMessage());
}
return $visibility;
}
开发者ID:reasonat,项目名称:women,代码行数:31,代码来源:public.php
示例19: node_load
$node = node_load($nid);
$node->field_modeldata[0]['value'] = $_POST["data"];
$node->changed = time();
$node->title = $_POST["title"];
$node->body = $_POST["description"];
if (node_access("update", $node)) {
$node->revision = 1;
node_save($node);
insightica_set_tags_csv($node->nid, $_POST["tags"]);
}
echo $node->nid;
} else {
$node = new stdClass();
$node->title = $_POST["title"];
$node->body = $_POST["description"];
$node->type = "insight";
$node->uid = $user->uid;
$node->teaser = "";
$node->filter = 1;
$node->status = 1;
$node->comment = 2;
$node->created = time();
$node->changed = time();
$node->field_modeldata[0]['value'] = $_POST["data"];
$now = microtime(true);
if (node_access("create", $node)) {
node_save($node);
insightica_set_tags_csv($node->nid, $_POST["tags"]);
}
echo $node->nid;
}
开发者ID:juanmanunez,项目名称:insight-maker,代码行数:31,代码来源:save.php
示例20: hook_cart_display
/**
* Controls the display of an item in the cart.
*
* Product type modules allow the creation of nodes that can be added to the
* cart. The cart determines how they are displayed through this hook. This is
* especially important for product kits, because it may be displayed as a
* single unit in the cart even though it is represented as several items.
*
* This hook is only called for the module that owns the cart item in
* question, as set in $item->module.
*
* @param $item
* The item in the cart to display.
*
* @return
* A form array containing the following elements:
* - "nid"
* - #type: value
* - #value: The node id of the $item.
* - "module"
* - #type: value
* - #value: The module implementing this hook and the node represented by
* $item.
* - "remove"
* - #type: submit
* - #value: t('Remove'); when clicked, will remove $item from the cart.
* - "description"
* - #type: markup
* - #value: Themed markup (usually an unordered list) displaying extra
* information.
* - "title"
* - #type: markup
* - #value: The displayed title of the $item.
* - "#total"
* - "type": float
* - "value": Numeric price of $item. Notice the '#' signifying that this is
* not a form element but just a value stored in the form array.
* - "data"
* - #type: hidden
* - #value: The serialized $item->data.
* - "qty"
* - #type: textfield
* - #value: The quantity of $item in the cart. When "Update cart" is
* clicked, the customer's input is saved to the cart.
*/
function hook_cart_display($item)
{
$node = node_load($item->nid);
$element = array();
$element['nid'] = array('#type' => 'value', '#value' => $node->nid);
$element['module'] = array('#type' => 'value', '#value' => 'uc_product');
$element['remove'] = array('#type' => 'checkbox');
$element['title'] = array('#value' => node_access('view', $node) ? l($item->title, 'node/' . $node->nid) : check_plain($item->title));
$context = array('revision' => 'altered', 'type' => 'cart_item', 'subject' => array('cart_item' => $item, 'node' => $node));
$price_info = array('price' => $item->price, 'qty' => $item->qty);
$element['#total'] = uc_price($price_info, $context);
$element['data'] = array('#type' => 'hidden', '#value' => serialize($item->data));
$element['qty'] = array('#type' => 'textfield', '#default_value' => $item->qty, '#size' => 5, '#maxlength' => 6);
if ($description = uc_product_get_description($item)) {
$element['description'] = array('#value' => $description);
}
return $element;
}
开发者ID:sojo,项目名称:d6_friendsofsilence,代码行数:63,代码来源:hooks.php
注:本文中的node_access函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论