本文整理匯總了PHP中Team::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP Team::set方法的具體用法?PHP Team::set怎麽用?PHP Team::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Team
的用法示例。
在下文中一共展示了Team::set方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _ops_loaddb
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);
}
示例2: _ops_update
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: _submit
function _submit($stationTag = null)
{
if ($stationTag === null) {
trace("missing station id");
rest_sendBadRequestResponse(401, "missing stationId");
// doesn't return
}
$station = Station::getFromTag($stationTag);
if ($station === false) {
trace("can't find station from tag");
rest_sendBadRequestResponse(404, "can find station stationTag=" . $stationTag);
// doesn't return
}
$team = new Team($station->get('teamAtStation'), -1);
if ($team === false) {
trace("can't find team", __FILE__, __LINE__, __METHOD__);
rest_sendBadRequestResponse(404, "can find team at station stationTag=" . $stationTag . " teamId=" . $team->get('OID'));
// doesn't return
}
$stationType = new StationType($station->get('typeId'), -1);
if ($stationType === false) {
trace("can't find station type stationTag = " . $stationTag, __FILE__, __LINE__, __METHOD__);
rest_sendBadRequestResponse(500, "can't find station type stationTag=" . $stationTag);
}
$rpi = RPI::getFromStationId($station->get('OID'));
if ($rpi === false) {
trace("_start_challenge can't find RPI stationTag=" . $stationTag, __FILE__, __LINE__, __METHOD__);
rest_sendBadRequestResponse(500, "can't find RPI stationTag=" . $stationTag);
}
$json = json_getObjectFromRequest("POST");
// won't return if an error happens
json_checkMembers("candidate_answer,is_correct,fail_message", $json);
$count = $team->get('count');
$team->setChallengeData($json);
trace("count=" . $count);
$points = 3 - $count;
if (!$json['is_correct']) {
$count++;
$team->set('count', $count);
trace("count=" . $count);
$challenge_complete = $count > 2;
$team->_updateScore($stationType, 0);
//TODO add legacy update score
} else {
$challenge_complete = true;
}
if ($challenge_complete) {
switch ($stationType->get('typeCode')) {
case StationType::STATION_TYPE_HMB:
// Leave scoring up to brata submit for CPA and CTS but HMB needs it
$team->_updateScore($stationType, $points);
$station->endChallenge();
$team->endChallenge();
break;
default:
// FSL does not have pi, CPA and CTS not done until scan last qr
// so technically challenge not complete until the brata submit
break;
}
}
if (Event::createEvent(Event::TYPE_SUBMIT, $team, $station, $points) === false) {
trace("create event failed " . $team->get('OID') . " " . $station->get('OID'), __FILE__, __LINE__, __METHOD__);
rest_sendBadRequestResponse(500, "database create failed");
}
$json = array("message_version" => 0, "message_timestamp" => date("Y-m-d H:i:s"), "theatric_delay_ms" => $stationType->get('delay'), "challenge_complete" => $challenge_complete);
json_sendObject($json);
}
示例4: _resetdb
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', "dcarreir@harris.com");
$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";
//.........這裏部分代碼省略.........