From d9f97c24063abe62ec6275d0ea1de7bb19df3eb9 Mon Sep 17 00:00:00 2001 From: Ren Date: Sat, 7 Sep 2024 20:25:47 +0100 Subject: [PATCH 1/8] bugfix commit --- docs/install.md | 40 ++------------------- schema/base.sql | 2 +- src/Classes/MyRadio/MyRadioNews.php | 6 +++- src/Classes/ServiceAPI/MyRadio_Season.php | 2 +- src/Classes/ServiceAPI/MyRadio_Track.php | 6 +--- src/Classes/ServiceAPI/MyRadio_User.php | 6 ++-- src/Classes/ServiceAPI/Profile.php | 31 ++++++++-------- src/Public/js/myradio.newslist.js | 5 --- src/Public/js/myradio.profile.list.js | 5 --- src/Public/js/myradio.scheduler.termlist.js | 16 ++++----- src/Public/js/myradio.timeslot.js | 21 ++++++----- src/Templates/MyRadio/getOnAir.twig | 2 +- src/Templates/Profile/user.twig | 2 +- 13 files changed, 51 insertions(+), 93 deletions(-) diff --git a/docs/install.md b/docs/install.md index 276698eef..456097223 100644 --- a/docs/install.md +++ b/docs/install.md @@ -29,8 +29,7 @@ If you have Docker on your system, use Docker Compose to set up an environment. Simply run `docker compose up -d` and visit "https://localhost:4443/myradio/". If you encounter an error with autoload.php: -find the id of your myradio container using `docker dontainer ls` -enter a bash session with `docker exec -it [myradioid] bash` +enter a bash session with `docker compose exec myradio bash` then in this session run `composer install` finally exit the session by running `exit` @@ -176,42 +175,7 @@ To do this, you first need to: - Apply for a Season of your new Show (List My Shows -> New Season) - Schedule the Season (Shows Scheduler) -### Setting up your own 2016-site - -First pull [2016-site](https://github.com/UniversityRadioYork/2016-site) - -#### database - -Next you need a api_key to allow the website to access myradio's show information, - -login into database with details used during setup of myradio - -`INSERT INTO myury.api_key (key_string, description) VALUES ('ARANDOMSTRINGOFCHARACTERS', '2016-site development api key');` - -`INSERT INTO myury.api_key_auth (key_string, typeid) VALUES ('ARANDOMSTRINGOFCHARACTERS', (SELECT typeid FROM l_action WHERE phpconstant = 'AUTH_APISUDO'));` - -[please choose a better key than 'ARANDOMSTRINGOFCHARACTERS'] - -You might need add some other database columns to create shows - -for example: - -- explict podcasts (to create shows) -- selector (expected by 2016-site/can remove this from models/index.go 2016-site) - -2016-site uses parts of database that aren't made on myradio creation, - -#### finishing steps - -This will fix shows not loading on 2016-site when using the base myradio database - -After completing all these setups: - -you can use setup guide in [2016-site](https://github.com/UniversityRadioYork/2016-site), -And setup a reverse proxy to "https://localhost:4443/api/v2" or configure ssl for https connections -To complete the setup. - -### A note on Seasons and Terms +#### A note on Seasons and Terms MyRadio splits Shows into "Seasons". Any Season is applied to in relation to a "Term", which is a user defined space of time (normally 11-15 weeks). This is because The University of York has 12 week semesters, if you didn't know. diff --git a/schema/base.sql b/schema/base.sql index 705eb5832..27a365d72 100644 --- a/schema/base.sql +++ b/schema/base.sql @@ -1257,7 +1257,7 @@ CREATE TABLE mail_list ( COMMENT ON TABLE mail_list IS 'Definitions of mailing lists'; COMMENT ON COLUMN mail_list.listid IS 'Surrogate Key'; COMMENT ON COLUMN mail_list.listname IS 'Name of the list'; -COMMENT ON COLUMN mail_list.defn IS 'A SQL string that returns fname, nname ,sname and email address.'; +COMMENT ON COLUMN mail_list.defn IS 'A SQL string that returns fname ,sname and email address.'; COMMENT ON COLUMN mail_list.toexim IS 'Whether to create a mail alias on the email server for this list.'; COMMENT ON COLUMN mail_list.listaddress IS 'If the list is exported, this is the list''s email address.'; COMMENT ON COLUMN mail_list.subscribable IS 'Whether members can (un)subscribe freely.'; diff --git a/src/Classes/MyRadio/MyRadioNews.php b/src/Classes/MyRadio/MyRadioNews.php index 3f5b23755..9b5b75dbe 100644 --- a/src/Classes/MyRadio/MyRadioNews.php +++ b/src/Classes/MyRadio/MyRadioNews.php @@ -75,7 +75,11 @@ public static function getNewsItem($newsentryid, MyRadio_User $user = null) $db = Database::getInstance(); $news = $db->fetchOne( - 'SELECT newsentryid, fname || \' \' || sname AS author, fname || \' "\' || nname || \'" \' || sname AS nickname, timestamp AS posted, content + 'SELECT newsentryid, + CASE WHEN nname IS NULL + THEN fname || \' \' || sname + ELSE fname || \' "\' || nname || \'" \' || sname + END AS name, timestamp AS posted, content FROM public.news_feed, public.member WHERE newsentryid=$1 AND news_feed.memberid = member.memberid', diff --git a/src/Classes/ServiceAPI/MyRadio_Season.php b/src/Classes/ServiceAPI/MyRadio_Season.php index 9de2b0345..a2d1ac749 100644 --- a/src/Classes/ServiceAPI/MyRadio_Season.php +++ b/src/Classes/ServiceAPI/MyRadio_Season.php @@ -188,7 +188,7 @@ public static function create($params = []) * Select an appropriate value for $term_id. */ $term_id = MyRadio_Term::getActiveApplicationTerm()->getID(); - $num_weeks = MyRadio_Term::getActiveApplicationTerm()->getTermWeeks(); + $num_weeks = MyRadio_Term::getActiveApplicationTerm()->getTermWeeks(); //Start a transaction self::$db->query('BEGIN'); diff --git a/src/Classes/ServiceAPI/MyRadio_Track.php b/src/Classes/ServiceAPI/MyRadio_Track.php index 3ec3bb297..12d2a4dc6 100644 --- a/src/Classes/ServiceAPI/MyRadio_Track.php +++ b/src/Classes/ServiceAPI/MyRadio_Track.php @@ -634,11 +634,7 @@ public function reportExplicit() $title = htmlspecialchars($this->getTitle()); $artist = htmlspecialchars($this->getArtist()); - if (empty($currentUser->getNName()) == True) { - $userName = htmlspecialchars($currentUser->getFName() . ' ' . $currentUser->getSName()); - } else { - $userName = htmlspecialchars($currentUser->getFName() . ' "' . $currentUser->getNName() . '" ' . $currentUser->getSName()); - } + $userName = htmlspecialchars($currentUser->getFName() . ' ' . $currentUser->getSName()); $editUrl = URLUtils::makeURL('Library', 'editTrack', ['trackid' => $this->getID()]); MyRadioEmail::sendEmailToList( MyRadio_List::getByName('playlisting'), diff --git a/src/Classes/ServiceAPI/MyRadio_User.php b/src/Classes/ServiceAPI/MyRadio_User.php index a2c3126eb..e4be07239 100755 --- a/src/Classes/ServiceAPI/MyRadio_User.php +++ b/src/Classes/ServiceAPI/MyRadio_User.php @@ -442,7 +442,7 @@ public function getFName() } /** - * Returns the User's first name. + * Returns the User's nickname. * * @return string The User's first name */ @@ -475,7 +475,6 @@ public function getName() } else { return $this->fname.' "'.$this->nname.'" '.$this->sname; } - return $this->fname.' '.$this->nname.' '.$this->sname; } public function getLastLogin() @@ -2418,7 +2417,7 @@ public function getEmptyData(){ $data['bio'] = 'This user is hidden'; $data['memberid'] = $this->getID(); $data['fname'] = 'Hidden'; - $data['nname'] = 'Hidden'; + $data['nname'] = NULL; $datap['sname'] = 'User'; $data['public_email'] = ''; $data['url'] = $this->getURL(); @@ -2476,7 +2475,6 @@ public function toDataSource($mixins = []) 'fname' => $this->getFName(), 'nname' => $this->getNName(), 'sname' => $this->getSName(), - //Warning this will leak user emails to public as the api isn't secure 'public_email' => $this->getPublicEmail(), 'url' => $this->getURL(), 'receive_email' => $this->getReceiveEmail(), diff --git a/src/Classes/ServiceAPI/Profile.php b/src/Classes/ServiceAPI/Profile.php index a45d22a4f..df98cbf40 100644 --- a/src/Classes/ServiceAPI/Profile.php +++ b/src/Classes/ServiceAPI/Profile.php @@ -57,11 +57,6 @@ public static function getThisYearsMembers() return self::getMembersForYear(CoreUtils::getAcademicYear()); } - function rem_inx ($str, $ind) - { - return substr($str,0,$ind++). substr($str,$ind); - } - /** * Returns an Array representation of the given year's URY Members. * @@ -69,21 +64,21 @@ function rem_inx ($str, $ind) * a member, sorted by their name: * * memberid: The user's unique memberid - * name: The user's last and first names formatted as sname, fname + * name: The user's last and first names and possibly nickname formatted as fname "nname" sname * college: The name of the member's college (not the ID!) * paid: How much the member has paid this year */ public static function getMembersForYear($year) { self::wakeup(); - - /* Adding nickname can cause issues if the nickname is null; - * If you work out a way to have a default value for null values in SQL, - * message me on slack @Ren Herring - */ + $result = self::$db->fetchAll( - 'SELECT member.memberid, CONCAT(fname, \', \' ,sname) AS name, fname || \' "\' || nname || \'" \' || sname as nickname, l_college.descr AS college, paid, email, eduroam + 'SELECT member.memberid, + CASE WHEN nname IS NULL + THEN fname || \' \' || sname + ELSE fname || \' "\' || nname || \'" \' || sname + END AS name, l_college.descr AS college, paid, email, eduroam FROM member INNER JOIN (SELECT * FROM member_year WHERE year = $1) AS member_year ON ( member.memberid = member_year.memberid ), l_college WHERE member.college = l_college.collegeid @@ -114,8 +109,11 @@ public static function getCurrentOfficers() if (self::$currentOfficers === false) { self::wakeup(); self::$currentOfficers = self::$db->fetchAll( - 'SELECT team.team_name AS team, officer.officer_name AS officership, - sname || \', "\' || nname || \'", \' || fname AS name, member.memberid + 'SELECT team.team_name AS team, officer.officer_name AS officership + CASE WHEN nname IS NULL + THEN fname || \' \' || sname + ELSE fname || \' "\' || nname || \'" \' || sname + END AS name, member.memberid FROM member, officer, member_officer, team WHERE member_officer.memberid = member.memberid AND officer.officerid = member_officer.officerid @@ -149,7 +147,10 @@ public static function getOfficers() self::wakeup(); self::$officers = self::$db->fetchAll( 'SELECT team.team_name AS team, officer.type, officer.officer_name AS officership, - fname || \'"\' || nname || \'"\' || sname AS name, member.memberid, officer.officerid + CASE WHEN nname IS NULL + THEN fname || \' \' || sname + ELSE fname || \' "\' || nname || \'" \' || sname + END AS name, member.memberid, officer.officerid FROM team LEFT JOIN officer ON team.teamid = officer.teamid AND officer.status = \'c\' LEFT JOIN member_officer ON officer.officerid = member_officer.officerid diff --git a/src/Public/js/myradio.newslist.js b/src/Public/js/myradio.newslist.js index 34554805a..21dde34ce 100644 --- a/src/Public/js/myradio.newslist.js +++ b/src/Public/js/myradio.newslist.js @@ -8,11 +8,6 @@ $(".twig-datatable").dataTable({ { "sTitle": "Author" }, - //nickname - { - "sTitle": "nickname", - "sClass": "left", - }, //posted { "sTitle": "Time" diff --git a/src/Public/js/myradio.profile.list.js b/src/Public/js/myradio.profile.list.js index 83f97a7c3..d7d987dcf 100644 --- a/src/Public/js/myradio.profile.list.js +++ b/src/Public/js/myradio.profile.list.js @@ -11,11 +11,6 @@ $(".twig-datatable").dataTable({ "sClass": "left", "aDataSort": [ 1, 2 ] }, - //nickname - { - "sTitle": "Nickname", - "sClass": "left", - }, //college { "sTitle": "College" diff --git a/src/Public/js/myradio.scheduler.termlist.js b/src/Public/js/myradio.scheduler.termlist.js index d0982fcaa..e27c41208 100644 --- a/src/Public/js/myradio.scheduler.termlist.js +++ b/src/Public/js/myradio.scheduler.termlist.js @@ -1,26 +1,26 @@ $(".twig-datatable").dataTable({ - "aaSorting": [[2, "desc"]], + "aaSorting": [[4, "desc"]], "aoColumns": [ //termid { "bVisible": false }, - //start - { - "sTitle": "Start Date" - }, //descr { "sTitle": "Name" }, //num_weeks { - "bVisible": false + "bVisible": true }, //week_names { - "bVisible": false, + "bVisible": false + }, + //start + { + "sTitle": "Start Date" } ], "bPaginate": true -}); +}); \ No newline at end of file diff --git a/src/Public/js/myradio.timeslot.js b/src/Public/js/myradio.timeslot.js index 3e73cc444..c7b68ad2c 100644 --- a/src/Public/js/myradio.timeslot.js +++ b/src/Public/js/myradio.timeslot.js @@ -1,3 +1,14 @@ +//Name helper function for concating names; +function NameHelper(data) { + if (empty(data[row].user.nname) != false) { + return data[row].user.fname + ' "' + data[row].user.nname + '" ' + data[row].user.sname; + } + else { + return data[row].user.fname + " " + data[row].user.sname; + } +} + + /* global moment, myradio */ /** * Handles the interactivityness of timeslot selection @@ -69,14 +80,8 @@ $("#timeslots").on( check.attr("name", "signin[]") .attr("id", "signin_"+data[row].user.memberid) .attr("value", data[row].user.memberid); - if (empty(data[row].user.nname) != false) { - label.attr("for", "signin_"+data[row].user.memberid) - .html(data[row].user.fname + ' "' + data[row].user.nname + '" ' + data[row].user.sname); - } - else { - label.attr("for", "signin_"+data[row].user.memberid) - .html(data[row].user.fname + " " + data[row].user.sname); - } + label.attr("for", "signin_"+data[row].user.memberid) + .html(NameHelper(data)); if (data[row].signedby !== null) { check.attr("checked", "checked") .attr("disabled", "true"); diff --git a/src/Templates/MyRadio/getOnAir.twig b/src/Templates/MyRadio/getOnAir.twig index cda80ac08..cac0713dd 100644 --- a/src/Templates/MyRadio/getOnAir.twig +++ b/src/Templates/MyRadio/getOnAir.twig @@ -9,7 +9,7 @@
  • - Become a Paid Member + Become a Paid Member {% if config.base_url not in config.payment_url %}   {% endif %} diff --git a/src/Templates/Profile/user.twig b/src/Templates/Profile/user.twig index 701dbbeec..f5d8ed57d 100644 --- a/src/Templates/Profile/user.twig +++ b/src/Templates/Profile/user.twig @@ -155,7 +155,7 @@ by {{train.awarded_by.value}} {% if train.revoked_by %} , revoked on {{train.revoked_time|date("j/n/Y")}} by - {{train.revoked_by.fname}} {{train.revoked_by.sname}} + {{train.revoked_by.fname}} {{train.revoked_by.sname}} {% endif %}
  • From b631a4e2d2022f7ac8122bfc118c94af47ff0ffe Mon Sep 17 00:00:00 2001 From: Ren Date: Sat, 7 Sep 2024 23:33:57 +0100 Subject: [PATCH 2/8] hopefully that's it --- docs/install.md | 4 +--- src/Classes/ServiceAPI/MyRadio_User.php | 2 +- src/Public/js/myradio.scheduler.termlist.js | 16 ++++++++-------- src/Public/js/myradio.timeslot.js | 6 +++--- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/docs/install.md b/docs/install.md index 456097223..27fbffe86 100644 --- a/docs/install.md +++ b/docs/install.md @@ -29,9 +29,7 @@ If you have Docker on your system, use Docker Compose to set up an environment. Simply run `docker compose up -d` and visit "https://localhost:4443/myradio/". If you encounter an error with autoload.php: -enter a bash session with `docker compose exec myradio bash` -then in this session run `composer install` -finally exit the session by running `exit` +Simply run the following docker command `docker compose exec myradio composer install` ## Vagrant Install diff --git a/src/Classes/ServiceAPI/MyRadio_User.php b/src/Classes/ServiceAPI/MyRadio_User.php index e4be07239..b4780b329 100755 --- a/src/Classes/ServiceAPI/MyRadio_User.php +++ b/src/Classes/ServiceAPI/MyRadio_User.php @@ -444,7 +444,7 @@ public function getFName() /** * Returns the User's nickname. * - * @return string The User's first name + * @return string The User's nickname */ public function getNName() { diff --git a/src/Public/js/myradio.scheduler.termlist.js b/src/Public/js/myradio.scheduler.termlist.js index e27c41208..d0982fcaa 100644 --- a/src/Public/js/myradio.scheduler.termlist.js +++ b/src/Public/js/myradio.scheduler.termlist.js @@ -1,26 +1,26 @@ $(".twig-datatable").dataTable({ - "aaSorting": [[4, "desc"]], + "aaSorting": [[2, "desc"]], "aoColumns": [ //termid { "bVisible": false }, + //start + { + "sTitle": "Start Date" + }, //descr { "sTitle": "Name" }, //num_weeks - { - "bVisible": true - }, - //week_names { "bVisible": false }, - //start + //week_names { - "sTitle": "Start Date" + "bVisible": false, } ], "bPaginate": true -}); \ No newline at end of file +}); diff --git a/src/Public/js/myradio.timeslot.js b/src/Public/js/myradio.timeslot.js index c7b68ad2c..f271e519b 100644 --- a/src/Public/js/myradio.timeslot.js +++ b/src/Public/js/myradio.timeslot.js @@ -1,5 +1,5 @@ -//Name helper function for concating names; -function NameHelper(data) { +//Format names function for concating names; +function formatName(data) { if (empty(data[row].user.nname) != false) { return data[row].user.fname + ' "' + data[row].user.nname + '" ' + data[row].user.sname; } @@ -81,7 +81,7 @@ $("#timeslots").on( .attr("id", "signin_"+data[row].user.memberid) .attr("value", data[row].user.memberid); label.attr("for", "signin_"+data[row].user.memberid) - .html(NameHelper(data)); + .html(formatName(data)); if (data[row].signedby !== null) { check.attr("checked", "checked") .attr("disabled", "true"); From 6bdaa2bd014f99b7c4fcb1692a3cc3434cf63dac Mon Sep 17 00:00:00 2001 From: Ren Date: Fri, 13 Sep 2024 02:40:49 +0100 Subject: [PATCH 3/8] removes comment --- src/Public/js/myradio.timeslot.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Public/js/myradio.timeslot.js b/src/Public/js/myradio.timeslot.js index f271e519b..b922c2d6c 100644 --- a/src/Public/js/myradio.timeslot.js +++ b/src/Public/js/myradio.timeslot.js @@ -1,4 +1,3 @@ -//Format names function for concating names; function formatName(data) { if (empty(data[row].user.nname) != false) { return data[row].user.fname + ' "' + data[row].user.nname + '" ' + data[row].user.sname; From 4f7b701c8c3261436d40b2969dd37440727e2671 Mon Sep 17 00:00:00 2001 From: Ren Date: Fri, 13 Sep 2024 02:42:49 +0100 Subject: [PATCH 4/8] adds comment back --- src/Public/js/myradio.timeslot.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Public/js/myradio.timeslot.js b/src/Public/js/myradio.timeslot.js index b922c2d6c..ce6e93a8d 100644 --- a/src/Public/js/myradio.timeslot.js +++ b/src/Public/js/myradio.timeslot.js @@ -1,3 +1,4 @@ +//combines the first,nickname,last name of the user together function formatName(data) { if (empty(data[row].user.nname) != false) { return data[row].user.fname + ' "' + data[row].user.nname + '" ' + data[row].user.sname; From af0e66c788a09ddc4d78fa9a88d14a0dbaab7b16 Mon Sep 17 00:00:00 2001 From: Ren Date: Fri, 13 Sep 2024 02:45:19 +0100 Subject: [PATCH 5/8] removes unneeded code --- src/Classes/ServiceAPI/MyRadio_User.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Classes/ServiceAPI/MyRadio_User.php b/src/Classes/ServiceAPI/MyRadio_User.php index b4780b329..64c7ffc75 100755 --- a/src/Classes/ServiceAPI/MyRadio_User.php +++ b/src/Classes/ServiceAPI/MyRadio_User.php @@ -472,9 +472,8 @@ public function getName() { if (empty($this->nname)) { return $this->fname.' '.$this->sname; - } else { - return $this->fname.' "'.$this->nname.'" '.$this->sname; - } + } + return $this->fname.' "'.$this->nname.'" '.$this->sname; } public function getLastLogin() From 49408286cba7bcc736598f5c76c527d3d585875f Mon Sep 17 00:00:00 2001 From: Ren Date: Fri, 13 Sep 2024 02:46:41 +0100 Subject: [PATCH 6/8] adds pural --- src/Public/js/myradio.timeslot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Public/js/myradio.timeslot.js b/src/Public/js/myradio.timeslot.js index ce6e93a8d..d4e502a4a 100644 --- a/src/Public/js/myradio.timeslot.js +++ b/src/Public/js/myradio.timeslot.js @@ -1,4 +1,4 @@ -//combines the first,nickname,last name of the user together +//combines the first,nickname,last names of the user together function formatName(data) { if (empty(data[row].user.nname) != false) { return data[row].user.fname + ' "' + data[row].user.nname + '" ' + data[row].user.sname; From ad8acccecb5f7964c81868ebca1863a8c9cbb527 Mon Sep 17 00:00:00 2001 From: Ren Date: Fri, 13 Sep 2024 02:46:57 +0100 Subject: [PATCH 7/8] spacing --- src/Public/js/myradio.timeslot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Public/js/myradio.timeslot.js b/src/Public/js/myradio.timeslot.js index d4e502a4a..a94ed5c8f 100644 --- a/src/Public/js/myradio.timeslot.js +++ b/src/Public/js/myradio.timeslot.js @@ -1,4 +1,4 @@ -//combines the first,nickname,last names of the user together +//combines the first, nickname, last names of the user together function formatName(data) { if (empty(data[row].user.nname) != false) { return data[row].user.fname + ' "' + data[row].user.nname + '" ' + data[row].user.sname; From 711e0e5084ddba548baf60daf1f76e8d22ef3d7a Mon Sep 17 00:00:00 2001 From: Ren Date: Sun, 15 Sep 2024 17:08:16 +0100 Subject: [PATCH 8/8] fixes final changes --- src/Classes/ServiceAPI/MyRadio_User.php | 9 +++++---- src/Public/js/myradio.timeslot.js | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Classes/ServiceAPI/MyRadio_User.php b/src/Classes/ServiceAPI/MyRadio_User.php index 64c7ffc75..f0ef3c675 100755 --- a/src/Classes/ServiceAPI/MyRadio_User.php +++ b/src/Classes/ServiceAPI/MyRadio_User.php @@ -470,10 +470,11 @@ public function getSName() */ public function getName() { - if (empty($this->nname)) { - return $this->fname.' '.$this->sname; - } - return $this->fname.' "'.$this->nname.'" '.$this->sname; + if (!empty($this->nname)) { + return $this->fname.' "'.$this->nname.'" '.$this->sname; + } + return $this->fname.' '.$this->sname; + } public function getLastLogin() diff --git a/src/Public/js/myradio.timeslot.js b/src/Public/js/myradio.timeslot.js index a94ed5c8f..b922c2d6c 100644 --- a/src/Public/js/myradio.timeslot.js +++ b/src/Public/js/myradio.timeslot.js @@ -1,4 +1,3 @@ -//combines the first, nickname, last names of the user together function formatName(data) { if (empty(data[row].user.nname) != false) { return data[row].user.fname + ' "' + data[row].user.nname + '" ' + data[row].user.sname;