public function addgameAction() { $group_id = $this->_request->getParam('g'); $target_id = $this->_request->getParam('t'); $request = $this->getRequest(); $game_data = $request->getPost(); if (isset($_FILES["photo"]["error"])) { if ($_FILES["photo"]["error"] > 0) { if ($_FILES["photo"]["error"] != 4) { $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">×</button>' . $_FILES["photo"]["error"] . '</div>'); $this->_redirect("/planing/addgame"); } //else 4 = No file was uploaded, than do nothing. (add with default icon) } else { $allowed = array("jpg" => "image/jpg", "jpeg" => "image/jpeg", "gif" => "image/gif", "png" => "image/png"); $filename = $_FILES["photo"]["name"]; $filetype = $_FILES["photo"]["type"]; $filesize = $_FILES["photo"]["size"]; // Verify file extension $ext = pathinfo($filename, PATHINFO_EXTENSION); if (!array_key_exists($ext, $allowed)) { $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">×</button>' . $this->lang->_('FILE_WRONG_FORMAT') . '</div>'); $this->_redirect("/planing/addgame"); } // Verify file size - 5MB maximum $maxsize = 5 * 1024 * 1024; if ($filesize > $maxsize) { $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">×</button>' . $this->lang->_('FILE_SIZE_LIMIT') . '</div>'); $this->_redirect("/admin/addgame/g/" . $goalID); } // Verify MYME type of the file if (in_array($filetype, $allowed)) { // Check whether file exists before uploading it if (!file_exists($this->config->paths->upload->games . $_FILES["photo"]["name"])) { move_uploaded_file($_FILES["photo"]["tmp_name"], $this->config->paths->upload->games . $_FILES["photo"]["name"]); } } else { $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">×</button>' . $this->lang->_('FILE_ERROR') . '</div>'); $this->_redirect("/planing/addgame"); } } } else { $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">×</button>' . $this->lang->_('FILE_ERROR') . '</div>'); $this->_redirect("/planing/addgame"); } $gameName = trim($game_data['gameName']); if (!strlen($gameName)) { $this->msger->addMessage('<div class="alert alert-danger text-center" role="alert"><button type="button" class="close" data-dismiss="alert">×</button>' . $this->lang->_('REQUIRED_GAMENAME') . '</div>'); $this->_redirect('/planing/addgame'); } $games_DB = new Application_Model_DbTable_Game(); $new_game = array('goalID' => $target_id, 'name' => $game_data['gameName'], 'fieldID' => $_SESSION['Default']['field'], 'icon' => $_FILES["photo"]["name"]); try { $game_id = $games_DB->insert($new_game); } catch (Exception $ex) { die(json_encode(array('status' => 'danger', 'msg' => $ex->getMessage()))); } $groups_DB = new Application_Model_DbTable_Group(); $this->view->groupName = $groups_DB->getName($group_id); $this->_redirect("/planing/games/g/" . $group_id . "/t/" . $target_id); }
public function reportAction() { $groupID = $this->_request->getParam('g'); $_SESSION['Default']['report'] = true; $group_DB = new Application_Model_DbTable_Group(); $groupName = $group_DB->getName($groupID); $this->view->group_name = $groupName; $plans_DB = new Application_Model_DbTable_Planing(); $plans = $plans_DB->getByGroupReverse($groupID, $_SESSION['Default']['field']); $this->view->plans = $plans; }
public function deletestudentsAction() { $groupID = $this->_request->getParam('g'); $student_DB = new Application_Model_DbTable_StudentsInField(); $students = $student_DB->getAll($groupID); $this->view->students = $students; $this->view->groupID = $groupID; $groups_DB = new Application_Model_DbTable_Group(); $this->view->groupName = $groups_DB->getName($groupID); }
public function studentsAction() { $group_id = $this->_request->getParam('g'); $target_id = $this->_request->getParam('t'); $game_id = $this->_request->getParam('gm'); $is_recommend = $this->_request->getParam('recommend'); //Return After Planining if ($group_id && $target_id) { $student_DB = new Application_Model_DbTable_StudentsInField(); $grade_DB = new Application_Model_DbTable_Grade(); $students = $student_DB->getAll($group_id); $grades = $grade_DB->getAll($target_id); $_students = array(); foreach ($students as $s) { $s['grades'] = $grades; $_students[] = $s; } $this->view->students = $_students; $this->view->group_id = $group_id; $this->view->target_id = $target_id; $this->view->game_id = $game_id; $groups_DB = new Application_Model_DbTable_Group(); $this->view->groupName = $groups_DB->getName($group_id); } else { $plans_DB = new Application_Model_DbTable_Planing(); $last_plan = $plans_DB->getLastPlan($group_id, $_SESSION['Default']['field']); if ($last_plan) { $group_id = $last_plan['groupID']; $target_id = $last_plan['goal_id']; $game_id = $last_plan['game_id']; $student_DB = new Application_Model_DbTable_StudentsInField(); $grade_DB = new Application_Model_DbTable_Grade(); $students = $student_DB->getAll($group_id); $grades = $grade_DB->getAll($target_id); $_students = array(); foreach ($students as $s) { $s['grades'] = $grades; $_students[] = $s; } $this->view->students = $_students; $this->view->group_id = $group_id; $this->view->target_id = $target_id; $this->view->game_id = $game_id; $groups_DB = new Application_Model_DbTable_Group(); $this->view->groupName = $groups_DB->getName($group_id); } else { $this->view->group_id = $group_id; $groups_DB = new Application_Model_DbTable_Group(); $this->view->groupName = $groups_DB->getName($group_id); } } $games_DB = new Application_Model_DbTable_Game(); $this->view->gameName = $games_DB->getGameName($game_id); $notes = $this->getRequest()->getPost('notes'); if ($notes) { $comments_DB = new Application_Model_DbTable_Comments(); $new_comment = array('groupID' => $group_id, 'gameID' => $game_id, 'date' => date('Y-m-d H:i:s'), 'text' => $notes, 'fieldID' => $_SESSION['Default']['field']); try { $comment_id = $comments_DB->insert($new_comment); } catch (Exception $ex) { die(json_encode(array('status' => 'danger', 'msg' => $this->lang->_('FAILED_DOC')))); } } if ($is_recommend) { $this->recommend(); } }