Skip to content

Commit

Permalink
Merge pull request #20 from MasterSteelblade/dev
Browse files Browse the repository at this point in the history
Removed enum restriction on pronouns and converted it to be freeform.
  • Loading branch information
MasterSteelblade authored Mar 14, 2021
2 parents b4fadcb + e0ed037 commit ec988ea
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 31 deletions.
2 changes: 1 addition & 1 deletion html/process/settings/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
$passwordConfirmed = $user->confirmPassword($_POST['currentPassword']);
}
if (isset($_POST['pronouns'])) {
$user->updatePronoun($_POST['pronouns']);
$user->updatePronoun(substr($_POST['pronouns'], 0, 20));
}
if (isset($_POST['dashTheme'])) {
$user->setTheme($_POST['dashTheme']);
Expand Down
2 changes: 1 addition & 1 deletion html/process/user/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Force this to be a JSON return for a laugh
if (isset($_POST['g-recaptcha-response'])) {
$captcha = $_POST['g-recaptcha-response'];
$secretKey = $ENV['CAPTCHA_SECRETKEY'];
$secretKey = $_ENV['CAPTCHA_SECRETKEY'];
$captchaIP = $_SERVER['REMOTE_ADDR'];
$url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($secretKey) . '&response=' . urlencode($captcha);
$response = file_get_contents($url);
Expand Down
2 changes: 1 addition & 1 deletion html/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function(response) {
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="g-recaptcha" data-sitekey="<?php echo $ENV['CAPTCHA_SITEKEY']; ?>"></div>
<div class="g-recaptcha" data-sitekey="<?php echo $_ENV['CAPTCHA_SITEKEY']; ?>"></div>
</div>
</div>
</form>
Expand Down
8 changes: 2 additions & 6 deletions html/settings/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,9 @@ function(response) {
<div class="form-group row">
<div class="col">
<p>If you like, you can select pronouns to display next to your blog name on the dashboard. Set them here, then turn them on in blog settings for each blog you want them on.</p>
<p>This field is for pronouns only. For example, she/her, they/them, etc.</p>
<label class="control-label" for="pronouns">Pronouns:</label>
<select class="form-control" id="pronouns" name="pronouns">
<option value="none" <?php if ($user->pronouns == null) { echo 'selected'; } ?>>Not set</option>';
<option value="0" <?php if ($user->pronouns == 'they/them') { echo 'selected'; } ?>>they/them</option>';
<option value="1" <?php if ($user->pronouns == 'she/her') { echo 'selected'; } ?>>she/her</option>';
<option value="2" <?php if ($user->pronouns == 'he/him') { echo 'selected'; } ?>>he/him</option>';
</select>
<input id="pronouns" maxlength="20" class="form-control" name="pronouns" type="text" value="<?php echo $user->pronouns; ?>">
</div>
</div>
<div class="form-group row">
Expand Down
23 changes: 2 additions & 21 deletions src/classes/User.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,27 +329,8 @@ public function getByEmail(string $email) {
}

public function updatePronoun($option) {
if ($option == 'none') {
$values = array($this->ID);
$this->database->db_update("UPDATE users SET pronouns = null where id = $1", $values);
} else {
$pronoun = '';
switch ($option) {
case 0: // they
$pronoun = 'they/them';
break;
case 1: // she
$pronoun = 'she/her';
break;
case 2: //he
$pronoun = 'he/him';
break;
default:
$pronoun = 'they/them';
}
$values = array($this->ID, $pronoun);
$this->database->db_update("UPDATE users SET pronouns = $2 where id = $1", $values);
}
$values = array($this->ID, $option);
$this->database->db_update("UPDATE users SET pronouns = $2 where id = $1", $values);
}

public function updateMissing($array) {
Expand Down
2 changes: 1 addition & 1 deletion tests/prep/wf.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ CREATE TABLE public.users (
account_type public.account_types,
restrictions public.account_restrictions[] DEFAULT '{}'::public.account_restrictions[],
flags public.account_flags[] DEFAULT '{}'::public.account_flags[],
pronouns public.pronoun_sets
pronouns text
);


Expand Down

0 comments on commit ec988ea

Please sign in to comment.