<?php

$error['profile']['form'] = [];
$transactions = [];

do {
	$data = [
		'id' => $_SESSION['id'],
		'cancel' => isset($_GET['cancel']) && $_GET['cancel'] == 1 ? 1 : 0
	];

	$json = "";
	
	$cancelled = false;

	if (api(API_REQ_PROFILE, $data, $json)) {
		$transactions = $json['transactions'];
		$timezone = $json['timezone'];
		$tz = $json['tz'];
		
		
		if ($data['cancel']) {
			if (!isset($json['cancelled']) || $json['cancelled'] == 0) {
				$error['profile']['form']['cancel'][] = $languageError['profile']['cancel'];
			} else {
				$cancelled = true;
				$success['profile'][] = $languageSuccess['profile']['unsubscribed'];
				$success['profile'][] = $languageSuccess['profile']['logout'];
				
				session_destroy();
			}
		}

		break;
	}

	if (isset($json['code']) && $json['code'] == 2) {
		$error['profile']['form']['transaction'][] = $languageError['profile']['transaction'];
	} else {
		$error['profile']['form']['cancel'][] = $languageError['profile']['cancel'];
	}
} while (0);
