diff --git a/docs/install.md b/docs/install.md index 512703154..276698eef 100644 --- a/docs/install.md +++ b/docs/install.md @@ -24,10 +24,18 @@ The codespace includes Mailhog, which will trap any emails sent by MyRadio. To s click the Local Address next to port 8025 in the Ports panel. ## Docker Install + 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/". +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` ## Vagrant Install + MyRadio comes with a Vagrantfile based on Ubuntu 19.10. If you have [Vagrant](https://www.vagrantup.com) installed and want to get developing or playing right away, just run `vagrant up` and a few minutes @@ -43,8 +51,9 @@ so be sure to never run this in a production environment, or remove the permission before doing so. ## Uncontained Install + Install Apache2, PHP, Composer and PostgreSQL on your prefered Unix-based distro. -Or Windows, if you're into that. +Or Windows, if you're into that. MyRadio has been tested with Ubuntu and FreeBSD. cd to your MyRadio installation and run `composer install` @@ -74,6 +83,7 @@ Alias /api /usr/local/www/MyRadio/src/PublicAPI Restart Apache2, go to http://hostname/myradio To make a new postgresql server, run the following after: + ``` pg_createcluster [YOUR_POSTGRES_VERSION] myradio su postgres @@ -85,36 +95,47 @@ CREATE DATABASE myradio WITH OWNER=myradio; # Post-Installation ## Myradio Setup + CONNECT: - - Open up "https://localhost:4443/myradio/" in a browser - - [Use Chrome as this often fails to run on Firefox] - - It will say "connection not private" so press "advanced" and then "proceed" + +- Open up "https://localhost:4443/myradio/" in a browser +- [Use Chrome as this often fails to run on Firefox] +- It will say "connection not private" so press "advanced" and then "proceed" DATABASE: - - On the intro screen press "Click here to continue" - - Enter the database details (see Default Credentials) and press Next - - Press "run task", wait a few seconds and then press "run task" again. - - [This method is a workaround for a slight bug in how we build the database] - + +- On the intro screen press "Click here to continue" +- Enter the database details (see Default Credentials) and press Next +- Press "run task", wait a few seconds and then press "run task" again. +- [This method is a workaround for a slight bug in how we build the database] + USER: - - [Here you can make config changes but the defaults are autofilled] - - Press "complete starting set", scroll and press "save and continue" - - Input any first and last name, an email (NOT an @york.ac.uk email) and a password - - [If you enter an @york.ac.uk email you will not be able to login at all] - - Login using the email and password you just enterted + +- [Here you can make config changes but the defaults are autofilled] +- Press "complete starting set", scroll and press "save and continue" +- Input any first and last name, an email (NOT an @york.ac.uk email) and a password +- [If you enter an @york.ac.uk email you will not be able to login at all] +- Login using the email and password you just enterted + +- If you encounter an error you need to create the file /var/www/myradio/src/MyRadio_Config.local.php with the text from the "Show Config" button +- [if you are using docker this needs to be done within the docker container using `docker exec -it [myradioid] bash`] ## Default Credentials + Database: (when building the database, these credentials are needed) - - Hostname: `postgres` if running in Docker, `localhost` otherwise - - Database: myradio - - Username: myradio - - Password: myradio + +- Hostname: `postgres` if running in Docker, `localhost` otherwise +- Database: myradio +- Username: myradio +- Password: myradio Vagrant VM: (if you need to ssh into the virtual machine) - - Username: vagrant - - Password: vagrant + +- Username: vagrant +- Password: vagrant ## Tests + MyRadio uses [Codeception](http://codeception.com/quickstart) for its test suite. [This was written with a Vagrant install in mind - has not been tested on Docker] @@ -132,10 +153,11 @@ blanks the `myradio_test` database each time it is ran, so it can be used to reset the database and config file, should this prove necessary. Summary: -* `composer install` -* `vagrant up` -* `vagrant ssh -- /vagrant/scripts/reset-db.sh` -* `src/vendor/bin/codecept run` + +- `composer install` +- `vagrant up` +- `vagrant ssh -- /vagrant/scripts/reset-db.sh` +- `src/vendor/bin/codecept run` The vagrant initialisation script also runs `composer install`, but that is run on the virtual machine which also installs the PHP extensions required for @@ -143,17 +165,53 @@ Codeception. These extensions may be missing locally, so running composer will confirm that they are present. ## Next Steps + Once you've got through the setup wizard, the next thing that's most useful to you is most likely creating a show. To do this, you first need to: -- Create a Term (Show Scheduler -> Manage Terms) -- Create a Show (List My Shows -> Create a Show) -- Apply for a Season of your new Show (List My Shows -> New Season) -- Schedule the Season (Shows Scheduler) + +- Create a Term (Show Scheduler -> Manage Terms) +- Create a Show (List My Shows -> Create a Show) +- 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 -MyRadio splits Shows into "Seasons". Any Season is applied to in relation to a -"Term", which is a 10-week space of time. This is because The University of -York has 10 week terms, if you didn't know. +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/api.graphql b/schema/api.graphql index 1c326e09c..479c9ca74 100644 --- a/schema/api.graphql +++ b/schema/api.graphql @@ -99,6 +99,7 @@ type User implements Node & MyRadioObject { id: ID! @bind(method: "getID") itemId: Int! @bind(method: "getID") fname: String! @bind(method: "getFName") + nname: String! @bind(method: "getNName") sname: String! @bind(method: "getSName") # Public information @@ -393,6 +394,7 @@ type EmailDestination { type MemberSearchResult { memberid: Int! fname: String! + nname: String! sname: String! eduroam: String local_alias: String diff --git a/schema/api.json b/schema/api.json index 30482478f..d4f26524b 100644 --- a/schema/api.json +++ b/schema/api.json @@ -116,6 +116,9 @@ "fname": { "type": "string" }, + "nname": { + "type": "string" + }, "sname": { "type": "string" }, diff --git a/schema/base.sql b/schema/base.sql index ee39f2799..705eb5832 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, sname and email address.'; +COMMENT ON COLUMN mail_list.defn IS 'A SQL string that returns fname, nname ,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.'; @@ -1276,6 +1276,7 @@ COMMENT ON TABLE mail_subscription IS 'If a list is subscribable, then all membe CREATE TABLE member ( memberid integer DEFAULT nextval(('"member_memberid_seq"'::text)::regclass) NOT NULL, fname character varying(255) NOT NULL, + nname character varying(255), sname character varying(255) NOT NULL, college integer NOT NULL, phone character varying(255), diff --git a/schema/patches/19.sql b/schema/patches/19.sql new file mode 100644 index 000000000..5639051a8 --- /dev/null +++ b/schema/patches/19.sql @@ -0,0 +1,5 @@ +ALTER TABLE member + ADD COLUMN nname character varying(255); + +INSERT INTO metadata.metadata_key VALUES (20,'upload_starttime',false,'In the case where a manual upload is required (because an event started late) will need to start late. This is a UTC time.',300,false); +INSERT INTO metadata.metadata_key VALUES (21,'upload_endtime',false,'In the case where a manual upload is required (because an event started late) will need to finish early/late.',300,false); diff --git a/scripts/gdprdeleteuser.php b/scripts/gdprdeleteuser.php index 00ac3618d..34d84752a 100644 --- a/scripts/gdprdeleteuser.php +++ b/scripts/gdprdeleteuser.php @@ -40,7 +40,7 @@ try{ $db->query( 'INSERT INTO public.member( - memberid, fname, sname, college, receive_email, data_removal) + memberid, fname, nname, sname, college, receive_email, data_removal) VALUES ($1, \'deleted\', \'user\', 10, false, \'deleted\')', [$deletedUserId] ); diff --git a/src/Classes/MyRadio/MyRadioNews.php b/src/Classes/MyRadio/MyRadioNews.php index e607982dc..d536dbdb2 100644 --- a/src/Classes/MyRadio/MyRadioNews.php +++ b/src/Classes/MyRadio/MyRadioNews.php @@ -75,7 +75,7 @@ public static function getNewsItem($newsentryid, MyRadio_User $user = null) $db = Database::getInstance(); $news = $db->fetchOne( - 'SELECT newsentryid, fname || \' \' || sname AS author, timestamp AS posted, content + 'SELECT newsentryid, fname || \' \' || sname AS author, fname || \' "\' || nname || \'" \' || sname as nickname, 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 2a8f43cb6..191e01b28 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 7a6b7af44..903420642 100644 --- a/src/Classes/ServiceAPI/MyRadio_Track.php +++ b/src/Classes/ServiceAPI/MyRadio_Track.php @@ -634,7 +634,11 @@ public function reportExplicit() $title = htmlspecialchars($this->getTitle()); $artist = htmlspecialchars($this->getArtist()); - $userName = htmlspecialchars($currentUser->getFName() . ' ' . $currentUser->getSName()); + if (empty($currentUser->getNName()) == True) { + $userName = htmlspecialchars($currentUser->getFName() . ' ' . $currentUser->getSName()); + } else { + $userName = htmlspecialchars($currentUser->getFName() . ' "' . $currentUser->getNName() . '" ' . $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 723c73a06..d6fa6a7eb 100755 --- a/src/Classes/ServiceAPI/MyRadio_User.php +++ b/src/Classes/ServiceAPI/MyRadio_User.php @@ -47,6 +47,13 @@ class MyRadio_User extends ServiceAPI implements APICaller */ private $fname; + /** + * Stores the User's nickname. + * + * @var string + */ + private $nname; + /** * Stores the User's last name. * @@ -237,7 +244,7 @@ protected function __construct($memberid) $this->memberid = (int) $memberid; //Get the base data $data = self::$db->fetchOne( - 'SELECT fname, sname, college AS collegeid, l_college.descr AS college, + 'SELECT fname, nname, sname, college AS collegeid, l_college.descr AS college, phone, email, receive_email::boolean::text, local_name, local_alias, eduroam, account_locked::boolean::text, last_login, joined, profile_photo, bio, auth_provider, require_password_change::boolean::text, contract_signed::boolean::text, gdpr_accepted::boolean::text, @@ -434,6 +441,18 @@ public function getFName() return $this->fname; } + /** + * Returns the User's first name. + * + * @return string The User's first name + */ + public function getNName() + { + return $this->nname; + } + + + /** * Returns the User's surname. * @@ -451,7 +470,12 @@ public function getSName() */ public function getName() { - return $this->fname.' '.$this->sname; + 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() @@ -925,14 +949,14 @@ public static function findByName($name, $limit = -1) $names = explode(' ', $name); if (isset($names[1])) { return self::$db->fetchAll( - 'SELECT memberid, fname, sname, eduroam, local_alias FROM member + 'SELECT memberid, fname, nname, sname, eduroam, local_alias FROM member WHERE fname ILIKE $1 || \'%\' AND sname ILIKE $2 || \'%\' ORDER BY sname, fname LIMIT $3', [$names[0], $names[1], $limit] ); } else { return self::$db->fetchAll( - 'SELECT memberid, fname, sname, eduroam, local_alias FROM member + 'SELECT memberid, fname, nname, sname, eduroam, local_alias FROM member WHERE fname ILIKE $1 || \'%\' OR sname ILIKE $1 || \'%\' ORDER BY sname, fname LIMIT $2', [$name, $limit] @@ -1283,6 +1307,14 @@ public function setFName($fname) return $this; } + public function setNName($nname) + { + + $this->setCommonParam('nname', $nname); + + return $this; + } + /** * Set the User's official @ury.org.uk prefix. Usually fname.sname. * @@ -1661,6 +1693,17 @@ public function getEditForm() ] ) ) + ->addField( + new MyRadioFormField( + 'nname', + MyRadioFormField::TYPE_TEXT, + [ + 'required' => false, + 'label' => 'Nickname', + 'value' => $this->getNName(), + ] + ) + ) ->addField( new MyRadioFormField( 'sname', @@ -1756,7 +1799,7 @@ public function getEditForm() MyRadioFormField::TYPE_EMAIL, [ 'required' => false, - 'label' => 'Email', + 'label' => 'Public Email', 'value' => $this->email, ] ) @@ -1967,11 +2010,12 @@ public static function create($params) //Actually create the member! $r = self::$db->fetchColumn( - 'INSERT INTO public.member (fname, sname, college, phone, + 'INSERT INTO public.member (fname, nname, sname, college, phone, email, receive_email, eduroam, require_password_change) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING memberid', + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING memberid', [ $params['fname'], + $params['nname'], $params['sname'], $params['collegeid'], $params['phone'], @@ -2060,6 +2104,7 @@ public function activateMemberThisYear($paid = 0) * Creates a new User, or activates a user, if it already exists. * * @param string $fname The User's first name. + * @param string $nname The User's nick name. * @param string $sname The User's last name. * @param string $eduroam The User's @york.ac.uk address. * @param int $collegeid The User's college. @@ -2074,6 +2119,7 @@ public function activateMemberThisYear($paid = 0) */ public static function createOrActivate( $fname, + $nname, $sname, $eduroam = null, $collegeid = null, @@ -2093,6 +2139,7 @@ public static function createOrActivate( } else { $data = [ 'fname' => $fname, + 'nname' => $nname, 'sname' => $sname, 'eduroam' => $eduroam, 'collegeid' => $collegeid, @@ -2119,6 +2166,7 @@ public static function createOrActivate( */ public static function createActivateAPI( $fname, + $nname, $sname, $captcha, $eduroam = null, @@ -2208,6 +2256,16 @@ public static function getQuickAddForm() ] ) ) + ->addField( + new MyRadioFormField( + 'nname', + MyRadioFormField::TYPE_TEXT, + [ + 'required' => false, + 'label' => 'Nickname', + ] + ) + ) ->addField( new MyRadioFormField( 'sname', @@ -2295,6 +2353,14 @@ public static function getBulkAddForm() 'label' => 'First Name', ] ), + new MyRadioFormField( + 'nname', + MyRadioFormField::TYPE_TEXT, + [ + 'required' => false, + 'label' => 'Nickname', + ] + ), new MyRadioFormField( 'sname', MyRadioFormField::TYPE_TEXT, @@ -2347,6 +2413,7 @@ public function getEmptyData(){ $data['bio'] = 'This user is hidden'; $data['memberid'] = $this->getID(); $data['fname'] = 'Hidden'; + $data['nname'] = 'Hidden'; $datap['sname'] = 'User'; $data['public_email'] = ''; $data['url'] = $this->getURL(); @@ -2402,7 +2469,9 @@ public function toDataSource($mixins = []) $data = [ 'memberid' => $this->getID(), '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 ccd96a4a7..d710f7156 100644 --- a/src/Classes/ServiceAPI/Profile.php +++ b/src/Classes/ServiceAPI/Profile.php @@ -57,6 +57,11 @@ 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. * @@ -72,14 +77,22 @@ public static function getMembersForYear($year) { self::wakeup(); - return self::$db->fetchAll( - 'SELECT member.memberid, sname || \', \' || fname AS name, l_college.descr AS college, paid, email, eduroam + /* 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 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 ORDER BY sname ASC', [$year] ); + + + return $result; } /** @@ -102,7 +115,7 @@ public static function getCurrentOfficers() self::wakeup(); self::$currentOfficers = self::$db->fetchAll( 'SELECT team.team_name AS team, officer.officer_name AS officership, - sname || \', \' || fname AS name, member.memberid + sname || \', "\' || nname || \'", \' || fname AS name, member.memberid FROM member, officer, member_officer, team WHERE member_officer.memberid = member.memberid AND officer.officerid = member_officer.officerid @@ -136,7 +149,7 @@ 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 || \' \' || sname AS name, member.memberid, officer.officerid + fname || \'"\' || nname || \'"\' || sname 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/Controllers/Profile/bulkAdd.php b/src/Controllers/Profile/bulkAdd.php index a09a1de18..091e0c161 100644 --- a/src/Controllers/Profile/bulkAdd.php +++ b/src/Controllers/Profile/bulkAdd.php @@ -19,6 +19,7 @@ try { $user = MyRadio_User::createOrActivate( $params['fname'], + $params['nname'], $params['sname'], $params['eduroam'], $params['collegeid'] diff --git a/src/Controllers/Profile/edit.php b/src/Controllers/Profile/edit.php index 6a688da0e..553a8cfad 100644 --- a/src/Controllers/Profile/edit.php +++ b/src/Controllers/Profile/edit.php @@ -22,6 +22,7 @@ $data = $user->getEditForm()->readValues(); $user->setFName($data['fname']) + ->setNName($data['nname']) ->setSName($data['sname']) ->setCollegeID($data['collegeid']) ->setPhone($data['phone']) diff --git a/src/Controllers/Profile/quickAdd.php b/src/Controllers/Profile/quickAdd.php index e59f7141f..811d086e7 100644 --- a/src/Controllers/Profile/quickAdd.php +++ b/src/Controllers/Profile/quickAdd.php @@ -10,6 +10,7 @@ $params = MyRadio_User::getQuickAddForm()->readValues(); $user = MyRadio_User::createOrActivate( $params['fname'], + $params['nname'], $params['sname'], $params['eduroam'], $params['collegeid'], diff --git a/src/Controllers/Setup/user.php b/src/Controllers/Setup/user.php index ffb1fdb21..0a9cb24c3 100644 --- a/src/Controllers/Setup/user.php +++ b/src/Controllers/Setup/user.php @@ -12,6 +12,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_REQUEST['password'] === $_REQUEST['passwordchk']) { $params = [ 'fname' => $_REQUEST['first-name'], + 'nname' => $_REQUEST['nick-name'], 'sname' => $_REQUEST['last-name'], 'email' => $_REQUEST['email'], 'phone' => $_REQUEST['phone'], diff --git a/src/Controllers/root.php b/src/Controllers/root.php index afd0adef0..9ad288c7d 100644 --- a/src/Controllers/root.php +++ b/src/Controllers/root.php @@ -13,7 +13,7 @@ * This number is incremented every time a database patch is released. * Patches are scripts in schema/patches. */ -define('MYRADIO_CURRENT_SCHEMA_VERSION', 18); +define('MYRADIO_CURRENT_SCHEMA_VERSION', 19); /* * Turn on Error Reporting for the start. Once the Config object is loaded diff --git a/src/Public/js/myradio.form.js b/src/Public/js/myradio.form.js index b5ab54ed0..2a163e315 100644 --- a/src/Public/js/myradio.form.js +++ b/src/Public/js/myradio.form.js @@ -59,7 +59,12 @@ var MyRadioForm = { }, { displayKey: function (i) { - return i.fname + " " + i.sname; + if (i.nname != null) { + return i.fname + ' "' + i.nname + '" ' + i.sname; + } + else{ + return i.fname + ' ' + i.sname; + } }, source: memberLookup.ttAdapter(), templates: { @@ -76,13 +81,20 @@ var MyRadioForm = { } else { identity = "(#" + i.memberid + ")"; } - return $("

