updated core to 7.73
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
function node_overview_types() {
|
||||
$types = node_type_get_types();
|
||||
$names = node_type_get_names();
|
||||
$field_ui = module_exists('field_ui');
|
||||
$field_ui = module_exists('field_ui') && user_access('administer fields');
|
||||
$header = array(t('Name'), array('data' => t('Operations'), 'colspan' => $field_ui ? '4' : '2'));
|
||||
$rows = array();
|
||||
|
||||
@@ -255,11 +255,11 @@ function _node_characters($length) {
|
||||
*/
|
||||
function node_type_form_validate($form, &$form_state) {
|
||||
$type = new stdClass();
|
||||
$type->type = trim($form_state['values']['type']);
|
||||
$type->type = $form_state['values']['type'];
|
||||
$type->name = trim($form_state['values']['name']);
|
||||
|
||||
// Work out what the type was before the user submitted this form
|
||||
$old_type = trim($form_state['values']['old_type']);
|
||||
$old_type = $form_state['values']['old_type'];
|
||||
|
||||
$types = node_type_get_names();
|
||||
|
||||
@@ -288,7 +288,7 @@ function node_type_form_submit($form, &$form_state) {
|
||||
|
||||
$type = node_type_set_defaults();
|
||||
|
||||
$type->type = trim($form_state['values']['type']);
|
||||
$type->type = $form_state['values']['type'];
|
||||
$type->name = trim($form_state['values']['name']);
|
||||
$type->orig_type = trim($form_state['values']['orig_type']);
|
||||
$type->old_type = isset($form_state['values']['old_type']) ? $form_state['values']['old_type'] : $type->type;
|
||||
|
||||
@@ -329,6 +329,8 @@ function _node_mass_update_helper($nid, $updates) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_operation().
|
||||
*
|
||||
* Executes a batch operation for node_mass_update().
|
||||
*
|
||||
* @param array $nodes
|
||||
@@ -367,7 +369,9 @@ function _node_mass_update_batch_process($nodes, $updates, &$context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu callback: Reports the status of batch operation for node_mass_update().
|
||||
* Implements callback_batch_finished().
|
||||
*
|
||||
* Reports the status of batch operation for node_mass_update().
|
||||
*
|
||||
* @param bool $success
|
||||
* A boolean indicating whether the batch mass update operation successfully
|
||||
@@ -471,6 +475,7 @@ function node_admin_nodes() {
|
||||
$header['operations'] = array('data' => t('Operations'));
|
||||
|
||||
$query = db_select('node', 'n')->extend('PagerDefault')->extend('TableSort');
|
||||
$query->addTag('node_admin_filter');
|
||||
node_build_filter_query($query);
|
||||
|
||||
if (!user_access('bypass node access')) {
|
||||
@@ -503,14 +508,17 @@ function node_admin_nodes() {
|
||||
$options = array();
|
||||
foreach ($nodes as $node) {
|
||||
$langcode = entity_language('node', $node);
|
||||
$l_options = $langcode != LANGUAGE_NONE && isset($languages[$langcode]) ? array('language' => $languages[$langcode]) : array();
|
||||
$uri = entity_uri('node', $node);
|
||||
if ($langcode != LANGUAGE_NONE && isset($languages[$langcode])) {
|
||||
$uri['options']['language'] = $languages[$langcode];
|
||||
}
|
||||
$options[$node->nid] = array(
|
||||
'title' => array(
|
||||
'data' => array(
|
||||
'#type' => 'link',
|
||||
'#title' => $node->title,
|
||||
'#href' => 'node/' . $node->nid,
|
||||
'#options' => $l_options,
|
||||
'#href' => $uri['path'],
|
||||
'#options' => $uri['options'],
|
||||
'#suffix' => ' ' . theme('mark', array('type' => node_mark($node->nid, $node->changed))),
|
||||
),
|
||||
),
|
||||
@@ -695,6 +703,7 @@ function node_multiple_delete_confirm($form, &$form_state, $nodes) {
|
||||
function node_multiple_delete_confirm_submit($form, &$form_state) {
|
||||
if ($form_state['values']['confirm']) {
|
||||
node_delete_multiple(array_keys($form_state['values']['nodes']));
|
||||
cache_clear_all();
|
||||
$count = count($form_state['values']['nodes']);
|
||||
watchdog('content', 'Deleted @count posts.', array('@count' => $count));
|
||||
drupal_set_message(format_plural($count, 'Deleted 1 post.', 'Deleted @count posts.'));
|
||||
|
||||
+80
-45
@@ -17,11 +17,14 @@
|
||||
* During node operations (create, update, view, delete, etc.), there are
|
||||
* several sets of hooks that get invoked to allow modules to modify the base
|
||||
* node operation:
|
||||
* - Node-type-specific hooks: These hooks are only invoked on the primary
|
||||
* module, using the "base" return component of hook_node_info() as the
|
||||
* function prefix. For example, poll.module defines the base for the Poll
|
||||
* content type as "poll", so during creation of a poll node, hook_insert() is
|
||||
* only invoked by calling poll_insert().
|
||||
* - Node-type-specific hooks: When defining a node type, hook_node_info()
|
||||
* returns a 'base' component. Node-type-specific hooks are named
|
||||
* base_hookname() instead of mymodule_hookname() (in a module called
|
||||
* 'mymodule' for example). Only the node type's corresponding implementation
|
||||
* is invoked. For example, poll_node_info() in poll.module defines the base
|
||||
* for the 'poll' node type as 'poll'. So when a poll node is created,
|
||||
* hook_insert() is invoked on poll_insert() only.
|
||||
* Hooks that are node-type-specific are noted below.
|
||||
* - All-module hooks: This set of hooks is invoked on all implementing modules,
|
||||
* to allow other modules to modify what the primary node module is doing. For
|
||||
* example, hook_node_insert() is invoked on all modules when creating a poll
|
||||
@@ -195,7 +198,7 @@ function hook_node_grants($account, $op) {
|
||||
if (user_access('access private content', $account)) {
|
||||
$grants['example'] = array(1);
|
||||
}
|
||||
$grants['example_owner'] = array($account->uid);
|
||||
$grants['example_author'] = array($account->uid);
|
||||
return $grants;
|
||||
}
|
||||
|
||||
@@ -885,11 +888,10 @@ function hook_node_view_alter(&$build) {
|
||||
* name as the key. Each sub-array has up to 10 attributes. Possible
|
||||
* attributes:
|
||||
* - name: (required) The human-readable name of the node type.
|
||||
* - base: (required) The base string used to construct callbacks
|
||||
* corresponding to this node type (for example, if base is defined as
|
||||
* example_foo, then example_foo_insert will be called when inserting a node
|
||||
* of that type). This string is usually the name of the module, but not
|
||||
* always.
|
||||
* - base: (required) The base name for implementations of node-type-specific
|
||||
* hooks that respond to this node type. Base is usually the name of the
|
||||
* module or 'node_content', but not always. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
* - description: (required) A brief description of the node type.
|
||||
* - help: (optional) Help information shown to the user when creating a node
|
||||
* of this type.
|
||||
@@ -948,7 +950,7 @@ function hook_node_info() {
|
||||
* 'recent', or 'comments'. The values should be arrays themselves, with the
|
||||
* following keys available:
|
||||
* - title: (required) The human readable name of the ranking mechanism.
|
||||
* - join: (optional) The part of a query string to join to any additional
|
||||
* - join: (optional) An array with information to join any additional
|
||||
* necessary table. This is not necessary if the table required is already
|
||||
* joined to by the base query, such as for the {node} table. Other tables
|
||||
* should use the full table name as an alias to avoid naming collisions.
|
||||
@@ -972,7 +974,12 @@ function hook_ranking() {
|
||||
'title' => t('Average vote'),
|
||||
// Note that we use i.sid, the search index's search item id, rather than
|
||||
// n.nid.
|
||||
'join' => 'LEFT JOIN {vote_node_data} vote_node_data ON vote_node_data.nid = i.sid',
|
||||
'join' => array(
|
||||
'type' => 'LEFT',
|
||||
'table' => 'vote_node_data',
|
||||
'alias' => 'vote_node_data',
|
||||
'on' => 'vote_node_data.nid = i.sid',
|
||||
),
|
||||
// The highest possible score should be 1, and the lowest possible score,
|
||||
// always 0, should be 0.
|
||||
'score' => 'vote_node_data.average / CAST(%f AS DECIMAL)',
|
||||
@@ -1030,12 +1037,23 @@ function hook_node_type_delete($info) {
|
||||
/**
|
||||
* Respond to node deletion.
|
||||
*
|
||||
* This hook is invoked only on the module that defines the node's content type
|
||||
* (use hook_node_delete() to respond to all node deletions).
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* This hook is invoked from node_delete_multiple() after the node has been
|
||||
* removed from the node table in the database, before hook_node_delete() is
|
||||
* invoked, and before field_attach_delete() is called.
|
||||
* Use hook_node_delete() to respond to node deletion of all node types.
|
||||
*
|
||||
* This hook is invoked from node_delete_multiple() before hook_node_delete()
|
||||
* is invoked and before field_attach_delete() is called.
|
||||
*
|
||||
* Note that when this hook is invoked, the changes have not yet been written
|
||||
* to the database, because a database transaction is still in progress. The
|
||||
* transaction is not finalized until the delete operation is entirely
|
||||
* completed and node_delete_multiple() goes out of scope. You should not rely
|
||||
* on data in the database at this time as it is not updated yet. You should
|
||||
* also note that any write/update database queries executed from this hook are
|
||||
* also not committed immediately. Check node_delete_multiple() and
|
||||
* db_transaction() for more info.
|
||||
*
|
||||
* @param $node
|
||||
* The node that is being deleted.
|
||||
@@ -1051,8 +1069,11 @@ function hook_delete($node) {
|
||||
/**
|
||||
* Act on a node object about to be shown on the add/edit form.
|
||||
*
|
||||
* This hook is invoked only on the module that defines the node's content type
|
||||
* (use hook_node_prepare() to act on all node preparations).
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* Use hook_node_prepare() to respond to node preparation of all node types.
|
||||
*
|
||||
* This hook is invoked from node_object_prepare() before the general
|
||||
* hook_node_prepare() is invoked.
|
||||
@@ -1063,26 +1084,21 @@ function hook_delete($node) {
|
||||
* @ingroup node_api_hooks
|
||||
*/
|
||||
function hook_prepare($node) {
|
||||
if ($file = file_check_upload($field_name)) {
|
||||
$file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE));
|
||||
if ($file) {
|
||||
if (!image_get_info($file->uri)) {
|
||||
form_set_error($field_name, t('Uploaded file is not a valid image'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
$node->images['_original'] = $file->uri;
|
||||
_image_build_derivatives($node, TRUE);
|
||||
$node->new_file = TRUE;
|
||||
if (!isset($node->mymodule_value)) {
|
||||
$node->mymodule_value = 'foo';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a node editing form.
|
||||
*
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* Use hook_form_BASE_FORM_ID_alter(), with base form ID 'node_form', to alter
|
||||
* node forms for all node types.
|
||||
*
|
||||
* This hook, implemented by node modules, is called to retrieve the form
|
||||
* that is displayed to create or edit a node. This form is displayed at path
|
||||
* node/add/[node type] or node/[node ID]/edit.
|
||||
@@ -1138,8 +1154,11 @@ function hook_form($node, &$form_state) {
|
||||
/**
|
||||
* Respond to creation of a new node.
|
||||
*
|
||||
* This hook is invoked only on the module that defines the node's content type
|
||||
* (use hook_node_insert() to act on all node insertions).
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* Use hook_node_insert() to respond to node insertion of all node types.
|
||||
*
|
||||
* This hook is invoked from node_save() after the node is inserted into the
|
||||
* node table in the database, before field_attach_insert() is called, and
|
||||
@@ -1162,8 +1181,11 @@ function hook_insert($node) {
|
||||
/**
|
||||
* Act on nodes being loaded from the database.
|
||||
*
|
||||
* This hook is invoked only on the module that defines the node's content type
|
||||
* (use hook_node_load() to respond to all node loads).
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* Use hook_node_load() to respond to node load of all node types.
|
||||
*
|
||||
* This hook is invoked during node loading, which is handled by entity_load(),
|
||||
* via classes NodeController and DrupalDefaultEntityController. After the node
|
||||
@@ -1196,8 +1218,11 @@ function hook_load($nodes) {
|
||||
/**
|
||||
* Respond to updates to a node.
|
||||
*
|
||||
* This hook is invoked only on the module that defines the node's content type
|
||||
* (use hook_node_update() to act on all node updates).
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* Use hook_node_update() to respond to node update of all node types.
|
||||
*
|
||||
* This hook is invoked from node_save() after the node is updated in the
|
||||
* node table in the database, before field_attach_update() is called, and
|
||||
@@ -1218,8 +1243,11 @@ function hook_update($node) {
|
||||
/**
|
||||
* Perform node validation before a node is created or updated.
|
||||
*
|
||||
* This hook is invoked only on the module that defines the node's content type
|
||||
* (use hook_node_validate() to act on all node validations).
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* Use hook_node_validate() to respond to node validation of all node types.
|
||||
*
|
||||
* This hook is invoked from node_validate(), after a user has finished
|
||||
* editing the node and is previewing or submitting it. It is invoked at the end
|
||||
@@ -1252,8 +1280,11 @@ function hook_validate($node, $form, &$form_state) {
|
||||
/**
|
||||
* Display a node.
|
||||
*
|
||||
* This hook is invoked only on the module that defines the node's content type
|
||||
* (use hook_node_view() to act on all node views).
|
||||
* This is a node-type-specific hook, which is invoked only for the node type
|
||||
* being affected. See
|
||||
* @link node_api_hooks Node API hooks @endlink for more information.
|
||||
*
|
||||
* Use hook_node_view() to respond to node view of all node types.
|
||||
*
|
||||
* This hook is invoked during node viewing after the node is fully loaded, so
|
||||
* that the node type module can define a custom method for display, or add to
|
||||
@@ -1263,6 +1294,10 @@ function hook_validate($node, $form, &$form_state) {
|
||||
* The node to be displayed, as returned by node_load().
|
||||
* @param $view_mode
|
||||
* View mode, e.g. 'full', 'teaser', ...
|
||||
* @param $langcode
|
||||
* (optional) A language code to use for rendering. Defaults to the global
|
||||
* content language of the current request.
|
||||
*
|
||||
* @return
|
||||
* The passed $node parameter should be modified as necessary and returned so
|
||||
* it can be properly presented. Nodes are prepared for display by assembling
|
||||
@@ -1276,7 +1311,7 @@ function hook_validate($node, $form, &$form_state) {
|
||||
*
|
||||
* @ingroup node_api_hooks
|
||||
*/
|
||||
function hook_view($node, $view_mode) {
|
||||
function hook_view($node, $view_mode, $langcode = NULL) {
|
||||
if ($view_mode == 'full' && node_is_page($node)) {
|
||||
$breadcrumb = array();
|
||||
$breadcrumb[] = l(t('Home'), NULL);
|
||||
|
||||
@@ -9,8 +9,7 @@ required = TRUE
|
||||
configure = admin/structure/types
|
||||
stylesheets[all][] = node.css
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-04-03
|
||||
version = "7.22"
|
||||
; Information added by Drupal.org packaging script on 2020-09-16
|
||||
version = "7.73"
|
||||
project = "drupal"
|
||||
datestamp = "1365027012"
|
||||
|
||||
datestamp = "1600272641"
|
||||
|
||||
@@ -114,6 +114,7 @@ function node_schema() {
|
||||
'uid' => array('uid'),
|
||||
'tnid' => array('tnid'),
|
||||
'translate' => array('translate'),
|
||||
'language' => array('language'),
|
||||
),
|
||||
'unique keys' => array(
|
||||
'vid' => array('vid'),
|
||||
@@ -409,6 +410,7 @@ function node_schema() {
|
||||
'nid' => array(
|
||||
'description' => 'The {node}.nid that was read.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
@@ -925,6 +927,40 @@ function node_update_7013() {
|
||||
db_add_unique_key('node', 'vid', array('vid'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an index on {node}.language.
|
||||
*/
|
||||
function node_update_7014() {
|
||||
db_add_index('node', 'language', array('language'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable node types that may have been erroneously disabled in Drupal 7.36.
|
||||
*/
|
||||
function node_update_7015() {
|
||||
db_update('node_type')
|
||||
->fields(array('disabled' => 0))
|
||||
->condition('base', 'node_content')
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change {history}.nid to an unsigned int in order to match {node}.nid.
|
||||
*/
|
||||
function node_update_7016() {
|
||||
db_drop_primary_key('history');
|
||||
db_drop_index('history', 'nid');
|
||||
db_change_field('history', 'nid', 'nid', array(
|
||||
'description' => 'The {node}.nid that was read.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
));
|
||||
db_add_primary_key('history', array('uid', 'nid'));
|
||||
db_add_index('history', 'nid', array('nid'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup updates-7.x-extra".
|
||||
*/
|
||||
|
||||
+52
-32
@@ -210,7 +210,7 @@ function node_entity_info() {
|
||||
'custom settings' => FALSE,
|
||||
),
|
||||
'search_result' => array(
|
||||
'label' => t('Search result'),
|
||||
'label' => t('Search result highlighting input'),
|
||||
'custom settings' => FALSE,
|
||||
),
|
||||
);
|
||||
@@ -244,13 +244,7 @@ function node_field_display_node_alter(&$display, $context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity URI callback.
|
||||
*
|
||||
* @param $node
|
||||
* A node entity.
|
||||
*
|
||||
* @return array
|
||||
* An array with 'path' as the key and the path to the node as its value.
|
||||
* Implements callback_entity_info_uri().
|
||||
*/
|
||||
function node_uri($node) {
|
||||
return array(
|
||||
@@ -512,7 +506,8 @@ function node_type_load($name) {
|
||||
* - custom: TRUE or FALSE indicating whether this type is defined by a module
|
||||
* (FALSE) or by a user (TRUE) via Add Content Type.
|
||||
* - modified: TRUE or FALSE indicating whether this type has been modified by
|
||||
* an administrator. Currently not used in any way.
|
||||
* an administrator. When modifying an existing node type, set to TRUE, or
|
||||
* the change will be ignored on node_types_rebuild().
|
||||
* - locked: TRUE or FALSE indicating whether the administrator can change the
|
||||
* machine name of this type.
|
||||
* - disabled: TRUE or FALSE indicating whether this type has been disabled.
|
||||
@@ -1185,10 +1180,8 @@ function node_save($node) {
|
||||
module_invoke_all('node_' . $op, $node);
|
||||
module_invoke_all('entity_' . $op, $node, 'node');
|
||||
|
||||
// Update the node access table for this node. There's no need to delete
|
||||
// existing records if the node is new.
|
||||
$delete = $op == 'update';
|
||||
node_access_acquire_grants($node, $delete);
|
||||
// Update the node access table for this node.
|
||||
node_access_acquire_grants($node);
|
||||
|
||||
// Clear internal properties.
|
||||
unset($node->is_new);
|
||||
@@ -1405,12 +1398,7 @@ function node_build_content($node, $view_mode = 'full', $langcode = NULL) {
|
||||
$node->content = array();
|
||||
|
||||
// Allow modules to change the view mode.
|
||||
$context = array(
|
||||
'entity_type' => 'node',
|
||||
'entity' => $node,
|
||||
'langcode' => $langcode,
|
||||
);
|
||||
drupal_alter('entity_view_mode', $view_mode, $context);
|
||||
$view_mode = key(entity_view_mode_prepare('node', array($node->nid => $node), $view_mode, $langcode));
|
||||
|
||||
// The 'view' hook can be implemented to overwrite the default function
|
||||
// to display nodes.
|
||||
@@ -1593,6 +1581,7 @@ function node_permission() {
|
||||
),
|
||||
'access content overview' => array(
|
||||
'title' => t('Access the content overview page'),
|
||||
'description' => t('Get an overview of <a href="@url">all content</a>.', array('@url' => url('admin/content'))),
|
||||
),
|
||||
'access content' => array(
|
||||
'title' => t('View published content'),
|
||||
@@ -1620,7 +1609,7 @@ function node_permission() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gathers the rankings from the the hook_ranking() implementations.
|
||||
* Gathers the rankings from the hook_ranking() implementations.
|
||||
*
|
||||
* @param $query
|
||||
* A query object that has been extended with the Search DB Extender.
|
||||
@@ -1688,7 +1677,7 @@ function node_search_admin() {
|
||||
);
|
||||
$form['content_ranking']['#theme'] = 'node_search_admin';
|
||||
$form['content_ranking']['info'] = array(
|
||||
'#value' => '<em>' . t('The following numbers control which properties the content search should favor when ordering the results. Higher numbers mean more influence, zero means the property is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em>'
|
||||
'#markup' => '<p><em>' . t('Influence is a numeric multiplier used in ordering search results. A higher number means the corresponding factor has more influence on search results; zero means the factor is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em></p>'
|
||||
);
|
||||
|
||||
// Note: reversed to reflect that higher number = higher ranking.
|
||||
@@ -1875,7 +1864,7 @@ function theme_node_search_admin($variables) {
|
||||
|
||||
$output = drupal_render($form['info']);
|
||||
|
||||
$header = array(t('Factor'), t('Weight'));
|
||||
$header = array(t('Factor'), t('Influence'));
|
||||
foreach (element_children($form['factors']) as $key) {
|
||||
$row = array();
|
||||
$row[] = $form['factors'][$key]['#title'];
|
||||
@@ -2227,8 +2216,8 @@ function node_last_changed($nid) {
|
||||
/**
|
||||
* Returns a list of all the existing revision numbers.
|
||||
*
|
||||
* @param Drupal\node\Node $node
|
||||
* The node entity.
|
||||
* @param $node
|
||||
* The node object.
|
||||
*
|
||||
* @return
|
||||
* An associative array keyed by node revision number.
|
||||
@@ -2609,9 +2598,10 @@ function node_feed($nids = FALSE, $channel = array()) {
|
||||
|
||||
$node->link = url("node/$node->nid", array('absolute' => TRUE));
|
||||
$node->rss_namespaces = array();
|
||||
$account = user_load($node->uid);
|
||||
$node->rss_elements = array(
|
||||
array('key' => 'pubDate', 'value' => gmdate('r', $node->created)),
|
||||
array('key' => 'dc:creator', 'value' => $node->name),
|
||||
array('key' => 'dc:creator', 'value' => format_username($account)),
|
||||
array('key' => 'guid', 'value' => $node->nid . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false'))
|
||||
);
|
||||
|
||||
@@ -2669,15 +2659,26 @@ function node_feed($nids = FALSE, $channel = array()) {
|
||||
* An array in the format expected by drupal_render().
|
||||
*/
|
||||
function node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0, $langcode = NULL) {
|
||||
field_attach_prepare_view('node', $nodes, $view_mode, $langcode);
|
||||
entity_prepare_view('node', $nodes, $langcode);
|
||||
$build = array();
|
||||
$build = array('nodes' => array());
|
||||
$entities_by_view_mode = entity_view_mode_prepare('node', $nodes, $view_mode, $langcode);
|
||||
foreach ($entities_by_view_mode as $entity_view_mode => $entities) {
|
||||
field_attach_prepare_view('node', $entities, $entity_view_mode, $langcode);
|
||||
entity_prepare_view('node', $entities, $langcode);
|
||||
|
||||
foreach ($entities as $entity) {
|
||||
$build['nodes'][$entity->nid] = node_view($entity, $entity_view_mode, $langcode);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
$build['nodes'][$node->nid] = node_view($node, $view_mode, $langcode);
|
||||
$build['nodes'][$node->nid]['#weight'] = $weight;
|
||||
$weight++;
|
||||
}
|
||||
// Sort here, to preserve the input order of the entities that were passed to
|
||||
// this function.
|
||||
uasort($build['nodes'], 'element_sort');
|
||||
$build['nodes']['#sorted'] = TRUE;
|
||||
|
||||
return $build;
|
||||
}
|
||||
|
||||
@@ -2952,7 +2953,10 @@ function node_search_validate($form, &$form_state) {
|
||||
* system. When adding a node listing to your module, be sure to use a dynamic
|
||||
* query created by db_select() and add a tag of "node_access". This will allow
|
||||
* modules dealing with node access to ensure only nodes to which the user has
|
||||
* access are retrieved, through the use of hook_query_TAG_alter().
|
||||
* access are retrieved, through the use of hook_query_TAG_alter(). Tagging a
|
||||
* query with "node_access" does not check the published/unpublished status of
|
||||
* nodes, so the base query is responsible for ensuring that unpublished nodes
|
||||
* are not displayed to inappropriate users.
|
||||
*
|
||||
* Note: Even a single module returning NODE_ACCESS_DENY from hook_node_access()
|
||||
* will block access to the node. Therefore, implementers should take care to
|
||||
@@ -3295,6 +3299,17 @@ function node_query_entity_field_access_alter(QueryAlterableInterface $query) {
|
||||
/**
|
||||
* Helper for node access functions.
|
||||
*
|
||||
* Queries tagged with 'node_access' that are not against the {node} table
|
||||
* should add the base table as metadata. For example:
|
||||
* @code
|
||||
* $query
|
||||
* ->addTag('node_access')
|
||||
* ->addMetaData('base_table', 'taxonomy_index');
|
||||
* @endcode
|
||||
* If the query is not against the {node} table, an attempt is made to guess
|
||||
* the table, but is not recommended to rely on this as it is deprecated and not
|
||||
* allowed in Drupal 8. It is always safer to provide the table.
|
||||
*
|
||||
* @param $query
|
||||
* The query to add conditions to.
|
||||
* @param $type
|
||||
@@ -3623,7 +3638,8 @@ function node_access_rebuild($batch_mode = FALSE) {
|
||||
// Try to allocate enough time to rebuild node grants
|
||||
drupal_set_time_limit(240);
|
||||
|
||||
$nids = db_query("SELECT nid FROM {node}")->fetchCol();
|
||||
// Rebuild newest nodes first so that recent content becomes available quickly.
|
||||
$nids = db_query("SELECT nid FROM {node} ORDER BY nid DESC")->fetchCol();
|
||||
foreach ($nids as $nid) {
|
||||
$node = node_load($nid, NULL, TRUE);
|
||||
// To preserve database integrity, only acquire grants if the node
|
||||
@@ -3656,6 +3672,8 @@ function node_access_rebuild($batch_mode = FALSE) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_operation().
|
||||
*
|
||||
* Performs batch operation for node_access_rebuild().
|
||||
*
|
||||
* This is a multistep operation: we go through all nodes by packs of 20. The
|
||||
@@ -3670,7 +3688,7 @@ function _node_access_rebuild_batch_operation(&$context) {
|
||||
// Initiate multistep processing.
|
||||
$context['sandbox']['progress'] = 0;
|
||||
$context['sandbox']['current_node'] = 0;
|
||||
$context['sandbox']['max'] = db_query('SELECT COUNT(DISTINCT nid) FROM {node}')->fetchField();
|
||||
$context['sandbox']['max'] = db_query('SELECT COUNT(nid) FROM {node}')->fetchField();
|
||||
}
|
||||
|
||||
// Process the next 20 nodes.
|
||||
@@ -3694,6 +3712,8 @@ function _node_access_rebuild_batch_operation(&$context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements callback_batch_finished().
|
||||
*
|
||||
* Performs post-processing for node_access_rebuild().
|
||||
*
|
||||
* @param bool $success
|
||||
|
||||
+20
-17
@@ -371,35 +371,37 @@ function node_form_build_preview($form, &$form_state) {
|
||||
* @see node_form_build_preview()
|
||||
*/
|
||||
function node_preview($node) {
|
||||
if (node_access('create', $node) || node_access('update', $node)) {
|
||||
_field_invoke_multiple('load', 'node', array($node->nid => $node));
|
||||
// Clone the node before previewing it to prevent the node itself from being
|
||||
// modified.
|
||||
$cloned_node = clone $node;
|
||||
if (node_access('create', $cloned_node) || node_access('update', $cloned_node)) {
|
||||
_field_invoke_multiple('load', 'node', array($cloned_node->nid => $cloned_node));
|
||||
// Load the user's name when needed.
|
||||
if (isset($node->name)) {
|
||||
if (isset($cloned_node->name)) {
|
||||
// The use of isset() is mandatory in the context of user IDs, because
|
||||
// user ID 0 denotes the anonymous user.
|
||||
if ($user = user_load_by_name($node->name)) {
|
||||
$node->uid = $user->uid;
|
||||
$node->picture = $user->picture;
|
||||
if ($user = user_load_by_name($cloned_node->name)) {
|
||||
$cloned_node->uid = $user->uid;
|
||||
$cloned_node->picture = $user->picture;
|
||||
}
|
||||
else {
|
||||
$node->uid = 0; // anonymous user
|
||||
$cloned_node->uid = 0; // anonymous user
|
||||
}
|
||||
}
|
||||
elseif ($node->uid) {
|
||||
$user = user_load($node->uid);
|
||||
$node->name = $user->name;
|
||||
$node->picture = $user->picture;
|
||||
elseif ($cloned_node->uid) {
|
||||
$user = user_load($cloned_node->uid);
|
||||
$cloned_node->name = $user->name;
|
||||
$cloned_node->picture = $user->picture;
|
||||
}
|
||||
|
||||
$node->changed = REQUEST_TIME;
|
||||
$nodes = array($node->nid => $node);
|
||||
field_attach_prepare_view('node', $nodes, 'full');
|
||||
$cloned_node->changed = REQUEST_TIME;
|
||||
$nodes = array($cloned_node->nid => $cloned_node);
|
||||
|
||||
// Display a preview of the node.
|
||||
if (!form_get_errors()) {
|
||||
$node->in_preview = TRUE;
|
||||
$output = theme('node_preview', array('node' => $node));
|
||||
unset($node->in_preview);
|
||||
$cloned_node->in_preview = TRUE;
|
||||
$output = theme('node_preview', array('node' => $cloned_node));
|
||||
unset($cloned_node->in_preview);
|
||||
}
|
||||
drupal_set_title(t('Preview'), PASS_THROUGH);
|
||||
|
||||
@@ -542,6 +544,7 @@ function node_delete_confirm_submit($form, &$form_state) {
|
||||
if ($form_state['values']['confirm']) {
|
||||
$node = node_load($form_state['values']['nid']);
|
||||
node_delete($form_state['values']['nid']);
|
||||
cache_clear_all();
|
||||
watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
|
||||
drupal_set_message(t('@type %title has been deleted.', array('@type' => node_type_get_name($node), '%title' => $node->title)));
|
||||
}
|
||||
|
||||
+519
-198
File diff suppressed because it is too large
Load Diff
@@ -136,10 +136,29 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
|
||||
case 'body':
|
||||
case 'summary':
|
||||
if ($items = field_get_items('node', $node, 'body', $language_code)) {
|
||||
$column = ($name == 'body') ? 'value' : 'summary';
|
||||
$instance = field_info_instance('node', 'body', $node->type);
|
||||
$field_langcode = field_language('node', $node, 'body', $language_code);
|
||||
$replacements[$original] = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], $column) : $items[0][$column];
|
||||
// If the summary was requested and is not empty, use it.
|
||||
if ($name == 'summary' && !empty($items[0]['summary'])) {
|
||||
$output = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'summary') : $items[0]['summary'];
|
||||
}
|
||||
// Attempt to provide a suitable version of the 'body' field.
|
||||
else {
|
||||
$output = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'value') : $items[0]['value'];
|
||||
// A summary was requested.
|
||||
if ($name == 'summary') {
|
||||
if (isset($instance['display']['teaser']['settings']['trim_length'])) {
|
||||
$trim_length = $instance['display']['teaser']['settings']['trim_length'];
|
||||
}
|
||||
else {
|
||||
// Use default value.
|
||||
$trim_length = NULL;
|
||||
}
|
||||
// Generate an optionally trimmed summary of the body field.
|
||||
$output = text_summary($output, $instance['settings']['text_processing'] ? $items[0]['format'] : NULL, $trim_length);
|
||||
}
|
||||
}
|
||||
$replacements[$original] = $output;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-04-03
|
||||
version = "7.22"
|
||||
; Information added by Drupal.org packaging script on 2020-09-16
|
||||
version = "7.73"
|
||||
project = "drupal"
|
||||
datestamp = "1365027012"
|
||||
|
||||
datestamp = "1600272641"
|
||||
|
||||
@@ -211,7 +211,7 @@ function node_access_test_node_insert($node) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_nodeapi_update().
|
||||
* Implements hook_node_update().
|
||||
*/
|
||||
function node_access_test_node_update($node) {
|
||||
_node_access_test_node_write($node);
|
||||
|
||||
@@ -5,8 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-04-03
|
||||
version = "7.22"
|
||||
; Information added by Drupal.org packaging script on 2020-09-16
|
||||
version = "7.73"
|
||||
project = "drupal"
|
||||
datestamp = "1365027012"
|
||||
|
||||
datestamp = "1600272641"
|
||||
|
||||
@@ -161,3 +161,21 @@ function node_test_entity_view_mode_alter(&$view_mode, $context) {
|
||||
$view_mode = $change_view_mode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_node_insert().
|
||||
*
|
||||
* This tests saving a node on node insert.
|
||||
*
|
||||
* @see NodeSaveTest::testNodeSaveOnInsert()
|
||||
*/
|
||||
function node_test_node_insert($node) {
|
||||
// Set the node title to the node ID and save.
|
||||
if ($node->title == 'new') {
|
||||
$node->title = 'Node '. $node->nid;
|
||||
// Remove the is_new flag, so that the node is updated and not inserted
|
||||
// again.
|
||||
unset($node->is_new);
|
||||
node_save($node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-04-03
|
||||
version = "7.22"
|
||||
; Information added by Drupal.org packaging script on 2020-09-16
|
||||
version = "7.73"
|
||||
project = "drupal"
|
||||
datestamp = "1365027012"
|
||||
|
||||
datestamp = "1600272641"
|
||||
|
||||
Reference in New Issue
Block a user