summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-09-22 10:45:34 -0400
committerEvan Prodromou <evan@status.net>2010-09-22 10:45:34 -0400
commitb5cfcba4712809cb17eabba299ce5ff04f4d7d70 (patch)
tree38235bafd6ddf194e484b97321c0c341bea9de38 /lib
parent91a186251047127ad7f1238f47ff761d9127627c (diff)
parentf0105893b0b78ff88d08cc2417773ad8a44dc2fa (diff)
Merge branch '0.9.x' into activityexport
Conflicts: plugins/OStatus/OStatusPlugin.php
Diffstat (limited to 'lib')
-rw-r--r--lib/action.php23
-rw-r--r--lib/activityobject.php11
-rw-r--r--lib/adminpanelaction.php8
-rw-r--r--lib/applicationeditform.php15
-rw-r--r--lib/command.php2
-rw-r--r--lib/dbqueuemanager.php2
-rw-r--r--lib/default.php2
-rw-r--r--lib/feedlist.php2
-rw-r--r--lib/router.php2
-rw-r--r--lib/util.php42
10 files changed, 85 insertions, 24 deletions
diff --git a/lib/action.php b/lib/action.php
index 5c4b4a7b7..5482ac377 100644
--- a/lib/action.php
+++ b/lib/action.php
@@ -715,14 +715,14 @@ class Action extends HTMLOutputter // lawsuit
{
$this->elementStart('div', array('id' => 'aside_primary',
'class' => 'aside'));
- if (Event::handle('StartShowExportData', array($this))) {
- $this->showExportData();
- Event::handle('EndShowExportData', array($this));
- }
if (Event::handle('StartShowSections', array($this))) {
$this->showSections();
Event::handle('EndShowSections', array($this));
}
+ if (Event::handle('StartShowExportData', array($this))) {
+ $this->showExportData();
+ Event::handle('EndShowExportData', array($this));
+ }
$this->elementEnd('div');
}
@@ -1018,17 +1018,22 @@ class Action extends HTMLOutputter // lawsuit
}
}
+ $checked = false;
if ($etag) {
$if_none_match = (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)) ?
$_SERVER['HTTP_IF_NONE_MATCH'] : null;
- if ($if_none_match && $this->_hasEtag($etag, $if_none_match)) {
- header('HTTP/1.1 304 Not Modified');
- // Better way to do this?
- exit(0);
+ if ($if_none_match) {
+ // If this check fails, ignore the if-modified-since below.
+ $checked = true;
+ if ($this->_hasEtag($etag, $if_none_match)) {
+ header('HTTP/1.1 304 Not Modified');
+ // Better way to do this?
+ exit(0);
+ }
}
}
- if ($lm && array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
+ if (!$checked && $lm && array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
$if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
$ims = strtotime($if_modified_since);
if ($lm <= $ims) {
diff --git a/lib/activityobject.php b/lib/activityobject.php
index 0fc06948b..95615d581 100644
--- a/lib/activityobject.php
+++ b/lib/activityobject.php
@@ -428,6 +428,17 @@ class ActivityObject
$alink->height = $size;
$alink->width = $size;
$alink->url = Avatar::defaultImage($size);
+
+ if ($size == AVATAR_PROFILE_SIZE) {
+ // Hack for Twitter import: we don't have a 96x96 image,
+ // but we do have a 73x73 image. For now, fake it with that.
+ $avatar = $profile->getAvatar(73);
+ if ($avatar) {
+ $alink = AvatarLink::fromAvatar($avatar);
+ $alink->height= $size;
+ $alink->width = $size;
+ }
+ }
}
$object->avatarLinks[] = $alink;
diff --git a/lib/adminpanelaction.php b/lib/adminpanelaction.php
index 5c414bbd7..fae9f4fa5 100644
--- a/lib/adminpanelaction.php
+++ b/lib/adminpanelaction.php
@@ -396,6 +396,14 @@ class AdminPanelNav extends Widget
$menu_title, $action_name == 'snapshotadminpanel', 'nav_snapshot_admin_panel');
}
+ if (AdminPanelAction::canAdmin('license')) {
+ // TRANS: Menu item title/tooltip
+ $menu_title = _('Set site license');
+ // TRANS: Menu item for site administration
+ $this->out->menuItem(common_local_url('licenseadminpanel'), _('License'),
+ $menu_title, $action_name == 'licenseadminpanel', 'nav_license_admin_panel');
+ }
+
Event::handle('EndAdminPanelNav', array($this));
}
$this->action->elementEnd('ul');
diff --git a/lib/applicationeditform.php b/lib/applicationeditform.php
index f126b84ae..224b6eaa1 100644
--- a/lib/applicationeditform.php
+++ b/lib/applicationeditform.php
@@ -256,8 +256,9 @@ class ApplicationEditForm extends Form
// Default to Browser
- if ($this->application->type == Oauth_application::$browser
- || empty($this->application->type)) {
+ if (empty($this->application)
+ || empty($this->application->type)
+ || $this->application->type == Oauth_application::$browser) {
$attrs['checked'] = 'checked';
}
@@ -274,7 +275,7 @@ class ApplicationEditForm extends Form
'class' => 'radio',
'value' => Oauth_application::$desktop);
- if ($this->application->type == Oauth_application::$desktop) {
+ if (!empty($this->application) && $this->application->type == Oauth_application::$desktop) {
$attrs['checked'] = 'checked';
}
@@ -298,8 +299,9 @@ class ApplicationEditForm extends Form
// default to read-only access
- if ($this->application->access_type & Oauth_application::$readAccess
- || empty($this->application->access_type)) {
+ if (empty($this->application)
+ || empty($this->application->access_type)
+ || $this->application->access_type & Oauth_application::$readAccess) {
$attrs['checked'] = 'checked';
}
@@ -316,7 +318,8 @@ class ApplicationEditForm extends Form
'class' => 'radio',
'value' => 'rw');
- if ($this->application->access_type & Oauth_application::$readAccess
+ if (!empty($this->application)
+ && $this->application->access_type & Oauth_application::$readAccess
&& $this->application->access_type & Oauth_application::$writeAccess
) {
$attrs['checked'] = 'checked';
diff --git a/lib/command.php b/lib/command.php
index 4887cac45..b1f95fcb6 100644
--- a/lib/command.php
+++ b/lib/command.php
@@ -901,7 +901,7 @@ class HelpCommand extends Command
function handle($channel)
{
$channel->output($this->user,
- // TRANS: Help text for commands.
+ // TRANS: Help text for commands. Do not translate the command names themselves; they are fixed strings.
_("Commands:\n".
"on - turn on notifications\n".
"off - turn off notifications\n".
diff --git a/lib/dbqueuemanager.php b/lib/dbqueuemanager.php
index 3dda9fd1a..51553b899 100644
--- a/lib/dbqueuemanager.php
+++ b/lib/dbqueuemanager.php
@@ -100,7 +100,7 @@ class DBQueueManager extends QueueManager
}
} else {
$this->_log(LOG_INFO, "[$queue] Got empty/deleted item, discarding");
- $this->_fail($qi);
+ $this->_done($qi);
}
return true;
}
diff --git a/lib/default.php b/lib/default.php
index 45a4560ff..6200abada 100644
--- a/lib/default.php
+++ b/lib/default.php
@@ -300,7 +300,7 @@ $default =
'OpenID' => null),
),
'admin' =>
- array('panels' => array('design', 'site', 'user', 'paths', 'access', 'sessions', 'sitenotice')),
+ array('panels' => array('design', 'site', 'user', 'paths', 'access', 'sessions', 'sitenotice', 'license')),
'singleuser' =>
array('enabled' => false,
'nickname' => null),
diff --git a/lib/feedlist.php b/lib/feedlist.php
index 9ae83f5e8..7493e3575 100644
--- a/lib/feedlist.php
+++ b/lib/feedlist.php
@@ -61,7 +61,7 @@ class FeedList extends Widget
{
$this->out->elementStart('div', array('id' => 'export_data',
'class' => 'section'));
- $this->out->element('h2', null, _('Export data'));
+ $this->out->element('h2', null, _('Feeds'));
$this->out->elementStart('ul', array('class' => 'xoxo'));
foreach ($feeds as $feed) {
diff --git a/lib/router.php b/lib/router.php
index 7e1e6a2a4..fb5a3c7c3 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -690,6 +690,8 @@ class Router
$m->connect('admin/sessions', array('action' => 'sessionsadminpanel'));
$m->connect('admin/sitenotice', array('action' => 'sitenoticeadminpanel'));
$m->connect('admin/snapshot', array('action' => 'snapshotadminpanel'));
+ $m->connect('admin/license', array('action' => 'licenseadminpanel'));
+
$m->connect('getfile/:filename',
array('action' => 'getfile'),
diff --git a/lib/util.php b/lib/util.php
index 0b90cb01d..dc853f657 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -494,6 +494,29 @@ function common_is_real_login()
return common_logged_in() && $_SESSION['real_login'];
}
+/**
+ * Get a hash portion for HTTP caching Etags and such including
+ * info on the current user's session. If login/logout state changes,
+ * or we've changed accounts, or we've renamed the current user,
+ * we'll get a new hash value.
+ *
+ * This should not be considered secure information.
+ *
+ * @param User $user (optional; uses common_current_user() if left out)
+ * @return string
+ */
+function common_user_cache_hash($user=false)
+{
+ if ($user === false) {
+ $user = common_current_user();
+ }
+ if ($user) {
+ return crc32($user->id . ':' . $user->nickname);
+ } else {
+ return '0';
+ }
+}
+
// get canonical version of nickname for comparison
function common_canonical_nickname($nickname)
{
@@ -1105,26 +1128,30 @@ function common_date_string($dt)
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a minute ago');
} else if ($diff < 3300) {
+ $minutes = round($diff/60);
// TRANS: Used in notices to indicate when the notice was made compared to now.
- return sprintf( ngettext('about one minute ago', 'about %d minutes ago'), round($diff/60));
+ return sprintf( ngettext('about one minute ago', 'about %d minutes ago', $minutes), $minutes);
} else if ($diff < 5400) {
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about an hour ago');
} else if ($diff < 22 * 3600) {
+ $hours = round($diff/3600);
// TRANS: Used in notices to indicate when the notice was made compared to now.
- return sprintf( ngettext('about one hour ago', 'about %d hours ago'), round($diff/3600));
+ return sprintf( ngettext('about one hour ago', 'about %d hours ago', $hours), $hours);
} else if ($diff < 37 * 3600) {
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a day ago');
} else if ($diff < 24 * 24 * 3600) {
+ $days = round($diff/(24*3600));
// TRANS: Used in notices to indicate when the notice was made compared to now.
- return sprintf( ngettext('about one day ago', 'about %d days ago'), round($diff/(24*3600)));
+ return sprintf( ngettext('about one day ago', 'about %d days ago', $days), $days);
} else if ($diff < 46 * 24 * 3600) {
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a month ago');
} else if ($diff < 330 * 24 * 3600) {
+ $months = round($diff/(30*24*3600));
// TRANS: Used in notices to indicate when the notice was made compared to now.
- return sprintf( ngettext('about one month ago', 'about %d months ago'), round($diff/(30*24*3600)));
+ return sprintf( ngettext('about one month ago', 'about %d months ago',$months), $months);
} else if ($diff < 480 * 24 * 3600) {
// TRANS: Used in notices to indicate when the notice was made compared to now.
return _('about a year ago');
@@ -1453,7 +1480,12 @@ function common_log_db_error(&$object, $verb, $filename=null)
{
$objstr = common_log_objstring($object);
$last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
- common_log(LOG_ERR, $last_error->message . '(' . $verb . ' on ' . $objstr . ')', $filename);
+ if (is_object($last_error)) {
+ $msg = $last_error->message;
+ } else {
+ $msg = 'Unknown error (' . var_export($last_error, true) . ')';
+ }
+ common_log(LOG_ERR, $msg . '(' . $verb . ' on ' . $objstr . ')', $filename);
}
function common_log_objstring(&$object)