r63411 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63410‎ | r63411 | r63412 >
Date:20:12, 8 March 2010
Author:jeroendedauw
Status:resolved (Comments)
Tags:
Comment:
Added default name for logged in users and 3 more fields to store in the db.
Modified paths:
  • /trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php
@@ -59,31 +59,34 @@
6060
6161 $formBody = "<table width='$width'>";
6262
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+ }
6467 $formBody .= '<tr>' .
6568 Html::element( 'td', array('width' => '100%'), wfMsg( 'storyboard-yourname' ) ) .
6669 '<td>' .
67 - Html::input('name' ,'', 'text', array( 'size' => $fieldSize )
 70+ Html::input('name', $defaultName, 'text', array( 'size' => $fieldSize )
6871 ) . '</td></tr>';
6972
7073 $formBody .= '<tr>' .
7174 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 )
7376 ) . '</td></tr>';
7477
7578 $formBody .= '<tr>' .
7679 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 )
7881 ) . '</td></tr>';
7982
8083 $formBody .= '<tr>' .
8184 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 )
8386 ) . '</td></tr>';
8487
8588 $formBody .= '<tr>' .
8689 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 )
8891 ) . '</td></tr>';
8992
9093 $formBody .= '<tr><td colspan="2">' .
@@ -149,11 +152,15 @@
150153 'story_author_occupation' => $wgRequest->getText( 'occupation' ),
151154 'story_title' => $wgRequest->getText( 'storytitle' ),
152155 '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() ),
154158 );
 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+ }
155164
156 - // TODO: Add user id to $story if user is logged in
157 -
158165 $dbw->insert( 'storyboard', $story );
159166
160167 $responseHtml = ''; // TODO: create html response

Follow-up revisions

RevisionCommit summaryAuthorDate
r63421Follow up for r63411jeroendedauw21:32, 8 March 2010
r63441Follow up to r63411 and small typo fix in sql filejeroendedauw23:11, 8 March 2010

Comments

#Comment by Catrope (talk | contribs)   20:33, 8 March 2010
strlen($wgUser->getRealName()) > 0

Just use $wgUser->getRealName() ===

#Comment by Catrope (talk | contribs)   20:35, 8 March 2010

The above should read $wgUser->getRealName() === ''

+			'story_created' => wfTimestamp( TS_ISO_8601, time() ),
+			'story_modified' => wfTimestamp( TS_ISO_8601, time() ),

Don't put ISO 8601 timestamps in the DB, that'll break. Use $dbw->timestamp() instead.

#Comment by Jeroen De Dauw (talk | contribs)   21:29, 8 March 2010

Well, actually I think you really meant !==  :)

#Comment by Jeroen De Dauw (talk | contribs)   21:30, 8 March 2010

lol !==  :

#Comment by Jeroen De Dauw (talk | contribs)   21:31, 8 March 2010

Bad day... !==

Status & tagging log