v1.0 Initial commit of project
This commit is contained in:
72
pub/api/classes/API_platforms.php
Normal file
72
pub/api/classes/API_platforms.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace api\classes;
|
||||
|
||||
use api\classes\API;
|
||||
|
||||
require_once 'API.php';
|
||||
|
||||
class API_platforms extends API
|
||||
{
|
||||
public function getPlatforms($returnBoolean = false)
|
||||
{
|
||||
list($query, $types, $params) = $this->buildDynamicQuery('vc_platforms');
|
||||
|
||||
$items = $this->generalGetFunction($query, $types, $params, $returnBoolean, 'Platform');
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
public function createPlatforms()
|
||||
{
|
||||
if (isset($this->data['platform_image'])) {
|
||||
$query = "INSERT INTO vc_platforms (platform_uuid, platform_name, platform_slugify, platform_description, platform_enabled, platform_image, platform_create_timestamp) VALUES (UUID(), ?, ?, ?, ?, ?, ?)";
|
||||
$stmt = $this->prepareStatement($query);
|
||||
$stmt->bind_param('sssssi', $this->data['platform_name'], $this->data['platform_slugify'], $this->data['platform_description'], $this->data['platform_enabled'], $this->data['platform_image'], time());
|
||||
} else {
|
||||
$query = "INSERT INTO vc_platforms (platform_uuid, platform_name, platform_slugify, platform_description, platform_enabled, platform_create_timestamp) VALUES (UUID(), ?, ?, ?, ?, ?)";
|
||||
$stmt = $this->prepareStatement($query);
|
||||
$stmt->bind_param('ssssi', $this->data['platform_name'], $this->data['platform_slugify'], $this->data['platform_description'], $this->data['platform_enabled'], time());
|
||||
}
|
||||
|
||||
$this->executeStatement($stmt);
|
||||
$stmt->close();
|
||||
|
||||
$result = $this->getPlatformSlugify();
|
||||
if ($result->num_rows === 0) {
|
||||
$this->apiOutput(500, ['error' => 'Something went wrong creating the platform on the server.'], 'error_contact_support');
|
||||
}
|
||||
|
||||
$platform_data = $result->fetch_assoc();
|
||||
|
||||
$this->apiOutput(200, ['success' => $platform_data], 'item_added');
|
||||
}
|
||||
|
||||
public function getPlatformSlugify()
|
||||
{
|
||||
$query = "SELECT * FROM vc_platforms WHERE platform_slugify = ?";
|
||||
$stmt = $this->prepareStatement($query);
|
||||
$stmt->bind_param("s", $this->data['platform_slugify']);
|
||||
$this->executeStatement($stmt);
|
||||
return $stmt->get_result();
|
||||
}
|
||||
|
||||
public function editPlatforms()
|
||||
{
|
||||
if (isset($this->data['platform_image'])) {
|
||||
$query = "UPDATE vc_platforms SET platform_name = ?, platform_description = ?, platform_enabled = ?, platform_image = ?, platform_modified_timestamp = ? WHERE platform_uuid = ?";
|
||||
$stmt = $this->prepareStatement($query);
|
||||
$stmt->bind_param("ssisis", $this->data['platform_name'], $this->data['platform_description'], $this->data['platform_enabled'], $this->data['platform_image'], time(), $this->data['platform_uuid']);
|
||||
} else {
|
||||
$query = "UPDATE vc_platforms SET platform_name = ?, platform_description = ?, platform_enabled = ?, platform_modified_timestamp = ? WHERE platform_uuid = ?";
|
||||
$stmt = $this->prepareStatement($query);
|
||||
$stmt->bind_param("ssiis", $this->data['platform_name'], $this->data['platform_description'], $this->data['platform_enabled'], time(), $this->data['platform_uuid']);
|
||||
}
|
||||
|
||||
if ($this->executeStatement($stmt)) {
|
||||
$this->apiOutput(200, ['success' => 'Platform updated successfully.']);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user