grazie alessio!
so i'm trying moving in those skeleton ext (and php) and i've created my first one.
So i just want to make a few things:
i cannot setup the acp...can you help me? (i copy-paste parts of code from the ucp module and i arrange that one)i suppose the error is here $this->user->data['username_donatore']; (because it's not a user value) but i don't know how to move. is the db field and the form field.
here it is:the problem is that it doesn't achieve the data sent from the form, and so do not execute my SQL commandline...
so i'm trying moving in those skeleton ext (and php) and i've created my first one.
So i just want to make a few things:
- users make some choises from the ucp panel and sets 2 value into the database
- admin in acp can modify those parameters by only writing the name of the user, and the db will be setted for the user
i cannot setup the acp...can you help me? (i copy-paste parts of code from the ucp module and i arrange that one)
Code:
public function display_options(){// Add our common language file$this->language->add_lang('common', 'sebo/donatore');// Create a form key for preventing CSRF attacksadd_form_key('sebo_donatore_acp');// Create an array to collect errors that will be output to the user$errors = [];// Request the options the user can configure$data = ['username_donatore' => $this->request->variable('username_donatore', $this->data['username_donatore']),];// Is the form being submitted to us?if ($this->request->is_set_post('submit')){// Test if the submitted form is validif (!check_form_key('sebo_donatore_acp')){$errors[] = $this->language->lang('FORM_INVALID');}// If no errors, process the form dataif (empty($errors)){// Set the options the user configured$sql = 'UPDATE ' . USERS_TABLE . 'SET `user_donatore` = \'0\'WHERE username = ' . $this->user->data['username_donatore'];$this->db->sql_query($sql);// Option settings have been updated// Confirm this to the user and provide (automated) link back to previous pagemeta_refresh(3, $this->u_action);$message = $this->language->lang('ACP_DONATORE_SETTINGS_SAVED') . '<br /><br />' . $this->language->lang('RETURN_ACP', '<a href="' . $this->u_action . '">', '</a>');trigger_error($message);// Add option settings change action to the admin log$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_ACP_DONATORE_SETTINGS');// Option settings have been updated and logged// Confirm this to the user and provide link back to previous pagetrigger_error($this->language->lang('ACP_DONATORE_SETTING_SAVED') . adm_back_link($this->u_action));}}$s_errors = !empty($errors);// Set output variables for display in the template$this->template->assign_vars(['S_ERROR'=> $s_errors,'ERROR_MSG'=> $s_errors ? implode('<br />', $errors) : '','U_ACTION'=> $this->u_action,'S_USERNAME_DONATORE'=> $data['username_donatore'],]);}
Code:
username_donatore
here it is:
Code:
<form id="sebo_donatore_acp" name="sebo_donatore_acp" method="post" action="{{ U_UCP_ACTION }}"><fieldset><legend>{{ lang('SETTINGS') }}</legend><dl><dt><label for="username_donatore">{{ lang('ACP_DONATORE_ATTIVA') ~ lang('COLON') }}</label></dt><dd><label><input type="text" id="username_donatore" name="username_donatore"></label></dd></dl></fieldset><fieldset class="submit-buttons"><input class="button1" type="submit" id="submit" name="submit" value="{{ lang('SUBMIT') }}" />{{ S_FORM_TOKEN }}</fieldset></form>
Statistics: Posted by sebo — Fri Feb 16, 2024 12:24 am