From 4c838e4d7c1000364d6bd2c1c61df4cbe28510aa Mon Sep 17 00:00:00 2001 From: Celeo Date: Sat, 8 Aug 2026 14:35:34 -0700 Subject: [PATCH] Remove remaining forum DB access Public news/events endpoints, User::lastActivityForum, and SMFHelper all still queried the forum DB connection, which pointed at the now-deleted vatusa-old-forum database. Forums are retired for good (replaced by Discord, and by Cobalt/Mithril for events/news), so this removes the forum connection and all its callers rather than restoring it: - PublicController::getEvents/getNews now return an empty array - Deleted ForumCalendar, ForumMessages models and SMFHelper - Removed User::lastActivityForum and its dead SMFHelper::createPost calls - Removed the forum connection block from config/database.php and its DB_FORUM_* env vars --- .env.example | 6 +- app/ForumCalendar.php | 10 - app/ForumMessages.php | 9 - app/Helpers/SMFHelper.php | 217 ------------------ .../Controllers/API/v2/PublicController.php | 25 +- app/User.php | 33 --- config/database.php | 12 - 7 files changed, 5 insertions(+), 307 deletions(-) delete mode 100644 app/ForumCalendar.php delete mode 100644 app/ForumMessages.php delete mode 100644 app/Helpers/SMFHelper.php diff --git a/.env.example b/.env.example index 1b811013..145d3d5c 100644 --- a/.env.example +++ b/.env.example @@ -18,7 +18,7 @@ APP_URL=http://localhost:5002 LOGIN_URL=http://localhost:5002 # --------------------------------------------------------------------------- -# Primary database (MySQL). The app ALSO defines `forum`, `email`, and `moodle` +# Primary database (MySQL). The app ALSO defines `email` and `moodle` # connections (see config/database.php). They default to the values below if # their DB__* vars are unset; override them only if those systems exist. # --------------------------------------------------------------------------- @@ -30,10 +30,6 @@ DB_USERNAME=vatusa DB_PASSWORD=secret # Auxiliary connections (optional — leave commented unless you have them) -# DB_FORUM_HOST=127.0.0.1 -# DB_FORUM_DATABASE=forum -# DB_FORUM_USERNAME=forum -# DB_FORUM_PASSWORD= # DB_EMAIL_HOST=127.0.0.1 # DB_EMAIL_DATABASE=email # DB_MOODLE_HOST=127.0.0.1 diff --git a/app/ForumCalendar.php b/app/ForumCalendar.php deleted file mode 100644 index 211f58ef..00000000 --- a/app/ForumCalendar.php +++ /dev/null @@ -1,10 +0,0 @@ - - diff --git a/app/ForumMessages.php b/app/ForumMessages.php deleted file mode 100644 index 9ddd1cfd..00000000 --- a/app/ForumMessages.php +++ /dev/null @@ -1,9 +0,0 @@ - \ No newline at end of file diff --git a/app/Helpers/SMFHelper.php b/app/Helpers/SMFHelper.php deleted file mode 100644 index af28df4c..00000000 --- a/app/Helpers/SMFHelper.php +++ /dev/null @@ -1,217 +0,0 @@ -table("smf_members")->where('member_name', $cid) - ->update([ - 'id_group' => $grp, - 'additional_groups' => $addl - ]); - } - - /** - * @param $facility - * - * @return int - */ - public static function findFacilityStaffGroup($facility) - { - return static::findGroup($facility . " Staff"); - } - - /** - * @param $group - * - * @return int - */ - public static function findGroup($group) - { - $staff = 0; - $grp = \DB::connection('forum')->table("smf_membergroups")->where('group_name', $group)->first(); - if ($grp) { - $staff = $grp->id_group; - } - - return $staff; - } - - /** - * @param $cid - * - * @return bool|void - */ - - public static function setPermissions($cid) - { - if (in_array(app()->environment(), ["livedev", "dev", "devel"])) { - return true; - } - $primary = ""; - $secondary = []; - $roles = []; - - $user = User::find($cid); - - if ($user->rating == Helper::ratingIntFromShort("ADM")) { - if (!RoleHelper::isVATUSAStaff($user, true, true)) { - static::setGroups($cid, static::findGroup("VATSIM Leadership")); - - return; - } else { - // Allow for them to get the VATUSA Staff group - // as secondary group if they have a VATUSA Staff role - // per Mark Hubbert - static::setGroups($cid, static::findGroup("VATSIM Leadership"), static::findGroup("VATUSA Staff")); - - return; - } - } - - if ($user->facility()->atm == $user->cid || $user->facility()->datm == $user->cid) { - $roles[] = "ATM"; - } - if ($user->facility()->ta == $user->cid) { - $roles[] = "TA"; - } - if ($user->facility()->ec == $user->cid) { - $roles[] = "EC"; - } - if ($user->facility()->fe == $user->cid) { - $roles[] = "FE"; - } - if ($user->facility()->wm == $user->cid) { - $roles[] = "WM"; - } - - if (count($roles) > 0) { - $primary = static::findFacilityStaff($user->facility); - } else { - $primary = static::findGroup("Members"); - } - foreach ($roles as $role) { - $secondary[] = static::findGroup($role); - } - - if (RoleHelper::isVATUSAStaff($user, true, true)) { - $primary = static::findGroup("VATUSA Staff"); - if (RoleHelper::hasRole($user->cid, "ZHQ", "US1") || - RoleHelper::hasRole($user->cid, "ZHQ", "US2") || - RoleHelper::hasRole($user->cid, "ZHQ", "US3") || - RoleHelper::hasRole($user->cid, "ZHQ", "US4") || - RoleHelper::hasRole($user->cid, "ZHQ", "US6")|| - RoleHelper::hasRole($user->cid, "ZHQ", "US0")) { - $secondary[] = static::findGroup("Administrator"); - } - } - - if (RoleHelper::hasRole($cid, 'ZHQ', 'ACE')) { - $secondary[] = static::findGroup("Ace Team"); - } - if ($user->rating === Helper::ratingIntFromShort("SUP") && $primary === static::findGroup("Members")) { - //Supervisor over Members (same perms set), WT, INSs, and MTRs - $primary = static::findGroup("VATSIM Supervisors"); - $secondary[] = static::findGroup("Members"); - } - if (RoleHelper::isWebTeam($user)) { - if ($primary === static::findGroup("Members")) { - //WT Priority over INS, MTRs, Members - $primary = static::findGroup("Web Team"); - $secondary[] = static::findGroup("Members"); - } else { - $secondary[] = static::findGroup("Web Team"); - } - } - if (RoleHelper::isInstructor($user)) { - if ($primary === static::findGroup("Members")) { - //INS Priority over Members and MTRs - $primary = static::findGroup("Instructors"); - $secondary[] = static::findGroup("Members"); - } else { - $secondary[] = static::findGroup("Instructors"); - } - } - - if (RoleHelper::hasRole($cid, $user->facility, "MTR")) { - if ($primary === static::findGroup("Members")) { - //MTR Priority over Members - $primary = static::findGroup("Mentors"); - $secondary[] = static::findGroup("Members"); - } else { - $secondary[] = static::findGroup("Mentors"); - } - } - - - static::setGroups($cid, $primary, implode(",", $secondary)); - } - - public static function findFacilityStaff($facility) - { - return static::findGroup($facility . " Staff"); - } - - /** - * @param $memberID - * @param $board - * @param $subject - * @param $body - */ - public static function createPost($memberID, $board, $subject, $body) - { - /*$smf_subject = $subject; - $smf_subject = addslashes(htmlspecialchars($smf_subject)); - $smf_body = addslashes(htmlspecialchars($body)); - $smf_board = $board; - $smf_member = $memberID; //Website psuedo user - require_once(base_path() . "/../public_html/forums/SSI.php"); - require_once(base_path() . "/../public_html/forums/Sources/Subs-Post.php"); - - $msgOptions = [ - 'subject' => $smf_subject, - 'body' => $smf_body - ]; - $topicOptions = [ - 'board' => $smf_board, - ]; - $posterOptions = [ - 'id' => $smf_member - ]; - createPost($msgOptions, $topicOptions, $posterOptions);*/ - // Coming soon? - } - - /** - * @param $cid - * - * @return mixed - */ - public static function isRegistered($cid) - { - return \DB::connection("forum")->table("smf_members")->where("member_name", $cid)->count(); - } - - public static function updateData($cid, $last, $first, $email) - { - \DB::connection("forum")->table("smf_members") - ->where("member_name", $cid) - ->update([ - 'real_name' => "$first $last", - 'email_address' => "$email" - ]); - } -} diff --git a/app/Http/Controllers/API/v2/PublicController.php b/app/Http/Controllers/API/v2/PublicController.php index 2a75066f..687fad1a 100644 --- a/app/Http/Controllers/API/v2/PublicController.php +++ b/app/Http/Controllers/API/v2/PublicController.php @@ -2,10 +2,7 @@ namespace App\Http\Controllers\API\v2; -use App\ForumCalendar; -use App\ForumMessages; use Cache; -use Carbon\Carbon; use Illuminate\Http\Request; class PublicController extends APIController @@ -16,7 +13,7 @@ class PublicController extends APIController * @OA\Get( * path="/public/events/(limit)", * summary="Get events.", - * description="Get events (from Forums) set with a specific limit", + * description="Get events set with a specific limit", * tags={"public"}, * @OA\Parameter(name="limit", in="path", @OA\Schema(type="integer"), description="Limit"), * @OA\Response( @@ -37,13 +34,7 @@ class PublicController extends APIController public function getEvents(Request $request, $limit = 100) { - $data = ForumCalendar::limit($limit) - ->where('start_date', '>=', Carbon::now()->subHours(24)) - ->orderBy('start_date') - ->get() - ->toArray(); - - return response()->api($data); + return response()->api([]); } /** @@ -51,7 +42,7 @@ public function getEvents(Request $request, $limit = 100) * @OA\Get( * path="/public/news/(limits)", * summary="Get news.", - * description="Get news (from Forums) set with a specific limit", + * description="Get news set with a specific limit", * tags={"public"}, * @OA\Parameter(name="limit", in="path", @OA\Schema(type="integer"), description="Limit"), * @OA\Response( @@ -71,15 +62,7 @@ public function getEvents(Request $request, $limit = 100) */ public function getNews(Request $request, $limit = 100) { - $data = ForumMessages::where('smf_messages.id_board', 47) - ->join("smf_topics", "id_msg", "id_first_msg") - ->orderByDesc('id_msg') - ->limit($limit) - ->get() - ->makeHidden(['poster_email', 'poster_ip']) - ->toArray(); - - return response()->api($data); + return response()->api([]); } /** diff --git a/app/User.php b/app/User.php index dc1c07b4..8585c818 100644 --- a/app/User.php +++ b/app/User.php @@ -6,7 +6,6 @@ use App\Helpers\EmailHelper; use App\Helpers\RatingHelper; use App\Helpers\RoleHelper; -use App\Helpers\SMFHelper; use App\Helpers\VATSIMApi2Helper; use App\Models\ControllerEligibilityCache; use Illuminate\Auth\Authenticatable; @@ -176,16 +175,6 @@ public function lastActivityWebsite() return $this->lastactivity->diffInDays(null); } - /** - * @return string - */ - public function lastActivityForum() - { - $f = \DB::connection('forum')->table("smf_members")->where("member_name", $this->cid)->first(); - - return ($f) ? Carbon::createFromTimestamp($f->last_login)->diffInDays(null) : "Unknown"; - } - public function hasEmailAccess($email) { $eparts = explode("@", $email); @@ -366,11 +355,6 @@ public function removeFromFacility($by = "Automated", $msg = "None provided", $n Cache::forget("roster-$old_facility-home"); Cache::forget("roster-$old_facility-both"); - if ($this->rating >= RatingHelper::shortToInt("I1")) { - SMFHelper::createPost(7262, 82, - "User Removal: " . $this->fullname() . " (" . RatingHelper::intToShort($this->rating) . ") from " . $old_facility, - "User " . $this->fullname() . " (" . $this->cid . "/" . RatingHelper::intToShort($this->rating) . ") was removed from $old_facility and holds a higher rating. Please check for demotion requirements. [url=https://www.vatusa.net/mgt/controller/" . $this->cid . "]Member Management[/url]"); - } } public function addToFacility($facility) @@ -383,37 +367,20 @@ public function addToFacility($facility) $this->facility_join = Carbon::now(); $this->save(); - if ($this->rating >= RatingHelper::shortToInt("I1") && $this->rating < RatingHelper::shortToInt("SUP")) { - SMFHelper::createPost(7262, 82, - "User Addition: " . $this->fullname() . " (" . RatingHelper::intToShort($this->rating) . ") to " . $this->facility, - "User " . $this->fullname() . " (" . $this->cid . "/" . RatingHelper::intToShort($this->rating) . ") was added to " . $this->facility . " and holds a higher rating.\n\nPlease check for demotion requirements.\n\n[url=https://www.vatusa.net/mgt/controller/" . $this->cid . "]Member Management[/url]"); - } - - $fc = 0; - if ($oldfac->id != "ZZN" && $oldfac->id != "ZAE") { if (RoleHelper::has($this, $oldfac->id, "ATM") || RoleHelper::has($this, $oldfac->id, "DATM")) { EmailHelper::sendEmail(["vatusa2@vatusa.net"], "ATM or DATM discrepancy", "emails.transfers.atm", ["user" => $this, "oldfac" => $oldfac]); - $fc = 1; } elseif (RoleHelper::has($this, $oldfac->id, "TA")) { EmailHelper::sendEmail(["vatusa3@vatusa.net"], "TA discrepancy", "emails.transfers.ta", ["user" => $this, "oldfac" => $oldfac]); - $fc = 1; } elseif (RoleHelper::has($this, $oldfac->id, "EC") || RoleHelper::has($this, $oldfac->id, "FE") || RoleHelper::has($this, $oldfac->id, "WM")) { EmailHelper::sendEmail([$oldfac->id . "-atm@vatusa.net", $oldfac->id . "-datm@vatusa.net"], "Staff discrepancy", "emails.transfers.otherstaff", ["user" => $this, "oldfac" => $oldfac]); - $fc = 1; } } - if ($fc) { - SMFHelper::createPost(7262, 82, - "Staff discrepancy on transfer: " . $this->fullname() . " (" . RatingHelper::intToShort($this->rating), - "User " . $this->fullname() . " (" . $this->cid . "/" . RatingHelper::intToShort($this->rating) . ") was added to facility " . $this->facility . " but holds a staff position at " . $oldfac->id . ".\n\nPlease check for accuracy.\n\n[url=https://www.vatusa.net/mgt/controller/" . $this->cid . "]Member Management[/url] [url=https://www.vatusa.net/mgt/facility/" . $oldfac->id . "]Facility Management for Old Facility[/url] [url=https://www.vatusa.net/mgt/facility/" . $this->facility . "]Facility Management for New Facility[/url]"); - } - if ($facility->active) { $welcome = $facility->welcome_text; $fac = $facility->id; diff --git a/config/database.php b/config/database.php index 91e02c87..0c8791c8 100644 --- a/config/database.php +++ b/config/database.php @@ -51,18 +51,6 @@ 'prefix' => '', 'strict' => false, ], - 'forum' => [ - 'driver' => env('DB_FORUM_CONNECTION', 'mysql'), - 'host' => env('DB_FORUM_HOST', '127.0.0.1'), - 'port' => env('DB_FORUM_PORT', 3306), - 'database' => env('DB_FORUM_DATABASE', 'forum'), - 'username' => env('DB_FORUM_USERNAME', 'forum'), - 'password' => env('DB_FORUM_PASSWORD', ''), - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', - 'prefix' => '', - 'strict' => false - ], 'email' => [ 'driver' => env('DB_EMAIL_CONNECTION', 'mysql'), 'host' => env('DB_EMAIL_HOST', '127.0.0.1'),