Added WebUI PlaySMS transport

This commit is contained in:
laf
2015-11-16 10:40:09 -08:00
parent 4d8a84d604
commit 6ad95be58b
2 changed files with 254 additions and 2 deletions
+37 -1
View File
@@ -30,11 +30,13 @@ $config_extra = mres($_POST['config_extra']);
$config_room_id = mres($_POST['config_room_id']);
$config_from = mres($_POST['config_from']);
$config_userkey = mres($_POST['config_userkey']);
$config_user = mres($_POST['config_user']);
$config_to = mres($_POST['config_to']);
$config_token = mres($_POST['config_token']);
$status = 'error';
$message = 'Error with config';
if ($action == 'remove' || $action == 'remove-slack' || $action == 'remove-hipchat' || $action == 'remove-pushover' || $action == 'remove-boxcar' || $action == 'remove-clickatell') {
if ($action == 'remove' || $action == 'remove-slack' || $action == 'remove-hipchat' || $action == 'remove-pushover' || $action == 'remove-boxcar' || $action == 'remove-clickatell' || $action == 'remove-playsms') {
$config_id = mres($_POST['config_id']);
if (empty($config_id)) {
$message = 'No config id passed';
@@ -56,6 +58,9 @@ if ($action == 'remove' || $action == 'remove-slack' || $action == 'remove-hipch
elseif ($action == 'remove-clickatell') {
dbDelete('config', "`config_name` LIKE 'alert.transports.clickatell.$config_id.%'");
}
elseif ($action == 'remove-playsms') {
dbDelete('config', "`config_name` LIKE 'alert.transports.playsms.$config_id.%'");
}
$status = 'ok';
$message = 'Config item removed';
@@ -185,6 +190,37 @@ else if ($action == 'add-clickatell') {
}
}
}
elseif ($action == 'add-playsms') {
if (empty($config_value)) {
$message = 'No PlaySMS URL provided';
}
elseif (empty($config_user)) {
$message = 'No PlaySMS User provided';
}
elseif (empty($config_to)) {
$message = 'No mobile numbers provided';
}
else {
$config_id = dbInsert(array('config_name' => 'alert.transports.playsms.', 'config_value' => $config_value, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_value, 'config_descr' => 'PlaySMS Transport'), 'config');
if ($config_id > 0) {
dbUpdate(array('config_name' => 'alert.transports.playsms.'.$config_id.'.url'), 'config', 'config_id=?', array($config_id));
$additional_id['from'] = dbInsert(array('config_name' => 'alert.transports.playsms.'.$config_id.'.from', 'config_value' => $config_from, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_from, 'config_descr' => 'PlaySMS From'), 'config');
$additional_id['user'] = dbInsert(array('config_name' => 'alert.transports.playsms.'.$config_id.'.user', 'config_value' => $config_user, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_user, 'config_descr' => 'PlaySMS User'), 'config');
$additional_id['token'] = dbInsert(array('config_name' => 'alert.transports.playsms.'.$config_id.'.token', 'config_value' => $config_token, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $config_token, 'config_descr' => 'PlaySMS Token'), 'config');
$status = 'ok';
$message = 'Config item created';
$mobiles = explode('\n', $config_to);
foreach ($mobiles as $mobile) {
if (!empty($mobile)) {
dbInsert(array('config_name' => 'alert.transports.playsms.'.$config_id.'.to', 'config_value' => $mobile, 'config_group' => $config_group, 'config_sub_group' => $config_sub_group, 'config_default' => $v, 'config_descr' => 'PlaySMS mobile'), 'config');
}
}
}
else {
$message = 'Could not create config item';
}
}
}
else {
if (empty($config_group) || empty($config_sub_group) || empty($config_name) || empty($config_value)) {
$message = 'Missing config name or value';