diff --git a/admin/conference.php b/admin/conference.php
new file mode 100644
index 0000000..3b2a57a
--- /dev/null
+++ b/admin/conference.php
@@ -0,0 +1,211 @@
+.
+
+require 'load.php';
+
+// check if you can see the backend
+require_permission( 'backend' );
+
+// current Conference infos
+$conference = null;
+$conference_ID = null;
+
+// known text fields
+$TEXT_FIELDS = [
+ Conference::TITLE => __( "Titolo" ),
+ Conference::ACRONYM => __( "Titolo breve" ),
+ Conference::SUBTITLE => __( "Sottotitolo" ),
+ Conference::UID => __( "Codice" ),
+ Conference::EVENTS_URL => __( "URL Eventi" ),
+ Conference::PERSONS_URL => __( "URL Utenti" ),
+ Conference::START => __( "Inizio" ) . ' YYYY-MM-DD HH:ii:ss',
+ Conference::END => __( "Fine" ) . ' YYYY-MM-DD HH:ii:ss',
+];
+
+// check if we should create a new Conference
+if( isset( $_GET['create'] ) || isset( $_POST['create'] ) ) {
+
+ // check if you can create a new Conference
+ require_permission( 'add-conference' );
+
+// check if we are editing an already existing Conference
+} else {
+
+ // check the current Conference
+ $conference_ID = $_GET['id'] ?? $_POST['id'] ?? 0;
+
+ // check if the ID has sense
+ if( !$conference_ID ) {
+ error_die( "missing conference id" );
+ }
+
+ // query the Conference
+ $conference = ( new QueryConference() )
+ ->whereConferenceID( $conference_ID )
+ ->queryRow();
+
+ // no Conference no party
+ if( !$conference ) {
+
+ // I do not want to spend so much time for this
+ http_response_code( 404 );
+ echo "Missing Conference";
+ exit;
+
+ }
+
+ // check if I'm allowed to edit this conference
+ if( !$conference->isConferenceEditable() ) {
+
+ // no way
+ missing_privileges();
+ }
+}
+
+// check if you want to save the Conference
+if( is_action( 'save-conference' ) ) {
+
+ // receive data to be saved
+ $data = [];
+ foreach( $TEXT_FIELDS as $field => $label ) {
+
+ // something can be missing
+ $value = $_POST[ $field ] ?? '';
+
+ // cast everything to string
+ // note that it will be escaped later by the Query class
+ $data[ $field ] = (string) $value;
+ }
+
+ // prepare to query
+ $query = new QueryConference();
+
+ // here the user pressed the 'Save' button
+ if( $conference ) {
+
+ // save existing
+ $query->whereConference( $conference )
+ ->update( $data );
+ } else {
+
+ // create a new one
+ $query->insertRow( $data );
+
+ // gotcha!
+ $conference_ID = last_inserted_ID();
+ }
+
+ // POST -> redirect -> GET
+ http_redirect( Conference::editURL( [
+ 'id' => $conference_ID,
+ ] ) );
+}
+
+// events list
+$events = [];
+if( $conference ) {
+
+ // query all the visible Events related to this Conference
+ $events = ( new QueryEvent() )
+ ->whereConference( $conference )
+ ->queryGenerator();
+}
+
+Header::spawn( null, [
+ 'title' => __( "Conferenza" ),
+] );
+?>
+
+
+
+
= __( "Eventi" ) ?>
+
+
+
+
+
+
+ isEventEditable() ): ?>
+ - = HTML::a(
+ $event->getEventEditURL(),
+ esc_html( $event->getEventTitle() )
+ ) ?>
+
+
+
+
+
+
+ - = HTML::a(
+ Event::editURL( [
+ 'conference_uid' => $conference->getConferenceUID(),
+ ] ),
+ __( "Aggiungi Evento" )
+ ) ?>
+
+
+
+
+
+
+
+
+
+.
-
-require 'load.php';
-
-inject_in_module('header', function() {
- echo "\n\t";
-} );
-
-Header::spawn('credits');
-?>
-
-
= __("Di seguito sono riportati gli elementi utilizzati in questo sito, tra i migliori esempi di software libero e open source.") ?>
-
-
-
-
-
-
getLink()
- ) ?>
-
-
-
-
-
= __("Materiale") ?>
-
-
-
-
- - getURL(), $license->getShort() )
- ) ?>
-
-
-
-
-
- false] );
diff --git a/admin/event-edit.php b/admin/event-edit.php
index b3f670f..89db424 100644
--- a/admin/event-edit.php
+++ b/admin/event-edit.php
@@ -1,628 +1,635 @@
.
/*
* Event edit
*
* From this page you can create/edit an User and assign some skills/interests etc.
*/
// load configurations and framework
require 'load.php';
// inherit the Conference or specify one
-$conference_uid = CURRENT_CONFERENCE_UID;
-if( isset( $_REQUEST['conference'] ) ) {
- $conference_uid = $_REQUEST['conference'];
-}
+$conference_uid = $_GET['conference_uid'] ?? $_POST['conference_uid'] ?? CURRENT_CONFERENCE_UID;
// check if the Conference exists
-$conference = FullConference::factoryFromUID( $conference_uid )
+$conference = ( new QueryConference() )
+ ->whereConferenceUID( $conference_uid )
->queryRow();
+// no Conference no party
if( !$conference ) {
+ error( "missing conference with UID $conferene_uid" );
die_with_404();
}
// retrieve the Event (if existing)
$event = null;
-if( isset( $_GET['uid'] ) ) {
+if( isset( $_GET['id'] ) ) {
+
+ // no Event no party
$event = ( new QueryEvent() )
->whereConference( $conference )
->joinConference()
->joinChapter()
- ->whereEventUID( $_GET['uid'] )
+ ->whereEventID( $_GET['id'] )
->queryRow();
+ // no Event no party
if( !$event ) {
die_with_404();
}
+ // no editable no party
if( !$event->isEventEditable() ) {
- error_die("Can't edit event");
+ missing_privileges();
}
} else {
// check if there are permissions to add event
if( !has_permission( 'add-event' ) ) {
- die( 'missing permissions' );
+ missing_privileges();
}
}
$warning = null;
+// check if the user submitted a form
+// check which one
if( $_POST ) {
+ // the user is submitting the save form
if( is_action( 'save-event' ) ) {
$conference_ID = $conference->getConferenceID();
$data = [];
$data[] = new DBCol( Event::TITLE, $_POST['title'], 's' );
$data[] = new DBCol( Event::UID, $_POST['uid'], 's' );
$data[] = new DBCol( Event::LANGUAGE, $_POST['language'], 's' );
$data[] = new DBCol( Event::SUBTITLE, $_POST['subtitle'], 's' );
$data[] = new DBCol( Event::START, $_POST['start'], 's' );
$data[] = new DBCol( Event::END, $_POST['end'], 's' );
$data[] = new DBCol( Event::IMAGE, $_POST['image'], 'snull' );
$data[] = new DBCol( Chapter::ID, $_POST['chapter'], 'd' );
$data[] = new DBCol( Room::ID, $_POST['room'], 'd' );
$data[] = new DBCol( Track::ID, $_POST['track'], 'd' );
$data[] = new DBCol( Conference::ID, $conference_ID, 'd' );
// for each language save the fields
foreach( all_languages() as $lang ) {
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
$data[] = new DBCol( $field, $value, 'snull' );
}
}
// convert empty strings to NULL, if possible
foreach( $data as $row ) {
$row->promoteNULL();
}
if( $event ) {
// update the existing Event
( new QueryEvent() )
->whereEvent( $event )
->update( $data );
} else {
// insert a new Event
Event::factory()
->insertRow( $data );
}
$id = $event ? $event->getEventID() : last_inserted_ID();
// get the updated Event
$event = FullEvent::factory()
->whereInt( Event::ID, $id )
->queryRow();
// POST-redirect-GET
http_redirect( $event->getFullEventEditURL(), 303 );
}
/**
* Change the Image
*/
if( $event && is_action( 'change-image' ) ) {
// prepare the image uploader
$image = new FileUploader( 'image', [
'category' => 'image',
'override-filename' => "event-" . $event->getEventUID(),
] );
// prepare the image pathnames
$img_url = $event->getConferenceUID() . _ . 'images';
$img_path = ABSPATH . __ . $event->getConferenceUID() . __ . 'images';
// really upload that shitty image somewhere
if( $image->fileChoosed() ) {
$ok = $image->uploadTo( $img_path, $status, $filename, $ext );
if( $ok ) {
// now update
( new QueryEvent() )
->whereEvent( $event )
->update( [
'event_img' => $img_url . "/$filename.$ext",
] );
// POST-redirect-GET
http_redirect( $event->getFullEventEditURL(), 303 );
} else {
$warning = $image->getErrorMessage();
}
}
}
/*
* Add the user
*/
if( $event && is_action( 'add-user' ) && isset( $_POST['user'] ) ) {
// Add user
$user = User::factoryFromUID( $_POST['user'] )
->select( User::ID )
->queryRow();
if( $user ) {
( new QueryEventUser() )
->whereEvent( $event )
->whereUser( $user )
->delete();
( new QueryEventUser() )->insertRow( [
new DBCol( Event::ID, $event->getEventID(), 'd' ),
new DBCol( User ::ID, $user->getUserID(), 'd' ),
new DBCol( EventUser::ORDER, 0, 'd' ),
] );
}
}
/**
* Update an user order
*/
if( $event && is_action( 'update-user' ) && isset( $_POST['user'] ) ) {
$user = User::factoryFromUID( $_POST['user'] )
->select( User::ID )
->queryRow();
if( $user ) {
if ( !empty( $_POST['delete'] ) ) {
// Delete user
EventUser::delete( $event->getEventID(), $user->getUserID() );
} elseif( isset( $_POST['order'] ) ) {
// change order
EventUser::factory()
->whereInt( Event::ID, $event->getEventID() )
->whereInt( User ::ID, $user->getUserID() )
->update( [
new DBCol( EventUser::ORDER, $_POST['order'], 'd')
] );
}
}
}
// post -> redirect -> get (no: it hide errors)
// http_redirect( $_SERVER[ 'REQUEST_URI' ], 303 );
}
if( $event ) {
Header::spawn( null, [
'title' => sprintf(
__("Modifica %s: %s"),
$event->getChapterName(),
$event->getEventTitle()
),
] );
} else {
Header::spawn( null, [
'title' => sprintf(
__( "Aggiungi %s" ),
__( "Evento" )
),
] );
}
?>
= esc_html( $warning ) ?>
= HTML::a(
$conference->getConferenceURL(),
esc_html( $conference->getConferenceTitle() ) . icon( 'home', 'left' )
) ?>
= HTML::a(
// href
$event->getEventURL(),
// text
__( "Vedi" ) . icon( 'account_box', 'left' )
) ?>
= HTML::a(
ROOT . '/2016/user-edit.php',
sprintf(
__( "Aggiungi %s" ),
sprintf(
__( "Nuovo %s" ),
__( "Utente" )
)
)
) ?>
factoryUserByEvent()
->select( [
User::UID,
EventUser::ORDER,
] )
->defaultClass( EventUser::class )
->orderBy( EventUser::ORDER )
->queryGenerator();
?>
valid() ): ?>
$user ): ?>
.
-
-require 'load.php';
-
-$conference = FullConference::factoryFromUID( CURRENT_CONFERENCE_UID )
- ->queryRow();
-
-if( !$conference ) {
- die_with_404();
-}
-
-if( !isset( $_GET['uid'] ) ) {
- die_with_404();
-}
-
-$event = FullEvent::factoryByConferenceAndUID(
- $conference->getConferenceID(),
- $_GET['uid']
-)->queryRow();
-
-if( !$event ) {
- die_with_404();
-}
-
-$args = [
- 'title' => sprintf(
- __("%s: %s"),
- $event->getChapterName(),
- $event->getEventTitle()
- ),
- 'url' => $event->getEventURL( true ),
-];
-
-if( $event->hasEventImage() ) {
- $args['og'] = [
- 'image' => $event->getEventImage( true ),
- ];
-}
-
-Header::spawn( null, $args );
-?>
-
- isEventEditable() ): ?>
-
= HTML::a(
- $event->getFullEventEditURL(),
- __("Modifica") . icon('edit', 'left')
- ) ?>
- isEventTranslatable() ): ?>
-
= HTML::a(
- $event->getEventTranslateURL(),
- __("Traduci") . icon('edit', 'left')
- ) ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- = icon('folder', 'left'); echo __("Tema") ?> |
-
- = $event->getTrackName() ?>
- = $event->getTrackLabel() ?>
- |
-
-
- = icon('room', 'left'); echo __("Dove") ?> |
-
- = $event->getRoomName() ?>
- @ = HTML::a(
- $conference->getLocationGeoOSM(),
- $conference->getLocationName(),
- $conference->getLocationAddress(),
- null,
- 'target="_blank"'
- ) ?>
- = $conference->getLocationAddress() ?>
- |
-
-
- = icon('access_time', 'left'); echo __("Quando") ?> |
-
- = $event->getEventHumanStart() ?>
- getEventStart('d/m/Y'),
- $event->getEventStart('H:i')
- ) ?>
- = HTML::a(
- $event->getEventCalURL(),
- __( "Scarica promemoria calendario" )
- ) ?>
- |
-
-
-
-
-
-
-
- hasEventAbstract() ): ?>
-
-
-
= __("Abstract") ?>
- = $event->getEventAbstractHTML( ['p' => 'flow-text'] ) ?>
-
-
-
-
-
- hasEventDescription() ): ?>
-
-
-
= __("Descrizione") ?>
- = $event->getEventDescriptionHTML( ['p' => 'flow-text'] ) ?>
-
-
-
-
-
- hasEventNote() ): ?>
-
-
-
= __("Note") ?>
- = $event->getEventNoteHTML( ['p' => 'flow-text'] ) ?>
-
-
-
-
-
- factorySharebleByEvent()
- ->queryGenerator();
- ?>
- valid() ): ?>
-
-
-
= __("Materiale") ?>
-
-
-
- isSharableDownloadable() ): ?>
-
- getSharablePath(),
- icon('attachment', 'left') . $sharable->getSharableTitle(['prop' => true]),
- null,
- null,
- 'target="_blank"'
- ),
- $sharable->getSharableLicense()->getLink()
- ) ?>
-
- isSharableVideo() ): ?>
-
-
-
-
- getSharablePath(),
- icon('share', 'left') . $sharable->getSharableTitle( ['prop' => true] ),
- null,
- null,
- 'target="_blank"'
- ),
- $sharable->getSharableLicense()->getLink()
- ) ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
= __("Relatori") ?>
-
- factoryUserByEvent()
- ->queryGenerator(); ?>
-
- valid() ): ?>
-
-
-
-
-
-
- = HTML::a(
- $user->getUserURL(),
- "
" . esc_html( $user->getUserFullname() ) . "
",
- sprintf(
- __("Profilo di %s"),
- $user->getUserFullname()
- ),
- 'valign'
- ) ?>
-
-
-
-
-
-
-
= __("L'elenco dei relatori non è ancora noto.") ?>
-
-
-
-
- factoryPreviousFullEvent()
- ->select('event_uid', 'event_title', 'chapter_uid', 'conference_uid', 'event_start')
- ->limit(1)
- ->queryRow();
-
- $next = $event->factoryNextFullEvent()
- ->select('event_uid', 'event_title', 'chapter_uid', 'conference_uid', 'event_start')
- ->limit(1)
- ->queryRow();
- ?>
-
-
-
-
-
-
-
-
= icon('navigate_before'); echo __("Preceduto da") ?>
-
- = HTML::a(
- $previous->getEventURL(),
- esc_html( $previous->getEventTitle() )
- ) ?>
-
-
-
-
-
-
-
= __("A seguire"); echo icon('navigate_next') ?>
-
- = HTML::a(
- $next->getEventURL(),
- esc_html( $next->getEventTitle() )
- ) ?>
-
-
-
-
-
-
-
-
-
-
-.
class Footer {
- static function spawn( $args = [] ) {
+ public static function spawn( $args = [] ) {
+
+ // merge default arguments
$args = array_replace( [
'home' => true
], $args );
?>
-