php - Opencart : Permission Denied Error -


i have made custom module on opencart. while editing it's showing following error:

enter image description here

for have followed steps also. still getting same error:

   1. login admin, go system > user group.    2.  edit admin usergroup (probably top administrator group).    3. add permission new extension modules (both access permission , modify permission). 

here's controller demo if problem there :

<?php class controllerextensionmodulehelloworld extends controller {     private $error = array(); // used set errors, if any.      public function index() {         // loading language file of helloworld         $this->load->language('extension/module/helloworld');           // set title of page heading title in language file i.e., hello world         $this->document->settitle($this->language->get('heading_title'));          // load setting model  (all of opencart module & general settings saved using model )         $this->load->model('setting/setting');          // start if: validates , check if data coming save (post) method         if (($this->request->server['request_method'] == 'post') && $this->validate()) {             // parse coming data setting model save in database.             $this->model_setting_setting->editsetting('helloworld', $this->request->post);              // display success text on data save             $this->session->data['success'] = $this->language->get('text_success');              // redirect module listing             $this->response->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'ssl'));         }          // assign language data parsing view         $data['heading_title'] = $this->language->get('heading_title');          $data['text_edit']    = $this->language->get('text_edit');         $data['text_enabled'] = $this->language->get('text_enabled');         $data['text_disabled'] = $this->language->get('text_disabled');         $data['text_content_top'] = $this->language->get('text_content_top');         $data['text_content_bottom'] = $this->language->get('text_content_bottom');               $data['text_column_left'] = $this->language->get('text_column_left');         $data['text_column_right'] = $this->language->get('text_column_right');          $data['entry_code'] = $this->language->get('entry_code');         $data['entry_layout'] = $this->language->get('entry_layout');         $data['entry_position'] = $this->language->get('entry_position');         $data['entry_status'] = $this->language->get('entry_status');         $data['entry_sort_order'] = $this->language->get('entry_sort_order');          $data['button_save'] = $this->language->get('button_save');         $data['button_cancel'] = $this->language->get('button_cancel');         $data['button_add_module'] = $this->language->get('button_add_module');         $data['button_remove'] = $this->language->get('button_remove');          // block returns warning if         if (isset($this->error['warning'])) {             $data['error_warning'] = $this->error['warning'];         } else {             $data['error_warning'] = '';         }          // block returns error code if         if (isset($this->error['code'])) {             $data['error_code'] = $this->error['code'];         } else {             $data['error_code'] = '';         }               // making of breadcrumbs displayed on site         $data['breadcrumbs'] = array();         $data['breadcrumbs'][] = array(             'text'      => $this->language->get('text_home'),             'href'      => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'ssl'),             'separator' => false         );         $data['breadcrumbs'][] = array(             'text'      => $this->language->get('text_module'),             'href'      => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'ssl'),             'separator' => ' :: '         );         $data['breadcrumbs'][] = array(             'text'      => $this->language->get('heading_title'),             'href'      => $this->url->link('extension/module/helloworld', 'token=' . $this->session->data['token'], 'ssl'),             'separator' => ' :: '         );          $data['action'] = $this->url->link('extension/module/helloworld', 'token=' . $this->session->data['token'], 'ssl'); // url directed when save button pressed          $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'ssl'); // url redirected when cancel button pressed          // block checks, if hello world text field set parses view otherwise default          // hello world text field database , parse         if (isset($this->request->post['helloworld_text_field'])) {             $data['helloworld_text_field'] = $this->request->post['helloworld_text_field'];         } else {             $data['helloworld_text_field'] = $this->config->get('helloworld_text_field');         }             // block parses status (enabled / disabled)         if (isset($this->request->post['helloworld_status'])) {             $data['helloworld_status'] = $this->request->post['helloworld_status'];         } else {             $data['helloworld_status'] = $this->config->get('helloworld_status');         }          $data['header'] = $this->load->controller('common/header');         $data['column_left'] = $this->load->controller('common/column_left');         $data['footer'] = $this->load->controller('common/footer');          $this->response->setoutput($this->load->view('extension/module/helloworld.tpl', $data));      }      /* function validates data when save button pressed */     protected function validate() {          // block check user permission manipulate module         if (!$this->user->haspermission('modify', 'extension/module/helloworld')) {             $this->error['warning'] = $this->language->get('error_permission');         }          // block check if helloworld_text_field set save database,         // otherwise error returned         if (!$this->request->post['helloworld_text_field']) {             $this->error['code'] = $this->language->get('error_code');         }         /* end block*/          // block returns true if no error found, else false if error detected         if (!$this->error) {             return true;         } else {             return false;         }     } } 

find

$this->response->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'ssl')); 

replace

$this->response->redirect($this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=module', true)); 

for cancel button

find

   $data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'ssl'); // url redirected when cancel button pressed 

replace with

$data['cancel'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'] . '&type=module', true); 

for save button action

find

 $data['action'] = $this->url->link('extension/module/helloworld', 'token=' . $this->session->data['token'], 'ssl'); // url directed when save button pressed 

replace

if (!isset($this->request->get['module_id'])) {         $data['action'] = $this->url->link('extension/module/helloworld', 'token=' . $this->session->data['token'], true);     } else {         $data['action'] = $this->url->link('extension/module/helloworld', 'token=' . $this->session->data['token'] . '&module_id=' . $this->request->get['module_id'], true);     } 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -