/** * Returns a list of all known devices of the Request::GetGETUser() * * @access public * @return array */ public function ListDevicesDetails() { $user = Request::GetGETUser(); $devices = ZPushAdmin::ListDevices($user); $output = array(); ZLog::Write(LOGLEVEL_INFO, sprintf("WebserviceDevice::ListDevicesDetails(): found %d devices of user '%s'", count($devices), $user)); ZPush::GetTopCollector()->AnnounceInformation(sprintf("Retrieved details of %d devices", count($devices)), true); foreach ($devices as $devid) { $output[] = ZPushAdmin::GetDeviceDetails($devid, $user); } return $output; }
/** * Returns a list of all known devices with users and when they synchronized for the first time * * @access public * @return array */ public function ListDevicesDetails() { $devices = ZPushAdmin::ListDevices(false); $output = array(); ZLog::Write(LOGLEVEL_INFO, sprintf("WebserviceUsers::ListLastSync(): found %d devices", count($devices))); ZPush::GetTopCollector()->AnnounceInformation(sprintf("Retrieved details of %d devices and getting users", count($devices)), true); foreach ($devices as $deviceId) { $output[$deviceId] = array(); $users = ZPushAdmin::ListUsers($deviceId); foreach ($users as $user) { $output[$deviceId][$user] = ZPushAdmin::GetDeviceDetails($deviceId, $user); } } return $output; }
/** * Command "Resync folder(s)" * Resyncs a folder type of a specific device/user or of all users * * @return * @access public */ public static function CommandResyncFolder() { // if no device is specified, search for all devices of a user. If user is not set, all devices are returned. if (self::$device === false) { $devicelist = ZPushAdmin::ListDevices(self::$user); if (empty($devicelist)) { echo "\tno devices/users found\n"; return true; } } else { $devicelist = array(self::$device); } foreach ($devicelist as $deviceId) { $users = ZPushAdmin::ListUsers($deviceId); foreach ($users as $user) { if (self::$user && self::$user != $user) { continue; } self::resyncFolder($deviceId, $user, self::$type); } } }
/** * Command "Show all devices and users with last sync time" * Prints the device id of/and connected users * * @return * @access public */ public static function CommandShowLastSync() { $devicelist = ZPushAdmin::ListDevices(false); if (empty($devicelist)) { echo "\tno devices found\n"; } else { echo "All known devices and users and their last synchronization time\n\n"; echo str_pad("Device id", 36) . str_pad("Synchronized user", 30) . "Last sync time\n"; echo "-----------------------------------------------------------------------------------------------------\n"; } foreach ($devicelist as $deviceId) { $users = ZPushAdmin::ListUsers($deviceId); foreach ($users as $user) { $device = ZPushAdmin::GetDeviceDetails($deviceId, $user); echo str_pad($deviceId, 36) . str_pad($user, 30) . ($device->GetLastSyncTime() ? strftime("%Y-%m-%d %H:%M", $device->GetLastSyncTime()) : "never") . "\n"; } } }
/** * Command "Show all devices" and "Show devices of user" * Prints the device id of/and connected users * * @return * @access public */ public static function CommandShowDevices() { $devicelist = ZPushAdmin::ListDevices(self::$user); if (empty($devicelist)) { echo "\tno devices found\n"; } else { if (self::$user === false) { echo "All synchronized devices\n\n"; echo str_pad("Device id", 36) . "Synchronized users\n"; echo "-----------------------------------------------------\n"; } else { echo "Synchronized devices of user: "******"\n"; } } foreach ($devicelist as $deviceId) { if (self::$user === false) { echo str_pad($deviceId, 36) . implode(",", ZPushAdmin::ListUsers($deviceId)) . "\n"; } else { self::printDeviceData($deviceId, self::$user); } } }