Commit 9d796baa authored by Emiliano Balbuena's avatar Emiliano Balbuena
Browse files

(fix): Query issues; (chore): Tweak response

parent 9378e291
Loading
Loading
Loading
Loading
+29 −8
Original line number Original line Diff line number Diff line
@@ -29,7 +29,8 @@ class pro implements Interfaces\Api
            ->setUser(Session::getLoggedinUser());
            ->setUser(Session::getLoggedinUser());


        return Factory::response([
        return Factory::response([
            'active' => $manager->isActive()
            'isActive' => $manager->isActive(),
            /* TODO: Send values */
        ]);
        ]);
    }
    }


@@ -45,13 +46,28 @@ class pro implements Interfaces\Api
        $manager
        $manager
            ->setUser(Session::getLoggedinUser());
            ->setUser(Session::getLoggedinUser());


        switch ($pages[0]) {
            case 'enable':
                // TODO: Send and process payment data
                $success = $manager->enable(time() + (365 * 86400));
                $success = $manager->enable(time() + (365 * 86400));


                if (!$success) {
                    return Factory::response([
                    return Factory::response([
            'done' => $success,
                        'status' => 'error',
                        'message' => 'Error activating Pro',
                    ]);
                    ]);
                }
                }


                return Factory::response([/* TODO: Send values */]);

            default:
                return Factory::response([
                    'status' => 'error',
                    'message' => 'Unknown method'
                ]);
        }
    }

    /**
    /**
     * Equivalent to HTTP PUT method
     * Equivalent to HTTP PUT method
     * @param array $pages
     * @param array $pages
@@ -76,8 +92,13 @@ class pro implements Interfaces\Api


        $success = $manager->disable();
        $success = $manager->disable();


        if (!$success) {
            return Factory::response([
            return Factory::response([
            'done' => $success,
                'status' => 'error',
                'message' => 'Error disabling Pro',
            ]);
            ]);
        }
        }

        return Factory::response([]);
    }
}
}
+3 −1
Original line number Original line Diff line number Diff line
@@ -39,10 +39,12 @@ class InitializeValuesDelegate


        if (!$values) {
        if (!$values) {
            $values = new Values();
            $values = new Values();
            $values
                ->setUserGuid($user->guid);
        }
        }


        if (!$values->getDomain()) {
        if (!$values->getDomain()) {
            $values->setDomain("pro-{$user->username}.minds.com");
            $values->setDomain("pro-{$user->guid}.minds.com");
        }
        }


        $this->repository
        $this->repository
+2 −2
Original line number Original line Diff line number Diff line
@@ -49,11 +49,11 @@ class Repository
        $cqlOpts = [];
        $cqlOpts = [];


        if ($opts['user_guid']) {
        if ($opts['user_guid']) {
            $where .= 'user_guid = ?';
            $where[] = 'user_guid = ?';
            $values[] = new Bigint($opts['user_guid']);
            $values[] = new Bigint($opts['user_guid']);
        } elseif ($opts['domain']) {
        } elseif ($opts['domain']) {
            $cql = "SELECT * FROM pro_by_domain";
            $cql = "SELECT * FROM pro_by_domain";
            $where = 'domain = ?';
            $where[] = 'domain = ?';
            $values[] = $opts['domain'];
            $values[] = $opts['domain'];
        }
        }