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

@@ -190,8 +190,8 @@ function rules_upgrade_convert_rule_set($name, $cfg_old) {
$config = rules_plugin_factory('rule set');
$config->name = $name;
foreach (array('label', 'weight') as $key) {
if (isset($element[$key])) {
$target->$key = $element[$key];
if (isset($cfg_old[$key])) {
$config->$key = $cfg_old[$key];
}
}
if (isset($cfg_old['arguments'])) {

View File

@@ -74,7 +74,8 @@ function rules_action_data_calc($input1, $op, $input2, $settings, $state, $eleme
}
if (isset($result)) {
// Ensure results are valid integer values if necessary.
$var_info = rules_array_key($element->providesVariables());
$variables = $element->providesVariables();
$var_info = reset($variables);
if ($var_info['type'] == 'integer') {
$result = (int) $result;
}

View File

@@ -141,14 +141,14 @@ function rules_action_entity_delete($wrapper, $settings, $state, $element) {
* Condition: Entity is new.
*/
function rules_condition_entity_is_new($wrapper, $settings, $state, $element) {
return !$wrapper->getIdentifier() || !empty($entity->is_new);
return !$wrapper->getIdentifier() || !empty($wrapper->value()->is_new);
}
/**
* Condition: Entity has field.
*/
function rules_condition_entity_has_field($wrapper, $field_name, $settings, $state) {
return isset($wrapper->$field_name) || isset($entity->$field_name);
return isset($wrapper->$field_name) || isset($wrapper->value()->$field_name);
}
/**
@@ -157,3 +157,18 @@ function rules_condition_entity_has_field($wrapper, $field_name, $settings, $sta
function rules_condition_entity_is_of_type($wrapper, $type) {
return $wrapper->type() == $type;
}
/**
* Condition: Entity is of type and bundle.
*/
function rules_condition_entity_is_of_bundle($wrapper, $type, $bundles) {
return $wrapper->type() == $type && in_array($wrapper->getBundle(), $bundles);
}
/**
* Condition: User has access to field.
*/
function rules_condition_entity_field_access(EntityDrupalWrapper $wrapper, $field_name, $op, $account = NULL) {
$field = field_info_field($field_name);
return !empty($field) && field_access($op, $field, $wrapper->type(), $wrapper->value(), $account = NULL);
}

View File

@@ -268,6 +268,23 @@ function rules_entity_type_options($key = NULL) {
return $types;
}
/**
* Options list callback for getting a list of possible entity bundles.
*
* @param $element
* The element to return options for.
*/
function rules_entity_bundle_options(RulesAbstractPlugin $element) {
$bundles = array();
if (isset($element->settings['type'])) {
$entity_info = entity_get_info($element->settings['type']);
foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
$bundles[$bundle_name] = $bundle_info['label'];
}
}
return $bundles;
}
/**
* Entity actions access callback.
*
@@ -348,6 +365,69 @@ function rules_entity_condition_info() {
'group' => t('Entities'),
'base' => 'rules_condition_entity_is_of_type',
),
'entity_is_of_bundle' => array(
'label' => t('Entity is of bundle'),
'parameter' => array(
'entity' => array(
'type' => 'entity',
'label' => t('Entity'),
'description' => t('Specifies the entity for which to evaluate the condition.'),
),
'type' => array(
'type' => 'token',
'label' => t('Entity type'),
'description' => t('The type of the checked entity.'),
'options list' => 'rules_entity_action_type_options',
'restriction' => 'input',
),
'bundle' => array(
'type' => 'list<text>',
'label' => t('Entity bundle'),
'description' => t('The condition is met if the entity is of one of the selected bundles.'),
'options list' => 'rules_entity_bundle_options',
'restriction' => 'input',
),
),
'group' => t('Entities'),
'base' => 'rules_condition_entity_is_of_bundle',
),
'entity_field_access' => array(
'label' => t('User has field access'),
'parameter' => array(
'entity' => array(
'type' => 'entity',
'label' => t('Entity'),
'description' => t('Specifies the entity for which to evaluate the condition.'),
'restriction' => 'selector',
'wrapped' => TRUE,
),
'field' => array(
'type' => 'token',
'label' => t('Field name'),
'description' => t('The name of the field to check for.'),
'options list' => 'rules_condition_entity_has_field_options',
'restriction' => 'input',
),
'op' => array(
'type' => 'text',
'label' => t('Access operation'),
'options list' => 'rules_condition_entity_field_access_op_options',
'restriction' => 'input',
'optional' => TRUE,
'default value' => 'view',
),
'account' => array(
'type' => 'user',
'label' => t('User account'),
'description' => t('Specifies the user account for which to check access. If left empty, the currently logged in user will be used.'),
'restriction' => 'selector',
'optional' => TRUE,
'default value' => NULL,
),
),
'group' => t('Entities'),
'base' => 'rules_condition_entity_field_access',
),
);
}
@@ -369,6 +449,16 @@ function rules_condition_entity_has_field_options(RulesAbstractPlugin $element)
return $options;
}
/**
* Returns options for choosing a field_access() operation.
*/
function rules_condition_entity_field_access_op_options(RulesAbstractPlugin $element) {
return array(
'view' => t('View'),
'edit' => t('Edit'),
);
}
/**
* Assert that the entity has the field, if there is metadata for the field.
*/
@@ -396,6 +486,81 @@ function rules_condition_entity_is_of_type_assertions($element) {
}
}
/**
* Assert the selected entity type and bundle.
*/
function rules_condition_entity_is_of_bundle_assertions($element) {
if ($bundle = $element->settings['bundle']) {
$assertions = array();
$assertions['entity']['type'] = $element->settings['type'];
$assertions['entity']['bundle'] = $bundle;
return $assertions;
}
}
/**
* Process callback for the condition entity_is_of_bundle.
*/
function rules_condition_entity_is_of_bundle_process(RulesAbstractPlugin $element) {
// If we know the entity type, auto-populate it.
if (($info = $element->getArgumentInfo('entity')) && $info['type'] != 'entity') {
$element->settings['type'] = $info['type'];
}
}
/**
* Form alter callback for the condition entity_is_of_bundle.
*
* Use multiple steps to configure the condition as the needed bundle field list
* depends on the selected entity type.
*/
function rules_condition_entity_is_of_bundle_form_alter(&$form, &$form_state, $options, RulesAbstractPlugin $element) {
if (empty($element->settings['entity:select'])) {
$step = 1;
}
elseif (empty($element->settings['type'])) {
$step = 2;
}
else {
$step = 3;
}
$form['reload'] = array(
'#weight' => $form['submit']['#weight'] + 1,
'#type' => 'submit',
'#name' => 'reload',
'#value' => $step != 3 ? t('Continue') : t('Reload form'),
'#limit_validation_errors' => array(array('parameter', 'entity'), array('parameter', 'type')),
'#submit' => array('rules_form_submit_rebuild'),
'#ajax' => rules_ui_form_default_ajax('fade'),
'#attributes' => array('class' => array('rules-hide-js')),
);
// Use ajax and trigger as the reload button.
$form['parameter']['type']['settings']['type']['#ajax'] = $form['reload']['#ajax'] + array(
'event' => 'change',
'trigger_as' => array('name' => 'reload'),
);
switch ($step) {
case 1:
$form['reload']['#limit_validation_errors'] = array(array('parameter', 'entity'));
unset($form['parameter']['type']);
unset($form['reload']['#attributes']['class']);
// NO break;
case 2:
$form['negate']['#access'] = FALSE;
unset($form['parameter']['bundle']);
unset($form['submit']);
break;
case 3:
if (($info = $element->getArgumentInfo('entity')) && $info['type'] != 'entity') {
// Hide the entity type parameter if not needed.
unset($form['parameter']['type']);
}
break;
}
}
/**
* @}
*/

View File

@@ -19,9 +19,9 @@ files[] = ui/ui.plugins.inc
dependencies[] = entity_token
dependencies[] = entity
; Information added by drupal.org packaging script on 2012-10-23
version = "7.x-2.2+5-dev"
; Information added by drupal.org packaging script on 2013-03-27
version = "7.x-2.3"
core = "7.x"
project = "rules"
datestamp = "1350998486"
datestamp = "1364401818"

View File

@@ -128,7 +128,8 @@ function rules_schema() {
),
'primary key' => array('id', 'event'),
'foreign keys' => array(
'id' => array('rules_config' => 'id'),
'table' => 'rules_config',
'columns' => array('id' => 'id'),
),
);
$schema['rules_tags'] = array(
@@ -148,7 +149,8 @@ function rules_schema() {
),
'primary key' => array('id', 'tag'),
'foreign keys' => array(
'id' => array('rules_config' => 'id'),
'table' => 'rules_config',
'columns' => array('id' => 'id'),
),
);
$schema['rules_dependencies'] = array(
@@ -171,7 +173,8 @@ function rules_schema() {
'module' => array('module'),
),
'foreign keys' => array(
'id' => array('rules_config' => 'id'),
'table' => 'rules_config',
'columns' => array('id' => 'id'),
),
);
$schema['cache_rules'] = drupal_get_schema_unprocessed('system', 'cache');
@@ -269,7 +272,8 @@ function rules_update_7200() {
),
'primary key' => array('id', 'event'),
'foreign keys' => array(
'id' => array('rules_config' => 'id'),
'table' => 'rules_config',
'columns' => array('id' => 'id'),
),
);
db_create_table('rules_config', $schema['rules_config']);
@@ -353,7 +357,8 @@ function rules_update_7204() {
),
'primary key' => array('id', 'tag'),
'foreign keys' => array(
'id' => array('rules_config' => 'id'),
'table' => 'rules_config',
'columns' => array('id' => 'id'),
),
);
db_create_table('rules_tags', $schema['rules_tags']);
@@ -385,7 +390,8 @@ function rules_update_7205() {
'module' => array('module'),
),
'foreign keys' => array(
'id' => array('rules_config' => 'id'),
'table' => 'rules_config',
'columns' => array('id' => 'id'),
),
);
db_create_table('rules_dependencies', $schema['rules_dependencies']);

