non security modules update

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-20 16:32:07 +02:00
parent 6a8d30db08
commit 37fbabab56
466 changed files with 32690 additions and 9652 deletions

View File

@@ -19,16 +19,39 @@ function features_settings_form($form, $form_state) {
'#title' => t('Show components on create/edit feature form.'),
'#description' => t('Components with no options will not be shown no matter the setting below. Disabled components cannot be used with admin form.')
);
foreach ($components as $compontent => $info) {
$form['lock_components'] = array(
'#type' => 'fieldset',
'#title' => t('Lock components'),
'#description' => t('Locked components will be prevented from ever being reverted. For example, if site builder updates a feature with new settings for a field instance, but field instance is locked, it will not update that field. If the item is purely in code, like a view, the view changed when the code is updated no matter these settings.')
);
$form['features_lock_mode'] = array(
'#type' => 'radios',
'#title' => t('Features lock mode'),
'#options' => array(
'rebuild' => t('Allow rebuild (prevent revert)'),
'all' => t('Prevent rebuild and revert'),
),
'#description' => t('Rebuild will allow the feature to be updated till the point features has detected that the item has changed deliberately on the site, e.g. is overriden.'),
'#default_value' => variable_get('features_lock_mode', 'all'),
);
foreach ($components as $component => $info) {
if (empty($info['feature_source']) && empty($info['features_source'])) {
continue;
}
$form['show_components']['features_admin_show_component_' . $compontent] = array(
'#title' => t('@name (@machine)', array('@name' => $info['name'], '@machine' => $compontent)),
$form['show_components']['features_admin_show_component_' . $component] = array(
'#title' => t('@name (@machine)', array('@name' => $info['name'], '@machine' => $component)),
'#type' => 'checkbox',
'#default_value' => variable_get('features_admin_show_component_' . $compontent, TRUE),
'#default_value' => variable_get('features_admin_show_component_' . $component, TRUE),
);
if ($compontent == 'menu_links' && ($menus = menu_get_menus())) {
if (features_hook($component, 'features_revert') || features_hook($component, 'features_rebuild')) {
$form['lock_components']['features_component_locked_' . $component] = array(
'#title' => t('@name (@machine)', array('@name' => $info['name'], '@machine' => $component)),
'#type' => 'checkbox',
'#default_value' => variable_get('features_component_locked_' . $component, FALSE),
);
}
if ($component == 'menu_links' && ($menus = menu_get_menus())) {
$form['show_components']['features_admin_menu_links'] = array(
'#title' => t('Advanced Menu Link Settings'),
'#type' => 'fieldset',
@@ -104,23 +127,24 @@ function features_export_form($form, $form_state, $feature = NULL) {
'#description' => t('Example: Image gallery') . ' (' . t('Do not begin name with numbers.') . ')',
'#type' => 'textfield',
'#default_value' => !empty($feature->info['name']) ? $feature->info['name'] : '',
'#attributes' => array('class' => array('feature-name')),
);
$form['info']['module_name'] = array(
'#type' => 'textfield',
'#type' => 'machine_name',
'#title' => t('Machine-readable name'),
'#description' => t('Example: image_gallery') . '<br/>' . t('May only contain lowercase letters, numbers and underscores. <strong>Try to avoid conflicts with the names of existing Drupal projects.</strong>'),
'#required' => TRUE,
'#default_value' => $feature_name,
'#attributes' => array('class' => array('feature-module-name')),
'#element_validate' => array('features_export_form_validate_field'),
'#machine_name' => array(
'exists' => 'features_export_form_module_name_exists',
'source' => array('info', 'name'),
),
);
// If recreating this feature, disable machine name field and blank out
// js-attachment classes to ensure the machine name cannot be changed.
if (isset($feature)) {
// If recreating this feature, disable machine name field to ensure the
// machine name cannot be changed, unless user role has granted permission to
// edit machine name of disabled features.
if (isset($feature) && ($feature->status || !user_access('rename features'))) {
$form['info']['module_name']['#value'] = $feature_name;
$form['info']['module_name']['#disabled'] = TRUE;
$form['info']['name']['#attributes'] = array();
}
$form['info']['description'] = array(
'#title' => t('Description'),
@@ -223,6 +247,13 @@ function features_export_form($form, $form_state, $feature = NULL) {
return $form;
}
/**
* Machine name existence callback for the module name.
*/
function features_export_form_module_name_exists($value) {
return (bool) features_get_info('module', $value);
}
/**
* Return the render array elements for the Components selection on the Export form
* @param array $feature - feature associative array
@@ -779,16 +810,6 @@ function features_info_file_preview($form, &$form_state){
*/
function features_export_form_validate_field($element, &$form_state) {
switch ($element['#name']) {
case 'module_name':
if (!preg_match('!^[a-z0-9_]+$!', $element['#value'])) {
form_error($element, t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
}
// If user is filling out the feature name for the first time and uses
// the name of an existing module throw an error.
else if (empty($element['#default_value']) && features_get_info('module', $element['#value'])) {
form_error($element, t('A module by the name @name already exists on your site. Please choose a different name.', array('@name' => $element['#value'])));
}
break;
case 'project_status_url':
if (!empty($element['#value']) && !valid_url($element['#value'])) {
form_error($element, t('The URL %url is invalid. Please enter a fully-qualified URL, such as http://www.example.com/feed.xml.', array('%url' => $element['#value'])));
@@ -988,7 +1009,7 @@ function features_admin_form($form, $form_state) {
ksort($features);
foreach ($features as $name => $module) {
$package_title = !empty($module->info['package']) ? $module->info['package'] : t('Other');
$package = strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', $package_title));
$package = 'package_' . strtolower(preg_replace('/[^a-zA-Z0-9-]+/', '-', $package_title));
// Set up package elements
if (!isset($form[$package])) {
@@ -1052,6 +1073,7 @@ function features_admin_form($form, $form_state) {
}
$href = "admin/structure/features/{$name}";
$href_overridden = module_exists('diff') ? $href . '/diff' : $href;
$module_name = (user_access('administer features')) ? l($module->info['name'], $href) : $module->info['name'];
$form[$package]['status'][$name] = array(
'#type' => 'checkbox',
@@ -1081,7 +1103,7 @@ function features_admin_form($form, $form_state) {
$state .= l(t('Check'), "admin/structure/features/{$name}/status", array('attributes' => array('class' => array('admin-check'))));
$state .= theme('features_storage_link', array('storage' => FEATURES_REBUILDING, 'path' => $href));
$state .= theme('features_storage_link', array('storage' => FEATURES_NEEDS_REVIEW, 'path' => $href));
$state .= theme('features_storage_link', array('storage' => FEATURES_OVERRIDDEN, 'path' => $href));
$state .= theme('features_storage_link', array('storage' => FEATURES_OVERRIDDEN, 'path' => $href_overridden));
$state .= theme('features_storage_link', array('storage' => FEATURES_DEFAULT, 'path' => $href));
}
elseif (!empty($conflicts[$name])) {
@@ -1131,7 +1153,7 @@ function features_admin_components($form, $form_state, $feature) {
drupal_set_breadcrumb($breadcrumb);
module_load_include('inc', 'features', 'features.export');
$form = array();
$form['#feature'] = $feature;
// Store feature info for theme layer.
$form['module'] = array('#type' => 'value', '#value' => $feature->name);
@@ -1195,8 +1217,14 @@ function features_admin_components($form, $form_state, $feature) {
else if (array_key_exists($component, $conflicts)) {
$storage = FEATURES_CONFLICT;
}
// This can be removed if the css is fixed so link doesn't move when
// ajaxing and linke moved.
$lock_link = '<span class="features-lock-empty"></span>';
if (user_access('administer features') && (features_hook($component, 'features_revert') || features_hook($component, 'features_rebuild'))) {
$lock_link = ' ' . theme('features_lock_link', array('feature' => $feature->name, 'component' => $component));
}
$form['components'][$component] = array(
'#markup' => theme('features_storage_link', array('storage' => $storage, 'path' => $path)),
'#markup' => $lock_link . theme('features_storage_link', array('storage' => $storage, 'path' => $path)),
);
}
@@ -1367,6 +1395,71 @@ function features_feature_diff($feature, $component = NULL) {
return $output;
}
/**
* Page callback to lock a component.
*
* @param $feature
* Loaded feature object to be processed for component locking.
* @param $component
* (optional) A specific component to lock.
*
* @return
* Themed display of what is different.
*/
function features_admin_lock($feature, $type = 'ajax', $component = NULL) {
if ($type == 'ajax' && !empty($_GET['token']) && drupal_valid_token($_GET['token'], 'features/' . $feature->name . '/' . ($component ? $component : '')) == $_GET['token']) {
if (features_feature_is_locked($feature->name, $component, FALSE)) {
features_feature_unlock($feature->name, $component);
}
else {
features_feature_lock($feature->name, $component);
}
$commands = array();
$new_link = theme('features_lock_link', array('feature' => $feature->name, 'component' => $component));
$commands[] = ajax_command_replace('#features-lock-link-' . $feature->name . ($component ? '-' . $component : ''), $new_link);
$page = array('#type' => 'ajax', '#commands' => $commands);
ajax_deliver($page);
}
else {
return drupal_get_form('features_feature_lock_confirm_form', $feature, $component);
}
}
/**
* Confirm form for locking a feature.
*/
function features_feature_lock_confirm_form($form, $form_state, $feature, $component) {
$form['#feature'] = $feature;
$form['#component'] = $component;
$is_locked = features_feature_is_locked($feature->name, $component, FALSE);
$args = array(
'@name' => $feature->name,
'@component' => $component ? $component : t('all'),
'!action' => $is_locked ? t('unlock') : t('lock'),
);
$question = t('Are you sure you want to !action this Feature @name (component @component)?', $args);
return confirm_form($form, $question, 'admin/structure/features/' . $feature->name);
}
/**
* Submit callback to lock components of a feature.
*/
function features_feature_lock_confirm_form_submit($form, &$form_state) {
$feature = $form['#feature']->name;
$component = $form['#component'];
if (features_feature_is_locked($feature, $component, FALSE)) {
features_feature_unlock($feature, $component);
drupal_set_message(t('Feature @name (component @component) has been unlocked.', array('@name' => $feature, '@component' => $component ? $component : t('all'))));
}
else {
features_feature_lock($feature, $component);
drupal_set_message(t('Feature @name (component @component) has been locked.', array('@name' => $feature, '@component' => $component ? $component : t('all'))));
}
$form_state['redirect'] = 'admin/structure/features/' . $feature;
}
/**
* Compare the component names. Used to sort alphabetically.
*/