Abspeichern des Namen funktioniert

master
root 2017-09-27 22:17:59 +02:00
parent eda1e4d82e
commit f103b057aa
6 changed files with 1985 additions and 1938 deletions

5
includes/.htaccess Executable file
View File

@ -0,0 +1,5 @@
## Default .htaccess file
# Displaying PHP errors
php_flag display_errors on
php_value error_reporting 6143

View File

@ -29,6 +29,7 @@ class Comment extends ContextSource {
/* START Anpassung znilwiki */
public $CommentUsernameKOK = null; /* 25.10.2013 von Kai-Ole Kirsten */
public $UsernameKOK = null; /* 25.10.2013 von Kai-Ole Kirsten */
/* ENDE Anpassung znilwiki */
/**
@ -288,23 +289,37 @@ class Comment extends ContextSource {
wfSuppressWarnings();
$commentDate = date( 'Y-m-d H:i:s' );
wfRestoreWarnings();
/*if ( $this->getUser()->isLoggedIn() ) {
$kok_username = $user->getName();
} else {
$kok_username = $this->CommentUsernameKOK;
$kok_username = preg_replace('/<.*>/i', '', $kok_username);
$kok_username = preg_replace('/[^A-Za-z0-9. \-\@]/i', '', $kok_username);
$kok_username = str_replace("1'1", '', $kok_username);
$kok_username = str_replace('USER_NAME', '', $kok_username);
$kok_username = str_replace('DESC', '', $kok_username);
$kok_username = str_replace('(*)', '', $kok_username);
$kok_username = str_replace('EXEC', '', $kok_username);
}*/
// ##START## 2017-09-27 von Bernhard Linz
// if ( $this->getUser()->isLoggedIn() ) {
// $kok_username = $user->getName();
// $kok_username = $this->UsernameKOK;
// } else {
$kok_username = preg_match('/(?<=#START#).*?(?=#ENDE#)/s', $text, $result);
$kok_username = $result[0];
$text = str_replace('#START#' . $result[0] . '#ENDE#', '', $text);
// $kok_username = str_replace('#START#', '', $kok_username);
// $kok_username = str_replace('#ENDE#', '', $kok_username);
if ( $kok_username == "" ) {
$kok_username = $user->getName();
}
if ( $kok_username == "none" ) {
$kok_username = $user->getName();
}
// $kok_username = preg_replace('/<.*>/i', '', $kok_username);
// $kok_username = preg_replace('/[^A-Za-z0-9. \-\@]/i', '', $kok_username);
// $kok_username = str_replace("1'1", '', $kok_username);
// $kok_username = str_replace('USER_NAME', '', $kok_username);
// $kok_username = str_replace('DESC', '', $kok_username);
// $kok_username = str_replace('(*)', '', $kok_username);
// $kok_username = str_replace('EXEC', '', $kok_username); */
// }
// ##ENDE## 2017-09-27 von Bernhard Linz
$dbw->insert(
'Comments',
array(
'Comment_Page_ID' => $page->id,
'Comment_Username' => $user->getName(),
//'Comment_Username' => $user->getName(),
'Comment_Username' => $kok_username,
'Comment_user_id' => $user->getId(),
'Comment_Text' => $text,
'Comment_Date' => $commentDate,

View File

@ -576,7 +576,13 @@ class CommentsPage extends ContextSource {
htmlspecialchars( $login_title->getFullURL() )
)->text() . '</div>' . "\n";
}
// ##START## 27.09.2017 von Bernhard Linz
if ( !$this->getUser()->isLoggedIn() ) {
$output .= '<p><label for="txt_username">Name oder Emailadresse:</label><br /><input style="margin: 0px; width: 530px;" type="text" name="txt_username" id="txt_username" />' . "</p>";
} else {
$output .= '<p>Benutzer:<b>' . $this->getUser()->getName() . '</b></p>';
}
// ##ENDE## 27.09.2017 von Bernhard Linz
$output .= '<textarea name="commentText" id="comment" rows="5" cols="64"></textarea>' . "\n";
$output .= '<div class="c-form-button"><input type="button" value="' .
wfMessage( 'comments-post' )->plain() . '" class="site-button" /></div>' . "\n";

View File

@ -46,6 +46,10 @@ class CommentBlockAPI extends ApiBase {
'commentID' => array(
ApiBase::PARAM_REQUIRED => true,
ApiBase::PARAM_TYPE => 'integer'
),
'UsernameKOK' => array(
ApiBase::PARAM_REQUIRED => false,
ApiBase::PARAM_TYPE => 'string'
)
);
}

View File

@ -41,6 +41,8 @@ class CommentSubmitAPI extends ApiBase {
}
}
$kok_username = $this->getMain()->getVal( 'UsernameKOK' );
$result = $this->getResult();
$result->addValue( $this->getModuleName(), 'ok', 'ok' );
return true;
@ -67,6 +69,10 @@ class CommentSubmitAPI extends ApiBase {
'commentText' => array(
ApiBase::PARAM_REQUIRED => true,
ApiBase::PARAM_TYPE => 'string'
),
'UsernameKOK' => array(
ApiBase::PARAM_REQUIRED => false,
ApiBase::PARAM_TYPE => 'string'
)
);
}

View File

@ -136,12 +136,23 @@ var Comment = {
parentID = document.commentForm.commentParentId.value;
}
var commentText = document.commentForm.commentText.value;
/* ## START ## 27.09.2017 von Bernhard Linz: Prüfen ob txt_username einen Wert enthält. wenn nicht, ignorieren */
var UsernameKOK;
if (document.getElementById('txt_username')) {
// UsernameKOK = document.commentform.txt_username.value; /* Wert aus txt_username in die Variable übergeben, welche später an Comments_AjaxFunctions.php übergeben wird */
UsernameKOK = document.getElementById('txt_username').value;
} else {
UsernameKOK = "none"; /* Wenn Feld nicht existiert Variable auf "none" setzen */
}
commentText = commentText + "#START#" + UsernameKOK + "#ENDE#";
//window.alert( UsernameKOK );
/* ## ENDE ## 27.09.2017 von Bernhard Linz */
( new mw.Api() ).postWithToken( 'csrf', {
action: 'commentsubmit',
pageID: pageID,
parentID: parentID,
commentText: commentText
//UsernameKOK: UsernameKOK
} ).done( function( response ) {
if ( response.commentsubmit && response.commentsubmit.ok ) {
document.commentForm.commentText.value = '';