View File

@@ -6,9 +6,9 @@ files[] = rules_admin.module
files[] = rules_admin.inc
dependencies[] = rules
; Information added by drupal.org packaging script on 2012-10-23
version = "7.x-2.2+5-dev"
; Information added by drupal.org packaging script on 2013-03-27
version = "7.x-2.3"
core = "7.x"
project = "rules"
datestamp = "1350998486"
datestamp = "1364401818"

View File

@@ -7,9 +7,9 @@ core = 7.x
files[] = rules_i18n.i18n.inc
files[] = rules_i18n.rules.inc
files[] = rules_i18n.test
; Information added by drupal.org packaging script on 2012-10-23
version = "7.x-2.2+5-dev"
; Information added by drupal.org packaging script on 2013-03-27
version = "7.x-2.3"
core = "7.x"
project = "rules"
datestamp = "1350998486"
datestamp = "1364401818"

View File

@@ -12,9 +12,9 @@ files[] = includes/rules_scheduler.views_default.inc
files[] = includes/rules_scheduler.views.inc
files[] = includes/rules_scheduler_views_filter.inc
; Information added by drupal.org packaging script on 2012-10-23
version = "7.x-2.2+5-dev"
; Information added by drupal.org packaging script on 2013-03-27
version = "7.x-2.3"
core = "7.x"
project = "rules"
datestamp = "1350998486"
datestamp = "1364401818"

