0, 'error' => 'Kein Server ausgewählt' ] ) ); } if ( empty( $idLong ) ){ die( json_encode( [ 'status' => 0, 'error' => 'Keine Identität ausgewählt' ] ) ); } if ( empty( $_REQUEST['eventId'] ) || empty( $_REQUEST['votingId'] ) ){ die( json_encode( [ 'status' => 0, 'error' => 'Daten unvollständig' ] ) ); } $msg = new ParTCP_Outgoing_Message( $serverLong, $idLong, 'voting-comments-request' ); $msg->set( 'Event-Id', $_REQUEST['eventId'] ); $msg->set( 'Voting-Id', $_REQUEST['votingId'] ); $response = pas_check_response( $msg->send() ); if ( is_string( $response ) ){ die( json_encode( [ 'status' => 0, 'error' => $response ] ) ); } $generalComments = $response->get('General-Comments'); $optionComments = $response->get('Option-Comments'); //$result = var_export( $generalComments, TRUE ) . var_export( $optionComments, TRUE ); $result = ''; if ( $generalComments ){ $result = "ALLGEMEINE KOMMENTARE\n\n" . implode( "\n\n", $generalComments ) . "\n\n"; } if ( ! empty( $optionComments ) ){ ksort( $optionComments, SORT_NATURAL ); foreach ( $optionComments as $option => $data ){ $number = substr( $option, 7 ) + 1; $result .= "\nKOMMENTARE ZU OPTION {$number}\n\n"; ksort( $data, SORT_NATURAL ); foreach ( $data as $vote => $comments ){ $result .= '# ' . substr( $vote, 5 ) . " #\n\n" . implode( "\n\n", $comments ) . "\n\n"; } } } if ( ! $result ){ die( json_encode( [ 'status' => 0, 'error' => 'Keine Kommentare vorhanden' ] ) ); } echo json_encode( [ 'status' => 1, 'file_name' => 'comments ' . basename( $_REQUEST['eventId'] ) . " {$_REQUEST['votingId']}.txt", 'file_data' => $result ] ); // end of file ajax/export_voting_comments.php