From dfbd7b9df32161bd284378daa985b138795a648b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Wed, 5 Sep 2018 23:45:51 +0900 Subject: [PATCH] Add: insert active apps for new maestro as registrating --- src/web/server/admin/register_maestro.php | 37 ++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/web/server/admin/register_maestro.php b/src/web/server/admin/register_maestro.php index 1fb275e..b666d4f 100644 --- a/src/web/server/admin/register_maestro.php +++ b/src/web/server/admin/register_maestro.php @@ -6,7 +6,6 @@ include "./../setup/connect_db.php"; $maestroID = $_POST["maestro_id"]; - $result = register_maestro($maestroID); if($result <= 0) { set_error_message("마에스트로 계정 활성화 실패"); @@ -30,6 +29,8 @@ if($result === null || $result === 0) { exit; } +add_default_activated_apps($maestroID); + send_result_success(); exit; @@ -94,4 +95,38 @@ function set_maestro_test_player($maestroID, $playerID) { return $stmt->affected_rows; } +function add_default_activated_apps($maestroID) { + global $db_conn; + + $query = " + SELECT AppID + FROM app + WHERE Status = 1; + "; + $stmt = $db_conn->prepare($query); + $stmt->bind_param("i", $maestroID); + $stmt->execute(); + $stmt->bind_result($appID); + + $activeAppList = array(); + while($stmt->fetch()) { + array_push($activeAppList, $appID); + } + $stmt->close(); + + $count = count($activeAppList); + for($i = 0; $i < $count; $i++) { + $activeAppID = $activeAppList[$i]; + + $query = " + INSERT INTO active_app (MaestroID, AppID) + VALUES (?, ?); + "; + $stmt = $db_conn->prepare($query); + $stmt->bind_param("ii", $maestroID, $activeAppID); + $stmt->execute(); + $stmt->close(); + } +} + ?> \ No newline at end of file