make new event work, sort of

This commit is contained in:
Evan Prodromou 2011-03-09 02:48:14 -05:00
parent ca36dfecf9
commit 53e67b5ed5
3 changed files with 39 additions and 9 deletions

View File

@ -58,7 +58,7 @@ class EventPlugin extends MicroappPlugin
{ {
$schema = Schema::get(); $schema = Schema::get();
$schema->ensureTable('event', Happening::schemaDef()); $schema->ensureTable('happening', Happening::schemaDef());
$schema->ensureTable('rsvp', RSVP::schemaDef()); $schema->ensureTable('rsvp', RSVP::schemaDef());
return true; return true;

View File

@ -66,7 +66,7 @@ class EventForm extends Form
function formClass() function formClass()
{ {
return 'form_settings ajax'; return 'form_settings ajax-notice';
} }
/** /**

View File

@ -146,7 +146,7 @@ class NeweventAction extends Action
throw new ClientException(_('Event must have an end time.')); throw new ClientException(_('Event must have an end time.'));
} }
$saved = Event::saveNew($this->user->getProfile(), $saved = Happening::saveNew($this->user->getProfile(),
$this->start_time, $this->start_time,
$this->end_time, $this->end_time,
$this->title, $this->title,
@ -159,7 +159,21 @@ class NeweventAction extends Action
return; return;
} }
if ($this->boolean('ajax')) {
header('Content-Type: text/xml;charset=utf-8');
$this->xw->startDocument('1.0', 'UTF-8');
$this->elementStart('html');
$this->elementStart('head');
// TRANS: Page title after sending a notice.
$this->element('title', null, _('Event saved'));
$this->elementEnd('head');
$this->elementStart('body');
$this->showNotice($saved);
$this->elementEnd('body');
$this->elementEnd('html');
} else {
common_redirect($saved->bestUrl(), 303);
}
} }
/** /**
@ -200,4 +214,20 @@ class NeweventAction extends Action
return false; return false;
} }
} }
/**
* Output a notice
*
* Used to generate the notice code for Ajax results.
*
* @param Notice $notice Notice that was saved
*
* @return void
*/
function showNotice($notice)
{
$nli = new NoticeListItem($notice, $this);
$nli->show();
}
} }