Little Tweeks
This commit is contained in:
parent
946a93a23b
commit
ab92a58289
@ -23,14 +23,16 @@ class CronApi extends ApiController
|
||||
$pluginsFiles = array_diff(scandir($dir), ['..', '.']);
|
||||
foreach ($pluginsFiles as $key => $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')){
|
||||
if (!method_exists($pluginMakeClass, 'make')) {
|
||||
|
||||
continue;
|
||||
}
|
||||
$result[$className] = $pluginMakeClass->make();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Print Result
|
||||
$this->response($result);
|
||||
|
@ -1,8 +1,11 @@
|
||||
<?php
|
||||
|
||||
class RoomsApi extends ApiController{
|
||||
class RoomsApi extends ApiController
|
||||
{
|
||||
|
||||
public function default(){
|
||||
public function
|
||||
default()
|
||||
{
|
||||
//$this->requireAuth();
|
||||
$response = [];
|
||||
$roomIds = [];
|
||||
@ -21,17 +24,15 @@ class RoomsApi extends ApiController{
|
||||
foreach (explode('-', $subDevicesData[$subDeviceKey][$key]['type']) as $word) {
|
||||
$type .= ucfirst($word);
|
||||
}
|
||||
if(class_exists($type)){
|
||||
if (!class_exists($type)) {
|
||||
continue;
|
||||
}
|
||||
$deviceClass = new $type;
|
||||
if (method_exists($deviceClass,'translate')){
|
||||
if (!method_exists($deviceClass, 'translate')) {
|
||||
continue;
|
||||
}
|
||||
$subDevicesData[$subDeviceKey][$key]['value'] = $deviceClass->translate($subDevicesData[$subDeviceKey][$key]['value']);
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +47,8 @@ class RoomsApi extends ApiController{
|
||||
$this->response($response);
|
||||
}
|
||||
|
||||
public function update($roomId){
|
||||
public function update($roomId)
|
||||
{
|
||||
//$this->requireAuth();
|
||||
|
||||
$subDevicesData = SubDeviceManager::getSubdevicesByRoomIds([$roomId]);
|
||||
|
@ -33,13 +33,16 @@ class DeviceManager{
|
||||
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();
|
||||
$device = array (
|
||||
'name' => $name,
|
||||
'token' => $token,
|
||||
'room_id' => $defaultRoom,
|
||||
);
|
||||
if (!empty($type)) {
|
||||
$device['type'] = $type;
|
||||
}
|
||||
try {
|
||||
Db::add ('devices', $device);
|
||||
return Db::loadOne("SELECT device_id FROM devices WHERE token = ?", array($token))['device_id'];
|
||||
|
@ -44,7 +44,7 @@ class DatabaseBackup
|
||||
foreach ($files as $file) {
|
||||
$zip->addFile($file);
|
||||
}
|
||||
echo $zip->close();
|
||||
$zip->close();
|
||||
foreach ($files as $file) {
|
||||
unlink($file);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
class AirQuality extends VirtualDeviceManager
|
||||
class ExamplePlugin extends VirtualDeviceManager
|
||||
{
|
||||
function make(){
|
||||
//Getting Data
|
||||
|
Loading…
Reference in New Issue
Block a user