/** * Get a the self-tags associated with this profile * * @return string the concatenated string of tags */ function getTags() { return implode(' ', Profile_tag::getSelfTagsArray($this->profile)); }
/** * Content area of the page * * Shows a form for uploading an avatar. * * @return void */ function showContent() { $user = $this->scoped->getUser(); $this->elementStart('form', array('method' => 'post', 'id' => 'form_settings_profile', 'class' => 'form_settings', 'action' => common_local_url('profilesettings'))); $this->elementStart('fieldset'); // TRANS: Profile settings form legend. $this->element('legend', null, _('Profile information')); $this->hidden('token', common_session_token()); // too much common patterns here... abstractable? $this->elementStart('ul', 'form_data'); if (Event::handle('StartProfileFormData', array($this))) { $this->elementStart('li'); // TRANS: Field label in form for profile settings. $this->input('nickname', _('Nickname'), $this->trimmed('nickname') ?: $this->scoped->getNickname(), _('1-64 lowercase letters or numbers, no punctuation or spaces.'), null, false, !common_config('profile', 'changenick') ? array('disabled' => 'disabled', 'placeholder' => null) : array('placeholder' => null)); $this->elementEnd('li'); $this->elementStart('li'); // TRANS: Field label in form for profile settings. $this->input('fullname', _('Full name'), $this->trimmed('fullname') ?: $this->scoped->getFullname()); $this->elementEnd('li'); $this->elementStart('li'); // TRANS: Field label in form for profile settings. $this->input('homepage', _('Homepage'), $this->trimmed('homepage') ?: $this->scoped->getHomepage(), _('URL of your homepage, blog, or profile on another site.')); $this->elementEnd('li'); $this->elementStart('li'); $maxBio = Profile::maxBio(); if ($maxBio > 0) { // TRANS: Tooltip for field label in form for profile settings. Plural // TRANS: is decided by the number of characters available for the // TRANS: biography (%d). $bioInstr = sprintf(_m('Describe yourself and your interests in %d character.', 'Describe yourself and your interests in %d characters.', $maxBio), $maxBio); } else { // TRANS: Tooltip for field label in form for profile settings. $bioInstr = _('Describe yourself and your interests.'); } // TRANS: Text area label in form for profile settings where users can provide // TRANS: their biography. $this->textarea('bio', _('Bio'), $this->trimmed('bio') ?: $this->scoped->getDescription(), $bioInstr); $this->elementEnd('li'); $this->elementStart('li'); // TRANS: Field label in form for profile settings. $this->input('location', _('Location'), $this->trimmed('location') ?: $this->scoped->location, _('Where you are, like "City, State (or Region), Country".')); $this->elementEnd('li'); if (common_config('location', 'share') == 'user') { $this->elementStart('li'); // TRANS: Checkbox label in form for profile settings. $this->checkbox('sharelocation', _('Share my current location when posting notices'), $this->arg('sharelocation') ? $this->boolean('sharelocation') : $this->scoped->shareLocation()); $this->elementEnd('li'); } Event::handle('EndProfileFormData', array($this)); $this->elementStart('li'); // TRANS: Field label in form for profile settings. $this->input('tags', _('Tags'), $this->trimmed('tags') ?: implode(' ', Profile_tag::getSelfTagsArray($this->scoped)), _('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated.')); $this->elementEnd('li'); $this->elementStart('li'); $language = common_language(); // TRANS: Dropdownlist label in form for profile settings. $this->dropdown('language', _('Language'), get_nice_language_list(), _('Preferred language.'), false, $language); $this->elementEnd('li'); $timezone = common_timezone(); $timezones = array(); foreach (DateTimeZone::listIdentifiers() as $k => $v) { $timezones[$v] = $v; } $this->elementStart('li'); // TRANS: Dropdownlist label in form for profile settings. $this->dropdown('timezone', _('Timezone'), $timezones, _('What timezone are you normally in?'), true, $timezone); $this->elementEnd('li'); $this->elementStart('li'); $this->checkbox('autosubscribe', _('Automatically subscribe to whoever ' . 'subscribes to me (best for non-humans)'), $this->arg('autosubscribe') ? $this->boolean('autosubscribe') : $user->autosubscribe); $this->elementEnd('li'); $this->elementStart('li'); $this->dropdown('subscribe_policy', _('Subscription policy'), array(User::SUBSCRIBE_POLICY_OPEN => _('Let anyone follow me'), User::SUBSCRIBE_POLICY_MODERATE => _('Ask me first')), _('Whether other users need your permission to follow your updates.'), false, empty($user->subscribe_policy) ? User::SUBSCRIBE_POLICY_OPEN : $user->subscribe_policy); $this->elementEnd('li'); } $this->elementStart('li'); $this->checkbox('private_stream', _('Make updates visible only to my followers'), $this->arg('private_stream') ? $this->boolean('private_stream') : $user->private_stream); $this->elementEnd('li'); $this->elementEnd('ul'); // TRANS: Button to save input in profile settings. $this->submit('save', _m('BUTTON', 'Save')); $this->elementEnd('fieldset'); $this->elementEnd('form'); }
/** * Save fields that should be stored in the main profile object * * XXX: There's a lot of dupe code here from ProfileSettingsAction. * Do not want. */ function saveStandardProfileDetails() { $fullname = $this->trimmed('extprofile-fullname'); $location = $this->trimmed('extprofile-location'); $tagstring = $this->trimmed('extprofile-tags'); $bio = $this->trimmed('extprofile-bio'); if ($tagstring) { $tags = array_map('common_canonical_tag', preg_split('/[\\s,]+/', $tagstring)); } else { $tags = array(); } foreach ($tags as $tag) { if (!common_valid_profile_tag($tag)) { // TRANS: Validation error in form for profile settings. // TRANS: %s is an invalid tag. throw new Exception(sprintf(_m('Invalid tag: "%s".'), $tag)); } } $oldTags = Profile_tag::getSelfTagsArray($this->scoped); $newTags = array_diff($tags, $oldTags); if ($fullname != $this->scoped->getFullname() || $location != $this->scoped->location || !empty($newTags) || $bio != $this->scoped->getDescription()) { $orig = clone $this->scoped; // Skipping nickname change here until we add logic for when the site allows it or not // old Profilesettings will still let us do that. $this->scoped->fullname = $fullname; $this->scoped->bio = $bio; $this->scoped->location = $location; $loc = Location::fromName($location); if (empty($loc)) { $this->scoped->lat = null; $this->scoped->lon = null; $this->scoped->location_id = null; $this->scoped->location_ns = null; } else { $this->scoped->lat = $loc->lat; $this->scoped->lon = $loc->lon; $this->scoped->location_id = $loc->location_id; $this->scoped->location_ns = $loc->location_ns; } $result = $this->scoped->update($orig); if ($result === false) { common_log_db_error($this->scoped, 'UPDATE', __FILE__); // TRANS: Server error thrown when user profile settings could not be saved. throw new ServerException(_m('Could not save profile.')); } // Set the user tags $result = Profile_tag::setSelfTags($this->scoped, $tags); Event::handle('EndProfileSaveForm', array($this)); } }