예제 #1
0
 public function run()
 {
     if (app::$session != 'admin') {
         app::$content['ajax_error'] = "Access only for admins!";
         view::set_special("ajax", "browser/error/ajax.html");
     } elseif (count(app::$param) > 0 && method_exists($this, app::$param[0])) {
         $this->{app::$param[0]}();
     }
     $this->generate_html_output();
 }
예제 #2
0
 public function run()
 {
     // debug::add_info("(".__FILE__.")<b>".__CLASS__."</b>::".__FUNCTION__."() betreten.");
     if (app::$session != 'admin') {
         app::$content['ajax_error'] = "Access only for admins!";
         view::set_special("ajax", "browser/error/ajax.html");
     } elseif (count(app::$param) > 0 && method_exists($this, app::$param[0])) {
         $this->{app::$param[0]}();
     }
     $this->generate_html_output();
 }
예제 #3
0
 public function delete()
 {
     view::set_special("ajax", "browser/ajax/modal.html");
     $id = app::$request['id'];
     $cls = "model_signup" . date("Y");
     $sup = $cls::get_entry_by_id($id);
     if (is_null($sup)) {
         app::$content['modal']["heading"] = "<div class='text-danger'>Fail!</div>";
         app::$content['modal']["content"] = "A Signupd with id {$id} not found!";
         return;
     }
     // @TODO: remove assignments from each player !!!
     $cls::delete_entry_by_id($id);
     app::$content['modal']["heading"] = "<div class='text-success'>Success!</div>";
     app::$content['modal']["content"] = "The Signup with id {$id} has been deleted!";
 }
예제 #4
0
 public function assign()
 {
     view::set_special("ajax", "browser/ajax/modal.html");
     if (!array_key_exists("json", app::$request)) {
         app::$content['modal']["heading"] = "<div class='text-danger'>Fail!</div>";
         app::$content['modal']["content"] = "No json data given!";
         return;
     }
     $jObj = app::$request['json'];
     $awrd_id = $jObj->award_id;
     $players = $jObj->players;
     if (count($players) == 0) {
         app::$content['modal']["heading"] = "<div class='text-danger'>Fail!</div>";
         app::$content['modal']["content"] = "No players selected!";
         return;
     }
     $cls = "model_award" . date("Y");
     $awrd = $cls::get_entry_by_id($awrd_id);
     foreach ($players as $player) {
         $cls = "model_player" . date("Y");
         $ply = $cls::get_entry_by_id($player);
         if (is_null($ply->awards) || $ply->awards == "") {
             $awards = array();
         } else {
             $awards = json_decode($ply->awards);
         }
         $do = true;
         if (count($awards) > 0) {
             foreach ($awards as $aw) {
                 if ($aw->month == $awrd->month && $aw->type == $awrd->type) {
                     $do = false;
                 }
             }
         }
         if ($do) {
             $awards[] = array("month" => $awrd->month, "type" => $awrd->type);
             $ply->awards = json_encode($awards);
             $ply->save();
         }
     }
     app::$content['modal']["heading"] = "<div class='text-success'>Success!</div>";
     app::$content['modal']["content"] = "The award <strong class='text-primary'>{$awrd->filename}</strong> has been assigned!";
 }
예제 #5
0
 public function dates()
 {
     view::set_special("ajax", "browser/ajax/modal.html");
     app::$content['modal']["heading"] = "<div class='text-success'>Success!</div>";
     app::$content['modal']["content"] = "The award <strong class='text-primary'>{$awrd->filename}</strong> has been assigned!";
 }
예제 #6
0
 private static function set_base_cli_layout()
 {
     // debug::add_info("(".__FILE__.")<b>".__CLASS__."</b>::".__FUNCTION__."() betreten.");
     if (cfg::$debug) {
         view::set_special("debug", "cli/debug/debug.cli");
     }
 }
예제 #7
0
 public function award()
 {
     view::set_special("ajax", "browser/ajax/modal.html");
     if (!is_array($_FILES) || !array_key_exists("file", $_FILES)) {
         app::$content['modal']["heading"] = "<div class='text-danger'>Fail!</div>";
         app::$content['modal']["content"] = "No image file received!";
         return;
     }
     $blob = addslashes(file_get_contents($_FILES['file']['tmp_name']));
     $filename = $_FILES['file']['name'];
     $mime = $_FILES['file']['type'];
     $cls = "model_award" . date("Y");
     if (!is_null($cls::get_award_by_month_type(intval(app::$request['month']), app::$request['type']))) {
         app::$content['modal']["heading"] = "<div class='text-danger'>Fail!</div>";
         app::$content['modal']["content"] = "This award has alread been uploaded!";
         return;
     }
     $award = new $cls();
     $award->month = intval(app::$request['month']);
     $award->type = app::$request['type'];
     $award->file = $blob;
     $award->filename = $filename;
     $award->mime = $mime;
     $award->save();
     unlink($_FILES['file']['tmp_name']);
     app::$content['modal']["heading"] = "<div class='text-success'>Success!</div>";
     app::$content['modal']["content"] = "Award {$filename} successfully uploaded!";
 }