From 506c2d7491f7f229a1469ef176fee6c21d61a6c6 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 12 Feb 2010 12:22:12 -0800 Subject: Initial upgraded Atom output for group timelines --- lib/api.php | 2 +- lib/atom10feed.php | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 69 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/api.php b/lib/api.php index 8f1fe1ef7..494b595d1 100644 --- a/lib/api.php +++ b/lib/api.php @@ -1103,7 +1103,7 @@ class ApiAction extends Action } } - function serverError($msg, $code = 500, $content_type = 'json') + function serverError($msg, $code = 500, $content_type = 'xml') { $action = $this->trimmed('action'); diff --git a/lib/atom10feed.php b/lib/atom10feed.php index ccca76a09..806a9684b 100644 --- a/lib/atom10feed.php +++ b/lib/atom10feed.php @@ -51,6 +51,7 @@ class Atom10Feed extends XMLStringer public $xw; private $namespaces; private $authors; + private $subject; private $categories; private $contributors; private $generator; @@ -74,6 +75,7 @@ class Atom10Feed extends XMLStringer function __construct($indent = true) { parent::__construct($indent); $this->namespaces = array(); + $this->authors = array(); $this->links = array(); $this->entries = array(); $this->addNamespace('xmlns', 'http://www.w3.org/2005/Atom'); @@ -93,6 +95,64 @@ class Atom10Feed extends XMLStringer $this->namespaces = array_merge($this->namespaces, $ns); } + function addAuthor($name, $uri = null, $email = null) + { + $xs = new XMLStringer(true); + + $xs->elementStart('author'); + + if (!empty($name)) { + $xs->element('name', null, $name); + } else { + throw new Atom10FeedException( + 'author element must contain a name element.' + ); + } + + if (!is_null($uri)) { + $xs->element('uri', null, $uri); + } + + if (!is_null(email)) { + $xs->element('email', null, $email); + } + + $xs->elementEnd('author'); + + array_push($this->authors, $xs->getString()); + } + + /** + * Add an Author to the feed via raw XML string + * + * @param string $xmlAuthor An XML string representation author + * + * @return void + */ + function addAuthorRaw($xmlAuthor) + { + array_push($this->authors, $xmlAuthor); + } + + function renderAuthors() + { + foreach ($this->authors as $author) { + $this->raw($author); + } + } + + /** + * Add a activity feed subject via raw XML string + * + * @param string $xmlSubject An XML string representation of the subject + * + * @return void + */ + function setActivitySubject($xmlSubject) + { + $this->subject = $xmlSubject; + } + function getNamespaces() { return $this->namespaces; @@ -136,9 +196,9 @@ class Atom10Feed extends XMLStringer } } - function addEntryRaw($entry) + function addEntryRaw($xmlEntry) { - array_push($this->entries, $entry); + array_push($this->entries, $xmlEntry); } function addEntry($entry) @@ -164,6 +224,12 @@ class Atom10Feed extends XMLStringer $this->validate(); $this->initFeed(); + $this->renderAuthors(); + + if (!empty($this->subject)) { + $this->raw($this->subject); + } + $this->renderEntries(); $this->endFeed(); -- cgit v1.2.3-54-g00ecf From 38f42d56bc5f2871d69d1df066a1f1d76e7cbc68 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 12 Feb 2010 15:24:15 -0800 Subject: Session fix for PHP 5.3 configurations where cookies are excluded from $_REQUEST via request_order in php.ini (Fedora 12, MacPorts known to be affected) --- lib/util.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/util.php b/lib/util.php index a07fe49e3..209dc2254 100644 --- a/lib/util.php +++ b/lib/util.php @@ -367,7 +367,8 @@ function common_current_user() if ($_cur === false) { - if (isset($_REQUEST[session_name()]) || (isset($_SESSION['userid']) && $_SESSION['userid'])) { + if (isset($_COOKIE[session_name()]) || isset($_GET[session_name()]) + || (isset($_SESSION['userid']) && $_SESSION['userid'])) { common_ensure_session(); $id = isset($_SESSION['userid']) ? $_SESSION['userid'] : false; if ($id) { -- cgit v1.2.3-54-g00ecf