From 2d14b8b7fc5fa4ecb98d99ca9ecbb6bc855318cd Mon Sep 17 00:00:00 2001 From: "reed%reedloden.com" Date: Tue, 10 Oct 2006 20:19:01 +0000 Subject: [PATCH] Bug 356077 - "Changes to Firefox Party tool" [p=rflint@dslr.net] git-svn-id: svn://10.0.0.236/trunk@213456 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/partytool/config/routes.php | 7 +-- .../webtools/partytool/config/sql/dist.sql | 9 ++++ .../partytool/controllers/components/mail.php | 2 +- .../controllers/feeds_controller.php | 30 ++++++++++-- .../controllers/pages_controller.php | 44 +++++++++++++++++- .../controllers/parties_controller.php | 25 +++++++--- .../controllers/users_controller.php | 6 +-- mozilla/webtools/partytool/models/party.php | 7 ++- .../partytool/vendors/webServices.php | 13 ++++-- .../partytool/views/feeds/comments.thtml | 2 +- .../partytool/views/layouts/default.thtml | 12 ++--- .../partytool/views/pages/display.thtml | 46 +++++++++---------- .../partytool/views/parties/invited.thtml | 6 ++- .../partytool/views/parties/view.thtml | 16 ++++--- .../webtools/partytool/views/users/view.thtml | 7 +-- 15 files changed, 167 insertions(+), 65 deletions(-) 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 @@ <?php echo APP_NAME." - Latest Comments"; ?> - <![CDATA[<?php echo substr($comment['comments']['text'], 0, 25); ?>]]> + <![CDATA[<?php echo substr($comment['comments']['text'], 0, 25).'...'; ?>]]> url('/party/view/'.$comment['comments']['assoc'].'#c'.$comment['comments']['id']); ?> diff --git a/mozilla/webtools/partytool/views/layouts/default.thtml b/mozilla/webtools/partytool/views/layouts/default.thtml index 1dc953bdf73..e78d0658f7d 100755 --- a/mozilla/webtools/partytool/views/layouts/default.thtml +++ b/mozilla/webtools/partytool/views/layouts/default.thtml @@ -19,10 +19,10 @@
@@ -32,8 +32,8 @@ diff --git a/mozilla/webtools/partytool/views/pages/display.thtml b/mozilla/webtools/partytool/views/pages/display.thtml index 7db92365fda..c2d1c965f6e 100755 --- a/mozilla/webtools/partytool/views/pages/display.thtml +++ b/mozilla/webtools/partytool/views/pages/display.thtml @@ -1,28 +1,28 @@ -
-

- Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla porta tellus ac leo suscipit euismod. Aenean id ante. Vestibulum consectetuer. Integer diam neque, iaculis eget, ultricies ac, elementum sit amet, risus. Proin blandit. Cras quam. Aenean sollicitudin, lorem vel lobortis bibendum, lorem nibh gravida elit, et aliquam dolor libero bibendum sem. Cras pharetra. Vivamus ligula nisl, mattis sed, molestie nec, interdum ac, massa. In eros pede, dictum at, mollis eu, adipiscing eget, ante. Nunc elit nunc, tincidunt sit amet, tincidunt eu, euismod id, massa. Vivamus molestie. Sed non dui non velit semper egestas. Maecenas vulputate. Quisque sapien. Pellentesque interdum, libero rutrum tincidunt molestie, dui pede eleifend quam, quis tempor sapien ligula et turpis. - Maecenas ut sem. Nam adipiscing sem sit amet magna. Curabitur a risus non ipsum mattis tempor. Fusce in arcu. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed eu diam nec nisi ultrices laoreet. Pellentesque tincidunt, enim nec malesuada tristique, est neque luctus dui, sit amet posuere nunc nulla vel diam. Phasellus pharetra tortor ut massa lacinia adipiscing. Morbi in nulla. Proin ut diam et tortor hendrerit congue. Mauris porttitor fringilla augue. Etiam faucibus rutrum enim. - Maecenas varius massa sit amet nulla. Nunc sit amet mauris. Nunc eu purus a sapien aliquam aliquam. Donec sodales commodo dolor. Fusce volutpat. Sed quis ipsum nec dolor facilisis facilisis. Fusce leo massa, tincidunt in, sodales eu, sodales nec, libero. Etiam vehicula. Ut egestas. Ut consectetuer dolor ac est. Phasellus viverra euismod nisl. Nunc ut felis nec erat vulputate ullamcorper. Praesent rhoncus cursus nunc. Quisque elementum. Etiam euismod erat sit amet lorem. -

