Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Nickname back, OML #1197

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 53 additions & 33 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ 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:
Simply run the following docker command `docker compose exec myradio composer install`

## 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
Expand All @@ -43,8 +48,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`
Expand Down Expand Up @@ -74,6 +80,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
Expand All @@ -85,36 +92,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]
Expand All @@ -132,28 +150,30 @@ 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
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)

### 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.
- 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)

#### 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.
2 changes: 2 additions & 0 deletions schema/api.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -393,6 +394,7 @@ type EmailDestination {
type MemberSearchResult {
memberid: Int!
fname: String!
nname: String!
sname: String!
eduroam: String
local_alias: String
Expand Down
3 changes: 3 additions & 0 deletions schema/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
"fname": {
"type": "string"
},
"nname": {
"type": "string"
},
"sname": {
"type": "string"
},
Expand Down
5 changes: 5 additions & 0 deletions schema/patches/19.sql
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 2 additions & 2 deletions scripts/gdprdeleteuser.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
try{
$db->query(
'INSERT INTO public.member(
memberid, fname, sname, college, receive_email, data_removal)
VALUES ($1, \'deleted\', \'user\', 10, false, \'deleted\')',
memberid, fname, nname, sname, college, receive_email, data_removal)
VALUES ($1, \'deleted\', \'\' ,\'user\', 10, false, \'deleted\')',
[$deletedUserId]
);
} catch (exception $e) {
Expand Down
6 changes: 5 additions & 1 deletion src/Classes/MyRadio/MyRadioNews.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, 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',
Expand Down
56 changes: 52 additions & 4 deletions src/Classes/ServiceAPI/MyRadio_User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -434,6 +441,18 @@ public function getFName()
return $this->fname;
}

/**
* Returns the User's nickname.
*
* @return string The User's nickname
*/
public function getNName()
{
return $this->nname;
}



/**
* Returns the User's surname.
*
Expand All @@ -451,7 +470,11 @@ public function getSName()
*/
public function getName()
{
if (!empty($this->nname)) {
return $this->fname.' "'.$this->nname.'" '.$this->sname;
}
return $this->fname.' '.$this->sname;

}

public function getLastLogin()
Expand Down Expand Up @@ -930,14 +953,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]
Expand Down Expand Up @@ -1288,6 +1311,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.
*
Expand Down Expand Up @@ -1666,6 +1697,17 @@ public function getEditForm()
]
)
)
->addField(
new MyRadioFormField(
'nname',
MyRadioFormField::TYPE_TEXT,
[
'required' => false,
'label' => 'Nickname',
'value' => $this->getNName(),
]
)
)
->addField(
new MyRadioFormField(
'sname',
Expand Down Expand Up @@ -1761,7 +1803,7 @@ public function getEditForm()
MyRadioFormField::TYPE_EMAIL,
[
'required' => false,
'label' => 'Email',
'label' => 'Public Email',
'value' => $this->email,
]
)
Expand Down Expand Up @@ -2065,6 +2107,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 $sname The User's last name.
* @param string $eduroam The User's @york.ac.uk address.
* @param int $collegeid The User's college.
Expand All @@ -2079,6 +2122,7 @@ public function activateMemberThisYear($paid = 0)
*/
public static function createOrActivate(
$fname,

$sname,
$eduroam = null,
$collegeid = null,
Expand All @@ -2098,6 +2142,7 @@ public static function createOrActivate(
} else {
$data = [
'fname' => $fname,

'sname' => $sname,
'eduroam' => $eduroam,
'collegeid' => $collegeid,
Expand All @@ -2124,6 +2169,7 @@ public static function createOrActivate(
*/
public static function createActivateAPI(
$fname,

$sname,
$captcha,
$eduroam = null,
Expand Down Expand Up @@ -2352,6 +2398,7 @@ public function getEmptyData(){
$data['bio'] = 'This user is hidden';
$data['memberid'] = $this->getID();
$data['fname'] = 'Hidden';
$data['nname'] = NULL;
$datap['sname'] = 'User';
$data['public_email'] = '';
$data['url'] = $this->getURL();
Expand Down Expand Up @@ -2407,6 +2454,7 @@ public function toDataSource($mixins = [])
$data = [
'memberid' => $this->getID(),
'fname' => $this->getFName(),
'nname' => $this->getNName(),
'sname' => $this->getSName(),
'public_email' => $this->getPublicEmail(),
'url' => $this->getURL(),
Expand Down
Loading