r27314 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r27313‎ | r27314 | r27315 >
Date:14:01, 8 November 2007
Author:gri6507
Status:old
Tags:
Comment:
made the extension more compatible with User Contact Links extension
Modified paths:
  • /trunk/extensions/TodoTasks/SpecialTaskList.php (modified) (history)
  • /trunk/extensions/TodoTasks/SpecialTaskList_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/TodoTasks/SpecialTaskList_body.php
@@ -32,44 +32,45 @@
3333 return true;
3434 }
3535
36 -function getUserIDFromUserText($user) {
37 - $dbr = wfGetDB( DB_SLAVE );
38 - $userid = 0;
39 -
40 - if (preg_match('/^\s*(.*?)\s*$/', $user, $matches))
41 - $user = $matches[1];
42 -
43 - $u = User::newFromName($user);
44 - if ($u) {
45 - $userid = $u->idForName(); // valid userName
46 - }
47 - if (!$userid) { // if not a valid userName, try as a userRealName
48 - $userid = $dbr->selectField( 'user', 'user_id', array( 'user_real_name' => $user ), 'renderTodo' );
49 - if (!$userid) { // if not valid userRealName, try case insensitive userRealName
50 - $sql = "SELECT user_id FROM ". $dbr->tableName('user') ." WHERE UPPER(user_real_name) LIKE '%" . strtoupper($user)
51 -. "%'";
52 - $res = $dbr->query( $sql, __METHOD__ );
53 - if ($dbr->numRows($res)) {
54 - $row = $dbr->fetchRow($res);
55 - $userid = $row[0];
56 - }
57 - $dbr->freeResult($res);
58 - if (!$userid) { // if not case insensitive userRealName, try case insensitive lastname
59 - list ($first, $last) = preg_split('/\s+/', $user);
60 - if ($last != '') {
61 - $sql = "SELECT user_id FROM ". $dbr->tableName('user') ." WHERE UPPER(user_real_name) LIKE '%" .
62 -strtoupper($last) . "%'";
63 - $res = $dbr->query( $sql, __METHOD__ );
64 - if ($dbr->numRows($res)) {
65 - $row = $dbr->fetchRow($res);
66 - $userid = $row[0];
 36+# only create the following function if it was not already installed with the User Contact Links extension
 37+if (!function_exists('getUserIDFromUserText')) {
 38+ function getUserIDFromUserText($user) {
 39+ $dbr = wfGetDB( DB_SLAVE );
 40+ $userid = 0;
 41+
 42+ if (preg_match('/^\s*(.*?)\s*$/', $user, $matches))
 43+ $user = $matches[1];
 44+
 45+ $u = User::newFromName($user);
 46+ if ($u) {
 47+ $userid = $u->idForName(); // valid userName
 48+ }
 49+ if (!$userid) { // if not a valid userName, try as a userRealName
 50+ $userid = $dbr->selectField( 'user', 'user_id', array( 'user_real_name' => $user ), 'renderTodo' );
 51+ if (!$userid) { // if not valid userRealName, try case insensitive userRealName
 52+ $sql = "SELECT user_id FROM ". $dbr->tableName('user') ." WHERE UPPER(user_real_name) LIKE '%" . strtoupper($user) . "%'";
 53+ $res = $dbr->query( $sql, __METHOD__ );
 54+ if ($dbr->numRows($res)) {
 55+ $row = $dbr->fetchRow($res);
 56+ $userid = $row[0];
 57+ }
 58+ $dbr->freeResult($res);
 59+ if (!$userid) { // if not case insensitive userRealName, try case insensitive lastname
 60+ list ($first, $last) = preg_split('/\s+/', $user);
 61+ if ($last != '') {
 62+ $sql = "SELECT user_id FROM ". $dbr->tableName('user') ." WHERE UPPER(user_real_name) LIKE '%" . strtoupper($last) . "%'";
 63+ $res = $dbr->query( $sql, __METHOD__ );
 64+ if ($dbr->numRows($res)) {
 65+ $row = $dbr->fetchRow($res);
 66+ $userid = $row[0];
 67+ }
 68+ $dbr->freeResult($res);
6769 }
68 - $dbr->freeResult($res);
6970 }
7071 }
7172 }
 73+ return $userid;
7274 }
73 - return $userid;
7475 }
7576
7677 function getValidProjects() {
Index: trunk/extensions/TodoTasks/SpecialTaskList.php
@@ -18,7 +18,7 @@
1919
2020 if (!defined('MEDIAWIKI')) die();
2121
22 -$wgTodoTasksExtensionVersion = '0.9.0';
 22+$wgTodoTasksExtensionVersion = '0.9.1';
2323
2424 $wgExtensionCredits['parserhook'][] = array(
2525 'version' => $wgTodoTasksExtensionVersion,
@@ -37,7 +37,7 @@
3838 'description' => 'Adds a special page for reviewing tasks assignments'
3939 );
4040
41 -$wgUseProjects = false;
 41+$wgUseProjects = true;
4242
4343 $wgAutoloadClasses['TaskList'] = dirname(__FILE__) . '/SpecialTaskList_body.php';
4444 $wgSpecialPages['TaskList'] = 'TaskList';

Status & tagging log