security update for contrib modules

This commit is contained in:
2019-04-23 16:27:46 +02:00
parent 3c1b4f164e
commit 868629cbb2
729 changed files with 41254 additions and 20866 deletions
@@ -2,8 +2,7 @@
/**
* @file
*
* Plugin to provide an argument handler for all entity ids
* Plugin to provide an argument handler for all entity ids.
*/
/**
@@ -17,7 +16,7 @@ $plugin = array(
'get child' => 'ctools_argument_entity_id_get_child',
'get children' => 'ctools_argument_entity_id_get_children',
'default' => array(
'entity_id' => ''
'entity_id' => '',
),
'placeholder form' => 'ctools_argument_entity_id_ctools_argument_placeholder',
);
@@ -41,6 +40,7 @@ function ctools_argument_entity_id_get_children($original_plugin, $parent) {
$plugins[$plugin_id] = $plugin;
}
drupal_alter('ctools_entity_contexts', $plugins);
return $plugins;
}
@@ -60,9 +60,12 @@ function ctools_argument_entity_id_context($arg = NULL, $conf = NULL, $empty = F
return ctools_context_create('entity:' . $entity_type, $arg);
}
// Trim spaces and other garbage.
$arg = trim($arg);
if (!is_numeric($arg)) {
$preg_matches = array();
$match = preg_match('/\[id: (\d+)\]/', $arg, $preg_matches);
$match = preg_match('/\[id: (\d+)\]/', $arg, $preg_matches);
if (!$match) {
$match = preg_match('/^id: (\d+)/', $arg, $preg_matches);
}
@@ -70,18 +73,18 @@ function ctools_argument_entity_id_context($arg = NULL, $conf = NULL, $empty = F
if ($match) {
$id = $preg_matches[1];
}
if (is_numeric($id)) {
if (isset($id) && is_numeric($id)) {
return ctools_context_create('entity:' . $entity_type, $id);
}
return FALSE;
}
$entity = entity_load($entity_type, array($arg));
if (!$entity) {
$entities = entity_load($entity_type, array($arg));
if (empty($entities)) {
return FALSE;
}
return ctools_context_create('entity:' . $entity_type, $entity[$arg]);
return ctools_context_create('entity:' . $entity_type, reset($entities));
}
function ctools_argument_entity_id_settings_form(&$form, &$form_state, $conf) {
@@ -119,7 +122,7 @@ function ctools_argument_entity_id_settings_form(&$form, &$form_state, $conf) {
$form['settings']['entity_id'] = array(
'#type' => 'value',
'#value' => $conf['entity_id'],
'#value' => isset($conf['entity_id']) ? $conf['entity_id'] : '',
);
$form['settings']['entity_type'] = array(
@@ -132,11 +135,12 @@ function ctools_argument_entity_id_settings_form(&$form, &$form_state, $conf) {
function ctools_argument_entity_id_ctools_argument_placeholder($conf) {
$conf = array(
'#title' => t('Enter the title or ID of a @entity entity', array('@entity' => $conf['keyword'])),
'#type' => 'textfield',
'#maxlength' => 512,
'#title' => t('Enter the title or ID of a @entity entity', array('@entity' => $conf['keyword'])),
'#type' => 'textfield',
'#maxlength' => 512,
'#autocomplete_path' => 'ctools/autocomplete/' . $conf['keyword'],
'#weight' => -10,
'#weight' => -10,
);
return $conf;
}
@@ -2,8 +2,7 @@
/**
* @file
*
* Plugin to provide an argument handler for a node id
* Plugin to provide an argument handler for a node id.
*/
/**
@@ -47,4 +46,3 @@ function ctools_argument_nid_context($arg = NULL, $conf = NULL, $empty = FALSE)
return ctools_context_create('node', $node);
}
@@ -2,8 +2,7 @@
/**
* @file
*
* Plugin to provide an argument handler for a Node add form
* Plugin to provide an argument handler for a Node add form.
*/
/**
@@ -12,7 +11,7 @@
*/
$plugin = array(
'title' => t("Node add form: node type"),
// keyword to use for %substitution
// Keyword to use for %substitution.
'keyword' => 'node_type',
'description' => t('Creates a node add form context from a node type argument.'),
'context' => 'ctools_node_add_context',
@@ -29,4 +28,3 @@ function ctools_node_add_context($arg = NULL, $conf = NULL, $empty = FALSE) {
return ctools_context_create('node_add_form', $arg);
}
@@ -2,8 +2,7 @@
/**
* @file
*
* Plugin to provide an argument handler for a Node edit form
* Plugin to provide an argument handler for a Node edit form.
*/
/**
@@ -12,7 +11,7 @@
*/
$plugin = array(
'title' => t("Node edit form: node ID"),
// keyword to use for %substitution
// Keyword to use for %substitution.
'keyword' => 'node',
'description' => t('Creates a node edit form context from a node ID argument.'),
'context' => 'ctools_node_edit_context',
@@ -48,4 +47,3 @@ function ctools_node_edit_context($arg = NULL, $conf = NULL, $empty = FALSE) {
// This will perform a node_access check, so we don't have to.
return ctools_context_create('node_edit_form', $node);
}
@@ -2,8 +2,7 @@
/**
* @file
*
* Plugin to provide an argument handler for a node revision id
* Plugin to provide an argument handler for a node revision id.
*/
/**
@@ -47,4 +46,3 @@ function ctools_argument_rid_context($arg = NULL, $conf = NULL, $empty = FALSE)
return ctools_context_create('node', $node);
}
@@ -2,16 +2,16 @@
/**
* @file
*
* Plugin to provide an argument handler for a raw string
* Plugin to provide an argument handler for a raw string.
*/
/**
* Plugins are described by creating a $plugin array which will be used
* by the system that includes this file.
*/
$plugin = array(
'title' => t("String"),
// keyword to use for %substitution
// Keyword to use for %substitution.
'keyword' => 'string',
'description' => t('A string is a minimal context that simply holds a string that can be used for some other purpose.'),
'settings form' => 'ctools_string_settings_form',
@@ -20,7 +20,8 @@ $plugin = array(
'#type' => 'textfield',
'#description' => t('Enter a value for this argument'),
),
'path placeholder' => 'ctools_string_path_placeholder', // This is in pagemanager.
// This is in pagemanager.
'path placeholder' => 'ctools_string_path_placeholder',
);
/**
@@ -39,7 +40,7 @@ function ctools_string_context($arg = NULL, $conf = NULL, $empty = FALSE) {
}
/**
* Settings form for the argument
* Settings form for the argument.
*/
function ctools_string_settings_form(&$form, &$form_state, $conf) {
$form['settings']['use_tail'] = array(
@@ -48,7 +49,6 @@ function ctools_string_settings_form(&$form, &$form_state, $conf) {
'#default_value' => !empty($conf['use_tail']),
'#description' => t('If checked, this string will include all arguments. For example, if the path is "path/%" and the user visits "path/foo/bar", if this is not checked the string will be "foo". If it is checked the string will be "foo/bar".'),
);
// return $form;
}
/**
@@ -61,4 +61,4 @@ function ctools_string_path_placeholder($argument) {
else {
return '%pm_arg_tail';
}
}
}
@@ -2,8 +2,7 @@
/**
* @file
*
* Plugin to provide an argument handler for a Taxonomy term
* Plugin to provide an argument handler for a Taxonomy term.
*/
/**
@@ -12,12 +11,13 @@
*/
$plugin = array(
'title' => t("Taxonomy term: ID"),
// keyword to use for %substitution
// Keyword to use for %substitution.
'keyword' => 'term',
'description' => t('Creates a single taxonomy term from a taxonomy ID or taxonomy term name.'),
'context' => 'ctools_term_context',
'default' => array('input_form' => 'tid', 'breadcrumb' => TRUE, 'transform' => FALSE),
'settings form' => 'ctools_term_settings_form',
'settings form validate' => 'ctools_term_settings_form_validate',
'placeholder form' => 'ctools_term_ctools_argument_placeholder',
'breadcrumb' => 'ctools_term_breadcrumb',
);
@@ -31,6 +31,16 @@ function ctools_term_context($arg = NULL, $conf = NULL, $empty = FALSE) {
return ctools_context_create_empty('entity:taxonomy_term');
}
if (isset($conf['vocabularies'])) {
$vocabularies = $conf['vocabularies'];
}
else {
$vids = isset($conf['vids']) ? $conf['vids'] : array();
// Convert legacy use of vids to machine names.
$vocabularies = _ctools_term_vocabulary_machine_name_convert($vids);
}
if (is_object($arg)) {
$term = $arg;
}
@@ -50,14 +60,13 @@ function ctools_term_context($arg = NULL, $conf = NULL, $empty = FALSE) {
}
$terms = taxonomy_get_term_by_name($arg);
$conf['vids'] = is_array($conf['vids']) ? array_filter($conf['vids']) : NULL;
if ((count($terms) > 1) && isset($conf['vids'])) {
// If only one term is found, fall through to vocabulary check below.
if ((count($terms) > 1) && $vocabularies) {
foreach ($terms as $potential) {
foreach ($conf['vids'] as $vid => $active) {
if ($active && $potential->vid == $vid) {
foreach ($vocabularies as $machine_name) {
if ($potential->vocabulary_machine_name == $machine_name) {
$term = $potential;
// break out of the foreaches AND the case
// Break out of the foreaches AND the case.
break 3;
}
}
@@ -72,7 +81,7 @@ function ctools_term_context($arg = NULL, $conf = NULL, $empty = FALSE) {
}
}
if (!empty($conf['vids']) && array_filter($conf['vids']) && empty($conf['vids'][$term->vid])) {
if ($vocabularies && !isset($vocabularies[$term->vocabulary_machine_name])) {
return NULL;
}
@@ -82,7 +91,7 @@ function ctools_term_context($arg = NULL, $conf = NULL, $empty = FALSE) {
}
/**
* Settings form for the argument
* Settings form for the argument.
*/
function ctools_term_settings_form(&$form, &$form_state, $conf) {
// @todo allow synonym use like Views does.
@@ -98,13 +107,20 @@ function ctools_term_settings_form(&$form, &$form_state, $conf) {
$vocabularies = taxonomy_get_vocabularies();
$options = array();
foreach ($vocabularies as $vid => $vocab) {
$options[$vid] = $vocab->name;
$options[$vocab->machine_name] = $vocab->name;
}
$form['settings']['vids'] = array(
// Fallback on legacy 'vids', when no vocabularies are available.
if (empty($conf['vocabularies']) && !empty($conf['vids'])) {
$conf['vocabularies'] = _ctools_term_vocabulary_machine_name_convert(array_filter($conf['vids']));
unset($conf['vids']);
}
$form['settings']['vocabularies'] = array(
'#title' => t('Limit to these vocabularies'),
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => !empty($conf['vids']) ? $conf['vids'] : array(),
'#default_value' => !empty($conf['vocabularies']) ? $conf['vocabularies'] : array(),
'#description' => t('If no vocabularies are checked, terms from all vocabularies will be accepted.'),
);
@@ -120,7 +136,12 @@ function ctools_term_settings_form(&$form, &$form_state, $conf) {
'#type' => 'checkbox',
'#default_value' => !empty($conf['transform']),
);
// return $form;
}
function ctools_term_settings_form_validate(&$form, &$form_state) {
// Filter the selected vocabularies to avoid storing redundant data.
$vocabularies = array_filter($form_state['values']['settings']['vocabularies']);
form_set_value($form['settings']['vocabularies'], $vocabularies, $form_state);
}
/**
@@ -134,6 +155,7 @@ function ctools_term_ctools_argument_placeholder($conf) {
'#type' => 'textfield',
'#description' => t('Enter a taxonomy term ID.'),
);
case 'term':
return array(
'#type' => 'textfield',
@@ -161,3 +183,21 @@ function ctools_term_breadcrumb($conf, $context) {
$breadcrumb = array_merge(drupal_get_breadcrumb(), array_reverse($breadcrumb));
drupal_set_breadcrumb($breadcrumb);
}
/**
* Helper function to convert convert legacy vocabulary ids into machine names.
*
* @param array $vids
* Array of either vids.
*
* @return array
* A keyed array of machine names.
*/
function _ctools_term_vocabulary_machine_name_convert($vids) {
$vocabularies = taxonomy_vocabulary_load_multiple($vids);
$return = array();
foreach ($vocabularies as $vocabulary) {
$return[$vocabulary->machine_name] = $vocabulary->machine_name;
}
return $return;
}
@@ -2,8 +2,7 @@
/**
* @file
*
* Plugin to provide an argument handler for a Taxonomy term
* Plugin to provide an argument handler for a Taxonomy term.
*/
/**
@@ -12,7 +11,7 @@
*/
$plugin = array(
'title' => t("Taxonomy term (multiple): ID"),
// keyword to use for %substitution
// Keyword to use for %substitution.
'keyword' => 'term',
'description' => t('Creates a group of taxonomy terms from a list of tids separated by a comma or a plus sign. In general the first term of the list will be used for panes.'),
'context' => 'ctools_terms_context',
@@ -45,7 +44,7 @@ function ctools_terms_context($arg = NULL, $conf = NULL, $empty = FALSE) {
}
/**
* Settings form for the argument
* Settings form for the argument.
*/
function ctools_terms_settings_form(&$form, &$form_state, $conf) {
$form['settings']['breadcrumb'] = array(
@@ -54,7 +53,6 @@ function ctools_terms_settings_form(&$form, &$form_state, $conf) {
'#default_value' => !empty($conf['breadcrumb']),
'#description' => t('If checked, taxonomy term parents will appear in the breadcrumb trail.'),
);
// return $form;
}
/**
@@ -65,6 +63,7 @@ function ctools_terms_breadcrumb($conf, $context) {
return;
}
$current = new stdClass();
$current->tid = $context->tids[0];
$breadcrumb = array();
while ($parents = taxonomy_get_parents($current->tid)) {
@@ -2,8 +2,7 @@
/**
* @file
*
* Plugin to provide an argument handler for a user id
* Plugin to provide an argument handler for a user id.
*/
/**
@@ -12,7 +11,7 @@
*/
$plugin = array(
'title' => t("User: ID"),
// keyword to use for %substitution
// Keyword to use for %substitution.
'keyword' => 'user',
'description' => t('Creates a user context from a user ID argument.'),
'context' => 'ctools_argument_uid_context',
@@ -21,7 +20,8 @@ $plugin = array(
'#description' => t('Enter the user ID of a user for this argument'),
),
'default' => array('to_arg' => TRUE),
'path placeholder' => '%pm_uid_arg', // This is in pagemanager.
// This is in pagemanager.
'path placeholder' => '%pm_uid_arg',
'path placeholder to_arg' => TRUE,
'no ui' => TRUE,
);
@@ -2,8 +2,7 @@
/**
* @file
*
* Plugin to provide an argument handler for a Taxonomy term
* Plugin to provide an argument handler for a Taxonomy term.
*/
/**
@@ -12,7 +11,7 @@
*/
$plugin = array(
'title' => t("User edit form: User ID"),
// keyword to use for %substitution
// Keyword to use for %substitution.
'keyword' => 'user',
'description' => t('Creates a user edit form context from a user ID argument.'),
'context' => 'ctools_user_edit_context',
@@ -30,18 +29,18 @@ function ctools_user_edit_context($arg = NULL, $conf = NULL, $empty = FALSE) {
if ($empty) {
return ctools_context_create_empty('user_edit_form');
}
if(is_object($arg)){
if (is_object($arg)) {
return ctools_context_create('user_edit_form', $arg);
}
if (!is_numeric($arg)) {
return FALSE;
}
$account= user_load($arg);
$account = user_load($arg);
if (!$account) {
return NULL;
}
// This will perform a node_access check, so we don't have to.
return ctools_context_create('user_edit_form', $account);
}
}
@@ -2,8 +2,7 @@
/**
* @file
*
* Plugin to provide an argument handler for a username
* Plugin to provide an argument handler for a username.
*/
/**
@@ -12,7 +11,7 @@
*/
$plugin = array(
'title' => t("User: name"),
// keyword to use for %substitution
// Keyword to use for %substitution.
'keyword' => 'user',
'description' => t('Creates a user context from a user name.'),
'context' => 'ctools_argument_user_name_context',
@@ -42,6 +41,3 @@ function ctools_argument_user_name_context($arg = NULL, $conf = NULL, $empty = F
}
return ctools_context_create('user', $account);
}
@@ -2,8 +2,7 @@
/**
* @file
*
* Plugin to provide an argument handler for a vocabulary id
* Plugin to provide an argument handler for a vocabulary id.
*/
/**
@@ -12,7 +11,7 @@
*/
$plugin = array(
'title' => t("Vocabulary: ID"),
// keyword to use for %substitution
// Keyword to use for %substitution.
'keyword' => 'vocabulary',
'description' => t('Creates a vocabulary context from a vocabulary ID argument.'),
'context' => 'ctools_vid_context',
@@ -43,4 +42,3 @@ function ctools_vid_context($arg = NULL, $conf = NULL, $empty = FALSE) {
return ctools_context_create('vocabulary', $vocabulary);
}