Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
NochexDevTeam authored Feb 23, 2018
1 parent ebdb227 commit 51c1ccb
Show file tree
Hide file tree
Showing 15 changed files with 663 additions and 0 deletions.
10 changes: 10 additions & 0 deletions extensions/nochex/config/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>

<p>Directory access is forbidden.</p>

</body>
</html>
48 changes: 48 additions & 0 deletions extensions/nochex/config/nochex.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php defined('EXTPATH') OR exit('No direct script access allowed');

/*
|--------------------------------------------------------------------------
| Extension Meta
|--------------------------------------------------------------------------
|
| The extension meta data that tells TastyIgniter that an extension is a valid module, payment or widget,
| only array element name and version are STRONGLY required
|
| 'name' => The name of your extension
| 'version' => The current version number of the extension, such as 1.0 or 1.0.3.
| 'type' => The type of your extension, could be module, payment or widget
| 'title' => The title of your extension, a readable name
| 'author' => The name of the extension author. More than one author may be listed, separated by comma.
| 'description' => A short description of the extension. Keep this description to fewer than 128 characters.
| 'settings' => Whether to enable/disable extension admin settings page.
|
*/
$config['extension_meta'] = array(
'name' => 'nochex',
'version' => '1.0',
'type' => 'payment',
'title' => 'Nochex',
'author' => 'Nochex Ltd',
'description' => 'This extension will allow you to accept payments using Nochex.',
'settings' => TRUE,
);

/*
|--------------------------------------------------------------------------
| Extension Permission (Optional)
|--------------------------------------------------------------------------
|
| The extension permission rule that will be saved then assigned to the current staff group
| installing the extension
|
| 'name' => The name of the permission e.g Module.ModuleName or Payment.ModuleName
| 'action' => The extension permitted action array (access, manage, add, delete)
| 'description' => A short description of the permission. Keep this description
| to fewer than 128 characters.
|
*/
$config['extension_permission'] = array(
'name' => 'Payment.Nochex',
'action' => array('manage'),
'description' => 'Ability to manage Nochex Payment module',
);
141 changes: 141 additions & 0 deletions extensions/nochex/controllers/Admin_nochex.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?php if ( ! defined('BASEPATH')) exit('No direct access allowed');

class Admin_nochex extends Admin_Controller {

public function index($module = array()) {
$this->lang->load('nochex/nochex');

$this->user->restrict('Payment.Nochex');

$this->load->model('Statuses_model');

$title = (isset($module['title'])) ? $module['title'] : $this->lang->line('_text_title');

$this->template->setTitle('Payment: ' . $title);
$this->template->setHeading('Payment: ' . $title);
$this->template->setButton($this->lang->line('button_save'), array('class' => 'btn btn-primary', 'onclick' => '$(\'#edit-form\').submit();'));
$this->template->setButton($this->lang->line('button_save_close'), array('class' => 'btn btn-default', 'onclick' => 'saveClose();'));
$this->template->setButton($this->lang->line('button_icon_back'), array('class' => 'btn btn-default', 'href' => site_url('extensions')));

$ext_data = array();
if ( ! empty($module['ext_data']) AND is_array($module['ext_data'])) {
$ext_data = $module['ext_data'];
}

if (isset($this->input->post['title'])) {
$data['title'] = $this->input->post('title');
} else if (isset($ext_data['title'])) {
$data['title'] = $ext_data['title'];
} else {
$data['title'] = $title;
}

if (isset($this->input->post['merchantID'])) {
$data['merchantID'] = $this->input->post('merchantID');
} else if (isset($ext_data['merchantID'])) {
$data['merchantID'] = $ext_data['merchantID'];
} else {
$data['merchantID'] = '';
}


if (isset($this->input->post['api_mode'])) {
$data['api_mode'] = $this->input->post('api_mode');
} else if (isset($ext_data['api_mode'])) {
$data['api_mode'] = $ext_data['api_mode'];
} else {
$data['api_mode'] = '';
}

if (isset($ext_data['order_total'])) {
$data['order_total'] = $ext_data['order_total'];
} else {
$data['order_total'] = '';
}

if (isset($this->input->post['order_status'])) {
$data['order_status'] = $this->input->post('order_status');
} else if (isset($ext_data['order_status'])) {
$data['order_status'] = $ext_data['order_status'];
} else {
$data['order_status'] = '';
}

if (isset($this->input->post['paid_order_status'])) {
$data['paid_order_status'] = $this->input->post('paid_order_status');
} else if (isset($ext_data['paid_order_status'])) {
$data['paid_order_status'] = $ext_data['paid_order_status'];
} else {
$data['paid_order_status'] = '';
}


if (isset($this->input->post['priority'])) {
$data['priority'] = $this->input->post('priority');
} else if (isset($ext_data['priority'])) {
$data['priority'] = $ext_data['priority'];
} else {
$data['priority'] = '';
}

if (isset($this->input->post['status'])) {
$data['status'] = $this->input->post('status');
} else if (isset($ext_data['status'])) {
$data['status'] = $ext_data['status'];
} else {
$data['status'] = '';
}

$data['statuses'] = array();
$results = $this->Statuses_model->getStatuses('order');
foreach ($results as $result) {
$data['statuses'][] = array(
'status_id' => $result['status_id'],
'status_name' => $result['status_name'],
);
}

if ($this->input->post() AND $this->_updateNochex() === TRUE) {
if ($this->input->post('save_close') === '1') {
redirect('extensions');
}

redirect('extensions/edit/payment/nochex');
}

return $this->load->view('nochex/Admin_nochex', $data, TRUE);
}

private function _updateNochex() {
$this->user->restrict('Payment.Nochex.Manage');

if ($this->input->post() AND $this->validateForm() === TRUE) {

if ($this->Extensions_model->updateExtension('payment', 'nochex', $this->input->post())) {
$this->alert->set('success', sprintf($this->lang->line('alert_success'), $this->lang->line('_text_title') . ' payment ' . $this->lang->line('text_updated')));
} else {
$this->alert->set('warning', sprintf($this->lang->line('alert_error_nothing'), $this->lang->line('text_updated')));
}

return TRUE;
}
}

private function validateForm() {
$this->form_validation->set_rules('title', 'lang:label_title', 'xss_clean|trim|required|min_length[2]|max_length[128]');
$this->form_validation->set_rules('api_mode', 'lang:label_api_mode', 'xss_clean|trim|required');
$this->form_validation->set_rules('order_total', 'lang:label_order_total', 'xss_clean|trim|required|numeric');
$this->form_validation->set_rules('order_status', 'lang:label_order_status', 'xss_clean|trim|required|integer');
$this->form_validation->set_rules('paid_order_status', 'lang:label_paid_order_status', 'xss_clean|trim|required|integer');
$this->form_validation->set_rules('status', 'lang:label_status', 'xss_clean|trim|required|integer');

if ($this->form_validation->run() === TRUE) {
return TRUE;
} else {
return FALSE;
}
}
}

/* End of file nochex.php */
/* Location: ./extensions/nochex/controllers/nochex.php */
Loading

0 comments on commit 51c1ccb

Please sign in to comment.