diff --git a/2016/event-translate.php b/2016/event-translate.php new file mode 100644 index 0000000..8468de8 --- /dev/null +++ b/2016/event-translate.php @@ -0,0 +1,119 @@ +. + +// load the framework +require 'load.php'; + +// only allow translators +// read the Event ID +$id = isset( $_GET['id'] ) + ? (int) $_GET['id'] + : null; + +// require the Event ID +if( !$id ) { + die_with_404(); +} + +// query the Event +$event = ( new QueryEvent() ) + ->whereEventID( $id ) + ->joinConference() + ->joinTrack() + ->queryRow(); + +// no Event no party +if( !$event ) { + die_with_404(); +} + +// no permissions no party +if( !$event->isEventEditable() && !has_permission( 'translate' ) ) { + error_die( 'not enough permissions' ); +} + +$DEFAULT_LANGUAGE = RegisterLanguage::instance()->getDefault(); + +// register form action +if( is_action( 'translate-event' ) ) { + + $tosave = []; + + // for each language save the fields + foreach( all_languages() as $lang ) { + + // do not allow to edit the default language + if( $lang === $DEFAULT_LANGUAGE ) { + continue; + } + + foreach( Event::fields_i18n() as $i18n_column => $label ) { + // generic column name in this language + $field = $i18n_column . '_' . $lang->getISO(); + + // sent column value + $value = $_POST[ $field ] ?? null; + + // prepare to be saved + $tosave[] = new DBCol( $field, $value, 'snull' ); + } + } + + // update the fields + ( new QueryEvent() ) + ->whereEvent( $event ) + ->update( $tosave ); +} + +// print the site header +Header::spawn( null, [ + 'title' => $event->getEventTitle(), +] ); +?> + +
+ +

+

+ +
+ + +
+ +
+ +
+
+ +
+
+ +
+ +