diff --git a/mozilla/webtools/partytool/config/routes.php b/mozilla/webtools/partytool/config/routes.php
index c0da26d26a1..baf123c7dea 100755
--- a/mozilla/webtools/partytool/config/routes.php
+++ b/mozilla/webtools/partytool/config/routes.php
@@ -1,5 +1,5 @@
connect('/pages/edit', array('controller' => 'pages', 'action' => 'edit'));
$Route->connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
$Route->connect('/privacy-policy', array('controller' => 'pages', 'action' => 'privacy'));
?>
diff --git a/mozilla/webtools/partytool/config/sql/dist.sql b/mozilla/webtools/partytool/config/sql/dist.sql
index f1c4a56bdff..6e1e56c413f 100755
--- a/mozilla/webtools/partytool/config/sql/dist.sql
+++ b/mozilla/webtools/partytool/config/sql/dist.sql
@@ -16,6 +16,15 @@ CREATE TABLE `guests` (
KEY `pid` (`pid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+CREATE TABLE `pages` (
+ `id` int(10) NOT NULL auto_increment,
+ `text` text collate utf8_unicode_ci NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+
+INSERT INTO `pages` (`id`, `text`) VALUES (1, '<h2>Join the Fun!</h2>\n<p>All over the world, we're celebrating the launch of Firefox 2. Join the fun by hosting or attending a party. We're targeting the weekend of October 27th for the shared celebration, but if you're hosting, you make the call.</p>\n\n<p>To join the fun, <a href="/users/register">register</a> for a Firefox Party account, and sign up to host or attend.</p>\n\n<p style="border: 1px solid #555; background: #faffd4; padding: 5px; font-weight: bold">Be one of the first 50 party hosts registered and get three extra launch exclusive t-shirts with your purchase of the <a href="">Firefox 2 Party Pack</a>. We're selling the party packs and shirts at cost, so it's a great deal, and for parties with unusually large attendance, we'll be sending out additional swag for door prizes and other give-aways. Stay tuned for updates!</p>');
+INSERT INTO `pages` (`id`, `text`) VALUES (2, '1162007940');
+
CREATE TABLE `parties` (
`id` int(10) NOT NULL auto_increment,
`owner` int(10) NOT NULL default '0',
diff --git a/mozilla/webtools/partytool/controllers/components/mail.php b/mozilla/webtools/partytool/controllers/components/mail.php
index eeba95dcefb..ddf01fba7f7 100644
--- a/mozilla/webtools/partytool/controllers/components/mail.php
+++ b/mozilla/webtools/partytool/controllers/components/mail.php
@@ -40,7 +40,7 @@ class MailComponent extends Object {
break;
case "invite":
- $this->message = $this->head."
\nYou've been invited by a friend to join them in celebrating the release of Firefox 2. To join them, just click here and sign up for an account.\n
+ $this->message = $this->head."
\nYou've been invited by a friend to join them in celebrating the release of Firefox 2. Simply click here to confirm or cancel this invitation. If you don't already have an account, you'll need to create one.\n
If you're unable to use the link above, simply paste the following URL into your browser: ".$params['link'].$this->foot;
break;
}
diff --git a/mozilla/webtools/partytool/controllers/feeds_controller.php b/mozilla/webtools/partytool/controllers/feeds_controller.php
index 9499279a264..96abae1e653 100755
--- a/mozilla/webtools/partytool/controllers/feeds_controller.php
+++ b/mozilla/webtools/partytool/controllers/feeds_controller.php
@@ -34,40 +34,60 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
+vendor('webServices');
class FeedsController extends AppController {
var $name = 'Feeds';
function index() {
- header('Content-type: text/xml');
+ header('Content-type: application/rss+xml');
$this->layout = 'ajax';
$this->set('count', $this->Feed->findCount());
}
function latest() {
- header('Content-type: text/xml');
+ header('Content-type: application/rss+xml');
$this->layout = 'ajax';
$this->set('latest', $this->Feed->findAll('', '', 'id DESC', 10, 1));
}
function users() {
- header('Content-type: text/xml');
+ header('Content-type: application/rss+xml');
$this->layout = 'ajax';
$this->set('count', $this->Feed->getUserCount());
}
function comments($id = null) {
$this->layout = 'ajax';
- header('Content-type: text/xml');
+ header('Content-type: application/rss+xml');
if (!is_numeric($id))
return;
$this->set('comments', $this->Feed->getComments($id));
$this->set('pid', $id);
}
+
+ function photos($id = null) {
+ $this->layout = 'ajax';
+ header('Content-type: application/atom+xml');
+ if (!is_numeric($id))
+ return;
+
+ $party = $this->Feed->findById($id);
+ $this->set('party', $party);
+
+ if (FLICKR_API_KEY != null) {
+ if ($party['Feeds']['useflickr'] == 1) {
+ $data = array('type' => 'flickr', 'userid' => $party['Feeds']['flickrid'], 'randomize' => false);
+ $flickr = new webServices($data);
+ $photoset = $flickr->fetchPhotos(FLICKR_TAG_PREFIX.$id, 10, (($party['Feeds']['flickrperms']) ? false : true));
+ $this->set('flickr', $photoset, 0, 9);
+ }
+ }
+ }
function upcoming() {
$this->layout = 'ajax';
- header('Content-type: text/xml');
+ header('Content-type: application/rss+xml');
$this->set('latest', $this->Feed->findAll('WHERE date > '. time(), '', 'date ASC', 10, 1));
}
diff --git a/mozilla/webtools/partytool/controllers/pages_controller.php b/mozilla/webtools/partytool/controllers/pages_controller.php
index 77ffa5a05a4..dc1b405165c 100755
--- a/mozilla/webtools/partytool/controllers/pages_controller.php
+++ b/mozilla/webtools/partytool/controllers/pages_controller.php
@@ -34,17 +34,59 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
+uses('sanitize');
class PagesController extends AppController {
var $name = 'Pages';
+ var $components = array('Unicode');
function display() {
$this->pageTitle = 'Home';
$this->set('current', 'home');
$this->set('pcount', $this->Page->findCount());
$this->set('ucount', $this->Page->getUsers());
+ $text = $this->Page->query('SELECT text FROM pages WHERE id = 1');
+ $time = $this->Page->query('SELECT text FROM pages WHERE id = 2');
+ $this->set('time', $time[0]['pages']['text']);
+ $this->set('front_text', preg_replace("/(\d{2,5});/e",
+ '$this->Unicode->unicode2utf(${1})',
+ html_entity_decode($text[0]['pages']['text'])));
}
function privacy() {
$this->pageTitle = 'Privacy Policy';
}
-}
\ No newline at end of file
+
+ function edit() {
+ if (isset($_SESSION['User']['id']) && $_SESSION['User']['role'] == 1) {
+ if (empty($this->data)) {
+ $text = $this->Page->query('SELECT text FROM pages WHERE id = 1');
+ $time = $this->Page->query('SELECT text FROM pages WHERE id = 2');
+ $this->data['Pages']['text'] = preg_replace("/(\d{2,5});/e",
+ '$this->Unicode->unicode2utf(${1})',
+ html_entity_decode($text[0]['pages']['text']));
+ $this->set('selected', date('Y-m-d H:i:s', $time[0]['pages']['text']));
+ }
+
+ else {
+ // Paranoid? Nah...
+ if ($_SESSION['User']['role'] == 1) {
+ $clean = new Sanitize();
+ $clean->cleanArray($this->data);
+ $date = mktime($this->data['Pages']['date_hour'],
+ $this->data['Pages']['date_min'],
+ 0,
+ $this->data['Pages']['date_month'],
+ $this->data['Pages']['date_day'],
+ $this->data['Pages']['date_year']);
+
+ $this->Page->execute('UPDATE pages SET text = "'.$this->data['Pages']['text'].'" WHERE pages.id = 1');
+ $this->Page->execute('UPDATE pages SET text = "'.$date.'" WHERE pages.id = 2');
+ $this->redirect('/');
+ }
+ }
+ }
+ else
+ die();
+ }
+}
+?>
diff --git a/mozilla/webtools/partytool/controllers/parties_controller.php b/mozilla/webtools/partytool/controllers/parties_controller.php
index aaef76c5c4e..e410ab8b98c 100644
--- a/mozilla/webtools/partytool/controllers/parties_controller.php
+++ b/mozilla/webtools/partytool/controllers/parties_controller.php
@@ -218,7 +218,7 @@ class PartiesController extends AppController {
$this->set('current', 'parties');
$this->set('host', $this->Party->getHost($party['Party']['owner']));
$this->set('party', $party);
- $this->set('isguest', $this->Party->isGuest($id, $_SESSION['User']['id']));
+ $this->set('isguest', $this->Party->isGuest($id, @$_SESSION['User']['id']));
$this->pageTitle = $party['Party']['name'];
$this->set('map', 'mapInit('.$party['Party']['lat'].','.$party['Party']['long'].
','.$party['Party']['zoom'].',\'stationary\')');
@@ -227,7 +227,7 @@ class PartiesController extends AppController {
if (FLICKR_API_KEY != null) {
if ($party['Party']['useflickr'] == 1) {
- $data = array('type' => 'flickr', 'userid' => $party['Party']['flickrid']);
+ $data = array('type' => 'flickr', 'userid' => $party['Party']['flickrid'], 'randomize' => true);
$flickr = new webServices($data);
$photoset = $flickr->fetchPhotos(FLICKR_TAG_PREFIX.$party['Party']['id'], 15, (($party['Party']['flickrperms']) ? false : true));
$this->set('flickr', array_slice($photoset, 0, 9));
@@ -271,6 +271,7 @@ class PartiesController extends AppController {
$this->Session->setFlash($this->data['Party']['einvite'].' has been
invited. You can invite another guest below or click here
to return to your party.', 'infoFlash');
+ $this->data['Party']['einvite'] = null;
}
else {
$this->validateErrors($this->Party);
@@ -281,28 +282,38 @@ class PartiesController extends AppController {
}
}
- function invited($icode = null) {
- if ($icode == "cancel") {
+ function invited($icode = null, $conf = null) {
+ $this->pageTitle = "Confirm Invite";
+ if ($icode == 'cancel') {
$this->Session->delete('invite');
+ $this->Session->delete('invitestep');
$this->redirect('/');
}
else {
- $this->pageTitle = "Confirm Invite";
$clean = new Sanitize();
$icode = $clean->sql($icode);
$party = $this->Party->findByInvitecode($icode);
+
if (empty($party['Party']['id'])) {
$this->Session->setFlash('Could not find a party matching that invite code, please check it and try again.', 'errorFlash');
}
else {
- if (!empty($_SESSION['User']['id'])) {
- $this->Party->addGuest($_SESSION['User']['id'], $icode);
+ if (!empty($_SESSION['User']['id']) && !empty($_SESSION['invitestep']) && $conf == 'confirm') {
+ $this->Party->addGuest($_SESSION['User']['id'], $_SESSION['invite']);
$this->Session->setFlash('You have been successfully added to this party.', 'infoFlash');
$this->redirect('/parties/view/'.$party['Party']['id']);
}
+ else if (!empty($_SESSION['User']['id'])) {
+ $this->set('confirm_only', true);
+ $this->set('party', $party);
+ $this->set('icode', $icode);
+ $this->Session->write('invitestep', 'true');
+ $this->Session->write('invite', $icode);
+ }
+
else {
$this->Session->write('invite', $icode);
$this->set('party', $party);
diff --git a/mozilla/webtools/partytool/controllers/users_controller.php b/mozilla/webtools/partytool/controllers/users_controller.php
index b7570f26b05..1a83b229e8f 100644
--- a/mozilla/webtools/partytool/controllers/users_controller.php
+++ b/mozilla/webtools/partytool/controllers/users_controller.php
@@ -138,7 +138,7 @@ class UsersController extends AppController {
}
}
- function edit($id) {
+ function edit() {
if (!isset($_SESSION['User'])) {
$this->redirect('/users/login');
}
@@ -271,10 +271,10 @@ class UsersController extends AppController {
$this->pageTitle = $user['User']['name'];
$this->set('user', $user);
if (GMAP_API_KEY != null && !empty($user['User']['lat']))
- $this->set('map', $user['User']['lat'].','.$user['User']['long'].','.$user['User']['zoom'].',\'stationary\'');
+ $this->set('map', 'mapInit('.$user['User']['lat'].','.$user['User']['long'].','.$user['User']['zoom'].',\'stationary\');');
$this->Party->unbindModel(array('hasMany' => array('Comment')));
- $this->set('hparties', $this->Party->findByOwner($id));
+ $this->set('hparties', $this->User->hostOf($id));
$att = $this->User->query('SELECT parties.id, parties.name
FROM parties
LEFT JOIN guests
diff --git a/mozilla/webtools/partytool/models/party.php b/mozilla/webtools/partytool/models/party.php
index abe865dffd0..52ea372d77a 100755
--- a/mozilla/webtools/partytool/models/party.php
+++ b/mozilla/webtools/partytool/models/party.php
@@ -101,5 +101,10 @@ class Party extends AppModel {
}
}
}
+
+ function findByInvitecode($icode) {
+ $rv = $this->query('SELECT * FROM parties AS Party WHERE invitecode = "'.$icode.'" LIMIT 1');
+ return @$rv[0];
+ }
}
-?>
\ No newline at end of file
+?>
diff --git a/mozilla/webtools/partytool/vendors/webServices.php b/mozilla/webtools/partytool/vendors/webServices.php
index 8fa9a229691..9863b018903 100755
--- a/mozilla/webtools/partytool/vendors/webServices.php
+++ b/mozilla/webtools/partytool/vendors/webServices.php
@@ -38,15 +38,18 @@ class webServices {
var $userid;
var $host;
+ var $randomize;
function webServices($data) {
switch ($data['type']) {
case "flickr":
$this->host = "api.flickr.com";
- if (array_key_exists('userid', $data)) {
+ if (array_key_exists('userid', $data))
$this->userid = $data['userid'];
- }
+
+ if (array_key_exists('randomize', $data))
+ $this->randomize = $data['randomize'];
if (array_key_exists('username', $data)) {
$head = "GET /services/rest/?method=flickr.people.findByUsername&api_key=".FLICKR_API_KEY."&username=".$data['username']." HTTP/1.1\r\n";
@@ -99,8 +102,10 @@ class webServices {
'title' => $titles[$i][1]);
}
- // Randomize the results
- shuffle($arr);
+ if ($this->randomize) {
+ // Randomize the results
+ shuffle($arr);
+ }
return $arr;
}
diff --git a/mozilla/webtools/partytool/views/feeds/comments.thtml b/mozilla/webtools/partytool/views/feeds/comments.thtml
index b55c25e7688..fdac509c302 100755
--- a/mozilla/webtools/partytool/views/feeds/comments.thtml
+++ b/mozilla/webtools/partytool/views/feeds/comments.thtml
@@ -7,7 +7,7 @@