Skip to content

fix function filters_delete filters.php#2

Open
mckaygerhard wants to merge 1 commit intoroundcubevnz:masterfrom
Wangoviridans:patch-1
Open

fix function filters_delete filters.php#2
mckaygerhard wants to merge 1 commit intoroundcubevnz:masterfrom
Wangoviridans:patch-1

Conversation

@mckaygerhard
Copy link

function filters_delete() fixed

function filters_delete() fixed
@vascoleonidasleal
Copy link

Fix for delete filters

function filters_delete() {
$user = $this->rc->user;

$this->add_texts('localization/');
$this->register_handler('plugin.body', array($this, 'filters_form'));
$this->rc->output->set_pagetitle($this->gettext('filters'));

if (isset($_GET['filterid'])) {  // Use quotes around array keys
    $filter_id = intval($_GET['filterid']);  // Sanitize input
    $arr_prefs = $user->get_prefs();

    // Ensure 'filters' exists and is an array
    if (isset($arr_prefs['filters']) && is_array($arr_prefs['filters'])) {
        // Remove the filter using unset
        if (array_key_exists($filter_id, $arr_prefs['filters'])) {
            unset($arr_prefs['filters'][$filter_id]);

            // Re-index the array to avoid gaps
            $arr_prefs['filters'] = array_values($arr_prefs['filters']);

            // Save the updated preferences
            if ($user->save_prefs($arr_prefs)) {
                $this->rc->output->command('display_message', $this->gettext('successfullydeleted'), 'confirmation');
            } else {
                $this->rc->output->command('display_message', $this->gettext('unsuccessfullydeleted'), 'error');
            }
        } else {
            $this->rc->output->command('display_message', $this->gettext('filternotfound'), 'error');
        }
    }
}

$this->rc->overwrite_action('plugin.filters');
$this->rc->output->send('plugin');

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants