From fba140f4e0246a244664f0c0fb2361b027508d35 Mon Sep 17 00:00:00 2001
From: Zach Copley
Date: Fri, 7 May 2010 16:32:24 -0700
Subject: [PATCH 1/5] Fix for repeats from the API having null source
attribution
---
actions/apidirectmessagenew.php | 8 --------
actions/apistatusesretweet.php | 2 +-
actions/apistatusesupdate.php | 12 ------------
lib/apiaction.php | 9 +++++++++
lib/apiauth.php | 3 +--
5 files changed, 11 insertions(+), 23 deletions(-)
diff --git a/actions/apidirectmessagenew.php b/actions/apidirectmessagenew.php
index b9ac92d77b..65d065648f 100644
--- a/actions/apidirectmessagenew.php
+++ b/actions/apidirectmessagenew.php
@@ -52,7 +52,6 @@ require_once INSTALLDIR . '/lib/apiauth.php';
class ApiDirectMessageNewAction extends ApiAuthAction
{
- var $source = null;
var $other = null;
var $content = null;
@@ -76,13 +75,6 @@ class ApiDirectMessageNewAction extends ApiAuthAction
return;
}
- $this->source = $this->trimmed('source'); // Not supported by Twitter.
-
- $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api');
- if (empty($this->source) || in_array($this->source, $reserved_sources)) {
- $source = 'api';
- }
-
$this->content = $this->trimmed('text');
$this->user = $this->auth_user;
diff --git a/actions/apistatusesretweet.php b/actions/apistatusesretweet.php
index 128c881e25..9aa3374854 100644
--- a/actions/apistatusesretweet.php
+++ b/actions/apistatusesretweet.php
@@ -79,7 +79,7 @@ class ApiStatusesRetweetAction extends ApiAuthAction
$this->user = $this->auth_user;
- if ($this->user->id == $notice->profile_id) {
+ if ($this->user->id == $this->original->profile_id) {
$this->clientError(_('Cannot repeat your own notice.'),
400, $this->format);
return false;
diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php
index d4ef6b550d..e3e579b0de 100644
--- a/actions/apistatusesupdate.php
+++ b/actions/apistatusesupdate.php
@@ -64,8 +64,6 @@ class ApiStatusesUpdateAction extends ApiAuthAction
var $lat = null;
var $lon = null;
- static $reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api');
-
/**
* Take arguments for running
*
@@ -80,19 +78,9 @@ class ApiStatusesUpdateAction extends ApiAuthAction
parent::prepare($args);
$this->status = $this->trimmed('status');
- $this->source = $this->trimmed('source');
$this->lat = $this->trimmed('lat');
$this->lon = $this->trimmed('long');
- // try to set the source attr from OAuth app
- if (empty($this->source)) {
- $this->source = $this->oauth_source;
- }
-
- if (empty($this->source) || in_array($this->source, self::$reserved_sources)) {
- $this->source = 'api';
- }
-
$this->in_reply_to_status_id
= intval($this->trimmed('in_reply_to_status_id'));
diff --git a/lib/apiaction.php b/lib/apiaction.php
index 59dc47c23b..f87b046114 100644
--- a/lib/apiaction.php
+++ b/lib/apiaction.php
@@ -63,9 +63,12 @@ class ApiAction extends Action
var $count = null;
var $max_id = null;
var $since_id = null;
+ var $source = null;
var $access = self::READ_ONLY; // read (default) or read-write
+ static $reserved_sources = array('web', 'omb', 'ostatus', 'mail', 'xmpp', 'api');
+
/**
* Initialization.
*
@@ -89,6 +92,12 @@ class ApiAction extends Action
header('X-StatusNet-Warning: since parameter is disabled; use since_id');
}
+ $this->source = $this->trimmed('source');
+
+ if (empty($this->source) || in_array($this->source, self::$reserved_sources)) {
+ $this->source = 'api';
+ }
+
return true;
}
diff --git a/lib/apiauth.php b/lib/apiauth.php
index e78de618ee..95acbbd7bd 100644
--- a/lib/apiauth.php
+++ b/lib/apiauth.php
@@ -54,7 +54,6 @@ class ApiAuthAction extends ApiAction
{
var $auth_user_nickname = null;
var $auth_user_password = null;
- var $oauth_source = null;
/**
* Take arguments for running, looks for an OAuth request,
@@ -162,7 +161,7 @@ class ApiAuthAction extends ApiAction
// set the source attr
- $this->oauth_source = $app->name;
+ $this->source = $app->name;
$appUser = Oauth_application_user::staticGet('token', $access_token);
From 45392bef3382cd0bad30ebcd343d1cdd21e16f08 Mon Sep 17 00:00:00 2001
From: Brion Vibber
Date: Tue, 11 May 2010 12:16:13 -0700
Subject: [PATCH 2/5] Installer tweak for Windows: normalize line endings to
platform standard in generated config.php
Added a comment that the writable directory checks are insufficient to catch ACL problems on Windows; need a better check for that.
---
lib/installer.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/installer.php b/lib/installer.php
index 589a19a66e..58ffbfef7e 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -128,6 +128,7 @@ abstract class Installer
$pass = false;
}
+ // @fixme this check seems to be insufficient with Windows ACLs
if (!is_writable(INSTALLDIR)) {
$this->warning(sprintf('Cannot write config file to: %s
', INSTALLDIR),
sprintf('On your server, try this command: chmod a+w %s
', INSTALLDIR));
@@ -409,6 +410,10 @@ abstract class Installer
"\$config['db']['database'] = '{$this->db['database']}';\n\n".
($this->db['type'] == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n":'').
"\$config['db']['type'] = '{$this->db['type']}';\n\n";
+
+ // Normalize line endings for Windows servers
+ $cfg = str_replace("\n", PHP_EOL, $cfg);
+
// write configuration file out to install directory
$res = file_put_contents(INSTALLDIR.'/config.php', $cfg);
From 3d00cfd47fe5458a531df1b78b1833eb17321393 Mon Sep 17 00:00:00 2001
From: Brion Vibber
Date: Tue, 11 May 2010 12:22:14 -0700
Subject: [PATCH 3/5] Windows server fix: Use platform EOL in debug log file
---
lib/util.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/util.php b/lib/util.php
index c0013bb3da..efede1d4be 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -1365,7 +1365,7 @@ function common_log_line($priority, $msg)
{
static $syslog_priorities = array('LOG_EMERG', 'LOG_ALERT', 'LOG_CRIT', 'LOG_ERR',
'LOG_WARNING', 'LOG_NOTICE', 'LOG_INFO', 'LOG_DEBUG');
- return date('Y-m-d H:i:s') . ' ' . $syslog_priorities[$priority] . ': ' . $msg . "\n";
+ return date('Y-m-d H:i:s') . ' ' . $syslog_priorities[$priority] . ': ' . $msg . PHP_EOL;
}
function common_request_id()
From 5d0593ec342f76aa8062584a92108a66328ff41e Mon Sep 17 00:00:00 2001
From: Brion Vibber
Date: Wed, 12 May 2010 11:09:37 -0700
Subject: [PATCH 4/5] Fix keys() / keyTypes() mixup in SamplePlugin
---
plugins/Sample/User_greeting_count.php | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/plugins/Sample/User_greeting_count.php b/plugins/Sample/User_greeting_count.php
index d9a59770d3..fc0cbd28ff 100644
--- a/plugins/Sample/User_greeting_count.php
+++ b/plugins/Sample/User_greeting_count.php
@@ -94,29 +94,34 @@ class User_greeting_count extends Memcached_DataObject
/**
* return key definitions for DB_DataObject
*
- * DB_DataObject needs to know about keys that the table has; this function
- * defines them.
+ * DB_DataObject needs to know about keys that the table has, since it
+ * won't appear in StatusNet's own keys list. In most cases, this will
+ * simply reference your keyTypes() function.
*
- * @return array key definitions
+ * @return array list of key field names
*/
function keys()
{
- return array('user_id' => 'K');
+ return array_keys($this->keyTypes());
}
/**
* return key definitions for Memcached_DataObject
*
* Our caching system uses the same key definitions, but uses a different
- * method to get them.
+ * method to get them. This key information is used to store and clear
+ * cached data, so be sure to list any key that will be used for static
+ * lookups.
*
- * @return array key definitions
+ * @return array associative array of key definitions, field name to type:
+ * 'K' for primary key: for compound keys, add an entry for each component;
+ * 'U' for unique keys: compound keys are not well supported here.
*/
function keyTypes()
{
- return $this->keys();
+ return array('user_id' => 'K');
}
/**
From 2e808fdc82adc862be12118332d27a36a19123ca Mon Sep 17 00:00:00 2001
From: Brion Vibber
Date: Thu, 13 May 2010 16:47:58 -0700
Subject: [PATCH 5/5] More direct text for registration licensing/tos checkbox
for private and all-rights-reserved sites.
---
actions/register.php | 48 +++++++++++++++++++++++++++++++++++++-------
1 file changed, 41 insertions(+), 7 deletions(-)
diff --git a/actions/register.php b/actions/register.php
index da8d0a0bbc..7fdbb4ded6 100644
--- a/actions/register.php
+++ b/actions/register.php
@@ -491,6 +491,45 @@ class RegisterAction extends Action
$this->elementStart('li');
$this->element('input', $attrs);
$this->elementStart('label', array('class' => 'checkbox', 'for' => 'license'));
+ $this->raw($this->licenseCheckbox());
+ $this->elementEnd('label');
+ $this->elementEnd('li');
+ }
+ $this->elementEnd('ul');
+ $this->submit('submit', _('Register'));
+ $this->elementEnd('fieldset');
+ $this->elementEnd('form');
+ }
+
+ function licenseCheckbox()
+ {
+ $out = '';
+ switch (common_config('license', 'type')) {
+ case 'private':
+ // TRANS: Copyright checkbox label in registration dialog, for private sites.
+ $out .= htmlspecialchars(sprintf(
+ _('I understand that content and data of %1$s are private and confidential.'),
+ common_config('site', 'name')));
+ // fall through
+ case 'allrightsreserved':
+ if ($out != '') {
+ $out .= ' ';
+ }
+ if (common_config('license', 'owner')) {
+ // TRANS: Copyright checkbox label in registration dialog, for all rights reserved with a specified copyright owner.
+ $out .= htmlspecialchars(sprintf(
+ _('My text and files are copyright by %1$s.'),
+ common_config('license', 'owner')));
+ } else {
+ // TRANS: Copyright checkbox label in registration dialog, for all rights reserved with ownership left to contributors.
+ $out .= htmlspecialchars(_('My text and files remain under my own copyright.'));
+ }
+ // TRANS: Copyright checkbox label in registration dialog, for all rights reserved.
+ $out .= ' ' . _('All rights reserved.');
+ break;
+ case 'cc': // fall through
+ default:
+ // TRANS: Copyright checkbox label in registration dialog, for Creative Commons-style licenses.
$message = _('My text and files are available under %s ' .
'except this private data: password, ' .
'email address, IM address, and phone number.');
@@ -499,14 +538,9 @@ class RegisterAction extends Action
'">' .
htmlspecialchars(common_config('license', 'title')) .
'';
- $this->raw(sprintf(htmlspecialchars($message), $link));
- $this->elementEnd('label');
- $this->elementEnd('li');
+ $out .= sprintf(htmlspecialchars($message), $link);
}
- $this->elementEnd('ul');
- $this->submit('submit', _('Register'));
- $this->elementEnd('fieldset');
- $this->elementEnd('form');
+ return $out;
}
/**