$result['status'] = 1; try { if (!isset($_POST['id']) || !isset($_POST['answer']) && !isset($_POST['status'])) { throw new UnexpectedValueException(); } $id = (int) $_POST['id']; $answer = isset($_POST['answer']) ? (int) $_POST['answer'] : (int) $_POST['status']; if (isset($_POST['mw']) && $_POST['mw'] == 1) { require_once '../lib/lib_multiwords.php'; check_permission(PERM_MULTITOKENS); MultiWordTask::register_answer($id, $_SESSION['user_id'], $answer); } else { if (isset($_POST['moder'])) { if (isset($_POST['status'])) { $result['status'] = save_moderated_status($id, $answer); } else { $result['status'] = save_moderated_answer($id, $answer, (int) $_POST['manual']); } } else { check_logged(); update_annot_instance($id, $answer); $am = new AchievementsManager((int) $_SESSION['user_id']); $am->emit(EventTypes::TASK_DONE); } } } catch (Exception $e) { $result['status'] = $e->getMessage(); $result['error'] = 1; } log_timing(true); die(json_encode($result));
function user_award_for_signup($user_id) { $am = new AchievementsManager($user_id); $am->emit(EventTypes::SIGNED_UP); }
if (isset($_GET['act'])) { $action = $_GET['act']; } else { $action = ''; } switch ($action) { case 'save': save_user_options($_POST); alert_set('success', 'Настройки сохранены'); header('Location:options.php'); break; case 'save_team': save_user_team($_POST['team_id'], $_POST['new_team_name']); if ($_POST['team_id'] || $_POST['new_team_name']) { $am = new AchievementsManager((int) $_SESSION['user_id']); $am->emit(EventTypes::JOINED_TEAM); } alert_set('success', 'Настройки сохранены'); header('Location:options.php'); break; case 'readonly_on': set_readonly_on(); header('Location:options.php'); break; case 'readonly_off': set_readonly_off(); header('Location:options.php'); break; default: check_logged(); $mgr = new UserOptionsManager();
<?php require_once '../lib/header_ajax.php'; require_once '../lib/lib_achievements.php'; if (!is_logged()) { return; } $am = new AchievementsManager((int) $_SESSION['user_id']); $am->emit(EventTypes::WANT_MORE); echo json_encode($result);
<?php if (php_sapi_name() == 'cli') { set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . PATH_SEPARATOR . __DIR__ . '/..'); require_once "lib/header.php"; require_once "lib/lib_achievements.php"; if (date("j") != 1) { die("Today is not the first day of the month, finishing.\n"); } print "Pinging dog achievement recalculation.. \n"; // get all users which registered the same day as today $users = sql_pe("SELECT user_id FROM users\n \tWHERE DATE(FROM_UNIXTIME(user_reg)) < DATE_SUB(DATE(NOW()), INTERVAL 15 DAY)\n \t ", array()); print "Month(s) (or at least 15 days) since registration passed for " . count($users) . " user(s)\n"; foreach ($users as $u) { $am = new AchievementsManager((int) $u['user_id']); $am->emit(EventTypes::MONTH_PASSED); } print "Achievements pinged, finishing\n"; }