View File

@@ -1455,6 +1455,57 @@ class RulesIntegrationTestCase extends DrupalWebTestCase {
function testEntityIntegration() {
global $user;
$page = $this->drupalCreateNode(array('type' => 'page'));
$article = $this->drupalCreateNode(array('type' => 'article'));
$result = rules_condition('entity_field_access')
->execute(entity_metadata_wrapper('node', $article), 'field_tags');
$this->assertTrue($result);
// Test entiy_is_of_bundle condition.
$result = rules_condition('entity_is_of_bundle', array(
'type' => 'node',
'bundle' => array('article'),
))->execute(entity_metadata_wrapper('node', $page));
$this->assertFalse($result, 'Entity is of bundle condition has not been met.');
$result = rules_condition('entity_is_of_bundle', array(
'type' => 'node',
'bundle' => array('article'),
))->execute(entity_metadata_wrapper('node', $article));
$this->assertTrue($result, 'Entity is of bundle condition has been met.');
// Also test a full rule so the integrity check must work.
$term_wrapped = entity_property_values_create_entity('taxonomy_term', array(
'name' => $this->randomName(),
'vocabulary' => 1,
))->save();
$rule = rule(array(
'node' => array('type' => 'node'),
));
$rule->condition('entity_is_of_bundle', array(
'entity:select' => 'node',
'bundle' => array('article'),
));
$rule->action('data_set', array('data:select' => 'node:field_tags', 'value' => array($term_wrapped->getIdentifier())));
$rule->integrityCheck();
$rule->execute($article);
$this->assertEqual($term_wrapped->getIdentifier(), $article->field_tags[LANGUAGE_NONE][0]['tid'], 'Entity is of bundle condition has been met.');
// Test again using an entity variable.
$article = $this->drupalCreateNode(array('type' => 'article'));
$rule = rule(array(
'entity' => array('type' => 'entity'),
));
$rule->condition('entity_is_of_bundle', array(
'entity:select' => 'entity',
'type' => 'node',
'bundle' => array('article'),
));
$rule->action('data_set', array('data:select' => 'entity:field_tags', 'value' => array($term_wrapped->getIdentifier())));
$rule->integrityCheck();
$rule->execute(entity_metadata_wrapper('node', $article));
$this->assertEqual($term_wrapped->getIdentifier(), $article->field_tags[LANGUAGE_NONE][0]['tid'], 'Entity is of bundle condition has been met.');
// Test CRUD actions.
$action = rules_action('entity_create', array(
'type' => 'node',
@@ -1883,8 +1934,11 @@ class RulesIntegrationTestCase extends DrupalWebTestCase {
// Test sending mail to all users of a role. First make sure there is a
// custom role and a user for it.
$user = $this->drupalCreateUser(array('administer nodes'));
$roles = array_keys($user->roles);
rules_action('mail_to_users_of_role', $settings + array('roles' => $roles))->execute();
$roles = $user->roles;
// Remove the authenticate role so we only use the new role created by
// drupalCreateUser().
unset($roles[DRUPAL_AUTHENTICATED_RID]);
rules_action('mail_to_users_of_role', $settings + array('roles' => array_keys($roles)))->execute();
$this->assertMail('to', $user->mail, 'Mail to users of a role has been sent.');
// Test reacting on new log entries and make sure the log entry is usable.

View File

@@ -6,9 +6,9 @@ files[] = rules_test.rules.inc
files[] = rules_test.rules_defaults.inc
hidden = TRUE
; Information added by drupal.org packaging script on 2012-10-23
version = "7.x-2.2+5-dev"
; Information added by drupal.org packaging script on 2013-03-27
version = "7.x-2.3"
core = "7.x"
project = "rules"
datestamp = "1350998486"
datestamp = "1364401818"

View File

@@ -1087,7 +1087,7 @@ class RulesContainerPluginUI extends RulesPluginUI {
'#theme' => 'rules_content_group',
'#caption' => t('Tags'),
'tags' => array(
'#markup' => implode(', ', $this->element->tags),
'#markup' => check_plain(drupal_implode_tags($this->element->tags)),
),
);
}

View File

@@ -616,7 +616,7 @@ function rules_ui_form_data_selection_auto_completion($parameter, $form_build_id
else {
$text = check_plain($selector) . ' (' . check_plain($info['label']) . ')';
}
$matches[$selector] = "<div" . drupal_attributes($attributes) . ">$text</div";
$matches[$selector] = "<div" . drupal_attributes($attributes) . ">$text</div>";
}
}
}