Delete unused DAOs, fix some replace errors

remotes/upstream/api-rewrite
Mike Koch 7 years ago
parent ad43c420bb
commit a702d157cd

@ -22,7 +22,7 @@ class TicketCreator {
throw new ValidationException($validationModel);
}
// Create the Tickets
// Create the ticket
}
/**
@ -30,7 +30,7 @@ class TicketCreator {
* @param $staff bool
* @param $heskSettings array HESK settings
* @param $modsForHeskSettings array Mods for HESK settings
* @return ValidationModel If errorKeys is empty, validation successful. Otherwise invalid Tickets
* @return ValidationModel If errorKeys is empty, validation successful. Otherwise invalid ticket
*/
function validate($ticketRequest, $staff, $heskSettings, $modsForHeskSettings) {
$TICKET_PRIORITY_CRITICAL = 0;

@ -13,6 +13,6 @@ class SQLException extends Exception {
function __construct($failingQuery) {
$this->failingQuery = $failingQuery;
parent::__construct('A SQL Exceptions occurred. Check the logs for more information.');
parent::__construct('A SQL exception occurred. Check the logs for more information.');
}
}

@ -1,28 +0,0 @@
<?php
function get_canned_response($hesk_settings, $id = NULL) {
$sql = "SELECT `id`, `message`, `title`, `reply_order` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "std_replies` ";
if ($id != NULL) {
$sql .= "WHERE `id` = ".intval($id);
}
$response = hesk_dbQuery($sql);
if (hesk_dbNumRows($response) == 0) {
return NULL;
}
$results = array();
while ($row = hesk_dbFetchAssoc($response)) {
$row['id'] = intval($row['id']);
$row['replyOrder'] = intval($row['reply_order']);
unset($row['reply_order']);
$row['title'] = hesk_html_entity_decode($row['title']);
$row['message'] = hesk_html_entity_decode($row['message']);
$results[] = $row;
}
return $id == NULL ? $results : $results[0];
}

@ -1,52 +0,0 @@
<?php
function get_status($hesk_settings, $id = NULL) {
$sql = "SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "statuses` ";
if ($id != NULL) {
$sql .= "WHERE `ID` = ".intval($id);
}
$response = hesk_dbQuery($sql);
if (hesk_dbNumRows($response) == 0) {
return NULL;
}
$results = array();
while ($row = hesk_dbFetchAssoc($response)) {
$row['id'] = intval($row['ID']);
unset($row['ID']);
$row['sort'] = intval($row['sort']);
foreach ($row as $key => $value) {
if ($key != 'id') {
$lowercase_key = lcfirst($key);
$row[$lowercase_key] = $row[$key];
unset($row[$key]);
}
if ($key == 'id' || $lowercase_key == 'closable'
|| $lowercase_key == 'key' || $lowercase_key == 'sort'
|| $lowercase_key == 'textColor') {
continue;
}
$row[$lowercase_key] = $row[$lowercase_key] == true;
}
$language_sql = "SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "text_to_status_xref` "
. "WHERE `status_id` = ".intval($row['id']);
$language_rs = hesk_dbQuery($language_sql);
if (hesk_dbNumRows($language_rs) > 0) {
$row['key'] = NULL;
$row['keys'] = array();
}
while ($language_row = hesk_dbFetchAssoc($language_rs)) {
unset($language_row['id']);
unset($language_row['status_id']);
$row['keys'][] = $language_row;
}
$results[] = $row;
}
return $id == NULL ? $results : $results[0];
}

@ -1,59 +0,0 @@
<?php
function get_ticket_for_id($hesk_settings, $user, $id = NULL) {
$sql = "SELECT `tickets`.* FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "tickets` AS `tickets` ";
$sql .= "INNER JOIN `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` AS `users` ON `users`.`id` = " . intval($user['id']) . " ";
$used_where_clause = false;
if ($id != NULL) {
$used_where_clause = true;
$sql .= "WHERE `tickets`.`id` = " . intval($id);
}
if (!$user['isadmin']) {
$clause = $used_where_clause ? ' AND ' : ' WHERE ';
$used_where_clause = true;
$sql .= $clause . ' `Categories` IN (' . $user['categories'] . ')';
$sql .= " AND ((`heskprivileges` LIKE '%can_view_tickets%' AND `owner` = " . intval($user['id']) . ")";
$sql .= " OR (`heskprivileges` LIKE '%can_view_unassigned%' AND `owner` = 0)";
$sql .= " OR (`heskprivileges` LIKE '%can_view_ass_others%' AND `owner` <> " . intval($user['id']) . "))";
}
$response = hesk_dbQuery($sql);
if (hesk_dbNumRows($response) == 0) {
return NULL;
}
$results = build_results($response);
return $id == NULL ? $results : $results[0];
}
function build_results($response) {
$results = array();
while ($row = hesk_dbFetchAssoc($response)) {
$row['id'] = intval($row['id']);
$row['Categories'] = intval($row['Categories']);
$row['priority'] = intval($row['priority']);
$row['status'] = intval($row['status']);
$row['replierid'] = intval($row['replierid']);
$row['archive'] = $row['archive'] == true;
$row['locked'] = $row['locked'] == true;
$row['html'] = $row['html'] == true;
$row['screen_resolution_height'] = convert_to_int($row['screen_resolution_height']);
$row['screen_resolution_width'] = convert_to_int($row['screen_resolution_width']);
$row['owner'] = convert_to_int($row['owner']);
$row['parent'] = convert_to_int($row['parent']);
$row['overdue_email_sent'] = $row['overdue_email_sent'] == true;
$results[] = $row;
}
return $results;
}
function convert_to_int($item) {
return $item != NULL ? intval($item) : NULL;
}

@ -1,26 +0,0 @@
<?php
function get_ticket_template($hesk_settings, $id = NULL) {
$sql = "SELECT `id`, `message`, `title`, `tpl_order` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "ticket_templates` ";
if ($id != NULL) {
$sql .= "WHERE `id` = ".intval($id);
}
$response = hesk_dbQuery($sql);
if (hesk_dbNumRows($response) == 0) {
return NULL;
}
$results = array();
while ($row = hesk_dbFetchAssoc($response)) {
$row['id'] = intval($row['id']);
$row['displayOrder'] = intval($row['tpl_order']);
unset($row['tpl_order']);
$row['title'] = hesk_html_entity_decode($row['title']);
$row['message'] = hesk_html_entity_decode($row['message']);
$results[] = $row;
}
return $id == NULL ? $results : $results[0];
}

@ -1,56 +0,0 @@
<?php
function get_user($hesk_settings, $id = NULL) {
$sql = "SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` ";
if ($id != NULL) {
$sql .= "WHERE `id` = " . intval($id);
}
$response = hesk_dbQuery($sql);
if (hesk_dbNumRows($response) == 0) {
return NULL;
}
$results = array();
while ($row = hesk_dbFetchAssoc($response)) {
$row['id'] = intval($row['id']);
$row['isadmin'] = get_boolean($row['isadmin']);
$row['signature'] = hesk_html_entity_decode($row['signature']);
$row['afterreply'] = intval($row['afterreply']);
$row['autostart'] = get_boolean($row['autostart']);
$row['notify_customer_new'] = get_boolean($row['notify_customer_new']);
$row['notify_customer_reply'] = get_boolean($row['notify_customer_reply']);
$row['show_suggested'] = get_boolean($row['show_suggested']);
$row['notify_new_unassigned'] = get_boolean($row['notify_new_unassigned']);
$row['notify_new_my'] = get_boolean($row['notify_new_my']);
$row['notify_reply_unassigned'] = get_boolean($row['notify_reply_unassigned']);
$row['notify_reply_my'] = get_boolean($row['notify_reply_my']);
$row['notify_assigned'] = get_boolean($row['notify_assigned']);
$row['notify_pm'] = get_boolean($row['notify_pm']);
$row['notify_note'] = get_boolean($row['notify_note']);
$row['notify_note_unassigned'] = get_boolean($row['notify_note_unassigned']);
$row['autoassign'] = get_boolean($row['autoassign']);
$row['ratingneg'] = intval($row['ratingneg']);
$row['ratingpos'] = intval($row['ratingpos']);
$row['autorefresh'] = intval($row['autorefresh']);
$row['active'] = get_boolean($row['active']);
$row['default_calendar_view'] = intval($row['default_calendar_view']);
$row['notify_overdue_unassigned'] = get_boolean($row['notify_overdue_unassigned']);
// TODO: Remove this once GitHub #346 is complete
$row['categories'] = explode(',', $row['categories']);
$row['heskprivileges'] = explode(',', $row['heskprivileges']);
$results[] = $row;
}
return $id == NULL ? $results : $results[0];
}
function get_boolean($value, $truthy_value = true) {
return $value == $truthy_value;
}

@ -1,7 +1,5 @@
<?php
// Properly handle error logging, as well as a fatal error workaround
//require_once(__DIR__ . '/autoload.php');
require_once(__DIR__ . '/bootstrap.php');
require_once(__DIR__ . '/autoload.php');
error_reporting(0);
set_error_handler('errorHandler');
@ -52,9 +50,9 @@ function exceptionHandler($exception) {
if (exceptionIsOfType($exception, 'SQLException')) {
/* @var $castedException \Core\Exceptions\SQLException */
$castedException = $exception;
print_error("Fought an uncaught Exceptions", sprintf("%s\n\n%s", $castedException->failingQuery, $exception->getTraceAsString()));
print_error("Fought an uncaught exception", sprintf("%s\n\n%s", $castedException->failingQuery, $exception->getTraceAsString()));
} else {
print_error("Fought an uncaught Exceptions", sprintf("%s\n\n%s", $exception->getMessage(), $exception->getTraceAsString()));
print_error("Fought an uncaught exception", sprintf("%s\n\n%s", $exception->getMessage(), $exception->getTraceAsString()));
}
}
@ -63,8 +61,8 @@ function exceptionHandler($exception) {
}
/**
* @param $exception Exception thrown Exceptions
* @param $class string The name of the expected Exceptions type
* @param $exception Exception thrown exception
* @param $class string The name of the expected exception type
* @return bool
*/
function exceptionIsOfType($exception, $class) {

Loading…
Cancel
Save