Code cleanup as suggested by the codacy service.
- Renamed get_service_details to populate_impacted_services - Removed unused variables
This commit is contained in:
parent
7ee0aa3540
commit
62e6f08e4f
|
@ -168,7 +168,7 @@ class Incident implements JsonSerializable
|
||||||
|
|
||||||
// Perform notification to subscribers
|
// Perform notification to subscribers
|
||||||
$notify = new Notification();
|
$notify = new Notification();
|
||||||
$notify->get_service_details($status_id);
|
$notify->populate_impacted_services($status_id);
|
||||||
|
|
||||||
$notify->type = $type;
|
$notify->type = $type;
|
||||||
$notify->time = $time;
|
$notify->time = $time;
|
||||||
|
@ -210,7 +210,7 @@ class Incident implements JsonSerializable
|
||||||
<div class="panel-footer clearfix">
|
<div class="panel-footer clearfix">
|
||||||
<small>
|
<small>
|
||||||
<?php echo _("Impacted service(s): ");
|
<?php echo _("Impacted service(s): ");
|
||||||
foreach ( $this->service_name as $key => $value ) {
|
foreach ( $this->service_name as $value ) {
|
||||||
echo '<span class="label label-default">'.$value . '</span> ';
|
echo '<span class="label label-default">'.$value . '</span> ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,10 @@ class Notification
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate an array of servicenames and service IDs affected by a given incident
|
* Generate an array of servicenames and service IDs affected by a given incident
|
||||||
* @param int $statsus_id The incident to query
|
* @param int $status_id The incident to query
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function get_service_details($status_id)
|
public function populate_impacted_services($status_id)
|
||||||
{
|
{
|
||||||
global $mysqli;
|
global $mysqli;
|
||||||
if (! empty($status_id)) {
|
if (! empty($status_id)) {
|
||||||
|
@ -89,7 +89,7 @@ class Notification
|
||||||
* Sends Telegram notification message using their web api.
|
* Sends Telegram notification message using their web api.
|
||||||
* @param string $userID The Telegram userid to send to
|
* @param string $userID The Telegram userid to send to
|
||||||
* @param string $firstname The users firstname
|
* @param string $firstname The users firstname
|
||||||
* @return void
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function submit_telegram($userID, $firstname)
|
public function submit_telegram($userID, $firstname)
|
||||||
{
|
{
|
||||||
|
@ -100,6 +100,10 @@ class Notification
|
||||||
|
|
||||||
$tg_message = urlencode($msg);
|
$tg_message = urlencode($msg);
|
||||||
$response = json_decode(file_get_contents("https://api.telegram.org/bot" . TG_BOT_API_TOKEN . "/sendMessage?chat_id=" . $userID . "&parse_mode=HTML&text=" . $tg_message), true);
|
$response = json_decode(file_get_contents("https://api.telegram.org/bot" . TG_BOT_API_TOKEN . "/sendMessage?chat_id=" . $userID . "&parse_mode=HTML&text=" . $tg_message), true);
|
||||||
|
if (! array_key_exists("ok", $response) || $response['ok'] != 1 ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -115,7 +115,7 @@ Class Subscriber
|
||||||
$stmt = $mysqli->prepare("INSERT INTO subscribers (typeID, userID, firstname, lastname, token, active, expires, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
$stmt = $mysqli->prepare("INSERT INTO subscribers (typeID, userID, firstname, lastname, token, active, expires, create_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
$stmt->bind_param("issssiii", $typeID, $userID, $firstname, $lastname, $token, $active, $expireTime, $updateTime);
|
$stmt->bind_param("issssiii", $typeID, $userID, $firstname, $lastname, $token, $active, $expireTime, $updateTime);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$query = $stmt->get_result();
|
//$query = $stmt->get_result();
|
||||||
|
|
||||||
$this->id = $mysqli->insert_id;
|
$this->id = $mysqli->insert_id;
|
||||||
$this->typeID = $typeID;
|
$this->typeID = $typeID;
|
||||||
|
|
Loading…
Reference in New Issue