security update for contrib modules
This commit is contained in:
@@ -140,7 +140,7 @@ function ctools_entity_from_field_get_children($parent_plugin, $parent) {
|
||||
|
||||
$plugin_entities = array(
|
||||
'to' => array($to_entity => $to_entity_info),
|
||||
'from' => array($from_entity => $from_entity_info)
|
||||
'from' => array($from_entity => $from_entity_info),
|
||||
);
|
||||
drupal_alter('ctools_entity_context', $plugins[$key], $plugin_entities, $key);
|
||||
}
|
||||
@@ -185,7 +185,7 @@ function ctools_entity_from_field_context($context, $conf) {
|
||||
$loaded_to_entity = array_shift($loaded_to_entity);
|
||||
|
||||
// Pass current user account and entity type to access callback.
|
||||
if (function_exists($to_entity_info['access callback']) && !call_user_func($to_entity_info['access callback'], 'view', $loaded_to_entity, $account, $to_entity)) {
|
||||
if (isset($to_entity_info['access callback']) && function_exists($to_entity_info['access callback']) && !call_user_func($to_entity_info['access callback'], 'view', $loaded_to_entity, $account, $to_entity)) {
|
||||
return ctools_context_create_empty('entity:' . $to_entity, NULL);
|
||||
}
|
||||
else {
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Plugin to provide an relationship handler for entities from query string.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugins are described by creating a $plugin array which will be used
|
||||
* by the system that includes this file.
|
||||
*/
|
||||
$plugin = array(
|
||||
'title' => t('Entity from query string'),
|
||||
'keyword' => 'query_string_entity',
|
||||
'description' => t('Entity from query string.'),
|
||||
'required context' => new ctools_context_required(t('Query string'), 'query_string'),
|
||||
'context' => 'ctools_entity_from_query_string_context',
|
||||
'edit form' => 'ctools_entity_from_query_string_settings_form',
|
||||
);
|
||||
|
||||
/**
|
||||
* Return a new context based on an existing context.
|
||||
*/
|
||||
function ctools_entity_from_query_string_context($context, $conf) {
|
||||
$entity_type = $conf['entity_type'];
|
||||
|
||||
// If unset it wants a generic, unfilled context, which is just NULL.
|
||||
if (empty($context->data) || !isset($context->data) || !is_numeric($context->data)) {
|
||||
return ctools_context_create_empty('entity:' . $entity_type, NULL);
|
||||
}
|
||||
|
||||
if (!empty($context->data) && is_numeric($context->data)) {
|
||||
// Load the entity from the query string value.
|
||||
$entity_id = $context->data;
|
||||
$entity = entity_load_single($entity_type, $entity_id);
|
||||
|
||||
// Send it to ctools.
|
||||
return ctools_context_create('entity:' . $entity_type, $entity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings form for the relationship.
|
||||
*/
|
||||
function ctools_entity_from_query_string_settings_form($form, &$form_state) {
|
||||
|
||||
// Get all avalible enity types.
|
||||
foreach (entity_get_info() as $key => $value) {
|
||||
$entity_types[$key] = $value['label'];
|
||||
}
|
||||
|
||||
$form['entity_type'] = array(
|
||||
'#title' => t('Entity type'),
|
||||
'#description' => t('Choose entity type to load from query value'),
|
||||
'#type' => 'select',
|
||||
'#options' => $entity_types,
|
||||
);
|
||||
if (isset($form_state['conf']['entity_type'])) {
|
||||
$form['entity_type']['#default_value'] = $form_state['conf']['entity_type'];
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit handler; settings form for the context.
|
||||
*/
|
||||
function ctools_entity_from_query_string_settings_form_submit($form, &$form_state) {
|
||||
$form_state['conf']['entity_type'] = $form_state['values']['entity_type'];
|
||||
}
|
||||
@@ -88,7 +88,7 @@ function ctools_entity_from_schema_get_children($parent_plugin, $parent) {
|
||||
$plugin_entities = array('to' => $from_entity_info, 'from' => $to_entity_info);
|
||||
$plugin_entities = array('to' => array($from_entity => $from_entity_info), 'from' => array($to_entity => $to_entity_info));
|
||||
drupal_alter('ctools_entity_context', $plugin, $plugin_entities, $plugin_id);
|
||||
$plugins[$plugin_id] = $plugin;
|
||||
$plugins[$plugin_id] = $plugin;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file relationships/term_parent.inc
|
||||
* @file
|
||||
* Plugin to provide an relationship handler for term parent.
|
||||
*/
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ function ctools_terms_from_node_context($context, $conf) {
|
||||
// Collect all terms for the chosen vocabulary and concatenate them.
|
||||
$node = $context->data;
|
||||
$terms = array();
|
||||
|
||||
|
||||
$fields = field_info_instances('node', $node->type);
|
||||
foreach ($fields as $name => $info) {
|
||||
$field_info = field_info_field($name);
|
||||
@@ -43,8 +43,24 @@ function ctools_terms_from_node_context($context, $conf) {
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($field_info['type'] == 'entityreference' && $field_info['settings']['target_type'] == 'taxonomy_term') {
|
||||
$items = field_get_items('node', $node, $name);
|
||||
if (is_array($items)) {
|
||||
$tids = array();
|
||||
foreach ($items as $item) {
|
||||
$tids[] = $item['target_id'];
|
||||
}
|
||||
|
||||
$term_objects = taxonomy_term_load_multiple($tids);
|
||||
foreach ($term_objects as $term) {
|
||||
if (empty($conf['vocabulary']) || in_array($term->vocabulary_machine_name, $conf['vocabulary'])) {
|
||||
$terms[] = $term->tid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($terms)) {
|
||||
$all_terms = ctools_break_phrase(implode($conf['concatenator'], $terms));
|
||||
return ctools_context_create('terms', $all_terms);
|
||||
|
||||
+30
@@ -15,6 +15,8 @@ $plugin = array(
|
||||
'description' => t('Adds user category edit form from a user context.'),
|
||||
'required context' => new ctools_context_required(t('User'), 'user'),
|
||||
'context' => 'ctools_user_category_edit_form_from_user_context',
|
||||
'edit form' => 'ctools_user_category_edit_form_from_user_settings_form',
|
||||
'defaults' => array('category' => NULL),
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -25,7 +27,35 @@ function ctools_user_category_edit_form_from_user_context($context, $conf) {
|
||||
return ctools_context_create_empty('user_edit_form', NULL);
|
||||
}
|
||||
|
||||
if (!empty($conf['category'])) {
|
||||
return ctools_context_create('user_edit_form', $context->data, array('category' => $conf['category']));
|
||||
}
|
||||
|
||||
if (isset($context->data->user_category)) {
|
||||
return ctools_context_create('user_edit_form', $context->data, array('category' => $context->data->user_category));
|
||||
}
|
||||
|
||||
return ctools_context_create('user_edit_form', $context->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings form for the relationship.
|
||||
*/
|
||||
function ctools_user_category_edit_form_from_user_settings_form($form, &$form_state) {
|
||||
$conf = $form_state['conf'];
|
||||
|
||||
$categories = _user_categories();
|
||||
$options = array();
|
||||
foreach ($categories as $category) {
|
||||
$options[$category['name']] = $category['title'];
|
||||
}
|
||||
$form['category'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Category'),
|
||||
'#options' => $options,
|
||||
'#default_value' => isset($conf['category']) ? $conf['category'] : NULL,
|
||||
'#empty_option' => 'Default',
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user