예제 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $file = Input::file('image');
     // your file upload input field in the form should be named 'file'
     $destinationPath = public_path() . '/uploads';
     $filename = $file->getClientOriginalName();
     //$extension =$file->getClientOriginalExtension(); //if you need extension of the file
     $uploadSuccess = Input::file('image')->move($destinationPath, $filename);
     $RandNumber = rand(0, 9999999999.0);
     if ($uploadSuccess) {
         require_once 'PHPImageWorkshop/ImageWorkshop.php';
         chmod($destinationPath . "/" . $filename, 0777);
         $layer = PHPImageWorkshop\ImageWorkshop::initFromPath(public_path() . '/uploads/' . $filename);
         unlink(public_path() . '/uploads/' . $filename);
         $layer->resizeInPixel(400, null, true);
         $layer->applyFilter(IMG_FILTER_CONTRAST, -16, null, null, null, true);
         $layer->applyFilter(IMG_FILTER_BRIGHTNESS, 9, null, null, null, true);
         $dirPath = public_path() . '/uploads/' . "team";
         $filename = "_" . $RandNumber . ".png";
         $createFolders = true;
         $backgroundColor = null;
         // transparent, only for PNG (otherwise it will be white if set null)
         $imageQuality = 100;
         // useless for GIF, usefull for PNG and JPEG (0 to 100%)
         $layer->save($dirPath, $filename, $createFolders, $backgroundColor, $imageQuality);
         chmod($dirPath . "/" . $filename, 0777);
         //connect & insert file record in database
         $team = Team::create(array("name" => Input::get("name"), "image" => $filename, "title" => Input::get("title"), "phone" => Input::get("phone"), "email" => Input::get("email"), "password" => Input::get("password"), "descriptions" => Input::get("descriptions")));
     }
     return View::make('team.manage');
 }
예제 #2
0
function _ops_update()
{
    $OID = max(0, intval($_POST['OID']));
    $CID = max(0, intval($_POST['CID']));
    $msg = "";
    loginRequireMgmt();
    if (!loginCheckPermission(USER::MGMT_TEAM)) {
        redirect("errors/401");
    }
    $itemName = "Team";
    $urlPrefix = "mgmt_team";
    $object = new Team();
    if ($OID) {
        $object->retrieve($OID, $CID);
        if (!$object->exists()) {
            $msg = "{$itemName} not found!";
        } else {
            transactionBegin();
            $object->merge($_POST);
            if ($object->update()) {
                transactionCommit();
                $msg = "{$itemName} updated!";
            } else {
                transactionRollback();
                $msg = "{$itemName} update failed";
            }
        }
    } else {
        $object->merge($_POST);
        for ($retry = 0; $retry < PIN_RETRY_MAX; $retry++) {
            $pin = Team::generatePIN();
            if (Team::getFromPin($pin) === false) {
                // not a duplicate
                $object->set('pin', $pin);
                transactionBegin();
                if ($object->create() !== false) {
                    transactionCommit();
                    $msg = "{$itemName} created!";
                    break;
                }
            }
        }
        if ($retry >= PIN_RETRY_MAX) {
            transactionRollback();
            $msg = "{$itemName} Create failed";
        }
    }
    redirect("{$urlPrefix}/manage", $msg);
}
예제 #3
0
파일: Batch.php 프로젝트: xJakub/LCE
    public function makeTeams() {

        $teams = [];
        foreach (explode("\n", file_get_contents("teams.txt")) as $line) {
            $parts = explode(" - ", " $line ");

            if (count($parts) != 2) continue;

            list($name, $username) = $parts;
            $username = trim($username);
            $name = trim($name);

            $team = Team::create();
            $team->isadmin = false;
            $team->ismember = true;

            if ($username[0] == '@') {
                $username = substr($username, 1);
                $team->isadmin = true;
            }
            else if ($username[0] == '!') {
                $username = substr($username, 1);
                $team->ismember = false;
            }

            $team->name = $name;
            $team->username = $username;
            $team->ispublic = true;

            if (!strlen($name)) {
                $team->name = $team->username;
                $team->ispublic = false;
            }

            $teams[] = $team;
        }

        if (count($teams) >= 1 && count($teams) != count(Team::find('1=1'))) {
            Team::truncate(true);
            Match::truncate(true);
            Model::saveAll($teams);
            ?>Equipos actualizados.<br><?
        }
        else {
            ?>No hay cambios en los equipos.<br><?
        }
    }
예제 #4
0
function _ops_loaddb()
{
    $urlPrefix = "mgmt_team";
    $item = "Team";
    if (isset($_FILES['csv_file']) && is_uploaded_file($_FILES['csv_file']['tmp_name'])) {
        // open the csv file for reading
        $file_path = $_FILES['csv_file']['tmp_name'];
        $handle = fopen($file_path, 'r');
        try {
            transactionBegin();
            $o = new Team();
            if ($o->deleteAll() === false) {
                throw new Exception("delete all {$item}");
            }
            while (($data = fgetcsv($handle, 1000, ',')) !== FALSE) {
                if (count($data) != 2) {
                    throw new Exception("wrong number of value of {$item}");
                }
                $s = School::getFromName($data[1]);
                if ($s === false) {
                    throw new Exception("Can't find shool {$data['1']}");
                }
                $pin = generatePin();
                if ($pin === false) {
                    throw new Exception("Couldn't create unique pin");
                }
                $o = new Team();
                $o->set('name', $data[0]);
                $o->set('pin', $pin);
                $o->set('schoolId', $s->get('OID'));
                if ($o->create() === false) {
                    throw new Exception("Can't create {$item} object");
                }
            }
            transactionCommit();
            $msg = "Load {$item} completed";
        } catch (Exception $e) {
            transactionRollback();
            $msg = "caught exception " . $e->getMessage();
        }
        // delete csv file
        unlink($file_path);
    } else {
        $msg = "error no file uploaded";
    }
    redirect("{$urlPrefix}/manage", $msg);
}
예제 #5
0
 public function post_add()
 {
     $input = Input::get();
     $rules = array('name' => 'required|unique:teams', 'alias' => 'required|max:128|unique:teams', 'description' => 'required');
     $validation = Validator::make($input, $rules);
     if ($validation->passes()) {
         // Modify input variables
         $input['alias'] = strtolower($input['alias']);
         // Create the team
         $team = Team::create($input);
         // Make the team active for the current year
         Year::current_year()->teams()->attach($team->id);
         return Redirect::to('rms/teams')->with('success', 'Successfully Added New Team');
     } else {
         return Redirect::to('rms/teams/add')->withErrors($validation)->withInput();
     }
 }
