Last active
April 10, 2018 11:49
-
-
Save beinoriusju/93d6bfef0879d45e74c753821f9c30ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ControllerExtensionModuleAgeRestriction extends Controller { | |
const DEFAULT_MODULE_SETTINGS = [ | |
'name' => 'Age Restriction (21)', | |
'message' => 'Are you %s and older?', | |
'age' => 21, | |
'redirect_url' => 'http://www.example.org', | |
'status' => 1 /* Enabled by default*/ | |
]; | |
private $error = array(); | |
public function index() { | |
if (!isset($this->request->get['module_id'])) { | |
$module_id = $this->addModule(); | |
$this->response->redirect($this->url->link('extension/module/age_restriction','&user_token='.$this->session->data['user_token'].'&module_id='.$module_id)); | |
} else { | |
$this->editModule($this->request->get['module_id']); | |
} | |
} | |
private function addModule() { | |
$this->load->model('setting/module'); | |
$this->model_setting_module->addModule('age_restriction', self::DEFAULT_MODULE_SETTINGS); | |
return $this->db->getLastId(); | |
} | |
protected function editModule($module_id) { | |
$data = array(); | |
$htmlOutput = $this->load->view('extension/module/age_restriction', $data); | |
$this->response->setOutput($htmlOutput); | |
} | |
public function validate() { | |
} | |
public function install() { | |
$this->load->model('setting/setting'); | |
$this->model_setting_setting->editSetting('module_age_restriction', ['module_age_restriction_status'=>1]); | |
} | |
public function uninstall() { | |
$this->load->model('setting/setting'); | |
$this->model_setting_setting->deleteSetting('module_age_restriction'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment