79 lines
2.6 KiB
PHP
79 lines
2.6 KiB
PHP
<?php
|
|
|
|
class Config_email extends MY_Controller
|
|
{
|
|
var $db_onedev;
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db_onedev = $this->load->database("onedev", true);
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
echo "EMAIL CONFIG API";
|
|
}
|
|
|
|
public function getdata()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$sql = "select *
|
|
from email_config_nofification
|
|
where
|
|
Email_ConfigNofificationIsActive = 'Y' LIMIT 1";
|
|
$rows = $this->db_onedev->query($sql)->row_array();
|
|
if (!$rows) {
|
|
$this->sys_error_db("emailconfig select");
|
|
exit;
|
|
}
|
|
|
|
$result = array("total" => count($rows), "records" => $rows);
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
|
|
public function save()
|
|
{
|
|
try {
|
|
if (!$this->isLogin) {
|
|
$this->sys_error("Invalid Token");
|
|
exit;
|
|
}
|
|
|
|
$prm = $this->sys_input;
|
|
$user_id = isset($this->sys_user['M_UserID']) ? (int) $this->sys_user['M_UserID'] : 0;
|
|
$sql = "update email_config_nofification SET
|
|
Email_ConfigNofificationTemplate = '{$prm['Email_ConfigNofificationTemplate']}',
|
|
Email_ConfigNofificationSender = '{$prm['Email_ConfigNofificationSender']}',
|
|
Email_ConfigNofificationUsername = '{$prm['Email_ConfigNofificationUsername']}',
|
|
Email_ConfigNofificationPassword = '{$prm['Email_ConfigNofificationPassword']}',
|
|
Email_ConfigNofificationServer = '{$prm['Email_ConfigNofificationServer']}',
|
|
Email_ConfigNofificationSendTime = '{$prm['Email_ConfigNofificationSendTime']}',
|
|
Email_ConfigNofificationLastUpdatedUserID = {$user_id}
|
|
where
|
|
Email_ConfigNofificationID = {$prm['Email_ConfigNofificationID']}";
|
|
$query = $this->db_onedev->query($sql);
|
|
|
|
if (!$query) {
|
|
$this->sys_error_db("email config update");
|
|
exit;
|
|
}
|
|
|
|
$result = array("total" => 1, "records" => array());
|
|
$this->sys_ok($result);
|
|
} catch (Exception $exc) {
|
|
$message = $exc->getMessage();
|
|
$this->sys_error($message);
|
|
}
|
|
}
|
|
}
|