1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
<?php
/**
* Kalkun
* An open source web based SMS Management
*
* @package Kalkun
* @author Kalkun Dev Team
* @license https://spdx.org/licenses/GPL-2.0-or-later.html
* @link https://kalkun.sourceforge.io/
*/
// ------------------------------------------------------------------------
/**
* Stop manager Class
*
* @package Kalkun
* @subpackage Plugin
* @category Controllers
*/
include_once(APPPATH.'plugins/Plugin_controller.php');
include_once(APPPATH.'plugins/Plugin_helper.php');
Plugin_helper::autoloader();
class Stop_manager extends Plugin_controller {
function __construct()
{
parent::__construct();
$this->load->model('stop_manager_model');
}
function index()
{
$this->load->helper('kalkun');
if ($_POST && is_null($this->input->post('search_name')))
{
$this->_phone_number_validation($this->input->post('destination_number'));
$this->stop_manager_model->add(
phone_format_e164($this->input->post('destination_number')),
($this->input->post('stop_type')) ? $this->input->post('stop_type') : \Kalkun\Plugins\StopManager\MsgIncoming::TYPE_NOT_SET,
$this->input->post('stop_message')
);
redirect('plugin/stop_manager');
}
$offset = 0;
if ( ! is_null($this->input->post('search_name')))
{
$data['stoplist'] = $this->stop_manager_model->get('search');
}
else
{
$this->load->library('pagination');
$config['base_url'] = site_url('plugin/stop_manager');
$config['total_rows'] = $this->stop_manager_model->get('count');
$config['per_page'] = $this->Kalkun_model->get_setting()->row('paging');
$config['cur_tag_open'] = '<span id="current">';
$config['cur_tag_close'] = '</span>';
($this->uri->segment(3, 0) === 'index') ? $config['uri_segment'] = 4 : $config['uri_segment'] = 3;
$this->pagination->initialize($config);
$offset = ($this->uri->segment(3, 0) === 'index') ? $this->uri->segment(4, 0) : $this->uri->segment(3, 0);
if ( ! is_numeric($offset))
{
show_404();
}
if (intval($offset) >= $this->stop_manager_model->get('count'))
{
$offset = 0;
}
$data['stoplist'] = $this->stop_manager_model->get('paginate', $config['per_page'], $offset);
}
$data['main'] = 'index';
$data['number'] = $offset + 1;
$data['search_name'] = $this->input->post('search_name') ? $this->input->post('search_name') : '';
$this->load->view('main/layout', $data);
}
function _remap($method, $params = array())
{
if (method_exists($this, $method))
{
return call_user_func_array(array($this, $method), $params);
}
else
{
if (is_numeric($method))
{
if (intval($method) < $this->stop_manager_model->get('count'))
{
$this->index($method);
return;
}
else
{
$this->index();
return;
}
}
show_404();
}
}
function delete()
{
if ($_POST)
{
$from = $this->input->post('from');
$type = $this->input->post('type');
$this->stop_manager_model->delete($from, $type);
}
}
// --------------------------------------------------------------------
/**
* Check if submitted phone number is valid
*
* @access public
*/
function _phone_number_validation($phone)
{
$this->load->helper('kalkun');
$result = is_phone_number_valid($phone);
if ($result !== TRUE)
{
show_error(tr($result), 400);
}
}
}
|