From: Zach Copley Date: Mon, 28 Feb 2011 23:39:43 +0000 (-0800) Subject: Merge branch '0.9.x' into 1.0.x X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b7d07466943a73e1c009467c8daa6e499810080f;p=quix0rs-gnu-social.git Merge branch '0.9.x' into 1.0.x Conflicts: actions/confirmaddress.php actions/emailsettings.php actions/hostmeta.php actions/imsettings.php actions/login.php actions/profilesettings.php actions/showgroup.php actions/smssettings.php actions/urlsettings.php actions/userauthorization.php actions/userdesignsettings.php classes/Memcached_DataObject.php index.php lib/accountsettingsaction.php lib/action.php lib/common.php lib/connectsettingsaction.php lib/designsettings.php lib/personalgroupnav.php lib/profileaction.php lib/userprofile.php plugins/ClientSideShorten/ClientSideShortenPlugin.php plugins/Facebook/FBConnectSettings.php plugins/Facebook/FacebookPlugin.php plugins/NewMenu/NewMenuPlugin.php plugins/NewMenu/newmenu.css --- b7d07466943a73e1c009467c8daa6e499810080f diff --cc actions/imsettings.php index 76fb2285c3,eb3f0cfd15..4680b3292b --- a/actions/imsettings.php +++ b/actions/imsettings.php @@@ -82,14 -82,11 +80,13 @@@ class ImsettingsAction extends Settings * * @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; } @@@ -210,8 -190,7 +207,12 @@@ * * @return Confirm_address address object for this user */ ++<<<<<<< HEAD + + function getConfirmation($transport) ++======= + function getConfirmation() ++>>>>>>> 0.9.x { $user = common_current_user(); @@@ -270,37 -248,38 +270,36 @@@ * * @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); } @@@ -386,16 -366,14 +384,15 @@@ * * @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; } diff --cc actions/showgroup.php index a895f81b84,2806944452..21256294f3 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@@ -216,48 -217,89 +217,70 @@@ class ShowgroupAction extends GroupDesi $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'); diff --cc actions/urlsettings.php index 140e28c999,0000000000..807f9492c7 mode 100644,000000..100644 --- a/actions/urlsettings.php +++ b/actions/urlsettings.php @@@ -1,243 -1,0 +1,244 @@@ +. + * + * @category Settings + * @package StatusNet + * @author Robin Millette + * @author Evan Prodromou + * @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 + * @author Zach Copley + * @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(_('Couldn\'t update user.')); ++ $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); + } +} diff --cc actions/userdesignsettings.php index e6caea3a1b,b82dea8dd6..8ce5e1f8f3 --- a/actions/userdesignsettings.php +++ b/actions/userdesignsettings.php @@@ -139,11 -120,8 +134,10 @@@ class UserDesignSettingsAction extends * * @return void */ - function saveDesign() { + $this->saveDesignPreferences(); + foreach ($this->args as $key => $val) { if (preg_match('/(#ho|ho)Td.*g/i', $val)) { $this->sethd(); diff --cc classes/Memcached_DataObject.php index b92b67e775,867b40cf3c..97f793f4d8 --- a/classes/Memcached_DataObject.php +++ b/classes/Memcached_DataObject.php @@@ -338,14 -338,10 +338,15 @@@ class Memcached_DataObject extends Safe } $start = microtime(true); + $fail = false; $result = null; if (Event::handle('StartDBQuery', array($this, $string, &$result))) { + common_perf_counter('query', $string); - $result = parent::_query($string); + try { + $result = parent::_query($string); + } catch (Exception $e) { + $fail = $e; + } Event::handle('EndDBQuery', array($this, $string, &$result)); } $delta = microtime(true) - $start; diff --cc lib/default.php index 186ac263c9,124c90c998..6090217d18 --- a/lib/default.php +++ b/lib/default.php @@@ -300,14 -312,15 +303,18 @@@ $default '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), diff --cc lib/router.php index 10e5291588,e956b02c63..ccc4b09781 --- a/lib/router.php +++ b/lib/router.php @@@ -405,14 -407,9 +407,14 @@@ class Route // 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', diff --cc lib/userprofile.php index 71b54682af,8bd68ae3d7..444bb08121 --- a/lib/userprofile.php +++ b/lib/userprofile.php @@@ -192,7 -215,11 +192,15 @@@ class UserProfile extends Widge $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. diff --cc plugins/FacebookBridge/FacebookBridgePlugin.php index c6ff9bf74d,37b931e23e..9c2a406090 --- a/plugins/FacebookBridge/FacebookBridgePlugin.php +++ b/plugins/FacebookBridge/FacebookBridgePlugin.php @@@ -154,30 -177,24 +177,24 @@@ class FacebookBridgePlugin extends Plug 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; }