security update core+modules

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-26 18:38:56 +02:00
parent 2f45ea820a
commit 7c96373038
1022 changed files with 30319 additions and 11259 deletions

View File

@@ -17,7 +17,11 @@ $plugin = array(
'settings form' => 'ctools_term_vocabulary_ctools_access_settings',
'settings form submit' => 'ctools_term_vocabulary_ctools_access_settings_submit',
'summary' => 'ctools_term_vocabulary_ctools_access_summary',
'required context' => new ctools_context_required(t('Vocabulary'), array('taxonomy_term', 'terms', 'taxonomy_vocabulary')),
'required context' => new ctools_context_required(t('Vocabulary'), array(
'taxonomy_term',
'terms',
'taxonomy_vocabulary'
)),
);
/**
@@ -27,15 +31,17 @@ function ctools_term_vocabulary_ctools_access_settings($form, &$form_state, $con
$options = array();
$vocabularies = taxonomy_get_vocabularies();
foreach ($vocabularies as $voc) {
$options[$voc->vid] = check_plain($voc->name);
$options[$voc->machine_name] = check_plain($voc->name);
}
$form['settings']['vids'] = array(
_ctools_term_vocabulary_ctools_access_map_vids($conf);
$form['settings']['machine_name'] = array(
'#type' => 'checkboxes',
'#title' => t('Vocabularies'),
'#options' => $options,
'#description' => t('Only the checked vocabularies will be valid.'),
'#default_value' => $conf['vids'],
'#default_value' => $conf['machine_name'],
);
return $form;
}
@@ -44,7 +50,7 @@ function ctools_term_vocabulary_ctools_access_settings($form, &$form_state, $con
* Compress the term_vocabularys allowed to the minimum.
*/
function ctools_term_vocabulary_ctools_access_settings_submit($form, &$form_state) {
$form_state['values']['settings']['vids'] = array_filter($form_state['values']['settings']['vids']);
$form_state['values']['settings']['machine_name'] = array_filter($form_state['values']['settings']['machine_name']);
}
/**
@@ -53,11 +59,13 @@ function ctools_term_vocabulary_ctools_access_settings_submit($form, &$form_stat
function ctools_term_vocabulary_ctools_access_check($conf, $context) {
// As far as I know there should always be a context at this point, but this
// is safe.
if (empty($context) || empty($context->data) || empty($context->data->vid)) {
if (empty($context) || empty($context->data) || empty($context->data->vocabulary_machine_name)) {
return FALSE;
}
if (array_filter($conf['vids']) && empty($conf['vids'][$context->data->vid])) {
_ctools_term_vocabulary_ctools_access_map_vids($conf);
if (array_filter($conf['machine_name']) && empty($conf['machine_name'][$context->data->vocabulary_machine_name])) {
return FALSE;
}
@@ -73,15 +81,47 @@ function ctools_term_vocabulary_ctools_access_summary($conf, $context) {
}
$vocabularies = taxonomy_get_vocabularies();
_ctools_term_vocabulary_ctools_access_map_vids($conf);
$names = array();
foreach (array_filter($conf['vids']) as $vid) {
$names[] = check_plain($vocabularies[$vid]->name);
if (!empty($conf['machine_name'])) {
foreach (array_filter($conf['machine_name']) as $machine_name) {
foreach ($vocabularies as $vocabulary) {
if ($vocabulary->machine_name === $machine_name) {
$names[] = check_plain($vocabulary->name);
continue;
}
}
}
}
if (empty($names)) {
return t('@identifier is any vocabulary', array('@identifier' => $context->identifier));
}
return format_plural(count($names), '@identifier vocabulary is "@vids"', '@identifier vocabulary is one of "@vids"', array('@vids' => implode(', ', $names), '@identifier' => $context->identifier));
return format_plural(count($names), '@identifier vocabulary is "@machine_names"', '@identifier vocabulary is one of "@machine_names"', array(
'@machine_names' => implode(', ', $names),
'@identifier' => $context->identifier
));
}
/**
* Helper function to map the vids from old features to the new machine_name.
*
* Add the machine_name key to $conf if the vids key exist.
*
* @param array $conf
* The configuration of this plugin.
*/
function _ctools_term_vocabulary_ctools_access_map_vids(&$conf) {
if (!empty($conf['vids'])) {
$conf['machine_name'] = array();
$vocabularies = taxonomy_get_vocabularies();
foreach ($conf['vids'] as $vid) {
$machine_name = $vocabularies[$vid]->machine_name;
$conf['machine_name'][$machine_name] = $vocabularies[$vid]->machine_name;
}
}
}