From 54ec631d4bc183ea9c78d60334ca3b8bc616f90d Mon Sep 17 00:00:00 2001 From: malle-pietje Date: Sun, 4 Aug 2024 15:35:26 +0200 Subject: [PATCH] added a new example demonstrating the change of site settings --- examples/toggle_auto_update_settings.php | 69 ++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 examples/toggle_auto_update_settings.php diff --git a/examples/toggle_auto_update_settings.php b/examples/toggle_auto_update_settings.php new file mode 100755 index 0000000..a3b1cf0 --- /dev/null +++ b/examples/toggle_auto_update_settings.php @@ -0,0 +1,69 @@ +login(); + +if ($login_results) { + /** + * we get the current site mgmt settings + */ + $current_site_settings = $unifi_connection->list_settings(); + + $mgmt_settings = []; + foreach ($current_site_settings as $section) { + if ($section->key == 'mgmt') { + $mgmt_settings = $section; + } + } + + /** + * toggle the auto upgrade setting and set the auto upgrade hour to 3 + */ + $mgmt_settings->auto_upgrade = !$mgmt_settings->auto_upgrade; + $mgmt_settings->auto_upgrade_hour = 3; + $mgmt_id = $mgmt_settings->_id; + $set_result = $unifi_connection->set_site_mgmt($mgmt_id, $mgmt_settings); + + echo 'done' . PHP_EOL; + exit(); +} + +echo 'login failed' . PHP_EOL; \ No newline at end of file