Skip to content

Commit b54b4eb

Browse files
committed
Show success message on biography update
1 parent 566c112 commit b54b4eb

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/controllers/User/Update.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ public function &run(Router &$router, View &$view, array &$args) {
189189
// biography change request
190190

191191
$model->profile->setBiography($model->biography);
192+
$model->biography_error = ['green', 'CHANGE_SUCCESS'];
192193
$profile_changed = true;
193194

194195
}

src/models/User/Update.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Update extends Model {
2121
public $profile;
2222

2323
public $biography;
24+
public $biography_error;
2425
public $biography_max_len = 255; // table design: varchar(255)
2526

2627
}

src/templates/User/Update.phtml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ switch ($this->getContext()->display_name_error[1]) {
5858
. $this->getContext()->display_name_error[1];
5959
}
6060

61+
switch ($this->getContext()->biography_error[1]) {
62+
case null: case '': $biography_error = ''; break;
63+
case 'CHANGE_FAILED':
64+
$biography_error = 'Failed to change biography.'; break;
65+
case 'CHANGE_SUCCESS':
66+
$biography_error = 'Your biography was updated.'; break;
67+
default:
68+
$biography_error = 'Internal error: '
69+
. $this->getContext()->biography_error[1];
70+
}
71+
6172
$this->additional_css[] = '/a/forms.css';
6273
require('./header.inc.phtml');
6374
?>
@@ -140,10 +151,17 @@ require('./header.inc.phtml');
140151
echo '<p>' . $display_name_error . '</p>';
141152
} ?>
142153
</section>
143-
<section>
154+
<section<?php
155+
if ($biography_error) {
156+
echo ' class="' .
157+
$this->getContext()->biography_error[0] . '"';
158+
} ?>>
144159
<hr/>
145160
<label for="biography">Biography:</label>
146161
<textarea maxlength="<?php echo $this->getContext()->biography_max_len; ?>" name="biography" id="biography"><?php echo filter_var($this->getContext()->biography, FILTER_SANITIZE_FULL_SPECIAL_CHARS); ?></textarea>
162+
<?php if ($biography_error) {
163+
echo '<p>' . $biography_error . '</p>';
164+
} ?>
147165
</section>
148166
<section>
149167
<hr/>

0 commit comments

Comments
 (0)