예제 #6
0
 public function run()
 {
     DB::table('team')->delete();
     //Groupe A
     Team::create(array('name' => 'Brésil', 'code' => 'BRA'));
     Team::create(array('name' => 'Mexique', 'code' => 'MEX'));
     Team::create(array('name' => 'Croatie', 'code' => 'CRO'));
     Team::create(array('name' => 'Cameroun', 'code' => 'CMR'));
     //Groupe B
     Team::create(array('name' => 'Pays-Bas', 'code' => 'NED'));
     Team::create(array('name' => 'Chili', 'code' => 'CHI'));
     Team::create(array('name' => 'Australie', 'code' => 'AUS'));
     Team::create(array('name' => 'Espagne', 'code' => 'ESP'));
     //Groupe C
     Team::create(array('name' => 'Colombie', 'code' => 'COL'));
     Team::create(array('name' => 'Côte d\'ivoire', 'code' => 'CIV'));
     Team::create(array('name' => 'Japon', 'code' => 'JPN'));
     Team::create(array('name' => 'Grèce', 'code' => 'GRE'));
     //Groupe D
     Team::create(array('name' => 'Costa Rica', 'code' => 'CRC'));
     Team::create(array('name' => 'Italie', 'code' => 'ITA'));
     Team::create(array('name' => 'Uruguay', 'code' => 'URU'));
     Team::create(array('name' => 'Angleterre', 'code' => 'ENG'));
     //Groupe E
     Team::create(array('name' => 'France', 'code' => 'FRA'));
     Team::create(array('name' => 'Équateur', 'code' => 'ECU'));
     Team::create(array('name' => 'Suisse', 'code' => 'SUI'));
     Team::create(array('name' => 'Honduras', 'code' => 'HON'));
     //Groupe F
     Team::create(array('name' => 'Argentine', 'code' => 'ARG'));
     Team::create(array('name' => 'Nigeria', 'code' => 'NGA'));
     Team::create(array('name' => 'Iran', 'code' => 'IRN'));
     Team::create(array('name' => 'Bosnie-Herzégovine', 'code' => 'BIH'));
     //Groupe G
     Team::create(array('name' => 'Allemagne', 'code' => 'GER'));
     Team::create(array('name' => 'États-Unis', 'code' => 'USA'));
     Team::create(array('name' => 'Ghana', 'code' => 'GHA'));
     Team::create(array('name' => 'Portugal', 'code' => 'POR'));
     //Groupe H
     Team::create(array('name' => 'Belgique', 'code' => 'BEL'));
     Team::create(array('name' => 'Corée du Sud', 'code' => 'KOR'));
     Team::create(array('name' => 'Russie', 'code' => 'RUS'));
     Team::create(array('name' => 'Algérie', 'code' => 'ALG'));
 }
예제 #7
0
 public function doAddTeam($data, Form $form)
 {
     // check if the player combination for a new team already exists
     $teamExists = $this->teamExists($data['PlayerOne'], $data['PlayerTwo']);
     if (!$teamExists) {
         // check other combination
         $teamExists = $this->teamExists($data['PlayerTwo'], $data['PlayerOne']);
     }
     if ($teamExists) {
         // team already exists
         return $this->redirectBack();
     } else {
         // check again - opposite order
         // create the new team with player ID's
         $team = Team::create();
         $team->PlayerOne = $data['PlayerOne'];
         $team->PlayerTwo = $data['PlayerTwo'];
         $team->write();
         $redirectLink = $this->Link() . '?success=1';
         return $this->redirect($redirectLink);
     }
 }
예제 #8
0
 /**
  * pickTeams
  * Take all players and assign teams as necessary. This is step one.
  * Players array gets shuffled to assign random players.
  * Does not define matches.  Only initial team assignment.
  *
  * 
  * @return void
  */
 public function pickTeams($random = true)
 {
     $players = $this->bracket->players;
     // Are there enough teams for a tournament?
     if (ceil(count($players) / $this->bracket->players_per_team) < 2) {
         return null;
     }
     // Setting the var random to true will shuffle the array of players.
     // Otherwise it will be a first second, third fourth, in order.
     if ($random) {
         shuffle($players);
     }
     // put the players in a random order to assign them.
     // DELETE any existing teams in the bracket.  We're drawing new teams heeeaaahhhhhh
     $this->bracket->teams()->delete();
     for ($i = 0; $i < count($players); $i += $this->bracket->players_per_team) {
         /*
         	CREATE the new team.  You could name it if you want... 
         */
         $team = Team::create(array('name' => date('F j, Y, g:i a')));
         /*
         	ATTACH players to the newly created team.
         	Every team has to have at least one.
         */
         for ($k = 0; $k < $this->bracket->players_per_team; $k++) {
             if (current($players) === false) {
                 continue;
             }
             $team->players()->attach(current($players));
             next($players);
         }
         /*
         	ASSOCIATE the new team with the bracket.
         	This team now has all the players assigned
         */
         $this->bracket->teams()->insert($team);
     }
     return count($this->bracket->teams);
 }
