diff --git a/docs/install.md b/docs/install.md index 276698eef..27fbffe86 100644 --- a/docs/install.md +++ b/docs/install.md @@ -29,10 +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` -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 @@ -176,42 +173,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..f0ef3c675 100755 --- a/src/Classes/ServiceAPI/MyRadio_User.php +++ b/src/Classes/ServiceAPI/MyRadio_User.php @@ -442,9 +442,9 @@ public function getFName() } /** - * Returns the User's first name. + * Returns the User's nickname. * - * @return string The User's first name + * @return string The User's nickname */ public function getNName() { @@ -470,12 +470,11 @@ public function getSName() */ public function getName() { - if (empty($this->nname)) { - return $this->fname.' '.$this->sname; - } else { - return $this->fname.' "'.$this->nname.'" '.$this->sname; + if (!empty($this->nname)) { + return $this->fname.' "'.$this->nname.'" '.$this->sname; } - return $this->fname.' '.$this->nname.' '.$this->sname; + return $this->fname.' '.$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.timeslot.js b/src/Public/js/myradio.timeslot.js index 3e73cc444..b922c2d6c 100644 --- a/src/Public/js/myradio.timeslot.js +++ b/src/Public/js/myradio.timeslot.js @@ -1,3 +1,13 @@ +function formatName(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 +79,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(formatName(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 %}