Skip to content

Commit

Permalink
Remove dead code.
Browse files Browse the repository at this point in the history
  • Loading branch information
edwh committed Jun 20, 2022
1 parent e933d34 commit 46c17b1
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 1,247 deletions.
78 changes: 0 additions & 78 deletions app/Http/Controllers/BattcatOraController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,84 +24,6 @@ public function index(Request $request)
{
// BattCat is now closed.
return redirect()->action('BattcatOraController@status');

// We record that we have visited this page, so that if we subsequently sign up, we can redirect back to it.
// This is an intentionally partial solution to the problem of redirecting after we log in.
$request->session()->put('redirectTime', time());
$request->session()->put('redirectTo', $request->path());

if (Auth::check()) {
$user = Auth::user();
} else {
$user = $this->_anon();
}
// if survey is being submitted
$thankyou = false;
if ($request->has('task-survey')) {
$inputs = $request->all();
unset($inputs['_token']);
unset($inputs['task-survey']);
$payload = json_encode($inputs);
$insert = [
'task' => 'BattCat',
'payload' => $payload,
'user_id' => $user->id,
'ip_address' => $_SERVER['REMOTE_ADDR'],
'session_id' => session()->getId(),
];
$MicrotaskSurvey = new MicrotaskSurvey;
$success = $MicrotaskSurvey->create($insert);
if (! $success) {
logger('MicrotaskSurvey error on insert.');
logger(print_r($insert, 1));
}
$thankyou = 'guest';
}

$this->Model = new BattcatOra;
// if opinion is being submitted
if ($request->has('id-ords')) {
if (! (is_numeric($request->input('fault-type-id')) && $request->input('fault-type-id') > 0)) {
return redirect()->back()->withErrors(['Oops, there was an error, please try again, sorry! If this error persists please contact The Restart Project.']);
}
$insert = [
'id_ords' => $request->input('id-ords'),
'fault_type_id' => $request->input('fault-type-id'),
'user_id' => $user->id,
'ip_address' => $_SERVER['REMOTE_ADDR'],
'session_id' => session()->getId(),
];
$this->Model = new BattcatOra;
$success = $this->Model->create($insert);
if (! $success) {
logger('BattCat error on insert.');
logger(print_r($insert, 1));
}
$submits = $this->_getSubmits($request, $user);
if ($submits == 5) {
if ($user->id == 0) {
// guest is redirected to modal survey
return redirect()->action('BattcatOraController@survey');
} else {
$thankyou = 'user';
}
}
}
$fault = $this->_fetchRecord($request);
if (! $fault) {
return redirect()->action('BattcatOraController@status')->withSuccess('done');
}
$progress = $this->Model->fetchProgress()[0]->total;
$fault->faulttypes = $this->Model->fetchFaultTypes($fault->repair_status);

return view('battcatora.index', [
'title' => 'BattCat',
'fault' => $fault,
'user' => $user,
'progress' => $progress > 1 ? $progress : 0,
'thankyou' => $thankyou,
'locale' => $this->_getUserLocale(),
]);
}