-
-
-
-
".(($pcount == 1) ? ' Party' : ' Parties'); ?> -
- iCALRSS -
+
+ + Edit + +
+
+
+
".(($pcount == 1) ? ' Party' : ' Parties'); ?> +
+ iCALRSS
-
-
".(($ucount == 1) ? ' Partygoer' : ' Partygoers'); ?> -
- RSS -
-
-

".(($days_left == 1) ? ' Day' : ' Days'); ?> left until Firefox 2!
-
\ No newline at end of file +
+
".(($ucount == 1) ? ' Partygoer' : ' Partygoers'); ?> +
+ RSS +
+
+
+
".(($days_left == 1) ? ' Day' : ' Days'); ?> left until Firefox 2! +
+
+
\ No newline at end of file diff --git a/mozilla/webtools/partytool/views/parties/invited.thtml b/mozilla/webtools/partytool/views/parties/invited.thtml index 3be855a1553..edbf108d8e0 100755 --- a/mozilla/webtools/partytool/views/parties/invited.thtml +++ b/mozilla/webtools/partytool/views/parties/invited.thtml @@ -1,5 +1,5 @@

Confirm Invite

- +

You've been invited to attend . To join this party please select one of the options below, or click here to cancel this invitation.

@@ -29,4 +29,8 @@
+ +

You've been invited to attend . + To join this party, click here, or cancel this invitation by clicking here.

\ No newline at end of file diff --git a/mozilla/webtools/partytool/views/parties/view.thtml b/mozilla/webtools/partytool/views/parties/view.thtml index b2db2e59726..7972a06b311 100755 --- a/mozilla/webtools/partytool/views/parties/view.thtml +++ b/mozilla/webtools/partytool/views/parties/view.thtml @@ -58,7 +58,7 @@ Invite a guest -

Photos

+

Photos Atom

No photos yet. Tag your flickr pictures with to display them here.

@@ -71,7 +71,7 @@
-

Comments

+

Comments RSS

url('/parties/view/all/'.$prev).'">Previous Page '; + echo '« Previous Page '; + if (isset($prev) && isset($next)) + echo ' | '; if (isset($next)) - echo 'Next Page'; + echo 'Next Page »'; $i = 0; foreach ($parties as $party): ?>
@@ -127,8 +129,10 @@
url('/parties/view/all/'.$prev).'">Previous Page '; + echo '« Previous Page '; + if (isset($prev) && isset($next)) + echo ' | '; if (isset($next)) - echo 'Next Page'; + echo 'Next Page »'; endif;?> diff --git a/mozilla/webtools/partytool/views/users/view.thtml b/mozilla/webtools/partytool/views/users/view.thtml index 6c3136074cf..59856afe70b 100755 --- a/mozilla/webtools/partytool/views/users/view.thtml +++ b/mozilla/webtools/partytool/views/users/view.thtml @@ -1,6 +1,6 @@ ".$user['User']['name'].""; + echo "

".$user['User']['name']."


"; if ($user['User']['showemail'] == 1 && @$_SESSION['User']) echo "Email: ".$user['User']['email']."
"; @@ -29,14 +29,15 @@ $i = 0; foreach ($hparties as $party) { - echo ''.$party['name'].''; + echo ''.$party['parties']['name'].''; echo ($i < $c) ? ', ' : '
'; $i++; } } ?> - + +