예제 #9
0
if ($_REQUEST['id'] && !($team = Team::lookup($_REQUEST['id']))) {
    $errors['err'] = sprintf(__('%s: Unknown or invalid'), __('team'));
}
if ($_POST) {
    switch (strtolower($_POST['do'])) {
        case 'update':
            if (!$team) {
                $errors['err'] = sprintf(__('%s: Unknown or invalid'), __('team'));
            } elseif ($team->update($_POST, $errors)) {
                $msg = sprintf(__('Successfully updated %s'), __('this team'));
            } elseif (!$errors['err']) {
                $errors['err'] = sprintf(__('Unable to update %s. Correct any error(s) below and try again.'), __('this team'));
            }
            break;
        case 'create':
            if ($id = Team::create($_POST, $errors)) {
                $msg = sprintf(__('Successfully added %s'), Format::htmlchars($_POST['team']));
                $_REQUEST['a'] = null;
            } elseif (!$errors['err']) {
                $errors['err'] = sprintf(__('Unable to add %s. Correct error(s) below and try again.'), __('this team'));
            }
            break;
        case 'mass_process':
            if (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) {
                $errors['err'] = sprintf(__('You must select at least %s.'), __('one team'));
            } else {
                $count = count($_POST['ids']);
                switch (strtolower($_POST['a'])) {
                    case 'enable':
                        $sql = 'UPDATE ' . TEAM_TABLE . ' SET isenabled=1 ' . ' WHERE team_id IN (' . implode(',', db_input($_POST['ids'])) . ')';
                        if (db_query($sql) && ($num = db_affected_rows())) {
예제 #10
0
 public function run()
 {
     DB::table('teams')->truncate();
     Team::create(array('name' => 'Real Madrid', 'type' => 'club', 'logo_image' => 'realmadrid.png', 'jersey_image' => 'madrid.png'));
     Team::create(array('name' => 'Barcelona', 'type' => 'club', 'logo_image' => 'barcelona.png', 'jersey_image' => 'barca.png'));
 }
예제 #11
0
function _resetdb()
{
    if (!isset($_POST['dataOption'])) {
        echo "error";
        exit;
    }
    $dataOption = $_POST['dataOption'];
    try {
        $dbh = getdbh();
        $list = explode(",", "v_leaderboard_main,v_ext_ranks,v_leaderboard_ext");
        foreach ($list as $view) {
            dropView($dbh, $view);
        }
        //
        //  rPI challenge data
        //
        $list = explode(",", "t_cts_data,t_fsl_data,t_hmb_data,t_cpa_data,t_ext_data");
        foreach ($list as $table) {
            dropTable($dbh, $table);
        }
        $list = explode(",", "t_event,t_user,t_rpi,t_station,t_stationtype,t_team,t_school");
        foreach ($list as $table) {
            dropTable($dbh, $table);
        }
        create_t_user($dbh);
        create_t_stationtype($dbh);
        create_t_station($dbh);
        create_t_school($dbh);
        create_t_team($dbh);
        create_t_event($dbh);
        create_t_rpi($dbh);
        create_v_leaderboard_main($dbh);
        create_v_ext_ranks($dbh);
        create_v_leaderboard_ext($dbh);
        //
        //  rPI challenge data
        //
        create_t_cts_data($dbh);
        create_t_fsl_data($dbh);
        create_t_hmb_data($dbh);
        create_t_cpa_data($dbh);
        create_t_ext_data($dbh);
        $admin = new User();
        $admin->set('username', "admin");
        $admin->setPassword('pass');
        $admin->set('email', "*****@*****.**");
        $admin->set('fullname', "administrator");
        $admin->setRoll(USER::ROLL_ADMIN);
        $admin->create();
        $stationType = StationType::makeStationType(StationType::STATION_TYPE_REG, "Register", false, 60, "Hello! You have been successfully registered and may start the competition. Good luck!", "If you see this message there was an internal error 1", "If you see this message there was an internal error 2", "If you see this message there was an internal error 3");
        if ($stationType === false) {
            echo "Create StationType REG failed";
        } else {
            createStations(1, "reg", $stationType->get('OID'));
        }
        $stationType = StationType::makeStationType(StationType::STATION_TYPE_CTS, "Crack The Safe", true, 60, "Welcome, Team! Your first assignment is to break into Professor Aardvark's safe where you will find the first clue to his Secret Laboratory. Measure the interior angles and pick the three correct angles for the safe combination. Good luck! [clue=[clue]]", "Success! Go quickly to the next team queue.", "You have failed the challenge. Go quickly to the next team queue.", "No luck, better try again!");
        $numStations = $dataOption == 1 ? 1 : 6;
        if ($stationType === false) {
            echo "Create StationType CTS failed";
        } else {
            createStations($numStations, "cts", $stationType->get('OID'));
        }
        $stationType = StationType::makeStationType(StationType::STATION_TYPE_FSL, "Find Secret Lab", false, 60, "Find and scan the [ordinal] at [waypoint-lat=[lat]] [waypoint-lon=[lng]].", "Success! Find and scan the [ordinal] marker at [waypoint-lat=[lat]] [waypoint-lon=[lng]].", "Too bad, you failed. Find and scan the [ordinal] marker at [waypoint-lat=[lat]] [waypoint-lon=[lng]].", "Wrong marker, try again!");
        if ($stationType === false) {
            echo "Create StationType FSL failed";
        } else {
            createStations(1, "fsl", $stationType->get('OID'));
        }
        $stationType = StationType::makeStationType(StationType::STATION_TYPE_HMB, "Defuse Hypermutation Bomb", true, 60, "The HMB has been triggered! Send the Energy Pulsator cycle time quickly!", "Success! Go quickly to the next team queue.", "Oops. Enough said. Go quickly to the next team queue.", "Nope, better try again!");
        $numStations = $dataOption == 1 ? 1 : 6;
        if ($stationType === false) {
            echo "Create StationType HMB failed";
        } else {
            createStations($numStations, "hmb", $stationType->get('OID'));
        }
        $stationType = StationType::makeStationType(StationType::STATION_TYPE_CPA, "Catch Provessor Aardvark", true, 2000, "PA is trying to escape. Quickly measure the [fence=label] [building=[label]] and scan Start QR Code.", "Watch now as the professor attempts to escape. Get him!", "Success! Go quickly to the team finish area.", "Professor Aardvark has escaped. Oh well. Go quickly to the team finish area.", "Miss! Try again!");
        $numStations = $dataOption == 1 ? 1 : 6;
        if ($stationType === false) {
            echo "Create StationType CPA failed";
        } else {
            createStations($numStations, "cpa", $stationType->get('OID'));
        }
        $stationType = StationType::makeStationType(StationType::STATION_TYPE_EXT, "Extra", false, 60, "You have 20 (TBR) minutes to provide the tower location and height. Good luck." . " [waypoint1-lat=[a_lat]] [waypoint1-lon=[a_lng]]" . " [waypoint2-lat=[b_lat]] [waypoint2-lon=[b_lng]]" . " [waypoint3-lat=[c_lat]] [waypoint3-lon=[c_lng]]", "Message received, return to base", "M didn't understand your message", "If you see this message there was an internal error 5");
        if ($stationType === false) {
            echo "Create StationType EXT failed";
        } else {
            createStations(1, "ext", $stationType->get('OID'));
        }
        if ($dataOption == 0) {
            redirect('mgmt_main', 'Database Initialized without test data!');
            return;
        }
        // generate test data
        // for ($i=1;$i < 21; $i++) {
        //  $user = new User();
        //  $user->set('username','user'.$i);
        //  $user->setPassword('pass'.$i);
        //  $user->set('email','email'.$i."@harris.com");
        //  $user->set('fullname','User #'.$i);
        //  if ($user->create()===false) echo "Create user $i failed";
        // }
        // keep an equal number of each of these items.
        $mascots = explode(",", "Unencoded,Encoded,Unencoded,Encoded,Unencoded,Encoded,Unencoded,Encoded,Unencoded,Encoded,Unencoded,Encoded,Unencoded,Encoded");
        $schools = explode(",", "Titusville HS,Edgewood Jr/Sr HS,Holy Trinity,West Shore Jr/Sr HS,Melbourne HS,Palm Bay Magnet HS,Bayside HS");
        // keep twice as many name&pins we will populate 2 teams / school
        $names = explode(",", "team1,team2,team3,team4,team5,team6,team7,team8,team9,team10,team11,team12,team13,team14");
        $pins = explode(",", "00001,00002,00003,00004,00005,00006,00007,00008,00009,00010,00011,00012,00013,00014");
        // always make the schools
        $numSchools = count($schools);
        for ($i = 0; $i < $numSchools; $i++) {
            $school = new School();
            $school->set("name", $schools[$i]);
            $school->set("mascot", $mascots[$i]);
            if ($school->create() === false) {
                echo "Create School {$i} failed";
            }
            $schools[$i] = $school->get('OID');
            // replace school name with OID for next part
        }
        // TODO always make the teams with random ids
        $numTeams = $dataOption == 1 ? 2 : count($names);
        for ($i = 0; $i < $numTeams; $i++) {
            $team = new Team();
            $team->set("name", $names[$i]);
            $team->set("schoolId", $schools[$i / 2]);
            /*use OID from previous step two teams / school */
            $team->set("pin", $pins[$i]);
            // to test ext we need special test data
            $team->set('extDuration', $i * 100);
            $team->set('towerH', $i);
            $team->set('towerD', $i);
            if ($team->create() === false) {
                echo "Create team {$i} failed";
            }
        }
        for ($i = 1; $i <= ($dataOption == 1 ? 1 : 5); $i++) {
            $cts = new CTSData();
            $station = Station::getFromTag("cts0" . $i);
            if ($station === false) {
                break;
            }
            $cts->set('stationId', $station->get('OID'));
            // hack assume get works
            if (isStudentServer() && $i == 1) {
                $cts->set('_1st', 39);
                $cts->set('_2nd', 57);
                $cts->set('_3rd', 13);
                $cts->set('_4th', 23);
                $cts->set('_5th', 48);
            } else {
                $cts->set('_1st', 10 + $i);
                $cts->set('_2nd', 20 + $i);
                $cts->set('_3rd', 30 + $i);
                $cts->set('_4th', 40 + $i);
                $cts->set('_5th', 50 + $i);
            }
            $cts->set('tolerance', 5.0);
            if ($cts->create() === false) {
                echo "Create CTS {$i} failed";
            }
        }
        for ($i = 1; $i <= ($dataOption == 1 ? 1 : 5); $i++) {
            $cpa = new CPAData();
            $station = Station::getFromTag("cpa0" . $i);
            if ($station === false) {
                break;
            }
            $cpa->set('stationId', $station->get('OID'));
            // hack assume get works
            if ($i == 1) {
                $cpa->set('label', $i);
                $cpa->set('fence', 240);
                $cpa->set('building', 127);
                $cpa->set('sum', 367);
            } else {
                $cpa->set('label', $i);
                $cpa->set('fence', 240 + $i);
                $cpa->set('building', 127 - $i);
                $cpa->set('sum', 367);
            }
            if ($cpa->create() === false) {
                echo "Create CTA {$i} failed";
            }
        }
        $hmb = new HMBData();
        $hmb->set('_1st_on', 1);
        $hmb->set('_1st_off', 1);
        $hmb->set('_2nd_on', 1);
        $hmb->set('_2nd_off', 10);
        $hmb->set('_3rd_on', 1);
        $hmb->set('_3rd_off', 22);
        $hmb->set('cycle', 506);
        if ($hmb->create() === false) {
            echo "Create HMB {$i} failed";
        }
        $fsl_data = array(array("1", +28.030924, -80.601834, "1", +28.032708, -80.600032, "1", +28.03167, -80.59855899999999, "1", +28.031062, -80.600013, 665.8, 600.1, 574.6), array("1", +28.030924, -80.601834, "1", +28.032708, -80.600032, "1", +28.03167, -80.59855899999999, "2", +28.030975, -80.60010699999999, 629.9, 632.4, 618.6), array("1", +28.030924, -80.601834, "1", +28.032708, -80.600032, "1", +28.03167, -80.59855899999999, "3", +28.030859, -80.60001800000001, 662.5, 674.1, 608.6));
        for ($i = 0; $i < count($fsl_data); $i++) {
            $fsl = new FSLData();
            $fsl->set('a_tag', $fsl_data[$i][0]);
            $fsl->set('a_lat', $fsl_data[$i][1]);
            $fsl->set('a_lng', $fsl_data[$i][2]);
            $fsl->set('b_tag', $fsl_data[$i][3]);
            $fsl->set('b_lat', $fsl_data[$i][4]);
            $fsl->set('b_lng', $fsl_data[$i][5]);
            $fsl->set('c_tag', $fsl_data[$i][6]);
            $fsl->set('c_lat', $fsl_data[$i][7]);
            $fsl->set('c_lng', $fsl_data[$i][8]);
            $fsl->set('l_tag', $fsl_data[$i][9]);
            $fsl->set('l_lat', $fsl_data[$i][10]);
            $fsl->set('l_lng', $fsl_data[$i][11]);
            $fsl->set('a_rad', $fsl_data[$i][12]);
            $fsl->set('b_rad', $fsl_data[$i][13]);
            $fsl->set('c_rad', $fsl_data[$i][14]);
            if ($fsl->create() === false) {
                echo "Create FSLData {$i} failed";
            }
        }
        $ext = new EXTData();
        $ext->set('a_lat', +28.031848);
        $ext->set('a_lng', -80.600938);
        $ext->set('b_lat', +28.031695);
        $ext->set('b_lng', -80.600413);
        $ext->set('c_lat', +28.031579);
        $ext->set('c_lng', -80.60087300000001);
        $ext->set('t_lat', +28.031698);
        $ext->set('t_lng', -80.60075500000001);
        $ext->set('height', 102);
        if ($ext->create() === false) {
            echo "Create EXTData {$i} failed";
        }
        redirect('mgmt_main', 'Database Initialized test data!');
    } catch (ErrorInfo $e) {
        echo $e->getMessage();
        die;
    }
}
예제 #12
0
파일: create_team.php 프로젝트: fg-ok/codev
 protected function display()
 {
     $this->smartyHelper->assign('activeGlobalMenuItem', 'Admin');
     if (Tools::isConnectedUser()) {
         if (!$this->session_user->isTeamMember(Config::getInstance()->getValue(Config::id_adminTeamId))) {
             $this->smartyHelper->assign('accessDenied', TRUE);
         } else {
             if (isset($_POST['team_name'])) {
                 // Form user selections
                 $team_name = Tools::getSecurePOSTStringValue('team_name');
                 $team_desc = Tools::getSecurePOSTStringValue('team_desc', '');
                 $teamleader_id = Tools::getSecurePOSTStringValue('teamleader_id');
                 $formatedDate = date("Y-m-d", time());
                 $now = Tools::date2timestamp($formatedDate);
                 // 1) --- create new Team
                 $teamid = Team::create($team_name, $team_desc, $teamleader_id, $now);
                 if ($teamid > 0) {
                     $team = TeamCache::getInstance()->getTeam($teamid);
                     // --- add teamLeader as 'manager'
                     $team->addMember($teamleader_id, $now, Team::accessLevel_manager);
                     // 2) --- add ExternalTasksProject
                     $team->addExternalTasksProject();
                     $stproj_name = Tools::getSecurePOSTStringValue("stproj_name");
                     if (isset($_POST['cb_createSideTaskProj'])) {
                         // 3) --- add <team> SideTaskProject
                         $stproj_id = $team->createSideTaskProject($stproj_name);
                         if ($stproj_id < 0) {
                             self::$logger->error("SideTaskProject creation FAILED");
                             echo "<span style='color:red'>ERROR: SideTaskProject creation FAILED</span>";
                             exit;
                         } else {
                             $stproj = ProjectCache::getInstance()->getProject($stproj_id);
                             // --- add teamLeader as Mantis manager of the SideTaskProject
                             $leader = UserCache::getInstance()->getUser($teamleader_id);
                             $access_level = 70;
                             // TODO mantis manager
                             $leader->setProjectAccessLevel($stproj_id, $access_level);
                             // 4) --- add SideTaskProject Categories
                             $stproj->addCategoryProjManagement(T_("Project Management"));
                             if (isset($_POST['cb_catInactivity'])) {
                                 $stproj->addCategoryInactivity(T_("Inactivity"));
                             }
                             if (isset($_POST['cb_catIncident'])) {
                                 $stproj->addCategoryIncident(T_("Incident"));
                             }
                             if (isset($_POST['cb_catTools'])) {
                                 $stproj->addCategoryTools(T_("Tools"));
                             }
                             if (isset($_POST['cb_catOther'])) {
                                 $stproj->addCategoryWorkshop(T_("Team Workshop"));
                             }
                             // 5) --- add SideTaskProject default SideTasks
                             if (isset($_POST['cb_taskProjManagement'])) {
                                 $stproj->addIssueProjManagement(Tools::getSecurePOSTStringValue('task_projManagement'));
                             }
                             if (isset($_POST['cb_taskMeeting'])) {
                                 $stproj->addIssueProjManagement(Tools::getSecurePOSTStringValue('task_meeting'));
                             }
                             if (isset($_POST['cb_taskIncident'])) {
                                 $stproj->addIssueIncident(Tools::getSecurePOSTStringValue('task_incident'));
                             }
                             if (isset($_POST['cb_taskTools'])) {
                                 $stproj->addIssueTools(Tools::getSecurePOSTStringValue('task_tools'));
                             }
                             if (isset($_POST['cb_taskOther'])) {
                                 $stproj->addIssueWorkshop(Tools::getSecurePOSTStringValue('task_other1'));
                             }
                         }
                     }
                 }
                 // 6) --- open EditTeam Page
                 header('Location: edit_team.php?teamid=' . $teamid);
             } else {
                 $this->smartyHelper->assign('users', SmartyTools::getSmartyArray(User::getUsers(), $this->session_userid));
             }
         }
     }
 }
예제 #13
0
global $T_INJS, $T_PMD_ACH, $T_PMD_IR, $T_PMD_INJ;
$T_INJS_REV = array_flip($T_INJS);
// Input sent?
if (isset($_FILES['xmlfile'])) {
    $file = $_FILES['xmlfile']['tmp_name'];
    $xml = new DOMDocument();
    $xml->load($file);
    $xmlteams = $xml->schemaValidate('xml/import.xsd') ? simplexml_load_file($file) : (object) array('team' => array());
    $map = array('owned_by_coach_id' => 'coach_id', 'f_race_id' => 'race_id', 'f_lid' => 'league_id', 'f_did' => 'division_id', 'rerolls' => 'rr', 'ff_bought' => 'ff', 'won_0' => 'won', 'lost_0' => 'lost', 'draw_0' => 'draw', 'wt_0' => 'wt', 'gf_0' => 'gf', 'ga_0' => 'ga');
    foreach ($xmlteams->team as $t) {
        # Corrections
        $t->played_0 = $t->won + $t->lost + $t->draw;
        $t->imported = 1;
        # Add team
        list($exitStatus, $tid) = Team::create(array_merge(array_intersect_key((array) $t, array_fill_keys(Team::$createEXPECTED, null)), array_combine(array_keys($map), array_values(array_intersect_key((array) $t, array_fill_keys(array_values($map), null))))));
        status(!$exitStatus, $exitStatus ? Team::$T_CREATE_ERROR_MSGS[$exitStatus] : "Created team '{$t->name}'");
        # Add players
        $ROLLBACK = false;
        if (is_numeric($tid) && !$exitStatus) {
            $team = new Team($tid);
            foreach ($t->players->player as $p) {
                $p = (object) (array) $p;
                # Get rid of SimpleXML objects.
                if (!$team->isPlayerPosValid($p->pos_id)) {
                    status(false, "Invalid race position ID '{$p->pos_id}' for '{$p->name}'");
                    $ROLLBACK = true;
                    break;
                }
                list($status1, $pid) = Player::create(array('nr' => $p->nr, 'f_pos_id' => $p->pos_id, 'name' => $p->name, 'team_id' => $tid), array('force' => true, 'free' => true));
                if ($status1) {
예제 #14
0
<?php

// It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
// You can get copies of the licenses here:
// 		http://www.affero.org/oagpl.html
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING".
/* vim:set noet ci pi sts=0 sw=4 ts=4: */
require "common.php";
if (!empty($_POST['process'])) {
    $valid = false;
    if (!empty($_POST['form_time']) && !empty($_POST['form_hash'])) {
        $valid = sha1($site_key . $_POST['form_time'] . $current_user->user_id) == $_POST['form_hash'];
    }
    if ($valid && empty($_POST['team_id'])) {
        Team::create($_POST);
    } else {
        if ($valid) {
            $league = new Team($_POST['team_id']);
            if (!$league->read()) {
                die(_("No se puede encontrar el equipo"));
            }
            $league->name = $_POST['name'];
            $league->shortname = $_POST['shortname'];
            $league->store();
        } else {
            if (!$valid) {
                die(_("El token del formulario no es correcto"));
            }
        }
    }
    $_GET['action'] = 'list';
예제 #15
0
/**
 * create Admin team & add to codev_config_table
 * @param string $name
 * @param int $leader_id
 * @return int
 */
function createAdminTeam($name, $leader_id)
{
    $now = time();
    $formatedDate = date("Y-m-d", $now);
    $today = Tools::date2timestamp($formatedDate);
    // create admin team
    $teamId = Team::getIdFromName($name);
    if (-1 == $teamId) {
        $teamId = Team::create($name, T_("CodevTT Administrators team"), $leader_id, $today);
    }
    if (-1 != $teamId) {
        // --- add to codev_config_table
        Config::getInstance()->setQuiet(true);
        Config::getInstance()->setValue(Config::id_adminTeamId, $teamId, Config::configType_int);
        Config::getInstance()->setQuiet(false);
        // add leader as member
        $adminTeam = TeamCache::getInstance()->getTeam($teamId);
        $adminTeam->addMember($leader_id, $today, Team::accessLevel_dev);
        $adminTeam->setEnabled(false);
        // add default ExternalTasksProject
        // TODO does Admin team needs ExternalTasksProject ?
        $adminTeam->addExternalTasksProject();
        // NOTE: CodevTT Admin team does not need any side task project.
    } else {
        echo "ERROR: {$name} team creation failed</br>";
    }
    return $teamId;
}
예제 #16
0
    private function _newTeam($ALLOW_EDIT)
    {
        global $lng, $settings, $raceididx, $rules;
        global $leagues, $divisions;
        // Form posted? -> Create team.
        if (isset($_POST['type']) && $_POST['type'] == 'newteam' && $ALLOW_EDIT) {
            if (get_magic_quotes_gpc()) {
                $_POST['name'] = stripslashes($_POST['name']);
            }
            @(list($lid, $did) = explode(',', $_POST['lid_did']));
            setupGlobalVars(T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS, array('lid' => (int) $lid));
            // Load correct $rules for league.
            list($exitStatus, $tid) = Team::create(array('name' => $_POST['name'], 'owned_by_coach_id' => (int) $this->coach_id, 'f_race_id' => (int) $_POST['rid'], 'treasury' => $rules['initial_treasury'], 'apothecary' => 0, 'rerolls' => $rules['initial_rerolls'], 'ff_bought' => $rules['initial_fan_factor'], 'ass_coaches' => $rules['initial_ass_coaches'], 'cheerleaders' => $rules['initial_cheerleaders'], 'won_0' => 0, 'lost_0' => 0, 'draw_0' => 0, 'played_0' => 0, 'wt_0' => 0, 'gf_0' => 0, 'ga_0' => 0, 'imported' => 0, 'f_lid' => (int) $lid, 'f_did' => isset($did) ? (int) $did : Team::T_NO_DIVISION_TIE));
            status(!$exitStatus, $exitStatus ? Team::$T_CREATE_ERROR_MSGS[$exitStatus] : null);
        }
        // Show new team form.
        ?>
    <br><br>
    <div class='boxCommon'>
        <h3 class='boxTitle<?php 
        echo T_HTMLBOX_COACH;
        ?>
'><?php 
        echo $lng->getTrn('cc/new_team');
        ?>
</h3>
        <div class='boxBody'>
        
    <form method="POST">
    <?php 
        echo $lng->getTrn('common/name');
        ?>
<br>
    <input type="text" name="name" size="20" maxlength="50">
    <br><br>
    <?php 
        echo $lng->getTrn('common/race');
        ?>
<br>
    <select name="rid">
        <?php 
        // We need to sort the array manually because of the translation
        foreach ($raceididx as $rid => &$rname) {
            $rname = $lng->getTrn('race/' . strtolower(str_replace(' ', '', $rname)));
        }
        unset($rname);
        // very important !
        asort($raceididx);
        // The, we display as usual
        foreach ($raceididx as $rid => $rname) {
            echo "<option value='{$rid}'>{$rname}</option>\n";
        }
        ?>
    </select>
    <br><br>
    <?php 
        echo $lng->getTrn('common/league') . '/' . $lng->getTrn('common/division');
        ?>
<br>
    <select name="lid_did">
        <?php 
        foreach ($leagues = Coach::allowedNodeAccess(Coach::NODE_STRUCT__TREE, $this->coach_id, array(T_NODE_LEAGUE => array('tie_teams' => 'tie_teams'))) as $lid => $lstruct) {
            if ($lstruct['desc']['tie_teams']) {
                echo "<OPTGROUP LABEL='" . $lng->getTrn('common/league') . ": " . $lstruct['desc']['lname'] . "'>\n";
                foreach ($lstruct as $did => $dstruct) {
                    if ($did != 'desc') {
                        echo "<option value='{$lid},{$did}'>" . $lng->getTrn('common/division') . ": " . $dstruct['desc']['dname'] . "</option>";
                    }
                }
                echo "</OPTGROUP>\n";
            } else {
                echo "<option value='{$lid}'>" . $lng->getTrn('common/league') . ": " . $lstruct['desc']['lname'] . "</option>";
            }
        }
        ?>
    </select>
    <br><br>    
    <input type='hidden' name='type' value='newteam'>
    <input type="submit" name="new_team" value="<?php 
        echo $lng->getTrn('common/create');
        ?>
" <?php 
        echo count($leagues) == 0 ? 'DISABLED' : '';
        ?>
>
    </form>
        </div>
    </div>
    <?php 
    }
예제 #17
0
    public static function handlePost($cid)
    {
        global $lng, $_POST, $coach, $raceididx, $DEA, $rules, $racesNoApothecary;
        if (!isset($_POST['action'])) {
            return;
        }
        if (!self::allowEdit($cid, $coach)) {
            status(false, $lng->getTrn('notallowed', 'TeamCreator'));
            return;
        }
        $lid_did = $_POST['lid_did'];
        @(list($lid, $did) = explode(',', $_POST['lid_did']));
        setupGlobalVars(T_SETUP_GLOBAL_VARS__LOAD_LEAGUE_SETTINGS, array('lid' => (int) $lid));
        // Load correct $rules for league.
        if (get_magic_quotes_gpc()) {
            $_POST['tname'] = stripslashes($_POST['tname']);
        }
        $rid = $_POST['raceid'];
        $race = $DEA[$raceididx[$rid]];
        /* Handle or the 'other' stuff around the team - rerolls etc */
        $rerolls = $_POST['qtyo0'];
        $fans = $_POST['qtyo1'];
        $cl = $_POST['qtyo2'];
        $ac = $_POST['qtyo3'];
        $treasury = $rules['initial_treasury'];
        $treasury -= $rerolls * $race['other']['rr_cost'];
        $treasury -= $fans * 10000;
        $treasury -= $cl * 10000;
        $treasury -= $ac * 10000;
        $rerolls += $rules['initial_rerolls'];
        $fans += $rules['initial_fan_factor'];
        $cl += $rules['initial_ass_coaches'];
        $ac += $rules['initial_cheerleaders'];
        if (!in_array($rid, $racesNoApothecary)) {
            $apoth = $_POST['qtyo4'];
            if ($apoth) {
                $treasury -= 50000;
            }
        } else {
            $apoth = 0;
        }
        /* Create an array with all the players in. Do this first to check for sufficient funds */
        $players = array();
        $idx = 0;
        $rosterNum = 1;
        foreach ($race['players'] as $pos => $d) {
            $pid = $_POST['pid' . $idx];
            if ($pid != $d['pos_id']) {
                // mismatched position ID
                status(false, $pid . ' but was ' . $d['pos_id']);
                return;
            }
            $qty = $_POST['qtyp' . $idx];
            for ($i = 0; $i < $qty; $i++) {
                $treasury -= $d['cost'];
                $player = array();
                $player['name'] = "";
                $player['nr'] = $rosterNum++;
                $player['f_pos_id'] = $d['pos_id'];
                $players[] = $player;
            }
            $idx++;
        }
        /* Enforce league rules and common BB ones */
        $errors = array();
        if ($treasury < 0) {
            $errors[] = $lng->getTrn('tooExpensive', 'TeamCreator');
        }
        if (sizeof($players) < 11) {
            $errors[] = $lng->getTrn('tooFewPlayers', 'TeamCreator');
        }
        if (sizeof($players) > $rules['max_team_players']) {
            $errors[] = $lng->getTrn('tooManyPlayers', 'TeamCreator');
        }
        if (self::checkLimit($rules['max_rerolls'], $rerolls)) {
            $errors[] = $lng->getTrn('tooManyRR', 'TeamCreator') . " " . $rerolls . " vs " . $rules['max_rerolls'];
        }
        if (self::checkLimit($rules['max_fan_factor'], $fans)) {
            $errors[] = $lng->getTrn('tooManyFF', 'TeamCreator') . " " . $fans . " vs " . $rules['max_fan_factor'];
        }
        if (self::checkLimit($rules['max_ass_coaches'], $ac)) {
            $errors[] = $lng->getTrn('tooManyAc', 'TeamCreator') . " " . $ac . " vs " . $rules['max_ass_coaches'];
        }
        if (self::checkLimit($rules['max_cheerleaders'], $cl)) {
            $errors[] = $lng->getTrn('tooManyCl', 'TeamCreator') . " " . $cl . " vs " . $rules['max_cheerleaders'];
        }
        /* Actually create the team in the database */
        if (sizeof($errors) == 0) {
            list($exitStatus, $tid) = Team::create(array('name' => $_POST['tname'], 'owned_by_coach_id' => (int) $cid, 'f_race_id' => (int) $rid, 'treasury' => $treasury, 'apothecary' => $apoth, 'rerolls' => $rerolls, 'ff_bought' => $fans, 'ass_coaches' => $ac, 'cheerleaders' => $cl, 'won_0' => 0, 'lost_0' => 0, 'draw_0' => 0, 'played_0' => 0, 'wt_0' => 0, 'gf_0' => 0, 'ga_0' => 0, 'imported' => 0, 'f_lid' => (int) $lid, 'f_did' => isset($did) ? (int) $did : Team::T_NO_DIVISION_TIE));
            if ($exitStatus) {
                $errors[] = Team::$T_CREATE_ERROR_MSGS[$exitStatus];
            }
        }
        /* Actually create all the players in the database */
        if (sizeof($errors) == 0) {
            $opts = array();
            $opts['free'] = 1;
            // already deducted cost from treasry
            foreach ($players as $player) {
                $player['team_id'] = $tid;
                list($exitStatus, $pid) = Player::create($player, $opts);
                if ($exitStatus) {
                    $errors = array_merge($errors, Player::$T_CREATE_ERROR_MSGS[$exitStatus]);
                }
            }
        }
        /* Report errors and reset the form, or redirect to the team page */
        if (sizeof($errors) > 0) {
            $msg = implode(",<br />", $errors);
            status(false, $msg);
            $post = (object) $_POST;
            echo <<<EOQ
   <script type="text/javascript">
      \$(document).ready(function() {
      document.getElementById('rid').value = {$post->rid};
      changeRace({$post->rid});
      document.getElementById('tname').value = '{$post->tname}';
EOQ;
            foreach ($_POST as $element => $value) {
                if (0 == strncmp($element, "qty", 3)) {
                    $idx = substr($element, 4, 1);
                    $type = substr($element, 3, 1);
                    echo <<<EOQ

      document.getElementById('{$element}').selectedIndex = {$value};
      updateQty({$idx}, '{$type}', {$value});
EOQ;
                }
            }
            echo <<<EOQ
      var lid = document.getElementById('lid_did');
      for (var i = 0; i < lid.options.length; i++) {
         if (lid.options[i].value=={$post->lid_did}) {
            lid.selectedIndex = i;
            break;
         }
      }
      });
   </script>
EOQ;
        } else {
            // Everything worked, redirect to the team page
            status(true, $lng->getTrn('created', 'TeamCreator'));
            $teamUrl = "'" . str_replace("amp;", "", urlcompile(T_URL_PROFILE, T_OBJ_TEAM, $tid, false, false)) . "'";
            echo <<<EOQ
   <script type="text/javascript">
      \$(document).ready(function() {
         window.location = {$teamUrl};
      });
   </script>
EOQ;
        }
    }