function m_delete_fields() { global $xoopsModule, $xoopsSecurity; $ids = rmc_server_var($_POST, 'ids', array()); //Verificamos que nos hayan proporcionado una categoría para eliminar if (empty($ids)) { redirectMsg('./fields.php', __('No fields selected!', 'match'), 1); die; } if (!$xoopsSecurity->check()) { redirectMsg('./fields.php', __('Session token expired!', 'match'), 1); die; } $db = XoopsDatabaseFactory::getDatabaseConnection(); $errors = ''; foreach ($ids as $k) { //Verificamos si la categoría es válida if ($k <= 0) { $errors .= sprintf(__('Field id "%s" is not valid!', 'match'), $k); continue; } //Verificamos si la categoría existe $field = new MCHField($k); if ($field->isNew()) { $errors .= sprintf(__('Field "%s" does not exists!', 'match'), $k); continue; } RMEvents::get()->run_event('match.delete.field', $field); if (!$field->delete()) { $errors .= sprintf(__('Field "%s" could not be deleted!', 'match'), $field->getVar('name')); } } if ($errors != '') { redirectMsg('./fields.php', __('Errors ocurred while trying to delete fields', 'match') . '<br />' . $errors, 1); die; } else { redirectMsg('./fields.php', __('Database updated successfully!', 'match'), 0); die; } }