liam-linux-account-manager/templates/server_sync_status_json.php

25 lines
717 B
PHP
Raw Permalink Normal View History

2021-11-16 15:11:32 +01:00
<?php
$sync_status = $this->get('sync_status');
$last_sync = $this->get('last_sync');
$pending = $this->get('pending');
$accounts = $this->get('accounts');
$json = new StdClass;
$json->sync_status = $sync_status;
if(is_null($last_sync)) {
$json->last_sync = null;
} else {
$json->last_sync = new StdClass;
$json->last_sync->date = $last_sync->date;
$json->last_sync->details = json_decode($last_sync->details)->value;
}
$json->accounts = array();
foreach($accounts as $account) {
$jsa = new StdClass;
$jsa->name = $account->name;
$jsa->sync_status = $account->sync_status;
$jsa->pending = $account->sync_is_pending();
$json->accounts[] = $jsa;
}
$json->pending = $pending;
out(json_encode($json), ESC_NONE);