Inheritance: extends Controller
 public function execute()
 {
     $ratingId = 0;
     $user = $this->getUser();
     if (!isset($user)) {
         $this->logger->debug(__LINE__, 'User is empty');
         throw new Exception('User is empty');
     }
     $wikiId = (int) $this->getMain()->getVal('wikiId');
     $score = $this->getMain()->getVal('score');
     if (!is_int($wikiId)) {
         $this->logger->error(__LINE__, 'wikiId 格式不正确');
         $this->getResult()->addValue(null, $this->getModuleName(), array('isSuccess' => false, 'message' => 'wikiId 格式不正确'));
         return true;
     }
     $ratingController = new RatingController($ratingId, $wikiId, $user, $this->getRequest()->getIP());
     try {
         $result = $ratingController->rate($score);
         $this->getResult()->addValue(null, $this->getModuleName(), $result);
     } catch (Exception $ex) {
         $this->logger->error(__LINE__, 'Cannot get the rating score, wikiId %d', $wikiId);
         $this->getResult()->addValue(null, $this->getModuleName(), array('isSuccess' => false, 'message' => '服务器错误,请稍后再试'));
     }
     return true;
 }
<?php

include_once "include/session.php";
session_start();
$user = get_loggedin_user();
if (isset($user)) {
    // if the user is currently logged in
    include_once "controller/rating.php";
    $rating_controller = new RatingController();
    $rating_controller->invoke_give_rating();
} else {
    // if the user is currently not logged in
    header("Location: login.php");
}
Beispiel #3
0
});
$routes->get('/beer/:id/edit/', function ($id) {
    BeerController::edit($id);
});
$routes->post('/beer/:id/edit/', function ($id) {
    BeerController::update($id);
});
$routes->post('/beer/:id/destroy/', function ($id) {
    BeerController::destroy($id);
});
$routes->get('/rating/', function () {
    RatingController::index();
});
$routes->get('/rating/create/', function () {
    RatingController::create();
});
$routes->post('/rating/create/', function () {
    RatingController::store();
});
$routes->get('/rating/:id/', function ($id) {
    RatingController::show($id);
});
$routes->get('/rating/:id/edit/', function ($id) {
    RatingController::edit($id);
});
$routes->post('/rating/:id/edit/', function ($id) {
    RatingController::update($id);
});
$routes->post('/rating/:id/destroy/', function ($id) {
    RatingController::destroy($id);
});
Beispiel #4
0
<?php

header('Content-type: application/json');
require_once "./RatingController.class.php";
require_once "./RatingService.class.php";
$ratingId = 0;
// The entrance
$ratingService = new RatingService();
$ratingService->setRatingId($ratingId);
$controller = new RatingController();
$controller->setRatingService($ratingService);
if ($_POST["action"] != null && $_POST["action"] === "rate") {
    $data = $controller->rate();
} elseif (isset($_GET["getscore"])) {
    $data = $controller->getScore();
} else {
    $data = $controller->actionError();
}
echo json_encode($data);
<?php

include_once "include/session.php";
session_start();
$user = get_loggedin_user();
if (isset($user)) {
    // if the user is currently logged in
    include_once "controller/rating.php";
    $rating_controller = new RatingController();
    $rating_controller->invoke_give_rating_organizer();
} else {
    // if the user is currently not logged in
    header("Location: login.php");
}