We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 963e7576 authored by Brion Vibber's avatar Brion Vibber

Merge branch 'testing' into moveaccount

parents 2a59453d 1d24ece3
...@@ -458,6 +458,9 @@ class ProfilesettingsAction extends AccountSettingsAction ...@@ -458,6 +458,9 @@ class ProfilesettingsAction extends AccountSettingsAction
$this->elementStart('div', array('id' => 'aside_primary', $this->elementStart('div', array('id' => 'aside_primary',
'class' => 'aside')); 'class' => 'aside'));
$this->elementStart('div', array('id' => 'account_actions',
'class' => 'section'));
$this->elementStart('ul'); $this->elementStart('ul');
if (Event::handle('StartProfileSettingsActions', array($this))) { if (Event::handle('StartProfileSettingsActions', array($this))) {
if ($user->hasRight(Right::BACKUPACCOUNT)) { if ($user->hasRight(Right::BACKUPACCOUNT)) {
...@@ -485,5 +488,6 @@ class ProfilesettingsAction extends AccountSettingsAction ...@@ -485,5 +488,6 @@ class ProfilesettingsAction extends AccountSettingsAction
} }
$this->elementEnd('ul'); $this->elementEnd('ul');
$this->elementEnd('div'); $this->elementEnd('div');
$this->elementEnd('div');
} }
} }
...@@ -77,4 +77,5 @@ VALUES ...@@ -77,4 +77,5 @@ VALUES
('twitvim','TwitVim','http://vim.sourceforge.net/scripts/script.php?script_id=2204', now()), ('twitvim','TwitVim','http://vim.sourceforge.net/scripts/script.php?script_id=2204', now()),
('Updating.Me','Updating.Me','http://updating.me/', now()), ('Updating.Me','Updating.Me','http://updating.me/', now()),
('urfastr','urfastr','http://urfastr.net/', now()), ('urfastr','urfastr','http://urfastr.net/', now()),
('yatca','Yatca','http://www.yatca.com/', now()); ('yatca','Yatca','http://www.yatca.com/', now()),
('rss.me', 'rss.me', 'http://rss.me/', now());
...@@ -96,7 +96,7 @@ class AccountSettingsNav extends Widget ...@@ -96,7 +96,7 @@ class AccountSettingsNav extends Widget
$action_name = $this->action->trimmed('action'); $action_name = $this->action->trimmed('action');
$this->action->elementStart('ul', array('class' => 'nav')); $this->action->elementStart('ul', array('class' => 'nav'));
if (Event::handle('StartAccountSettingsNav', array(&$this->action))) { if (Event::handle('StartAccountSettingsNav', array($this->action))) {
$user = common_current_user(); $user = common_current_user();
if(Event::handle('StartAccountSettingsProfileMenuItem', array($this, &$menu))){ if(Event::handle('StartAccountSettingsProfileMenuItem', array($this, &$menu))){
...@@ -142,7 +142,7 @@ class AccountSettingsNav extends Widget ...@@ -142,7 +142,7 @@ class AccountSettingsNav extends Widget
Event::handle('EndAccountSettingsOtherMenuItem', array($this, &$menu)); Event::handle('EndAccountSettingsOtherMenuItem', array($this, &$menu));
} }
Event::handle('EndAccountSettingsNav', array(&$this->action)); Event::handle('EndAccountSettingsNav', array($this->action));
} }
$this->action->elementEnd('ul'); $this->action->elementEnd('ul');
......
...@@ -96,7 +96,7 @@ class ConnectSettingsNav extends Widget ...@@ -96,7 +96,7 @@ class ConnectSettingsNav extends Widget
$action_name = $this->action->trimmed('action'); $action_name = $this->action->trimmed('action');
$this->action->elementStart('ul', array('class' => 'nav')); $this->action->elementStart('ul', array('class' => 'nav'));
if (Event::handle('StartConnectSettingsNav', array(&$this->action))) { if (Event::handle('StartConnectSettingsNav', array($this->action))) {
# action => array('prompt', 'title') # action => array('prompt', 'title')
$menu = array(); $menu = array();
...@@ -129,7 +129,7 @@ class ConnectSettingsNav extends Widget ...@@ -129,7 +129,7 @@ class ConnectSettingsNav extends Widget
$action_name === $menuaction); $action_name === $menuaction);
} }
Event::handle('EndConnectSettingsNav', array(&$this->action)); Event::handle('EndConnectSettingsNav', array($this->action));
} }
$this->action->elementEnd('ul'); $this->action->elementEnd('ul');
......
...@@ -73,7 +73,7 @@ class LoginGroupNav extends Widget ...@@ -73,7 +73,7 @@ class LoginGroupNav extends Widget
$this->action->elementStart('ul', array('class' => 'nav')); $this->action->elementStart('ul', array('class' => 'nav'));
if (Event::handle('StartLoginGroupNav', array(&$this->action))) { if (Event::handle('StartLoginGroupNav', array($this->action))) {
$this->action->menuItem(common_local_url('login'), $this->action->menuItem(common_local_url('login'),
_('Login'), _('Login'),
...@@ -87,7 +87,7 @@ class LoginGroupNav extends Widget ...@@ -87,7 +87,7 @@ class LoginGroupNav extends Widget
$action_name === 'register'); $action_name === 'register');
} }
Event::handle('EndLoginGroupNav', array(&$this->action)); Event::handle('EndLoginGroupNav', array($this->action));
} }
$this->action->elementEnd('ul'); $this->action->elementEnd('ul');
......
...@@ -99,6 +99,21 @@ class ProfileAction extends OwnerDesignAction ...@@ -99,6 +99,21 @@ class ProfileAction extends OwnerDesignAction
$this->showStatistics(); $this->showStatistics();
} }
/**
* Convenience function for common pattern of links to subscription/groups sections.
*
* @param string $actionClass
* @param string $title
* @param string $cssClass
*/
private function statsSectionLink($actionClass, $title, $cssClass='')
{
$this->element('a', array('href' => common_local_url($actionClass,
array('nickname' => $this->profile->nickname)),
'class' => $cssClass),
$title);
}
function showSubscriptions() function showSubscriptions()
{ {
$profile = $this->profile->getSubscriptions(0, PROFILES_PER_MINILIST + 1); $profile = $this->profile->getSubscriptions(0, PROFILES_PER_MINILIST + 1);
...@@ -106,7 +121,9 @@ class ProfileAction extends OwnerDesignAction ...@@ -106,7 +121,9 @@ class ProfileAction extends OwnerDesignAction
$this->elementStart('div', array('id' => 'entity_subscriptions', $this->elementStart('div', array('id' => 'entity_subscriptions',
'class' => 'section')); 'class' => 'section'));
if (Event::handle('StartShowSubscriptionsMiniList', array($this))) { if (Event::handle('StartShowSubscriptionsMiniList', array($this))) {
$this->element('h2', null, _('Subscriptions')); $this->elementStart('h2');
$this->statsSectionLink('subscriptions', _('Subscriptions'));
$this->elementEnd('h2');
$cnt = 0; $cnt = 0;
...@@ -120,10 +137,7 @@ class ProfileAction extends OwnerDesignAction ...@@ -120,10 +137,7 @@ class ProfileAction extends OwnerDesignAction
if ($cnt > PROFILES_PER_MINILIST) { if ($cnt > PROFILES_PER_MINILIST) {
$this->elementStart('p'); $this->elementStart('p');
$this->element('a', array('href' => common_local_url('subscriptions', $this->statsSectionLink('subscriptions', _('All subscriptions'), 'more');
array('nickname' => $this->profile->nickname)),
'class' => 'more'),
_('All subscriptions'));
$this->elementEnd('p'); $this->elementEnd('p');
} }
...@@ -141,7 +155,9 @@ class ProfileAction extends OwnerDesignAction ...@@ -141,7 +155,9 @@ class ProfileAction extends OwnerDesignAction
if (Event::handle('StartShowSubscribersMiniList', array($this))) { if (Event::handle('StartShowSubscribersMiniList', array($this))) {
$this->element('h2', null, _('Subscribers')); $this->elementStart('h2');
$this->statsSectionLink('subscribers', _('Subscribers'));
$this->elementEnd('h2');
$cnt = 0; $cnt = 0;
...@@ -155,10 +171,7 @@ class ProfileAction extends OwnerDesignAction ...@@ -155,10 +171,7 @@ class ProfileAction extends OwnerDesignAction
if ($cnt > PROFILES_PER_MINILIST) { if ($cnt > PROFILES_PER_MINILIST) {
$this->elementStart('p'); $this->elementStart('p');
$this->element('a', array('href' => common_local_url('subscribers', $this->statsSectionLink('subscribers', _('All subscribers'), 'more');
array('nickname' => $this->profile->nickname)),
'class' => 'more'),
_('All subscribers'));
$this->elementEnd('p'); $this->elementEnd('p');
} }
...@@ -170,10 +183,7 @@ class ProfileAction extends OwnerDesignAction ...@@ -170,10 +183,7 @@ class ProfileAction extends OwnerDesignAction
function showStatistics() function showStatistics()
{ {
$subs_count = $this->profile->subscriptionCount();
$subbed_count = $this->profile->subscriberCount();
$notice_count = $this->profile->noticeCount(); $notice_count = $this->profile->noticeCount();
$group_count = $this->profile->getGroups()->N;
$age_days = (time() - strtotime($this->profile->created)) / 86400; $age_days = (time() - strtotime($this->profile->created)) / 86400;
if ($age_days < 1) { if ($age_days < 1) {
// Rather than extrapolating out to a bajillion... // Rather than extrapolating out to a bajillion...
...@@ -186,57 +196,71 @@ class ProfileAction extends OwnerDesignAction ...@@ -186,57 +196,71 @@ class ProfileAction extends OwnerDesignAction
$this->element('h2', null, _('Statistics')); $this->element('h2', null, _('Statistics'));
// Other stats...? $profile = $this->profile;
$this->elementStart('dl', 'entity_user-id'); $actionParams = array('nickname' => $profile->nickname);
$this->element('dt', null, _('User ID')); $stats = array(
$this->element('dd', null, $this->profile->id); array(
$this->elementEnd('dl'); 'id' => 'user-id',
'label' => _('User ID'),
$this->elementStart('dl', 'entity_member-since'); 'value' => $profile->id,
$this->element('dt', null, _('Member since')); ),
$this->element('dd', null, date('j M Y', array(
strtotime($this->profile->created))); 'id' => 'member-since',
$this->elementEnd('dl'); 'label' => _('Member since'),
'value' => date('j M Y', strtotime($profile->created))
$this->elementStart('dl', 'entity_subscriptions'); ),
$this->elementStart('dt'); array(
$this->element('a', array('href' => common_local_url('subscriptions', 'id' => 'subscriptions',
array('nickname' => $this->profile->nickname))), 'label' => _('Subscriptions'),
_('Subscriptions')); 'link' => common_local_url('subscriptions', $actionParams),
$this->elementEnd('dt'); 'value' => $profile->subscriptionCount(),
$this->element('dd', null, $subs_count); ),
$this->elementEnd('dl'); array(
'id' => 'subscribers',
$this->elementStart('dl', 'entity_subscribers'); 'label' => _('Subscribers'),
$this->elementStart('dt'); 'link' => common_local_url('subscribers', $actionParams),
$this->element('a', array('href' => common_local_url('subscribers', 'value' => $profile->subscriberCount(),
array('nickname' => $this->profile->nickname))), ),
_('Subscribers')); array(
$this->elementEnd('dt'); 'id' => 'groups',
$this->element('dd', 'subscribers', $subbed_count); 'label' => _('Groups'),
$this->elementEnd('dl'); 'link' => common_local_url('usergroups', $actionParams),
'value' => $profile->getGroups()->N,
),
array(
'id' => 'notices',
'label' => _('Notices'),
'value' => $notice_count,
),
array(
'id' => 'daily_notices',
// TRANS: Average count of posts made per day since account registration
'label' => _('Daily average'),
'value' => $daily_count
)
);
// Give plugins a chance to add stats entries
Event::handle('ProfileStats', array($profile, &$stats));
foreach ($stats as $row) {
$this->showStatsRow($row);
}
$this->elementEnd('div');
}
$this->elementStart('dl', 'entity_groups'); private function showStatsRow($row)
{
$this->elementStart('dl', 'entity_' . $row['id']);
$this->elementStart('dt'); $this->elementStart('dt');
$this->element('a', array('href' => common_local_url('usergroups', if (!empty($row['link'])) {
array('nickname' => $this->profile->nickname))), $this->element('a', array('href' => $row['link']), $row['label']);
_('Groups')); } else {
$this->text($row['label']);
}
$this->elementEnd('dt'); $this->elementEnd('dt');
$this->element('dd', 'groups', $group_count); $this->element('dd', null, $row['value']);
$this->elementEnd('dl'); $this->elementEnd('dl');
$this->elementStart('dl', 'entity_notices');
$this->element('dt', null, _('Notices'));
$this->element('dd', null, $notice_count);
$this->elementEnd('dl');
$this->elementStart('dl', 'entity_daily_notices');
// TRANS: Average count of posts made per day since account registration
$this->element('dt', null, _('Daily average'));
$this->element('dd', null, $daily_count);
$this->elementEnd('dl');
$this->elementEnd('div');
} }
function showGroups() function showGroups()
...@@ -246,7 +270,9 @@ class ProfileAction extends OwnerDesignAction ...@@ -246,7 +270,9 @@ class ProfileAction extends OwnerDesignAction
$this->elementStart('div', array('id' => 'entity_groups', $this->elementStart('div', array('id' => 'entity_groups',
'class' => 'section')); 'class' => 'section'));
if (Event::handle('StartShowGroupsMiniList', array($this))) { if (Event::handle('StartShowGroupsMiniList', array($this))) {
$this->element('h2', null, _('Groups')); $this->elementStart('h2');
$this->statsSectionLink('usergroups', _('Groups'));
$this->elementEnd('h2');
if ($groups) { if ($groups) {
$gml = new GroupMiniList($groups, $this->profile, $this); $gml = new GroupMiniList($groups, $this->profile, $this);
...@@ -258,10 +284,7 @@ class ProfileAction extends OwnerDesignAction ...@@ -258,10 +284,7 @@ class ProfileAction extends OwnerDesignAction
if ($cnt > GROUPS_PER_MINILIST) { if ($cnt > GROUPS_PER_MINILIST) {
$this->elementStart('p'); $this->elementStart('p');
$this->element('a', array('href' => common_local_url('usergroups', $this->statsSectionLink('usergroups', _('All groups'), 'more');
array('nickname' => $this->profile->nickname)),
'class' => 'more'),
_('All groups'));
$this->elementEnd('p'); $this->elementEnd('p');
} }
......
...@@ -242,7 +242,7 @@ class UserProfile extends Widget ...@@ -242,7 +242,7 @@ class UserProfile extends Widget
$this->out->elementEnd('div'); $this->out->elementEnd('div');
return; return;
} }
if (Event::handle('StartProfilePageActionsSection', array(&$this->out, $this->profile))) { if (Event::handle('StartProfilePageActionsSection', array($this->out, $this->profile))) {
$cur = common_current_user(); $cur = common_current_user();
...@@ -250,13 +250,13 @@ class UserProfile extends Widget ...@@ -250,13 +250,13 @@ class UserProfile extends Widget
$this->out->element('h2', null, _('User actions')); $this->out->element('h2', null, _('User actions'));
$this->out->elementStart('ul'); $this->out->elementStart('ul');
if (Event::handle('StartProfilePageActionsElements', array(&$this->out, $this->profile))) { if (Event::handle('StartProfilePageActionsElements', array($this->out, $this->profile))) {
if (empty($cur)) { // not logged in if (empty($cur)) { // not logged in
if (Event::handle('StartProfileRemoteSubscribe', array(&$this->out, $this->profile))) { if (Event::handle('StartProfileRemoteSubscribe', array($this->out, $this->profile))) {
$this->out->elementStart('li', 'entity_subscribe'); $this->out->elementStart('li', 'entity_subscribe');
$this->showRemoteSubscribeLink(); $this->showRemoteSubscribeLink();
$this->out->elementEnd('li'); $this->out->elementEnd('li');
Event::handle('EndProfileRemoteSubscribe', array(&$this->out, $this->profile)); Event::handle('EndProfileRemoteSubscribe', array($this->out, $this->profile));
} }
} else { } else {
if ($cur->id == $this->profile->id) { // your own page if ($cur->id == $this->profile->id) { // your own page
...@@ -376,13 +376,13 @@ class UserProfile extends Widget ...@@ -376,13 +376,13 @@ class UserProfile extends Widget
} }
} }
Event::handle('EndProfilePageActionsElements', array(&$this->out, $this->profile)); Event::handle('EndProfilePageActionsElements', array($this->out, $this->profile));
} }
$this->out->elementEnd('ul'); $this->out->elementEnd('ul');
$this->out->elementEnd('div'); $this->out->elementEnd('div');
Event::handle('EndProfilePageActionsSection', array(&$this->out, $this->profile)); Event::handle('EndProfilePageActionsSection', array($this->out, $this->profile));
} }
} }
......
...@@ -74,7 +74,7 @@ class CasAuthenticationPlugin extends AuthenticationPlugin ...@@ -74,7 +74,7 @@ class CasAuthenticationPlugin extends AuthenticationPlugin
return true; return true;
} }
function onEndLoginGroupNav(&$action) function onEndLoginGroupNav($action)
{ {
$action_name = $action->trimmed('action'); $action_name = $action->trimmed('action');
......
...@@ -446,11 +446,11 @@ class FacebookPlugin extends Plugin ...@@ -446,11 +446,11 @@ class FacebookPlugin extends Plugin
/* /*
* Add a login tab for Facebook Connect * Add a login tab for Facebook Connect
* *
* @param Action &action the current action * @param Action $action the current action
* *
* @return void * @return void
*/ */
function onEndLoginGroupNav(&$action) function onEndLoginGroupNav($action)
{ {
if (self::hasKeys()) { if (self::hasKeys()) {
$action_name = $action->trimmed('action'); $action_name = $action->trimmed('action');
...@@ -470,11 +470,11 @@ class FacebookPlugin extends Plugin ...@@ -470,11 +470,11 @@ class FacebookPlugin extends Plugin
/* /*
* Add a tab for managing Facebook Connect settings * Add a tab for managing Facebook Connect settings
* *
* @param Action &action the current action * @param Action $action the current action
* *
* @return void * @return void
*/ */
function onEndConnectSettingsNav(&$action) function onEndConnectSettingsNav($action)
{ {
if (self::hasKeys()) { if (self::hasKeys()) {
$action_name = $action->trimmed('action'); $action_name = $action->trimmed('action');
......
...@@ -186,11 +186,11 @@ class FacebookBridgePlugin extends Plugin ...@@ -186,11 +186,11 @@ class FacebookBridgePlugin extends Plugin
* Add a login tab for Facebook, but only if there's a Facebook * Add a login tab for Facebook, but only if there's a Facebook
* application defined for the plugin to use. * application defined for the plugin to use.
* *
* @param Action &action the current action * @param Action $action the current action
* *
* @return void * @return void
*/ */
function onEndLoginGroupNav(&$action) function onEndLoginGroupNav($action)
{ {
$action_name = $action->trimmed('action'); $action_name = $action->trimmed('action');
...@@ -252,11 +252,11 @@ class FacebookBridgePlugin extends Plugin ...@@ -252,11 +252,11 @@ class FacebookBridgePlugin extends Plugin
* Add a tab for user-level Facebook settings if the user * Add a tab for user-level Facebook settings if the user
* has a link to Facebook * has a link to Facebook
* *
* @param Action &action the current action * @param Action $action the current action
* *
* @return void * @return void
*/ */
function onEndConnectSettingsNav(&$action) function onEndConnectSettingsNav($action)
{ {
if ($this->hasApplication()) { if ($this->hasApplication()) {
$action_name = $action->trimmed('action'); $action_name = $action->trimmed('action');
......
...@@ -279,19 +279,19 @@ class NewMenuPlugin extends Plugin ...@@ -279,19 +279,19 @@ class NewMenuPlugin extends Plugin
return true; return true;
} }
function onStartAccountSettingsNav(&$action) function onStartAccountSettingsNav($action)
{ {
$this->_settingsMenu($action); $this->_settingsMenu($action);
return false; return false;
} }
function onStartConnectSettingsNav(&$action) function onStartConnectSettingsNav($action)
{ {
$this->_settingsMenu($action); $this->_settingsMenu($action);
return false; return false;
} }
private function _settingsMenu(&$action) private function _settingsMenu($action)
{ {
$actionName = $action->trimmed('action'); $actionName = $action->trimmed('action');
...@@ -325,7 +325,7 @@ class NewMenuPlugin extends Plugin ...@@ -325,7 +325,7 @@ class NewMenuPlugin extends Plugin
_('Other options'), _('Other options'),
$actionName == 'othersettings'); $actionName == 'othersettings');
Event::handle('EndAccountSettingsNav', array(&$action)); Event::handle('EndAccountSettingsNav', array($action));
if (common_config('xmpp', 'enabled')) { if (common_config('xmpp', 'enabled')) {
$action->menuItem(common_local_url('imsettings'), $action->menuItem(common_local_url('imsettings'),
...@@ -346,7 +346,7 @@ class NewMenuPlugin extends Plugin ...@@ -346,7 +346,7 @@ class NewMenuPlugin extends Plugin
_('Authorized connected applications'), _('Authorized connected applications'),
$actionName == 'oauthconnectionsettings'); $actionName == 'oauthconnectionsettings');
Event::handle('EndConnectSettingsNav', array(&$action)); Event::handle('EndConnectSettingsNav', array($action));
} }
function onEndShowStyles($action) function onEndShowStyles($action)
......
...@@ -248,11 +248,11 @@ class OpenIDPlugin extends Plugin ...@@ -248,11 +248,11 @@ class OpenIDPlugin extends Plugin
* *
* If we're in openidOnly mode, we disable the menu for all other login. * If we're in openidOnly mode, we disable the menu for all other login.
* *
* @param Action &$action Action being executed * @param Action $action Action being executed
* *
* @return boolean hook return * @return boolean hook return
*/ */
function onStartLoginGroupNav(&$action) function onStartLoginGroupNav($action)
{ {
if (common_config('site', 'openidonly')) { if (common_config('site', 'openidonly')) {
$this->showOpenIDLoginTab($action); $this->showOpenIDLoginTab($action);
...@@ -268,11 +268,11 @@ class OpenIDPlugin extends Plugin ...@@ -268,11 +268,11 @@ class OpenIDPlugin extends Plugin
/** /**
* Menu item for login * Menu item for login
* *
* @param Action &$action Action being executed * @param Action $action Action being executed
* *
* @return boolean hook return * @return boolean hook return