Can I show who closed a task?

Hi All,

The powers that be (my boss) would like Kanboard to show who closed a task. I don’t know enough about PHP to figure this out myself. I’ve been trying to decipher how other information is shown, but I can’t get it to work. I already added a new column to the database called “closed_id” but I don’t understand how to get the “user_id” into that column. Further, I think that I would have to sort of cross-reference the “closed_id” to the “user_id” to pull the username into the display. Ideally, I would like it to look like this:

Screenshot 2023-05-22 081158

Also, I would need that to be cleared if a task is reopened. I know that all of this is possible, I just don’t know how to do it. Any help will be greatly appreciated. Thanks!

1 Like

Dont know much about the above, but on a side note, KanboardEmailHistory allows for an email to be sent when a task is closed, witha summary of all the details.

Only mentioning it, because it creates a comment automatically that the task has been closed and emailed to x.

1 Like

Did you take a look at the task’s activity stream?

1 Like

According to what you posted, the data I want is already in the task. Now I just need to find out where it’s stored so I can display it elsewhere.

Thanks for the heads up!

you might want to look at that too…

I’ve been searching through some of the php files and the database and I’m at a total loss. I thought I was on to something when I saw the following line in the TaskEventBuilder file:

case TaskModel::EVENT_CLOSE:
                return e('%s closed the task #%d', $author, $eventData['task']['id']);

but I don’t know how I would use that information.

In the details file, I see this section:

<?php if ($task['creator_username']): ?>
      <li>
         <strong><?= t('Creator:') ?></strong>
             <span><?= $this->text->e($task['creator_name'] ?: $task['creator_username']) ?></span>
      </li>
<?php endif ?>

so I was hoping that I could find something like a ‘closed_username’ somewhere that I could use.

I feel like I’m on the right track, but I’m not in the train. Can someone enlighten me?

I’ve had a fair amount of luck using the API: API Reference — Kanboard documentation . You can write quick-and-dirty scripts, or even use curl commands to interact with it. It’s possible the information you’re looking for is available through the API and you can write a simple web interface or CLI to query it. No idea if that’d work for your boss, but it’s something to try.

1 Like

So, I made a new column in the database called “closed_id” and I managed to get Kanboard to populate it with the ID of the user that closed the task. Now I’m trying to display that username on the details page by using this:

<li>
     <strong><?= t('Closed by:') ?></strong>
     <span><?= $this->text->e($task['closed_name'] ?: $task['closed_username']) ?></span>
</li>

but it tells me that I have an ‘undefined array key “closed_name”.’ Where do I define the array key? I’ve looked through the php files and I can’t find it.

you made a column, “closed_id” and are trying to call it using “closed_name” or “closed_username”? Surely you see the problem there, right?

That said, there is going to be more to it than that. All task data is generally supplied by the taskfinder, and so your column may not provide the data through the existing finder(as it may not be included in the current finder, depending on the function it uses). So you may have to account for that, get the “closed_id” and then perform another lookup through the usermodel to get the username or name. Where do you define those? Anywhere before it gets called, and in a manner that sends the data to said template, or even in said template. Generally speaking, the controller that calls on whatever template that is, sends an array of data to the template as well.

Notice below, task is sent to the template task/show via 'task' => $task and $task is defined as $task = $this->getTask.

Now trace it back further, and find out what is getTask? Well…

As you can see here, its calling the TaskFinderModel. Now go look at that model, getDetails Function, and in this instance, you are actually in luck, as it grabs all the columns, might not always be the case though if it uses getExtendedQuery for instance, so in this case you just need to used “closed_id” and lookup the username/name in the usermodel and then define it in the $task array…so…there ya go.

But I guess the question is, how would YOU include it? Well, there are actually a lot of answers here, some easy, some not so easy, some take a lot of work, some take no work. There isn’t just 1 answer, but I think you have enough information to answer it yourself now.

I’ll provide a hint though. $task['closed_name'] = ?????

Now I’m going to tell you a story:
I’ve spent alot of time writing plugins, and giving full detailed answers, im talking years and 1000’s of hours of work. I checked my paypal account the other day, and someone was generous enough to donate $750 bucks for Group_assign and all the work I put in to it. I was so excited, for such a generous donation. First time.

Literally that very same day, our toilet upstairs, sprung a leak, and so I had to call a plumber, I shit you not. This dude came over, lifted the toilet up, moved it 2 feet, and said the flange rusted out. Then he cut a hole in the ceiling downstairs to look at any damage. That’s all he did, and it took him 1 hour and a half to do it. Guess what he charged me. You guessed it, $750.

I’ll let you figure out the rest.

1 Like

Yeah, that was wishful thinking on my part. I’m not familiar with php, so I was hoping that maybe it would parse the info. Obviously, I was very wrong. :smiley:

Thank you so very much for your help and taking the time to explain how these files all work together. With the information you gave me in your post, I was able to get the username displayed right where I needed it.

Thanks again!

1 Like