Index: trunk/extensions/Poll/Poll_body.php |
— | — | @@ -43,17 +43,17 @@ |
44 | 44 | } |
45 | 45 | else { |
46 | 46 | $wgOut->addHtml( Xml::openElement( 'form', array('method'=> 'post', 'action' => 'index.php?title=Special:Poll&action=submit' ) ) ); |
47 | | - $wgOut->addHtml( Xml::openElement( 'table' ); |
48 | | - $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-question' ).':</td><td>'.Xml::input('poll_name').'</td></tr>' ); |
| 47 | + $wgOut->addHtml( Xml::openElement( 'table' ) ); |
| 48 | + $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-question' ).':</td><td>'.Xml::input('question').'</td></tr>' ); |
49 | 49 | $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 1:</td><td>'.Xml::input('poll_alternative_1').'</td></tr>' ); |
50 | 50 | $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 2:</td><td>'.Xml::input('poll_alternative_2').'</td></tr>' ); |
51 | 51 | $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 3:</td><td>'.Xml::input('poll_alternative_3').'</td></tr>' ); |
52 | 52 | $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 4:</td><td>'.Xml::input('poll_alternative_4').'</td></tr>' ); |
53 | 53 | $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 5:</td><td>'.Xml::input('poll_alternative_5').'</td></tr>' ); |
54 | 54 | $wgOut->addHtml( '<tr><td>'.wfMsg( 'poll-alternative' ).' 6:</td><td>'.Xml::input('poll_alternative_6').'</td></tr>' ); |
55 | | - $wgOut->addHtml( '<tr><td>'.Xml::submitButton(wfMsg( 'poll-submit' )).'</td></tr>' ); |
56 | | - $wgOut->addHtml( Xml::closeElement( table ) ); |
57 | | - $wgOut->addHtml( Xml::closeElement( form ) ); |
| 55 | + $wgOut->addHtml( '<tr><td>'.Xml::submitButton(wfMsg( 'poll-submit' )).''.Xml::hidden('action', 'create').'</td></tr>' ); |
| 56 | + $wgOut->addHtml( Xml::closeElement( 'table' ) ); |
| 57 | + $wgOut->addHtml( Xml::closeElement( 'form' ) ); |
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
— | — | @@ -77,5 +77,36 @@ |
78 | 78 | |
79 | 79 | public function submit() { |
80 | 80 | global $wgRequest, $wgOut, $wgUser; |
| 81 | + |
| 82 | + $type = htmlenttitles($_POST['action']); |
| 83 | + |
| 84 | + if($type == 'create') { |
| 85 | + $controll_create_right = $wgUser->isAllowed( 'poll-create' ); |
| 86 | + $controll_create_blocked = $wgUser->isBlocked(); |
| 87 | + if ( $controll_create_right != true ) { |
| 88 | + $wgOut->addWikiMsg( 'poll-create-right-error' ); |
| 89 | + } |
| 90 | + elseif ( $controll_create_blocked == true ) { |
| 91 | + $wgOut->addWikiMsg( 'poll-create-block-error' ); |
| 92 | + } |
| 93 | + else { |
| 94 | + $dbw = wfGetDB( DB_MASTER ); |
| 95 | + $question = $_POST['question']; |
| 96 | + $alternative_1 = $_POST['poll_alternative_1']; |
| 97 | + $alternative_2 = $_POST['poll_alternative_2']; |
| 98 | + $alternative_3 = ($_POST['poll_alternative_3'] != "")? $_POST['poll_alternative_3'] : ""; |
| 99 | + $alternative_4 = ($_POST['poll_alternative_4'] != "")? $_POST['poll_alternative_4'] : ""; |
| 100 | + $alternative_5 = ($_POST['poll_alternative_5'] != "")? $_POST['poll_alternative_5'] : ""; |
| 101 | + $alternative_6 = ($_POST['poll_alternative_6'] != "")? $_POST['poll_alternative_6'] : ""; |
| 102 | + |
| 103 | + if($question != "" && $alternative_1 != "" && $alternative_2 != "") { |
| 104 | + $dbw->insert( 'poll', array( 'question' => $question, 'alternative_1' => $alternative_1, 'alternative_2' => $alternative_2, |
| 105 | + 'alternative_3' => $alternative_3, 'alternative_4' => $alternative_4, 'alternative_5' => $alternative_5, |
| 106 | + 'alternative_6' => $alternative_6 ) ); |
| 107 | + } |
| 108 | + else { |
| 109 | + $wgOut->addWikiMsg( 'poll-create-fields-error' ); |
| 110 | + } |
| 111 | + } |
81 | 112 | } |
82 | 113 | } |
Index: trunk/extensions/Poll/Poll.i18n.php |
— | — | @@ -22,6 +22,10 @@ |
23 | 23 | 'poll-alternative' => 'Alternative', |
24 | 24 | 'poll-question' => 'Question', |
25 | 25 | 'poll-submit' => 'Submit', |
| 26 | + 'right-poll-create' => 'Create Poll', |
| 27 | + 'right-poll-vote' => 'Vote by a Poll', |
| 28 | + 'right-poll-admin' => 'Manage the Polls', |
| 29 | + 'poll-create-fields-error' => 'The fields Question, Alternative 1 and Alternative 2 must be set', |
26 | 30 | ); |
27 | 31 | |
28 | 32 | $messages['de'] = array( |
— | — | @@ -37,4 +41,8 @@ |
38 | 42 | 'poll-alternative' => 'Antwortmöglichkeit', |
39 | 43 | 'poll-question' => 'Frage', |
40 | 44 | 'poll-submit' => 'Absenden', |
| 45 | + 'right-poll-create' => 'Umfrage erstellen', |
| 46 | + 'right-poll-vote' => 'Bei einer Umfrage abstimmen', |
| 47 | + 'right-poll-admin' => 'Umfragen verwalten', |
| 48 | + 'poll-create-fields-error' => 'Die Felder Frage, Antwortmöglichkeit 1 sowie Antwortmöglichkeit 2 müssen ausgefüllt sein', |
41 | 49 | ); |
Index: trunk/extensions/Poll/Poll.php |
— | — | @@ -54,4 +54,4 @@ |
55 | 55 | $wgExtensionMessagesFiles['Poll'] = $dir . 'Poll.i18n.php'; |
56 | 56 | $wgExtensionAliasesFiles['Poll'] = $dir . 'Poll.alias.php'; |
57 | 57 | $wgSpecialPages['Poll'] = 'Poll'; # Let MediaWiki know about your new special page. |
58 | | -// FIXME: add $wgSpecialPageGroups |
| 58 | +$wgSpecialPageGroups['Poll'] = 'other'; |
\ No newline at end of file |