").text(i.fname + " " + i.sname + " " + identity); + if (i.nname != null) { + return $("

").text(i.fname + ' "' + i.nname + '" ' + i.sname + " " + identity); + } + else { + return $("

").text(i.fname + " " + i.sname + " " + identity); + } + } } }) .on( "typeahead:selected", function (e, obj) { + idField.val(obj.memberid); } ); diff --git a/src/Public/js/myradio.timeslot.js b/src/Public/js/myradio.timeslot.js index 03b3c655d..3e73cc444 100644 --- a/src/Public/js/myradio.timeslot.js +++ b/src/Public/js/myradio.timeslot.js @@ -69,12 +69,24 @@ $("#timeslots").on( check.attr("name", "signin[]") .attr("id", "signin_"+data[row].user.memberid) .attr("value", data[row].user.memberid); - label.attr("for", "signin_"+data[row].user.memberid) - .html(data[row].user.fname + " " + data[row].user.sname); + 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); + } if (data[row].signedby !== null) { check.attr("checked", "checked") .attr("disabled", "true"); - label.append(" (Signed in by "+data[row].signedby.fname + " "+data[row].signedby.sname + ")"); + if (empty(data[row].signedby.nname) != false ) { + label.append(" (Signed in by "+data[row].signedby.fname + ' "' + data[row].signedby.nname + '" ' + data[row].signedby.sname + ")"); + } + else { + label.append(" (Signed in by "+data[row].signedby.fname + " " + data[row].signedby.sname + ")"); + } + } else if (data[row].user.memberid == window.myradio.memberid) { check.attr("checked", "checked"); } @@ -86,12 +98,22 @@ $("#timeslots").on( if ($("#guest-signins").is(":empty")) { $("#guest-signins").append("Guest data has been added by:
"); } - $("#guest-signins").append( - $("") - .text(data[row].signedby.fname + " " + data[row].signedby.sname - + " (" + moment.unix(data[row].time).fromNow() + ")") - .append("
") - ); + if (empty(data[row].signedby.nname) != false) { + $("#guest-signins").append( + $("") + .text(data[row].signedby.fname + ' "' + data[row].signedby.nname + '" ' + data[row].signedby.sname + + " (" + moment.unix(data[row].time).fromNow() + ")") + .append("
") + ); + } + else { + $("#guest-signins").append( + $("") + .text(data[row].signedby.fname + " " + data[row].signedby.sname + + " (" + moment.unix(data[row].time).fromNow() + ")") + .append("
") + ); + } } } $("#signin-list").append( diff --git a/src/Templates/Profile/user.twig b/src/Templates/Profile/user.twig index bf8dc8efc..701dbbeec 100644 --- a/src/Templates/Profile/user.twig +++ b/src/Templates/Profile/user.twig @@ -13,7 +13,7 @@ Name: - {{user.fname}} {{user.sname}} + {{user.fname}} {{user.nname}} {{user.sname}} {% if user.college is defined %} @@ -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 %} diff --git a/src/Templates/Setup/user.twig b/src/Templates/Setup/user.twig index 6503a7529..3c0974faf 100644 --- a/src/Templates/Setup/user.twig +++ b/src/Templates/Setup/user.twig @@ -4,6 +4,10 @@


+ + +
+

diff --git a/tests/api/ShowSpecCest.php b/tests/api/ShowSpecCest.php index 82a4b7d1d..ae52bd316 100644 --- a/tests/api/ShowSpecCest.php +++ b/tests/api/ShowSpecCest.php @@ -7,6 +7,7 @@ class ShowSpecCest { public static $user = [ "fname" => "Testy", + "nname" => "Test", "sname" => "McTestFace", "receive_email" => false ];