summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-11-20 16:48:21 -0500
committerEvan Prodromou <evan@prodromou.name>2008-11-20 16:48:21 -0500
commit6f31f25105f59bee5d6a8eccf43952e1396846b3 (patch)
treeca3fe49756d05e81b5b2fed39bd3f0953fbb3fb8 /actions
parent8a0c438aedebaa0282e4f23c83dbe0d7d2635f33 (diff)
let users set their own profile tags from profilesettings
darcs-hash:20081120214821-84dde-c8569ef645b389de545f78bf01a270f28b871f02.gz
Diffstat (limited to 'actions')
-rw-r--r--actions/profilesettings.php30
1 files changed, 26 insertions, 4 deletions
diff --git a/actions/profilesettings.php b/actions/profilesettings.php
index 2ae736087..7f12de9fe 100644
--- a/actions/profilesettings.php
+++ b/actions/profilesettings.php
@@ -67,10 +67,9 @@ class ProfilesettingsAction extends SettingsAction {
'action' =>
common_local_url('profilesettings')));
common_hidden('token', common_session_token());
-
-
-
+
# too much common patterns here... abstractable?
+
common_input('nickname', _('Nickname'),
($this->arg('nickname')) ? $this->arg('nickname') : $profile->nickname,
_('1-64 lowercase letters or numbers, no punctuation or spaces'));
@@ -85,6 +84,9 @@ class ProfilesettingsAction extends SettingsAction {
common_input('location', _('Location'),
($this->arg('location')) ? $this->arg('location') : $profile->location,
_('Where you are, like "City, State (or Region), Country"'));
+ common_input('tags', _('Tags'),
+ ($this->arg('tags')) ? $this->arg('tags') : implode(' ', $user->getSelfTags()),
+ _('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated'));
$language = common_language();
common_dropdown('language', _('Language'), get_nice_language_list(), _('Preferred language'), TRUE, $language);
@@ -194,7 +196,8 @@ class ProfilesettingsAction extends SettingsAction {
$autosubscribe = $this->boolean('autosubscribe');
$language = $this->trimmed('language');
$timezone = $this->trimmed('timezone');
-
+ $tagstring = $this->trimmed('tags');
+
# Some validation
if (!Validate::string($nickname, array('min_length' => 1,
@@ -226,8 +229,18 @@ class ProfilesettingsAction extends SettingsAction {
return;
} else if (!is_null($language) && strlen($language) > 50) {
$this->show_form(_('Language is too long (max 50 chars).'));
+ return;
}
+ $tags = array_map('common_canonical_tag', preg_split('/[\s,]+/', $tagstring));
+
+ foreach ($tags as $tag) {
+ if (!common_valid_profile_tag($tag)) {
+ $this->show_form(sprintf(_('Invalid tag: "%s"'), $tag));
+ return;
+ }
+ }
+
$user = common_current_user();
$user->query('BEGIN');
@@ -300,6 +313,15 @@ class ProfilesettingsAction extends SettingsAction {
return;
}
+ # Set the user tags
+
+ $result = $user->setTags($tags);
+
+ if (!$result) {
+ common_server_error(_('Couldn\'t save tags.'));
+ return;
+ }
+
$user->query('COMMIT');
common_broadcast_profile($profile);