/**
Expand Down
36 changes: 0 additions & 36 deletions app/Http/Controllers/MisccatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,6 @@ class MisccatController extends Controller
public function index(Request $request)
{
return redirect()->action('MisccatController@status')->withSuccess('done');

if (Auth::check()) {
$user = Auth::user();
} else {
$user = Microtask::getAnonUserCta($request);
if ($user->action) {
return redirect()->action('MisccatController@cta');
}
}

if ($request->isMethod('post') && ! empty($_POST) && isset($_POST['iddevices'])) {
$data = $_POST;
$Misccat = new Misccat;
$insert = [
'iddevices' => $data['iddevices'],
'category' => $data['category'],
'eee' => $data['eee'],
'user_id' => $user->id,
'ip_address' => $_SERVER['REMOTE_ADDR'],
'session_id' => session()->getId(),
];
$success = $Misccat->create($insert);
if (! $success) {
logger(print_r($insert, 1));
logger('MiscCat error on insert.');
}
}

$Misccat = new Misccat;
$misc = $Misccat->fetchMisc()[0];
$misc->translate = rawurlencode($misc->problem);

return view('misccat.index', [
'misc' => $misc,
'user' => $user,
]);
}

public function cta(Request $request)
Expand Down
57 changes: 0 additions & 57 deletions app/Http/Controllers/PrintcatOraController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,63 +24,6 @@ public function index(Request $request)
{
// PrintCat is now closed.
return redirect()->action('PrintcatOraController@status');

// We record that we have visited this page, so that if we subsequently sign up, we can redirect back to it.
// This is an intentionally partial solution to the problem of redirecting after we log in.
$request->session()->put('redirectTime', time());
$request->session()->put('redirectTo', $request->path());

$partner = $request->input('partner', null);
if (Auth::check()) {
$user = Auth::user();
} else {
$user = Microtask::getAnonUserCta($request);
if ($user->action) {
return redirect()->action('PrintcatOraController@cta', ['partner' => $partner]);
}
}
$this->Model = new PrintcatOra;
if ($request->has('id-ords')) {
if (! (is_numeric($request->input('fault-type-id')) && $request->input('fault-type-id') > 0)) {
return redirect()->back()->withErrors(['Oops, there was an error, please try again, sorry! If this error persists please contact The Restart Project.']);
}
$insert = [
'id_ords' => $request->input('id-ords'),
'fault_type_id' => $request->input('fault-type-id'),
'user_id' => $user->id,
'ip_address' => $_SERVER['REMOTE_ADDR'],
'session_id' => session()->getId(),
];
$this->Model = new PrintcatOra;
$success = $this->Model->create($insert);
if (! $success) {
logger('PrintCat error on insert.');
logger(print_r($insert, 1));
}
}
$fault = $this->_fetchRecord($request);
if (! $fault) {
return redirect()->action('PrintcatOraController@status')->withSuccess('done');
}
$fault->translate = rawurlencode($fault->problem);
$fault_types = $this->Model->fetchFaultTypes();
$fault->suggestions = [];
// match problem terms with suggestions
foreach ($fault_types as $k => $v) {
if (! empty($v->regex) && preg_match('/'.$v->regex.'/', strtolower($fault->translation), $matches)) {
$fault->suggestions[$k] = $fault_types[$k];
}
}
// send non-suggested fault_types to view
$fault->faulttypes = array_diff_key($fault_types, $fault->suggestions);

return view('printcatora.index', [
'title' => 'PrintCat',
'fault' => $fault,
'user' => $user,
'partner' => $partner,
'locale' => $this->_getUserLocale(),
]);
}

protected function _getUserLocale()
Expand Down
103 changes: 0 additions & 103 deletions app/Http/Controllers/TabicatOraController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,109 +24,6 @@ public function index(Request $request)
{
// TabiCat is now closed.
return redirect()->action('TabicatOraController@status');

// We record that we have visited this page, so that if we subsequently sign up, we can redirect back to it.
// This is an intentionally partial solution to the problem of redirecting after we log in.
$request->session()->put('redirectTime', time());
$request->session()->put('redirectTo', $request->path());

if (Auth::check()) {
$user = Auth::user();
} else {
$user = $this->_anon();
}
// if survey is being submitted
if ($request->has('task-survey')) {
$inputs = $request->all();
unset($inputs['_token']);
unset($inputs['task-survey']);
$payload = json_encode($inputs);
$insert = [
'task' => 'TabiCat',
'payload' => $payload,
'user_id' => $user->id,
'ip_address' => $_SERVER['REMOTE_ADDR'],
'session_id' => session()->getId(),
];
$MicrotaskSurvey = new MicrotaskSurvey;
$success = $MicrotaskSurvey->create($insert);
if (! $success) {
logger('MicrotaskSurvey error on insert.');
logger(print_r($insert, 1));
}
}

$this->Model = new TabicatOra;
$signpost = false;
// if opinion is being submitted
if ($request->has('id-ords')) {
if (! (is_numeric($request->input('fault-type-id')) && $request->input('fault-type-id') > 0)) {
return redirect()->back()->withErrors(['Oops, there was an error, please try again, sorry! If this error persists please contact The Restart Project.']);
}
$insert = [
'id_ords' => $request->input('id-ords'),
'fault_type_id' => $request->input('fault-type-id'),
'user_id' => $user->id,
'ip_address' => $_SERVER['REMOTE_ADDR'],
'session_id' => session()->getId(),
];
$this->Model = new TabicatOra;
$success = $this->Model->create($insert);
if (! $success) {
logger('TabiCat error on insert.');
logger(print_r($insert, 1));
}
$submits = $this->_getSubmits($request, $user);
if ($submits < 5) {
$signpost = $submits;
} elseif ($submits == 5) {
if ($user->id == 0) {
// guest is redirected to modal survey
return redirect()->action('TabicatOraController@survey');
} else {
// logged-in user gets an extra signpost
$signpost = $submits;
}
}
}
// final "thank you" signpost after survey whether submitted or not
if ($request->session()->get('tabicatora.redirected_from_survey', false)) {
$request->session()->put('tabicatora.redirected_from_survey', false);
$signpost = 6;
}
// no signpost when showing survey
if ($request->session()->get('tabicatora.redirect_to_survey', false)) {
$request->session()->put('tabicatora.redirect_to_survey', false);
$request->session()->put('tabicatora.redirected_from_survey', true);
}
$fault = $this->_fetchRecord($request);
if (! $fault) {
return redirect()->action('TabicatOraController@status')->withSuccess('done');
}

$fault->translate = rawurlencode($fault->problem);
$fault_types = $this->Model->fetchFaultTypes();
$fault->suggestions = [];
// match problem terms with suggestions
foreach ($fault_types as $k => $v) {
if (! empty($v->regex) && preg_match('/'.$v->regex.'/', strtolower($fault->translation), $matches)) {
$fault->suggestions[$k] = $fault_types[$k];
}
}
// send non-suggested fault_types to view
$fault->faulttypes = array_diff_key($fault_types, $fault->suggestions);
// send the "poor data" fault_type to view
$poor_data = $this->Model->fetchFaultTypePoorData();
logger(print_r($poor_data, 1));

return view('tabicatora.index', [
'title' => 'TabiCat',
'fault' => $fault,
'poor_data' => $poor_data,
'user' => $user,
'signpost' => $signpost,
'locale' => $this->_getUserLocale(),
]);
}

/**
Expand Down
Loading

0 comments on commit 46c17b1

Please sign in to comment.