summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-06-29 08:53:05 -0700
committerBrion Vibber <brion@pobox.com>2010-06-29 08:53:05 -0700
commitc038164c0f41ba5c33f578f395c9fede80d96db8 (patch)
tree1452f6e5ae5786048a5a2835275c553e80c60462 /lib
parent7b7f09195a8082c8e26e87f7deb8b1002b852689 (diff)
parent452123916d08354d11a198517cbc91980a113fcd (diff)
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x
Diffstat (limited to 'lib')
-rw-r--r--lib/apiaction.php70
-rw-r--r--lib/atomgroupnoticefeed.php19
-rw-r--r--lib/atomnoticefeed.php2
-rw-r--r--lib/avatarlink.php2
-rw-r--r--lib/common.php4
-rw-r--r--lib/dbqueuemanager.php4
-rw-r--r--lib/mediafile.php54
-rw-r--r--lib/noticelist.php10
-rw-r--r--lib/router.php6
-rw-r--r--lib/themeuploader.php4
10 files changed, 142 insertions, 33 deletions
diff --git a/lib/apiaction.php b/lib/apiaction.php
index 27df55892..8de13a62d 100644
--- a/lib/apiaction.php
+++ b/lib/apiaction.php
@@ -271,11 +271,13 @@ class ApiAction extends Action
// Is the requesting user following this user?
$twitter_user['following'] = false;
+ $twitter_user['statusnet:blocking'] = false;
$twitter_user['notifications'] = false;
if (isset($this->auth_user)) {
$twitter_user['following'] = $this->auth_user->isSubscribed($profile);
+ $twitter_user['statusnet:blocking'] = $this->auth_user->hasBlocked($profile);
// Notifications on?
$sub = Subscription::pkeyGet(array('subscriber' =>
@@ -409,20 +411,32 @@ class ApiAction extends Action
function twitterGroupArray($group)
{
- $twitter_group=array();
- $twitter_group['id']=$group->id;
- $twitter_group['url']=$group->permalink();
- $twitter_group['nickname']=$group->nickname;
- $twitter_group['fullname']=$group->fullname;
- $twitter_group['original_logo']=$group->original_logo;
- $twitter_group['homepage_logo']=$group->homepage_logo;
- $twitter_group['stream_logo']=$group->stream_logo;
- $twitter_group['mini_logo']=$group->mini_logo;
- $twitter_group['homepage']=$group->homepage;
- $twitter_group['description']=$group->description;
- $twitter_group['location']=$group->location;
- $twitter_group['created']=$this->dateTwitter($group->created);
- $twitter_group['modified']=$this->dateTwitter($group->modified);
+ $twitter_group = array();
+
+ $twitter_group['id'] = $group->id;
+ $twitter_group['url'] = $group->permalink();
+ $twitter_group['nickname'] = $group->nickname;
+ $twitter_group['fullname'] = $group->fullname;
+
+ if (isset($this->auth_user)) {
+ $twitter_group['member'] = $this->auth_user->isMember($group);
+ $twitter_group['blocked'] = Group_block::isBlocked(
+ $group,
+ $this->auth_user->getProfile()
+ );
+ }
+
+ $twitter_group['member_count'] = $group->getMemberCount();
+ $twitter_group['original_logo'] = $group->original_logo;
+ $twitter_group['homepage_logo'] = $group->homepage_logo;
+ $twitter_group['stream_logo'] = $group->stream_logo;
+ $twitter_group['mini_logo'] = $group->mini_logo;
+ $twitter_group['homepage'] = $group->homepage;
+ $twitter_group['description'] = $group->description;
+ $twitter_group['location'] = $group->location;
+ $twitter_group['created'] = $this->dateTwitter($group->created);
+ $twitter_group['modified'] = $this->dateTwitter($group->modified);
+
return $twitter_group;
}
@@ -1360,6 +1374,34 @@ class ApiAction extends Action
}
}
+ function getTargetProfile($id)
+ {
+ if (empty($id)) {
+
+ // Twitter supports these other ways of passing the user ID
+ if (is_numeric($this->arg('id'))) {
+ return Profile::staticGet($this->arg('id'));
+ } else if ($this->arg('id')) {
+ $nickname = common_canonical_nickname($this->arg('id'));
+ return Profile::staticGet('nickname', $nickname);
+ } else if ($this->arg('user_id')) {
+ // This is to ensure that a non-numeric user_id still
+ // overrides screen_name even if it doesn't get used
+ if (is_numeric($this->arg('user_id'))) {
+ return Profile::staticGet('id', $this->arg('user_id'));
+ }
+ } else if ($this->arg('screen_name')) {
+ $nickname = common_canonical_nickname($this->arg('screen_name'));
+ return Profile::staticGet('nickname', $nickname);
+ }
+ } else if (is_numeric($id)) {
+ return Profile::staticGet($id);
+ } else {
+ $nickname = common_canonical_nickname($id);
+ return Profile::staticGet('nickname', $nickname);
+ }
+ }
+
function getTargetGroup($id)
{
if (empty($id)) {
diff --git a/lib/atomgroupnoticefeed.php b/lib/atomgroupnoticefeed.php
index c7c36af82..39a1fd456 100644
--- a/lib/atomgroupnoticefeed.php
+++ b/lib/atomgroupnoticefeed.php
@@ -96,4 +96,23 @@ class AtomGroupNoticeFeed extends AtomNoticeFeed
return $this->group;
}
+ function initFeed()
+ {
+ parent::initFeed();
+
+ $attrs = array();
+
+ if (!empty($this->cur)) {
+ $attrs['member'] = $this->cur->isMember($this->group)
+ ? 'true' : 'false';
+ $attrs['blocked'] = Group_block::isBlocked(
+ $this->group,
+ $this->cur->getProfile()
+ ) ? 'true' : 'false';
+ }
+
+ $attrs['member_count'] = $this->group->getMemberCount();
+
+ $this->element('statusnet:group_info', $attrs, null);
+ }
}
diff --git a/lib/atomnoticefeed.php b/lib/atomnoticefeed.php
index ef44de4b6..6ed803ce4 100644
--- a/lib/atomnoticefeed.php
+++ b/lib/atomnoticefeed.php
@@ -95,7 +95,7 @@ class AtomNoticeFeed extends Atom10Feed
$this->addNamespace(
'statusnet',
- 'http://status.net/ont/'
+ 'http://status.net/schema/api/1/'
);
}
diff --git a/lib/avatarlink.php b/lib/avatarlink.php
index e67799e2e..7d4256d6e 100644
--- a/lib/avatarlink.php
+++ b/lib/avatarlink.php
@@ -76,8 +76,8 @@ class AvatarLink
$alink = new AvatarLink();
$alink->url = $filename;
$alink->height = $size;
+ $alink->width = $size;
if (!empty($filename)) {
- $alink->width = $size;
$alink->type = self::mediatype($filename);
} else {
$alink->url = User_group::defaultLogo($size);
diff --git a/lib/common.php b/lib/common.php
index 064f6f73a..817434b97 100644
--- a/lib/common.php
+++ b/lib/common.php
@@ -22,10 +22,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
//exit with 200 response, if this is checking fancy from the installer
if (isset($_REQUEST['p']) && $_REQUEST['p'] == 'check-fancy') { exit; }
-define('STATUSNET_VERSION', '0.9.2');
+define('STATUSNET_VERSION', '0.9.3');
define('LACONICA_VERSION', STATUSNET_VERSION); // compatibility
-define('STATUSNET_CODENAME', 'King of Birds');
+define('STATUSNET_CODENAME', 'Half a World Away');
define('AVATAR_PROFILE_SIZE', 96);
define('AVATAR_STREAM_SIZE', 48);
diff --git a/lib/dbqueuemanager.php b/lib/dbqueuemanager.php
index 3032e4ec7..3dda9fd1a 100644
--- a/lib/dbqueuemanager.php
+++ b/lib/dbqueuemanager.php
@@ -135,9 +135,7 @@ class DBQueueManager extends QueueManager
if (empty($qi->claimed)) {
$this->_log(LOG_WARNING, "[$queue:item $qi->id] Ignoring failure for unclaimed queue item");
} else {
- $orig = clone($qi);
- $qi->claimed = null;
- $qi->update($orig);
+ $qi->releaseClaim();
}
$this->stats('error', $queue);
diff --git a/lib/mediafile.php b/lib/mediafile.php
index 1c96c42d7..c96c78ab5 100644
--- a/lib/mediafile.php
+++ b/lib/mediafile.php
@@ -180,7 +180,8 @@ class MediaFile
return;
}
- $mimetype = MediaFile::getUploadedFileType($_FILES[$param]['tmp_name']);
+ $mimetype = MediaFile::getUploadedFileType($_FILES[$param]['tmp_name'],
+ $_FILES[$param]['name']);
$filename = null;
@@ -241,19 +242,41 @@ class MediaFile
return new MediaFile($user, $filename, $mimetype);
}
- static function getUploadedFileType($f) {
+ /**
+ * Attempt to identify the content type of a given file.
+ *
+ * @param mixed $f file handle resource, or filesystem path as string
+ * @param string $originalFilename (optional) for extension-based detection
+ * @return string
+ *
+ * @fixme is this an internal or public method? It's called from GetFileAction
+ * @fixme this seems to tie a front-end error message in, kinda confusing
+ * @fixme this looks like it could return a PEAR_Error in some cases, if
+ * type can't be identified and $config['attachments']['supported'] is true
+ *
+ * @throws ClientException if type is known, but not supported for local uploads
+ */
+ static function getUploadedFileType($f, $originalFilename=false) {
require_once 'MIME/Type.php';
+ require_once 'MIME/Type/Extension.php';
+ $mte = new MIME_Type_Extension();
$cmd = &PEAR::getStaticProperty('MIME_Type', 'fileCmd');
$cmd = common_config('attachments', 'filecommand');
$filetype = null;
+ // If we couldn't get a clear type from the file extension,
+ // we'll go ahead and try checking the content. Content checks
+ // are unambiguous for most image files, but nearly useless
+ // for office document formats.
+
if (is_string($f)) {
// assuming a filename
$filetype = MIME_Type::autoDetect($f);
+
} else {
// assuming a filehandle
@@ -262,7 +285,32 @@ class MediaFile
$filetype = MIME_Type::autoDetect($stream['uri']);
}
- if (common_config('attachments', 'supported') === true || in_array($filetype, common_config('attachments', 'supported'))) {
+ // The content-based sources for MIME_Type::autoDetect()
+ // are wildly unreliable for office-type documents. If we've
+ // gotten an unclear reponse back or just couldn't identify it,
+ // we'll try detecting a type from its extension...
+ $unclearTypes = array('application/octet-stream',
+ 'application/vnd.ms-office',
+ 'application/zip');
+
+ if ($originalFilename && (!$filetype || in_array($filetype, $unclearTypes))) {
+ $type = $mte->getMIMEType($originalFilename);
+ if (is_string($type)) {
+ $filetype = $type;
+ }
+ }
+
+ $supported = common_config('attachments', 'supported');
+ if (is_array($supported)) {
+ // Normalize extensions to mime types
+ foreach ($supported as $i => $entry) {
+ if (strpos($entry, '/') === false) {
+ common_log(LOG_INFO, "sample.$entry");
+ $supported[$i] = $mte->getMIMEType("sample.$entry");
+ }
+ }
+ }
+ if ($supported === true || in_array($filetype, $supported)) {
return $filetype;
}
$media = MIME_Type::getMedia($filetype);
diff --git a/lib/noticelist.php b/lib/noticelist.php
index 432ea78d5..e23cf3b6d 100644
--- a/lib/noticelist.php
+++ b/lib/noticelist.php
@@ -463,12 +463,14 @@ class NoticeListItem extends Widget
$this->out->elementEnd('span');
}
+ /**
+ * @param number $dec decimal degrees
+ * @return array split into 'deg', 'min', and 'sec'
+ */
function decimalDegreesToDMS($dec)
{
-
- $vars = explode(".",$dec);
- $deg = $vars[0];
- $tempma = "0.".$vars[1];
+ $deg = intval($dec);
+ $tempma = abs($dec) - abs($deg);
$tempma = $tempma * 3600;
$min = floor($tempma / 60);
diff --git a/lib/router.php b/lib/router.php
index fec229c9b..7e1e6a2a4 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -667,9 +667,9 @@ class Router
);
// search
- $m->connect('api/search.atom', array('action' => 'twitapisearchatom'));
- $m->connect('api/search.json', array('action' => 'twitapisearchjson'));
- $m->connect('api/trends.json', array('action' => 'twitapitrends'));
+ $m->connect('api/search.atom', array('action' => 'ApiSearchAtom'));
+ $m->connect('api/search.json', array('action' => 'ApiSearchJSON'));
+ $m->connect('api/trends.json', array('action' => 'ApiTrends'));
$m->connect('api/oauth/request_token',
array('action' => 'apioauthrequesttoken'));
diff --git a/lib/themeuploader.php b/lib/themeuploader.php
index 18ef8c4d1..370965db0 100644
--- a/lib/themeuploader.php
+++ b/lib/themeuploader.php
@@ -55,10 +55,10 @@ class ThemeUploader
public static function fromUpload($name)
{
if (!isset($_FILES[$name]['error'])) {
- throw new ServerException(_("Theme upload missing or failed."));
+ throw new ServerException(_("The theme file is missing or the upload failed."));
}
if ($_FILES[$name]['error'] != UPLOAD_ERR_OK) {
- throw new ServerException(_("Theme upload missing or failed."));
+ throw new ServerException(_("The theme file is missing or the upload failed."));
}
return new ThemeUploader($_FILES[$name]['tmp_name']);
}