Ejemplo n.º 1
0
function top_action_already_exists($achievement_id, $action)
{
    $connection = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PWD);
    $statement = $connection->prepare("select count(*) from actions where active=1 and name=? and achievement_id=0");
    $statement->bindValue(1, $action, PDO::PARAM_STR);
    $statement->execute();
    $num_of_records = (int) $statement->fetchColumn();
    if ($num_of_records == 1) {
        $statement = $connection->prepare("select id from actions where active=1 and achievement_id=0 and name=?");
        $statement->bindValue(1, $action, PDO::PARAM_STR);
        $statement->execute();
        $action_id = (int) $statement->fetchColumn();
        associate_action($achievement_id, $action_id);
        return true;
    } else {
        if ($num_of_records > 1) {
            error_log("Line #" . __LINE__ . " " . __FUNCTION__ . "({$achievement_id}, {$action_id}): More than one action registered for this achievement.");
            return true;
        }
    }
}
Ejemplo n.º 2
0
require_once "achievements.php";
require_once "display.php";
require_once "filter.php";
require_once "notes.php";
require_once "requirements.php";
require_once "relations.php";
require_once "tags.php";
require_once "todo.php";
require_once "user.php";
error_log("DEBUG:" . $_POST['function_to_be_called']);
switch (filter_input(INPUT_POST, "function_to_be_called", FILTER_SANITIZE_STRING)) {
    case "activate_achievement":
        activate_achievement(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT));
        break;
    case "associate_action":
        associate_action(filter_input(INPUT_POST, 'achievement_id', FILTER_SANITIZE_NUMBER_INT), filter_input(INPUT_POST, 'action_id', FILTER_SANITIZE_NUMBER_INT));
        break;
    case "cancel_todo":
        cancel_todo(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT));
        break;
    case "cancel_work":
        cancel_work(filter_input(INPUT_POST, 'action_id', FILTER_SANITIZE_NUMBER_INT));
        break;
    case "change_description":
        change_description(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT), filter_input(INPUT_POST, 'description', FILTER_SANITIZE_STRING));
        break;
    case "change_documentation_status":
        change_documentation_status(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT), filter_input(INPUT_POST, 'status', FILTER_SANITIZE_STRING));
        break;
    case "change_due_date":
        echo "EX";