Hi all, so im attempting to compile one of my many mod's into an actual stand alone module.
Iv'e set the latest opencart up on a local machine, and im just starting to set up the new module. The issue i have is with the modify permission, it doesnt seem to make any difference if it's ticked or not. No matter what, the validation function seems to work.
Here's my code within the admin area index for it..
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->setSetting($this->request->post);
$this->session->data['success'] = $this->language->get('text_success');
$this->response->redirect($this->url->link('extension/extension', 'token=' . $this->session->data['token'], 'SSL'));
}
Here is the validate function:
private function validate() {
if (!$this->user->hasPermission('modify', 'extension/module/instashop')) {
$this->error['warning'] = $this->language->get('error_permission');
}
return !$this->error;
}
I can rename that "instashop" to anything i like, the page still acts like validation was passed and loads my extensions page with a success message. ATM the setSetting() does nothing, but it should still be failing should it not?
Am i missing something here?
It seems you are missing something with following line:
What happens if you did not set $this->error? It will always return true.
Seems you have missed initialization of error property at the very top i.e
Code: Select all
return !$this->error;
Seems you have missed initialization of error property at the very top i.e
Code: Select all
private $error = array();
XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart
I knew it would be something simple! Thank you a million times over, i was scratching my head over this for ages!
You are welcome!
XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart
Who is online
Users browsing this forum: Amazon [Bot] and 430 guests