Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Actions for edit/clone configuration options
In adm_config_report, show buttons for different editing actions:

- Action "Clone" creates new option and keeps old, overwritting if one already exists with those key values. exists
- Action "Edit" updates current configuration option, or moves the option if key values are changed, overwritting if one already exists

Fixes #20058
  • Loading branch information
cproensa authored and vboctor committed May 3, 2016
1 parent f5a278d commit 13bda67
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
26 changes: 24 additions & 2 deletions adm_config_report.php
Expand Up @@ -217,6 +217,7 @@ function check_config_value( $p_config ) {
$t_edit_option = gpc_get_string( 'config_option', $t_filter_config_value == META_FILTER_NONE ? '' : $t_filter_config_value );
$t_edit_type = gpc_get_string( 'type', CONFIG_TYPE_DEFAULT );
$t_edit_value = gpc_get_string( 'value', '' );
$t_edit_action = gpc_get_string( 'action', 'action_create' );

# Apply filters

Expand Down Expand Up @@ -412,6 +413,21 @@ function check_config_value( $p_config ) {
'config_option' => $v_config_id,
'type' => $v_type,
'value' => $v_value,
'action' => 'action_edit',
),
OFF );

# Clone button
print_button(
'#config_set_form',
lang_get( 'create_child_bug_button' ),
array(
'user_id' => $v_user_id,
'project_id' => $v_project_id,
'config_option' => $v_config_id,
'type' => $v_type,
'value' => $v_value,
'action' => 'action_clone',
),
OFF );

Expand Down Expand Up @@ -457,7 +473,7 @@ function check_config_value( $p_config ) {

<!-- Title -->
<legend><span>
<?php echo lang_get( 'set_configuration_option' ) ?>
<?php echo lang_get( 'set_configuration_option_' . $t_edit_action ) ?>
</span></legend>

<!-- Username -->
Expand All @@ -471,6 +487,7 @@ function check_config_value( $p_config ) {
</option>
<?php print_user_option_list( $t_edit_user_id ) ?>
</select>
<input type="hidden" name="original_user_id" value="<?php echo $t_edit_user_id; ?>" />
</span>
<span class="label-style"></span>
</div>
Expand All @@ -486,6 +503,7 @@ function check_config_value( $p_config ) {
</option>
<?php print_project_option_list( $t_edit_project_id, false ) ?>
</select>
<input type="hidden" name="original_project_id" value="<?php echo $t_edit_project_id; ?>" />
</span>
<span class="label-style"></span>
</div>
Expand All @@ -497,6 +515,7 @@ function check_config_value( $p_config ) {
<input type="text" name="config_option"
value="<?php echo string_attribute( $t_edit_option ); ?>"
size="64" maxlength="64" />
<input type="hidden" name="original_config_option" value="<?php echo $t_edit_option; ?>" />
</span>
<span class="label-style"></span>
</div>
Expand Down Expand Up @@ -524,7 +543,10 @@ function check_config_value( $p_config ) {
</div>

<!-- Submit button -->
<span class="submit-button"><input type="submit" name="config_set" class="button" value="<?php echo lang_get( 'set_configuration_option' ) ?>" /></span>
<span class="submit-button">
<input type="hidden" name="action" value="<?php echo $t_edit_action; ?>" />
<input type="submit" name="config_set" class="button" value="<?php echo lang_get( 'set_configuration_option_' . $t_edit_action ) ?>" />
</span>
</fieldset>
</form>
</div>
Expand Down
14 changes: 14 additions & 0 deletions adm_config_set.php
Expand Up @@ -52,6 +52,11 @@
$f_config_option = trim( gpc_get_string( 'config_option' ) );
$f_type = gpc_get_string( 'type' );
$f_value = gpc_get_string( 'value' );
$f_original_user_id = gpc_get_int( 'original_user_id' );
$f_original_project_id = gpc_get_int( 'original_project_id' );
$f_original_config_option = gpc_get_string( 'original_config_option' );
$f_edit_action = gpc_get_string( 'action' );


if( is_blank( $f_config_option ) ) {
error_parameters( 'config_option' );
Expand Down Expand Up @@ -126,6 +131,15 @@
}
}

if( 'action_edit' === $f_edit_action ){
# EDIT action doesn't keep original if key values are different.
if ( $f_original_config_option !== $f_config_option
|| $f_original_user_id !== $f_user_id
|| $f_original_project_id !== $f_project_id ){
config_delete( $f_original_config_option, $f_original_user_id, $f_original_project_id );
}
}

config_set( $f_config_option, $t_value, $f_user_id, $f_project_id );

form_security_purge( 'adm_config_set' );
Expand Down
3 changes: 3 additions & 0 deletions lang/strings_english.txt
Expand Up @@ -843,6 +843,9 @@ $s_all_users = 'All Users';
$s_set_configuration_option = 'Set Configuration Option';
$s_delete_config_sure_msg = 'Are you sure you wish to delete this configuration option?';
$s_configuration_corrupted = 'The configuration in the database is corrupted.';
$s_set_configuration_option_action_create = 'Create Configuration Option';
$s_set_configuration_option_action_edit = 'Edit Configuration Option';
$s_set_configuration_option_action_clone = 'Clone Configuration Option';

# manage_plugin_page.php
$s_plugin = 'Plugin';
Expand Down

0 comments on commit 13bda67

Please sign in to comment.