Index: trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php |
— | — | @@ -59,31 +59,34 @@ |
60 | 60 | |
61 | 61 | $formBody = "<table width='$width'>"; |
62 | 62 | |
63 | | - // TODO: if logged in, use real name as default, or username when not available |
| 63 | + $defaultName = ''; |
| 64 | + if ( $wgUser->isLoggedIn() ) { |
| 65 | + $defaultName = strlen($wgUser->getRealName()) > 0 ? $wgUser->getRealName() : $wgUser->getName(); |
| 66 | + } |
64 | 67 | $formBody .= '<tr>' . |
65 | 68 | Html::element( 'td', array('width' => '100%'), wfMsg( 'storyboard-yourname' ) ) . |
66 | 69 | '<td>' . |
67 | | - Html::input('name' ,'', 'text', array( 'size' => $fieldSize ) |
| 70 | + Html::input('name', $defaultName, 'text', array( 'size' => $fieldSize ) |
68 | 71 | ) . '</td></tr>'; |
69 | 72 | |
70 | 73 | $formBody .= '<tr>' . |
71 | 74 | Html::element( 'td', array('width' => '100%'), wfMsg( 'storyboard-location' ) ) . |
72 | | - '<td>' . Html::input('location' ,'', 'text', array( 'size' => $fieldSize ) |
| 75 | + '<td>' . Html::input('location', '', 'text', array( 'size' => $fieldSize ) |
73 | 76 | ) . '</td></tr>'; |
74 | 77 | |
75 | 78 | $formBody .= '<tr>' . |
76 | 79 | Html::element( 'td', array('width' => '100%'), wfMsg( 'storyboard-occupation' ) ) . |
77 | | - '<td>' . Html::input('occupation' ,'', 'text', array( 'size' => $fieldSize ) |
| 80 | + '<td>' . Html::input('occupation', '', 'text', array( 'size' => $fieldSize ) |
78 | 81 | ) . '</td></tr>'; |
79 | 82 | |
80 | 83 | $formBody .= '<tr>' . |
81 | 84 | Html::element( 'td', array('width' => '100%'), wfMsg( 'storyboard-contact' ) ) . |
82 | | - '<td>' . Html::input('contact' ,'', 'text', array( 'size' => $fieldSize ) |
| 85 | + '<td>' . Html::input('contact', '', 'text', array( 'size' => $fieldSize ) |
83 | 86 | ) . '</td></tr>'; |
84 | 87 | |
85 | 88 | $formBody .= '<tr>' . |
86 | 89 | Html::element( 'td', array('width' => '100%'), wfMsg( 'storyboard-storytitle' ) ) . |
87 | | - '<td>' . Html::input('storytitle' ,'', 'text', array( 'size' => $fieldSize ) |
| 90 | + '<td>' . Html::input('storytitle', '', 'text', array( 'size' => $fieldSize ) |
88 | 91 | ) . '</td></tr>'; |
89 | 92 | |
90 | 93 | $formBody .= '<tr><td colspan="2">' . |
— | — | @@ -149,11 +152,15 @@ |
150 | 153 | 'story_author_occupation' => $wgRequest->getText( 'occupation' ), |
151 | 154 | 'story_title' => $wgRequest->getText( 'storytitle' ), |
152 | 155 | 'story_text' => $wgRequest->getText( 'storytext' ), |
153 | | - // TODO: add other fields |
| 156 | + 'story_created' => wfTimestamp( TS_ISO_8601, time() ), |
| 157 | + 'story_modified' => wfTimestamp( TS_ISO_8601, time() ), |
154 | 158 | ); |
| 159 | + |
| 160 | + // If the user is logged in, also store his user id. |
| 161 | + if ( $wgUser->isLoggedIn() ) { |
| 162 | + $story[ 'story_author_id' ] = $wgUser->getId(); |
| 163 | + } |
155 | 164 | |
156 | | - // TODO: Add user id to $story if user is logged in |
157 | | - |
158 | 165 | $dbw->insert( 'storyboard', $story ); |
159 | 166 | |
160 | 167 | $responseHtml = ''; // TODO: create html response |