Little Tweeks
This commit is contained in:
parent
946a93a23b
commit
ab92a58289
@ -20,16 +20,18 @@ class CronApi extends ApiController
|
|||||||
//Run Plugins
|
//Run Plugins
|
||||||
$result = [];
|
$result = [];
|
||||||
$dir = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'app/plugins/';
|
$dir = $_SERVER['DOCUMENT_ROOT'] . BASEDIR . 'app/plugins/';
|
||||||
$pluginsFiles = array_diff(scandir($dir), ['..','.']);
|
$pluginsFiles = array_diff(scandir($dir), ['..', '.']);
|
||||||
foreach ($pluginsFiles as $key => $pluginFile) {
|
foreach ($pluginsFiles as $key => $pluginFile) {
|
||||||
$className = str_replace(".php", "", $pluginFile);
|
$className = str_replace(".php", "", $pluginFile);
|
||||||
echo " test s " . $className . '\\n';
|
if (!class_exists($className)) {
|
||||||
if(class_exists($className)){
|
continue;
|
||||||
$pluginMakeClass = new $className;
|
}
|
||||||
if (method_exists($pluginMakeClass,'make')){
|
$pluginMakeClass = new $className;
|
||||||
$result[$className] = $pluginMakeClass->make();
|
if (!method_exists($pluginMakeClass, 'make')) {
|
||||||
}
|
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
$result[$className] = $pluginMakeClass->make();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Print Result
|
//Print Result
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class RoomsApi extends ApiController{
|
class RoomsApi extends ApiController
|
||||||
|
{
|
||||||
|
|
||||||
public function default(){
|
public function
|
||||||
|
default()
|
||||||
|
{
|
||||||
//$this->requireAuth();
|
//$this->requireAuth();
|
||||||
$response = [];
|
$response = [];
|
||||||
$roomIds = [];
|
$roomIds = [];
|
||||||
@ -18,19 +21,17 @@ class RoomsApi extends ApiController{
|
|||||||
foreach ($subDevice as $key => $value) {
|
foreach ($subDevice as $key => $value) {
|
||||||
if (strpos($subDevicesData[$subDeviceKey][$key]['type'], '-') !== false) {
|
if (strpos($subDevicesData[$subDeviceKey][$key]['type'], '-') !== false) {
|
||||||
$type = "";
|
$type = "";
|
||||||
foreach(explode('-', $subDevicesData[$subDeviceKey][$key]['type']) as $word){
|
foreach (explode('-', $subDevicesData[$subDeviceKey][$key]['type']) as $word) {
|
||||||
$type .= ucfirst($word);
|
$type .= ucfirst($word);
|
||||||
}
|
}
|
||||||
if(class_exists($type)){
|
if (!class_exists($type)) {
|
||||||
$deviceClass = new $type;
|
|
||||||
if (method_exists($deviceClass,'translate')){
|
|
||||||
$subDevicesData[$subDeviceKey][$key]['value'] = $deviceClass->translate($subDevicesData[$subDeviceKey][$key]['value']);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
$deviceClass = new $type;
|
||||||
continue;
|
if (!method_exists($deviceClass, 'translate')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$subDevicesData[$subDeviceKey][$key]['value'] = $deviceClass->translate($subDevicesData[$subDeviceKey][$key]['value']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,7 +47,8 @@ class RoomsApi extends ApiController{
|
|||||||
$this->response($response);
|
$this->response($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($roomId){
|
public function update($roomId)
|
||||||
|
{
|
||||||
//$this->requireAuth();
|
//$this->requireAuth();
|
||||||
|
|
||||||
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds([$roomId]);
|
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds([$roomId]);
|
||||||
|
@ -33,13 +33,16 @@ class DeviceManager{
|
|||||||
WHERE devices.approved != ? ORDER BY $sort $sortType", Array(2));
|
WHERE devices.approved != ? ORDER BY $sort $sortType", Array(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function create ($name, $token) {
|
public static function create ($name, $token, $type = "") {
|
||||||
$defaultRoom = RoomManager::getDefaultRoomId();
|
$defaultRoom = RoomManager::getDefaultRoomId();
|
||||||
$device = array (
|
$device = array (
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
'room_id' => $defaultRoom,
|
'room_id' => $defaultRoom,
|
||||||
);
|
);
|
||||||
|
if (!empty($type)) {
|
||||||
|
$device['type'] = $type;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Db::add ('devices', $device);
|
Db::add ('devices', $device);
|
||||||
return Db::loadOne("SELECT device_id FROM devices WHERE token = ?", array($token))['device_id'];
|
return Db::loadOne("SELECT device_id FROM devices WHERE token = ?", array($token))['device_id'];
|
||||||
|
@ -44,7 +44,7 @@ class DatabaseBackup
|
|||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
$zip->addFile($file);
|
$zip->addFile($file);
|
||||||
}
|
}
|
||||||
echo $zip->close();
|
$zip->close();
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
unlink($file);
|
unlink($file);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
class AirQuality extends VirtualDeviceManager
|
class ExamplePlugin extends VirtualDeviceManager
|
||||||
{
|
{
|
||||||
function make(){
|
function make(){
|
||||||
//Getting Data
|
//Getting Data
|
||||||
|
Loading…
Reference in New Issue
Block a user