Page MenuHomePhabricator

tasks_patch_060116.txt

Authored By
bzimport
Nov 21 2014, 9:02 PM
Size
4 KB
Referenced Files
None
Subscribers
None

tasks_patch_060116.txt

diff -rupN old/Tasks.php extensions/Tasks/Tasks.php
--- old/Tasks.php 2006-01-16 10:30:53.552250000 -0500
+++ extensions/Tasks/Tasks.php 2006-01-16 10:49:16.427250000 -0500
@@ -688,6 +688,7 @@ function wfTasksExtension() { # Checked
$out = '';
$tasks = array();
$type = $wgRequest->getInt( 'type' );
+ $name = $wgRequest->getText( 'username' );
$comment = $wgRequest->getText( 'text', '' ); # Not evaluated here; stored in database through safe database function
$new_tasks = $this->get_valid_new_tasks( $title, $tasks );
@@ -695,7 +696,7 @@ function wfTasksExtension() { # Checked
# Trying to create a task that isn't available
$out .= '<p>' . wfMsgHtml('tasks_error1') . '</p>';
} else {
- $this->add_new_task( $title, $comment, $type );
+ $this->add_new_task( $title, $comment, $type, $name );
$out .= '<p>' . wfMsgHtml( 'tasks_ok1' ) . '</p>';
}
return $out;
@@ -704,16 +705,23 @@ function wfTasksExtension() { # Checked
/**
* Adds a new task
*/
- function add_new_task( $title, $comment, $type ) {
+ function add_new_task( $title, $comment, $type, $name ) {
global $wgUser;
$dbw =& wfGetDB( DB_MASTER );
+ $user_id = 0;
+ if ( !is_null($name) ) {
+ $user_id = $wgUser->idFromName($name);
+ if ( !ctype_digit($user_id) ) {
+ $user_id = 0; # (int)0 indicates assigned to "no one"
+ }
+ }
$dbw->insert( 'tasks',
array(
'task_page_id' => $title->getArticleID(),
'task_page_title' => $title->getPrefixedDBkey(),
'task_user_id' => $wgUser->getID(),
'task_user_text' => $wgUser->getName(),
- 'task_user_assigned' => 0, # default: No user assigned
+ 'task_user_assigned' => $user_id,
'task_status' => $this->get_status_number( 'open' ),
'task_comment' => $comment,
'task_type' => $type,
@@ -783,7 +791,14 @@ function wfTasksExtension() { # Checked
$out .= '<td align="left" valign="top">';
if( $task->task_user_assigned == 0 ) {
# Noone is assigned this task
- $out .= wfMsgForContent( 'tasks_assignedto', wfMsgHTML( 'tasks_noone' ) );
+ $out .= '<form method="get">' // Added a form in place of old "assign to me" link
+ . wfMsgHTML( 'tasks_assign_to' ) . ' <input type="text" name="username" />'
+ . '<input type="hidden" name="action" value="tasks" />'
+ . '<input type="hidden" name="mode" value="assignto" />'
+ . '<input type="hidden" name="title" value="'.htmlspecialchars($title->getPrefixedText()).'" />'
+ . '<input type="hidden" name="taskid" value="'.$tid.'" />'
+ . '<input type="submit" name="submit" value="' . wfMsgHTML( 'ok' ) . '" />'
+ . '</form>';
} else {
# Someone is assigned this task
$au = new User(); # Assigned user
@@ -898,6 +913,7 @@ function wfTasksExtension() { # Checked
global $wgUser, $wgRequest;
$mode = trim( $wgRequest->getVal( 'mode' ) );
+ $name = trim( $wgRequest->getVal( 'username' ) );
$taskid = $wgRequest->getInt( 'taskid', 0 );
if( $mode == '' || $taskid == 0 ) {
@@ -915,6 +931,7 @@ function wfTasksExtension() { # Checked
switch( $mode ) {
+ case 'assignto':
case 'assignme':
case 'unassignme':
@@ -924,6 +941,11 @@ function wfTasksExtension() { # Checked
if( $mode == 'unassignme' ) {
# Unassign me; this can be invoked for every user by editing the URL!
$user_id = 0;
+ } else if ( $mode == 'assignto' ) {
+ $user_id = $wgUser->idFromName($name);
+ if ( empty($user_id) ) {
+ break; # break as though "mode" were undefined (no action)
+ }
}
$do_set = array( # SET
'task_user_assigned' => $user_id, # Coming from $wgUser, so assumed safe
@@ -1264,6 +1286,7 @@ function wfTasksExtension() { # Checked
$out .= '</td><td valign="top">'
. '<textarea name="text" rows="4" cols="20" style="width:100%"></textarea><br />'
+ . wfMsgHTML( 'tasks_assign_to' ) . ' <input type="text" name="username" />'
. '<input type="submit" name="create_task" value="' . wfMsgHTML( 'ok' ) . '" />'
. '</td></tr></table>'
. '</form>'
diff -rupN old/language/en.php extensions/Tasks/language/en.php
--- old/language/en.php 2006-01-16 10:32:01.614750000 -0500
+++ extensions/Tasks/language/en.php 2006-01-16 10:49:38.942875000 -0500
@@ -18,8 +18,9 @@ $wgMessageCache->addMessages(
'tasks_create_header' => "Create a new task",
'tasks_existing_header' => "Existing tasks",
'tasks_existing_table_header' => "Task|Dates|Initial comment|Assignment/Actions/Page",
- 'tasks_noone' => "noone",
+ 'tasks_noone' => "no one",
'tasks_assign_me' => "Assign myself",
+ 'tasks_assign_to' => "Assign to",
'tasks_unassign_me' => "Remove my assignment",
'tasks_close' => "Close task",
'tasks_wontfix' => "Won't fix",

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2153
Default Alt Text
tasks_patch_060116.txt (4 KB)

Event Timeline