return $this->url;
}
+ public function getUri()
+ {
+ return $this->uri;
+ }
+
function getNotice()
{
- return Notice::getKV('uri', $this->uri);
+ return Notice::getKV('uri', $this->getUri());
}
- static function fromNotice($notice)
+ static function fromNotice(Notice $notice)
{
- return Happening::getKV('uri', $notice->uri);
+ return Happening::getKV('uri', $notice->getUri());
}
function getRSVPs()
);
}
- function saveNew($profile, $event, $verb, $options=array())
+ static public function beforeSchemaUpdate()
+ {
+ $table = strtolower(get_called_class());
+ $schema = Schema::get();
+ $schemadef = $schema->getTableDef($table);
+
+ // 2015-12-31 RSVPs refer to Happening by event_uri now, not event_id. Let's migrate!
+ if (isset($schemadef['fields']['event_uri'])) {
+ // We seem to have already migrated, good!
+ return;
+ }
+
+ // this is a "normal" upgrade from StatusNet for example
+ echo "\nFound old $table table, upgrading it to add 'event_uri' field...";
+
+ $schemadef['fields']['event_uri'] = array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'Event URI');
+ $schema->ensureTable($table, $schemadef);
+
+ $rsvp = new RSVP();
+ $rsvp->find();
+ while ($rsvp->fetch()) {
+ $event = Happening::getKV('id', $rsvp->event_id);
+ if (!$event instanceof Happening) {
+ continue;
+ }
+ $orig = clone($rsvp);
+ $rsvp->event_uri = $event->uri;
+ $rsvp->updateWithKeys($orig);
+ }
+ print "DONE.\n";
+ print "Resuming core schema upgrade...";
+ }
+
+ function saveNew(Profile $profile, $event, $verb, array $options = array())
{
if (array_key_exists('uri', $options)) {
$other = RSVP::getKV('uri', $options['uri']);