/** * check administrator authentication * role: administrator */ public function login() { if (Authenticate::is_authorized()) { transport("dashboard"); } else { $model_administrator = new Authenticate(); /* * populate login data for administrator * use setter method to registering information of authentication */ $model_administrator->set_email($_POST['username']); $model_administrator->set_password($_POST['password']); $model_administrator->set_type(Authenticate::SUPERUSER); $login = $model_administrator->authenticate(); /* * $login variable contain array which have 2 keys [granted] and [state] * granted {true|false} and state {active|pending} * just grant credential that return active and match email and password */ if ($login["granted"] && $login["state"] == User::ACTIVE) { transport("dashboard"); } else { $_SESSION['operation'] = 'error'; $_SESSION['message'] = $login["state"]; transport("administrator"); } } }
/** * show feedback management page on administrator feature. * role: administrator */ public function index() { if (Authenticate::is_authorized()) { $model_player = Player::getInstance(); $model_player->get_total_player(); $model_player->unread_new_player(); $this->framework->view->page = "feedback"; $this->framework->view->content = "/backend/pages/feedback"; $this->framework->view->show("backend/template"); } else { transport("administrator"); } }
/** * export/download overall report into pdf * role: administrator */ public function get_overall() { if (Authenticate::is_authorized()) { $model_player = Player::getInstance(); $model_feedback = Feedback::getInstance(); $model_administrator = Administrator::getInstance(); $model_leaderboard = Leaderboard::getInstance(); $model_report = new ReportGenerator(); $model_report->get_report_overall($model_player->get_player_report(), $model_feedback->retrieve_feedback_report(), $model_administrator->retrieve_traffic_report(), $model_leaderboard->get_top10_ranking()); $model_report->print_report(); } else { transport("administrator"); } }
/** * delete player and all related data with this player * role: administrator */ public function delete() { if (Authenticate::is_authorized()) { $model_player = Player::getInstance(); $id = $_POST["id"]; if ($model_player->delete_player($id)) { $_SESSION['operation'] = 'success'; } else { $_SESSION['operation'] = 'error'; } transport("player"); } else { transport("administrator"); } }
/** * update profile data from setting page. * role: administrator */ public function setting_update() { if (Authenticate::is_authorized()) { $model_administrator = Administrator::getInstance(); /* * populate data from post request. * make sure form data match with setting keys */ $data = [Administrator::COLUMN_STG_NAME => $_POST["website_name"], Administrator::COLUMN_STG_DESCRIPTION => $_POST["website_description"], Administrator::COLUMN_STG_KEYWORD => $_POST["website_keyword"], Administrator::COLUMN_STG_EMAIL => $_POST["website_email"], Administrator::COLUMN_STG_NUMBER => $_POST["website_number"], Administrator::COLUMN_STG_ADDRESS => $_POST["website_address"], Administrator::COLUMN_STG_FACEBOOK => $_POST["website_facebook"], Administrator::COLUMN_STG_TWITTER => $_POST["website_twitter"]]; /* * invoke update_setting() method in administrator model. * check the return value that indicate upload favicon and update database are success */ if ($model_administrator->update_setting($data)) { $_SESSION['setting_operation'] = 'success'; } else { $_SESSION['setting_operation'] = 'error'; } transport("dashboard/setting"); } else { transport("administrator"); } }