*
* @return void
*/
-
function showContent()
{
- if (!common_config('xmpp', 'enabled')) {
+ $transports = array();
+ Event::handle('GetImTransports', array(&$transports));
+ if (! $transports) {
$this->element('div', array('class' => 'error'),
- // TRANS: Message given in the Instant Messaging settings if XMPP is not enabled on the site.
+ // TRANS: Message given in the IM settings if IM is not enabled on the site.
_('IM is not available.'));
return;
}
*
* @return Confirm_address address object for this user
*/
++<<<<<<< HEAD
+
+ function getConfirmation($transport)
++=======
+ function getConfirmation()
++>>>>>>> 0.9.x
{
$user = common_current_user();
*
* @return void
*/
-
function savePreferences()
{
- $jabbernotify = $this->boolean('jabbernotify');
- $updatefrompresence = $this->boolean('updatefrompresence');
- $jabberreplies = $this->boolean('jabberreplies');
- $jabbermicroid = $this->boolean('jabbermicroid');
-
$user = common_current_user();
- assert(!is_null($user)); // should already be checked
-
- $user->query('BEGIN');
-
- $original = clone($user);
-
- $user->jabbernotify = $jabbernotify;
- $user->updatefrompresence = $updatefrompresence;
- $user->jabberreplies = $jabberreplies;
- $user->jabbermicroid = $jabbermicroid;
-
- $result = $user->update($original);
-
- if ($result === false) {
- common_log_db_error($user, 'UPDATE', __FILE__);
- // TRANS: Server error thrown on database error updating Instant Messaging preferences.
- $this->serverError(_('Could not update user.'));
- return;
+ $user_im_prefs = new User_im_prefs();
+ $user_im_prefs->query('BEGIN');
+ $user_im_prefs->user_id = $user->id;
+ if($user_im_prefs->find() && $user_im_prefs->fetch())
+ {
+ $preferences = array('notify', 'updatefrompresence', 'replies', 'microid');
+ do
+ {
+ $original = clone($user_im_prefs);
+ $new = clone($user_im_prefs);
+ foreach($preferences as $preference)
+ {
+ $new->$preference = $this->boolean($new->transport . '_' . $preference);
+ }
+ $result = $new->update($original);
+
+ if ($result === false) {
+ common_log_db_error($user, 'UPDATE', __FILE__);
+ // TRANS: Server error thrown on database error updating IM preferences.
+ $this->serverError(_('Couldn\'t update IM preferences.'));
+ return;
+ }
+ }while($user_im_prefs->fetch());
}
-
- $user->query('COMMIT');
-
- // TRANS: Confirmation message for successful Instant Messaging preferences save.
+ $user_im_prefs->query('COMMIT');
+ // TRANS: Confirmation message for successful IM preferences save.
$this->showForm(_('Preferences saved.'), true);
}
*
* @return void
*/
-
function cancelConfirmation()
{
- $jabber = $this->arg('jabber');
+ $screenname = $this->trimmed('screenname');
+ $transport = $this->trimmed('transport');
- $confirm = $this->getConfirmation();
+ $confirm = $this->getConfirmation($transport);
if (!$confirm) {
- // TRANS: Message given canceling IM address confirmation that is not pending.
+ // TRANS: Message given canceling Instant Messaging address confirmation that is not pending.
$this->showForm(_('No pending confirmation to cancel.'));
return;
}
$this->elementStart('div', array('id' => 'i',
'class' => 'entity_profile vcard author'));
- if (Event::handle('StartGroupProfileElements', array($this, $this->group))) {
-
- // TRANS: Group profile header (h2). Text hidden by default.
- $this->element('h2', null, _('Group profile'));
-
- $this->elementStart('dl', 'entity_depiction');
- // TRANS: Label for group avatar (dt). Text hidden by default.
- $this->element('dt', null, _('Avatar'));
- $this->elementStart('dd');
-
- $logo = ($this->group->homepage_logo) ?
- $this->group->homepage_logo : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
-
- $this->element('img', array('src' => $logo,
- 'class' => 'photo avatar',
- 'width' => AVATAR_PROFILE_SIZE,
- 'height' => AVATAR_PROFILE_SIZE,
- 'alt' => $this->group->nickname));
- $this->elementEnd('dd');
- $this->elementEnd('dl');
-
- $this->elementStart('dl', 'entity_nickname');
- // TRANS: Label for group nickname (dt). Text hidden by default.
- $this->element('dt', null, _('Nickname'));
- $this->elementStart('dd');
- $hasFN = ($this->group->fullname) ? 'nickname url uid' : 'fn org nickname url uid';
- $this->element('a', array('href' => $this->group->homeUrl(),
- 'rel' => 'me', 'class' => $hasFN),
- $this->group->nickname);
- $this->elementEnd('dd');
- $this->elementEnd('dl');
-
- if ($this->group->fullname) {
- $this->elementStart('dl', 'entity_fn');
- // TRANS: Label for full group name (dt). Text hidden by default.
- $this->element('dt', null, _('Full name'));
- $this->elementStart('dd');
- $this->element('span', 'fn org', $this->group->fullname);
- $this->elementEnd('dd');
- $this->elementEnd('dl');
- }
+ $logo = ($this->group->homepage_logo) ?
+ $this->group->homepage_logo : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
+
+ $this->element('img', array('src' => $logo,
+ 'class' => 'photo avatar entity_depiction',
+ 'width' => AVATAR_PROFILE_SIZE,
+ 'height' => AVATAR_PROFILE_SIZE,
+ 'alt' => $this->group->nickname));
+
+ $hasFN = ($this->group->fullname) ? 'entity_nickname nickname url uid' :
+ 'entity_nickname fn org nickname url uid';
+ $this->element('a', array('href' => $this->group->homeUrl(),
+ 'rel' => 'me', 'class' => $hasFN),
+ $this->group->nickname);
+
+ if ($this->group->fullname) {
+ $this->element('div', 'entity_fn fn org', $this->group->fullname);
+ }
- if ($this->group->location) {
- $this->elementStart('dl', 'entity_location');
- // TRANS: Label for group location (dt). Text hidden by default.
- $this->element('dt', null, _('Location'));
- $this->element('dd', 'label', $this->group->location);
- $this->elementEnd('dl');
- }
+ if ($this->group->location) {
+ $this->element('div', 'entity_location label', $this->group->location);
+ }
- if ($this->group->homepage) {
- $this->elementStart('dl', 'entity_url');
- // TRANS: Label for group URL (dt). Text hidden by default.
- $this->element('dt', null, _('URL'));
- $this->elementStart('dd');
- $this->element('a', array('href' => $this->group->homepage,
- 'rel' => 'me', 'class' => 'url'),
- $this->group->homepage);
- $this->elementEnd('dd');
- $this->elementEnd('dl');
+ if ($this->group->homepage) {
+ $this->element('a', array('href' => $this->group->homepage,
+ 'rel' => 'me',
+ 'class' => 'url entity_url'),
+ $this->group->homepage);
+ }
+
+ if ($this->group->description) {
+ $this->element('div', 'note entity_note', $this->group->description);
+ }
+
+ if (common_config('group', 'maxaliases') > 0) {
+ $aliases = $this->group->getAliases();
+
+ if (!empty($aliases)) {
+ $this->element('div',
+ 'aliases entity_aliases',
+ implode(' ', $aliases));
}
+
+ if ($this->group->description) {
+ $this->elementStart('dl', 'entity_note');
+ // TRANS: Label for group description or group note (dt). Text hidden by default.
+ $this->element('dt', null, _('Note'));
+ $this->element('dd', 'note', $this->group->description);
+ $this->elementEnd('dl');
+ }
+
+ if (common_config('group', 'maxaliases') > 0) {
+ $aliases = $this->group->getAliases();
+
+ if (!empty($aliases)) {
+ $this->elementStart('dl', 'entity_aliases');
+ // TRANS: Label for group aliases (dt). Text hidden by default.
+ $this->element('dt', null, _('Aliases'));
+ $this->element('dd', 'aliases', implode(' ', $aliases));
+ $this->elementEnd('dl');
+ }
+ }
+
+ Event::handle('EndGroupProfileElements', array($this, $this->group));
}
$this->elementEnd('div');
--- /dev/null
- $this->serverError(_('Couldn\'t update user.'));
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Miscellaneous settings
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Settings
+ * @package StatusNet
+ * @author Robin Millette <millette@status.net>
+ * @author Evan Prodromou <evan@status.net>
+ * @copyright 2008-2009 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET') && !defined('LACONICA')) {
+ exit(1);
+}
+
+
+
+/**
+ * Miscellaneous settings actions
+ *
+ * Currently this just manages URL shortening.
+ *
+ * @category Settings
+ * @package StatusNet
+ * @author Robin Millette <millette@status.net>
+ * @author Zach Copley <zach@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+class UrlsettingsAction extends SettingsAction
+{
+ /**
+ * Title of the page
+ *
+ * @return string Title of the page
+ */
+
+ function title()
+ {
+ return _('URL settings');
+ }
+
+ /**
+ * Instructions for use
+ *
+ * @return instructions for use
+ */
+
+ function getInstructions()
+ {
+ // TRANS: Instructions for tab "Other" in user profile settings.
+ return _('Manage various other options.');
+ }
+
+ function showScripts()
+ {
+ parent::showScripts();
+ $this->autofocus('urlshorteningservice');
+ }
+
+ /**
+ * Content area of the page
+ *
+ * Shows a form for uploading an avatar.
+ *
+ * @return void
+ */
+
+ function showContent()
+ {
+ $user = common_current_user();
+
+ $this->elementStart('form', array('method' => 'post',
+ 'id' => 'form_settings_other',
+ 'class' => 'form_settings',
+ 'action' =>
+ common_local_url('urlsettings')));
+ $this->elementStart('fieldset');
+ $this->hidden('token', common_session_token());
+ $this->elementStart('ul', 'form_data');
+
+ Event::handle('GetUrlShorteners', array(&$shorteners));
+
+ $services = array();
+
+ foreach ($shorteners as $name => $value)
+ {
+ $services[$name] = $name;
+ if ($value['freeService']) {
+ // TRANS: Used as a suffix for free URL shorteners in a dropdown list in the tab "Other" of a
+ // TRANS: user's profile settings. This message has one space at the beginning. Use your
+ // TRANS: language's word separator here if it has one (most likely a single space).
+ $services[$name] .= _(' (free service)');
+ }
+ }
+
+ // Include default values
+
+ $services['none'] = _('[none]');
+ $services['internal'] = _('[internal]');
+
+ if ($services) {
+
+ asort($services);
+
+ $this->elementStart('li');
+ // TRANS: Label for dropdown with URL shortener services.
+ $this->dropdown('urlshorteningservice', _('Shorten URLs with'),
+ // TRANS: Tooltip for for dropdown with URL shortener services.
+ $services, _('Automatic shortening service to use.'),
+ false, $user->urlshorteningservice);
+ $this->elementEnd('li');
+ }
+ $this->elementStart('li');
+ $this->input('maxurllength',
+ _('URL longer than'),
+ (!is_null($this->arg('maxurllength'))) ?
+ $this->arg('maxurllength') : User_urlshortener_prefs::maxUrlLength($user),
+ _('URLs longer than this will be shortened, 0 means always shorten.'));
+ $this->elementEnd('li');
+ $this->elementStart('li');
+ $this->input('maxnoticelength',
+ _('Text longer than'),
+ (!is_null($this->arg('maxnoticelength'))) ?
+ $this->arg('maxnoticelength') : User_urlshortener_prefs::maxNoticeLength($user),
+ _('URLs in notices longer than this will be shortened, 0 means always shorten.'));
+ $this->elementEnd('li');
+ $this->elementEnd('ul');
+ // TRANS: Button text for saving "Other settings" in profile.
+ $this->submit('save', _m('BUTTON','Save'));
+ $this->elementEnd('fieldset');
+ $this->elementEnd('form');
+ }
+
+ /**
+ * Handle a post
+ *
+ * Saves the changes to url-shortening prefs and shows a success or failure
+ * message.
+ *
+ * @return void
+ */
+
+ function handlePost()
+ {
+ // CSRF protection
+ $token = $this->trimmed('token');
+ if (!$token || $token != common_session_token()) {
+ $this->showForm(_('There was a problem with your session token. '.
+ 'Try again, please.'));
+ return;
+ }
+
+ $urlshorteningservice = $this->trimmed('urlshorteningservice');
+
+ if (!is_null($urlshorteningservice) && strlen($urlshorteningservice) > 50) {
+ // TRANS: Form validation error for form "Other settings" in user profile.
+ $this->showForm(_('URL shortening service is too long (maximum 50 characters).'));
+ return;
+ }
+
+ $maxurllength = $this->trimmed('maxurllength');
+
+ if (!Validate::number($maxurllength, array('min' => 0))) {
+ throw new ClientException(_('Invalid number for max url length.'));
+ }
+
+ $maxnoticelength = $this->trimmed('maxnoticelength');
+
+ if (!Validate::number($maxnoticelength, array('min' => 0))) {
+ throw new ClientException(_('Invalid number for max notice length.'));
+ }
+
+ $user = common_current_user();
+
+ assert(!is_null($user)); // should already be checked
+
+ $user->query('BEGIN');
+
+ $original = clone($user);
+
+ $user->urlshorteningservice = $urlshorteningservice;
+
+ $result = $user->update($original);
+
+ if ($result === false) {
+ common_log_db_error($user, 'UPDATE', __FILE__);
+ // TRANS: Server error displayed when "Other" settings in user profile could not be updated on the server.
++ $this->serverError(_('Could not update user.'));
+ return;
+ }
+
+ $prefs = User_urlshortener_prefs::getPrefs($user);
+ $orig = null;
+
+ if (empty($prefs)) {
+ $prefs = new User_urlshortener_prefs();
+
+ $prefs->user_id = $user->id;
+ $prefs->created = common_sql_now();
+ } else {
+ $orig = clone($prefs);
+ }
+
+ $prefs->urlshorteningservice = $urlshorteningservice;
+ $prefs->maxurllength = $maxurllength;
+ $prefs->maxnoticelength = $maxnoticelength;
+
+ if (!empty($orig)) {
+ $result = $prefs->update($orig);
+ } else {
+ $result = $prefs->insert();
+ }
+
+ if (!$result) {
+ throw new ServerException(_('Error saving user URL shortening preferences.'));
+ }
+
+ $user->query('COMMIT');
+
++ // TRANS: Confirmation message after saving preferences.
+ $this->showForm(_('Preferences saved.'), true);
+ }
+}
*
* @return void
*/
-
function saveDesign()
{
+ $this->saveDesignPreferences();
+
foreach ($this->args as $key => $val) {
if (preg_match('/(#ho|ho)Td.*g/i', $val)) {
$this->sethd();
}
$start = microtime(true);
+ $fail = false;
$result = null;
if (Event::handle('StartDBQuery', array($this, $string, &$result))) {
- $result = parent::_query($string);
+ common_perf_counter('query', $string);
+ try {
+ $result = parent::_query($string);
+ } catch (Exception $e) {
+ $fail = $e;
+ }
Event::handle('EndDBQuery', array($this, $string, &$result));
}
$delta = microtime(true) - $start;
'OStatus' => null,
'WikiHashtags' => null,
'RSSCloud' => null,
+ 'ClientSideShorten' => null,
+ 'StrictTransportSecurity' => null,
'OpenID' => null),
'locale_path' => false, // Set to a path to use *instead of* each plugin's own locale subdirectories
+ 'server' => null,
+ 'sslserver' => null,
+ 'path' => null,
+ 'sslpath' => null,
),
+ 'pluginlist' => array(),
'admin' =>
- array('panels' => array('design', 'site', 'user', 'paths', 'access', 'sessions', 'sitenotice', 'license')),
+ array('panels' => array('design', 'site', 'user', 'paths', 'access', 'sessions', 'sitenotice', 'license', 'plugins')),
'singleuser' =>
array('enabled' => false,
'nickname' => null),
// statuses API
+ $m->connect('api',
+ array('action' => 'Redirect',
+ 'nextAction' => 'doc',
+ 'args' => array('title' => 'api')));
+
$m->connect('api/statuses/public_timeline.:format',
array('action' => 'ApiTimelinePublic',
- 'format' => '(xml|json|rss|atom)'));
+ 'format' => '(xml|json|rss|atom|as)'));
$m->connect('api/statuses/friends_timeline.:format',
array('action' => 'ApiTimelineFriends',
$tags = Profile_tag::getTags($this->profile->id, $this->profile->id);
if (count($tags) > 0) {
++<<<<<<< HEAD
+ $this->out->elementStart('ul', 'tags xoxo entity_tags');
++=======
+ $this->out->elementStart('dl', 'entity_tags');
+ // TRANS: DT for tags in a profile.
+ $this->out->element('dt', null, _('Tags'));
+ $this->out->elementStart('dd');
+ $this->out->elementStart('ul', 'tags xoxo');
++>>>>>>> 0.9.x
foreach ($tags as $tag) {
$this->out->elementStart('li');
// Avoid space by using raw output.
function onRouterInitialized($m)
{
// Always add the admin panel route
- $m->connect('admin/facebook', array('action' => 'facebookadminpanel'));
+ $m->connect('panel/facebook', array('action' => 'facebookadminpanel'));
- // Only add these routes if an application has been setup on
- // Facebook for the plugin to use.
- if ($this->hasApplication()) {
-
- $m->connect(
- 'main/facebooklogin',
- array('action' => 'facebooklogin')
- );
- $m->connect(
- 'main/facebookfinishlogin',
- array('action' => 'facebookfinishlogin')
- );
- $m->connect(
- 'settings/facebook',
- array('action' => 'facebooksettings')
- );
- $m->connect(
- 'facebook/deauthorize',
- array('action' => 'facebookdeauthorize')
- );
-
- }
+ $m->connect(
+ 'main/facebooklogin',
+ array('action' => 'facebooklogin')
+ );
+ $m->connect(
+ 'main/facebookfinishlogin',
+ array('action' => 'facebookfinishlogin')
+ );
+ $m->connect(
+ 'settings/facebook',
+ array('action' => 'facebooksettings')
+ );
+ $m->connect(
+ 'facebook/deauthorize',
+ array('action' => 'facebookdeauthorize')
+ );
return true;
}