$user = $current_user->user_id; if (!check_security_key($_POST['key'])) { error(_('clave de control incorrecta')); } $db->transaction(); $exists = User::get_pref($user, 'sub_follow', $id); if (empty($_POST['change'])) { $dict['value'] = $exists; $globals['access_log'] = false; // Don't log it, to avoid IP blocks } else { if ($exists) { User::delete_pref($user, 'sub_follow', $id); $dict['value'] = 0; } else { User::set_pref($user, 'sub_follow', $id); $dict['value'] = 1; } } $db->commit(); echo json_encode($dict); // end function error($mess) { $dict['error'] = $mess; echo json_encode($dict); die; } /****** function check_delete_defaults($uid) { // Check if the user is suscribed to all default
// You can get copies of the licenses here: // http://www.affero.org/oagpl.html // AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING". include '../config.php'; if (!check_security_key($_POST['control_key'])) { die; } $user = intval($_POST['id']); $key = $_POST['key']; $value = intval($_POST['value']); if (!$value) { $value = false; } if (!$user || $user != $current_user->user_id) { die; } if (empty($key)) { die; } if (!empty($_POST['set'])) { $value = intval($_POST['value']); if (User::set_pref($user, $key, $value)) { $res = $value; } else { $res = false; } } else { $res = User::get_pref($user, $key, $value); } header('Content-Type: application/json; charset=UTF-8'); echo json_encode($res);