Post by craigbaines » Fri Dec 02, 2016 1:45 pm

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?

New member

Posts

Joined
Wed Jun 25, 2014 8:39 am

Post by opencartmart » Fri Dec 02, 2016 2:37 pm

It seems you are missing something with following line:

Code: Select all

return !$this->error;
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

private $error = array(); 

XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart


Active Member

Posts

Joined
Wed Oct 02, 2013 3:59 am

Post by craigbaines » Fri Dec 02, 2016 2:48 pm

I knew it would be something simple! Thank you a million times over, i was scratching my head over this for ages!

New member

Posts

Joined
Wed Jun 25, 2014 8:39 am

Post by opencartmart » Fri Dec 02, 2016 2:51 pm

You are welcome!

XForm - Opencart Form Builder
Xshippingpro - An advanced Shipping Module
Need Professional support? Skype: opencartmart


Active Member

Posts

Joined
Wed Oct 02, 2013 3:59 am
Who is online

Users browsing this forum: Amazon [Bot] and 430 guests