(sending again, my last message didnt appear in the list) ------------------- In my own special page, I've made a custom query (e.g., DELETE * from table). I want to display an HTML link, which when clicked by the user viewing that page executes that SQL query. How can I do that?
Hi,
I would made it with a url parameter:
$skin = $wgUser->getSkin(); $table = 'mytable'; $id = 0; $wgOut->addHtml( $skin->link( $this->getTitle(), wfMsg('mymessage'), array(), array( 'action' => 'delete', 'table' => $table, 'id' => $id ) ) );
...
$action = htmlentities( $wgRequest->getText( 'action' ) ); $table = htmlentities( $wgRequest->getText( 'table' ) ); $id = htmlentities( $wgRequest->getText( 'id' ) );
if( $action == 'delete' AND ( $table == 'mytable' ) ) $this->delete( $table, $id );
...
private function delete( $table, $id ) { $dbw = wfGetDB( DB_MASTER ); $dbw->delete( $table, array( 'id' => $id ) ); }
Viele Grüße Jan
-----Ursprüngliche Nachricht----- Von: mediawiki-l-bounces@lists.wikimedia.org [mailto:mediawiki-l-bounces@lists.wikimedia.org] Im Auftrag von Eric K Gesendet: Freitag, 28. August 2009 14:08 An: mediawiki-l@lists.wikimedia.org Betreff: [Mediawiki-l] Special Page: Executing SQL query with a browser click
(sending again, my last message didnt appear in the list) ------------------- In my own special page, I've made a custom query (e.g., DELETE * from table). I want to display an HTML link, which when clicked by the user viewing that page executes that SQL query. How can I do that?
_______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Hi,
some changes to my mail:
global $wgUser, $wgOut; $skin = $wgUser->getSkin(); $table = 'mytable'; $id = 0; $wgOut->addHtml( $skin->link( $this->getTitle(), wfMsg('mymessage'), array(), array( 'action' => 'delete_all', 'table' => $table) ) );
...
global $wgRequest; $action = htmlentities( $wgRequest->getText( 'action' ) ); $table = htmlentities( $wgRequest->getText( 'table' ) );
switch( $action ) { case 'delete_all': $this->delete_all( $table ); break; default: break; } ...
private function delete_all( $table ) { // $table == 'mytable' is for controlling that the user can't delete any Mediawiki tables if( ( $table == 'mytable' ) OR ( $table == 'mytable2' ) ) { $dbw = wfGetDB( DB_MASTER ); $dbw->delete( $table, '*' ); } }
So you can add for all actions a function.
Viele Grüße Jan
-----Ursprüngliche Nachricht----- Von: mediawiki-l-bounces@lists.wikimedia.org [mailto:mediawiki-l-bounces@lists.wikimedia.org] Im Auftrag von Jan Luca Gesendet: Freitag, 28. August 2009 19:13 An: 'MediaWiki announcements and site admin list' Betreff: Re: [Mediawiki-l] Special Page: Executing SQL query with a browser click
Hi,
I would made it with a url parameter:
$skin = $wgUser->getSkin(); $table = 'mytable'; $id = 0; $wgOut->addHtml( $skin->link( $this->getTitle(), wfMsg('mymessage'), array(), array( 'action' => 'delete', 'table' => $table, 'id' => $id ) ) );
...
$action = htmlentities( $wgRequest->getText( 'action' ) ); $table = htmlentities( $wgRequest->getText( 'table' ) ); $id = htmlentities( $wgRequest->getText( 'id' ) );
if( $action == 'delete' AND ( $table == 'mytable' ) ) $this->delete( $table, $id );
...
private function delete( $table, $id ) { $dbw = wfGetDB( DB_MASTER ); $dbw->delete( $table, array( 'id' => $id ) ); }
Viele Grüße Jan
-----Ursprüngliche Nachricht----- Von: mediawiki-l-bounces@lists.wikimedia.org [mailto:mediawiki-l-bounces@lists.wikimedia.org] Im Auftrag von Eric K Gesendet: Freitag, 28. August 2009 14:08 An: mediawiki-l@lists.wikimedia.org Betreff: [Mediawiki-l] Special Page: Executing SQL query with a browser click
(sending again, my last message didnt appear in the list) ------------------- In my own special page, I've made a custom query (e.g., DELETE * from table). I want to display an HTML link, which when clicked by the user viewing that page executes that SQL query. How can I do that?
_______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
_______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Jan, thanks so much! This worked perfectly.
--- On Fri, 8/28/09, Jan Luca jan@jans-seite.de wrote:
From: Jan Luca jan@jans-seite.de Subject: Re: [Mediawiki-l] Special Page: Executing SQL query with a browser click To: "'MediaWiki announcements and site admin list'" mediawiki-l@lists.wikimedia.org Date: Friday, August 28, 2009, 1:06 PM
Hi,
some changes to my mail:
global $wgUser, $wgOut; $skin = $wgUser->getSkin(); $table = 'mytable'; $id = 0; $wgOut->addHtml( $skin->link( $this->getTitle(), wfMsg('mymessage'), array(), array( 'action' => 'delete_all', 'table' => $table) ) );
...
global $wgRequest; $action = htmlentities( $wgRequest->getText( 'action' ) ); $table = htmlentities( $wgRequest->getText( 'table' ) );
switch( $action ) { case 'delete_all': $this->delete_all( $table ); break; default: break; } ...
private function delete_all( $table ) { // $table == 'mytable' is for controlling that the user can't delete any Mediawiki tables if( ( $table == 'mytable' ) OR ( $table == 'mytable2' ) ) { $dbw = wfGetDB( DB_MASTER ); $dbw->delete( $table, '*' ); } }
So you can add for all actions a function.
Viele Grüße Jan
-----Ursprüngliche Nachricht----- Von: mediawiki-l-bounces@lists.wikimedia.org [mailto:mediawiki-l-bounces@lists.wikimedia.org] Im Auftrag von Jan Luca Gesendet: Freitag, 28. August 2009 19:13 An: 'MediaWiki announcements and site admin list' Betreff: Re: [Mediawiki-l] Special Page: Executing SQL query with a browser click
Hi,
I would made it with a url parameter:
$skin = $wgUser->getSkin(); $table = 'mytable'; $id = 0; $wgOut->addHtml( $skin->link( $this->getTitle(), wfMsg('mymessage'), array(), array( 'action' => 'delete', 'table' => $table, 'id' => $id ) ) );
...
$action = htmlentities( $wgRequest->getText( 'action' ) ); $table = htmlentities( $wgRequest->getText( 'table' ) ); $id = htmlentities( $wgRequest->getText( 'id' ) );
if( $action == 'delete' AND ( $table == 'mytable' ) ) $this->delete( $table, $id );
...
private function delete( $table, $id ) { $dbw = wfGetDB( DB_MASTER ); $dbw->delete( $table, array( 'id' => $id ) ); }
Viele Grüße Jan
-----Ursprüngliche Nachricht----- Von: mediawiki-l-bounces@lists.wikimedia.org [mailto:mediawiki-l-bounces@lists.wikimedia.org] Im Auftrag von Eric K Gesendet: Freitag, 28. August 2009 14:08 An: mediawiki-l@lists.wikimedia.org Betreff: [Mediawiki-l] Special Page: Executing SQL query with a browser click
(sending again, my last message didnt appear in the list) ------------------- In my own special page, I've made a custom query (e.g., DELETE * from table). I want to display an HTML link, which when clicked by the user viewing that page executes that SQL query. How can I do that?
_______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
_______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
_______________________________________________ MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org