0, 'error' => 'Kein Server ausgewählt' ] ) ); } if ( empty( $idLong ) ){ die( json_encode( [ 'status' => 0, 'error' => 'Keine Identität ausgewählt' ] ) ); } if ( empty( $_REQUEST['eventId'] ) ){ die( json_encode( [ 'status' => 0, 'error' => 'Daten unvollständig: ' . var_export( $_REQUEST, TRUE ) ] ) ); } $fields = [ 'name' => [ 'fld' => 'name' ], 'description' => [ 'fld' => 'description' ], 'short_description' => [ 'fld' => 'shortDescription' ], 'link_url' => [ 'fld' => 'linkUrl' ], 'estimated_turnout' => [ 'fld' => 'estimated_turnout', 'int' => 1 ], 'is_demo' => [ 'fld' => 'is_demo' ], 'is_live' => [ 'fld' => 'is_live' ], 'issue_service.host' => [ 'fld' => 'issueServiceHost' ], 'issue_service.id_provider' => [ 'fld' => 'issueServiceIdProvider' ], 'issue_service.terms' => [ 'fld' => 'issueServiceTerms' ], 'lot_code_rules.final_length' => [ 'fld' => 'lotCodeFinalLength', 'int' => 1 ], 'lot_code_rules.char_list' => [ 'fld' => 'lotCodeCharList' ], 'lot_code_rules.crc_length' => [ 'fld' => 'lotCodeCrcLength', 'int' => 1 ], 'lot_code_rules.group_length' => [ 'fld' => 'lotCodeGroupLength', 'int' => 1 ], 'lot_code_rules.group_separator' => [ 'fld' => 'lotCodeGroupSeparator' ], 'naming_rules.prefix' => [ 'fld' => 'userNamePrefix' ], 'naming_rules.counter_width' => [ 'fld' => 'userNameCounterWidth', 'int' => 1 ], 'naming_rules.crc_length' => [ 'fld' => 'userNameCrcLength', 'int' => 1 ], 'naming_rules.group_length' => [ 'fld' => 'userNameGroupLength', 'int' => 1 ], 'naming_rules.group_separator' => [ 'fld' => 'userNameGroupSeparator' ], 'credential_rules.final_length' => [ 'fld' => 'credentialFinalLength', 'int' => 1 ], 'credential_rules.char_list' => [ 'fld' => 'credentialCharList' ], 'credential_rules.crc_length' => [ 'fld' => 'credentialCrcLength', 'int' => 1 ], 'credential_rules.group_length' => [ 'fld' => 'credentialGroupLength', 'int' => 1 ], 'credential_rules.group_separator' => [ 'fld' => 'credentialGroupSeparator' ], 'active_sessions' => [ 'fld' => 'activeSessions', 'list' => 1 ], 'badge_categories' => [ 'fld' => 'badge_categories' ], ]; foreach ( $fields as $key => $field ){ $name = $field['fld']; if ( isset( $_REQUEST[ $name ] ) ){ if ( ! empty( $field['int'] ) ){ $value = (int) $_REQUEST[ $name ]; } elseif ( ! empty( $field['list'] ) ){ $value = array_map( 'trim', explode( "\n", $_REQUEST[ $name ] ) ); } elseif ( $name == 'issueServiceTerms' ){ $lines = explode( "\n", $_REQUEST[ $name ] ); $value = []; foreach ( $lines as $line ){ $parts = array_map( 'trim', explode( ':', $line ) ); if ( ! empty( $parts[1] ) ){ $value[ $parts[0] ] = $parts[1]; } } } elseif ( $name == 'badge_categories' ){ $value = []; foreach ( $_REQUEST['badge_categories'] as $category ){ if ( empty( $category['mapping'] ) ){ unset( $category['mapping'] ); } else { $category['mapping'] = array_map( 'trim', explode( ',', $category['mapping'] ) ); } $category['voting_member'] = (bool) $category['voting_member']; $value[] = $category; } } else { $value = $_REQUEST[ $name ]; } $parts = explode( '.', $key ); if ( empty( $parts[1] ) ){ $data[ $key ] = $value; } else { $data[ $parts[0] ][ $parts[1] ] = $value; } } } if ( empty( $data ) ){ die( json_encode( [ 'status' => 0, 'error' => 'Daten unvollständig: ' . var_export( $_REQUEST, TRUE ) ] ) ); } $msg = new ParTCP_Outgoing_Message( $serverLong, $idLong, 'event-update-request' ); $msg->set( 'Event-Id', $_REQUEST['eventId'] ); $msg->set( 'Event-Data', $data ); $msg->set_date(); $response = pas_check_response( $msg->send() ); if ( is_string( $response ) ){ die( json_encode( [ 'status' => 0, 'error' => $response ] ) ); } echo json_encode( [ 'status' => 1, 'error' => '' ] ); // end of file ajax/update_event.php