Automation Execution Time & Owner
This commit is contained in:
@@ -18,8 +18,10 @@ class AutomationManager{
|
||||
}
|
||||
|
||||
public function create ($name, $onDays, $doCode, $ifCode, $automationId = "") {
|
||||
$userId = UserManager::getUserData('user_id');
|
||||
$scene = array (
|
||||
'name' => $name,
|
||||
'owner_id' => $userId,
|
||||
'on_days' => $onDays,
|
||||
'if_something' => $ifCode,
|
||||
'do_something' => $doCode,
|
||||
@@ -55,7 +57,7 @@ class AutomationManager{
|
||||
$run = false;
|
||||
$restart = false;
|
||||
|
||||
if ($automation['active'] == 1 && $automation['locked'] != 1){
|
||||
if ($automation['active'] == 1 && $automation['locked'] != 1){
|
||||
Db::edit('automation', array('locked' => 1), 'WHERE automation_id = ?', array($automation['automation_id']));
|
||||
if (in_array($dayNameNow, $actionDays)){
|
||||
if (in_array($onValue['type'], ['sunSet', 'sunRise', 'time','now'])) {
|
||||
@@ -160,7 +162,7 @@ class AutomationManager{
|
||||
}
|
||||
|
||||
$logManager->write("[AUTOMATIONS] automation id ". $automation['automation_id'] . " was executed");
|
||||
Db::edit('automation', array('executed' => 1), 'WHERE automation_id = ?', array($automation['automation_id']));
|
||||
Db::edit('automation', array('executed' => 1, 'execution_time' => date("Y-m-d H:i:s")), 'WHERE automation_id = ?', array($automation['automation_id']));
|
||||
} else if ($restart) {
|
||||
$logManager->write("[AUTOMATIONS] automation id ". $automation['automation_id'] . " was restarted");
|
||||
Db::edit('automation', array('executed' => 0), 'WHERE automation_id = ?', array($automation['automation_id']));
|
||||
|
@@ -21,6 +21,16 @@ class UserManager
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserId ($userId) {
|
||||
try {
|
||||
$user = Db::loadOne ("SELECT * FROM users WHERE user_id = ?", [$userId]);
|
||||
return $user;
|
||||
} catch(PDOException $error) {
|
||||
echo $error->getMessage();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
public function getAvatarUrl(){
|
||||
$email = self::getUserData('email');
|
||||
return 'https://secure.gravatar.com/avatar/' . md5( strtolower( trim( $email ) ) );
|
||||
|
Reference in New Issue
Block a user