Tracking which user created which task



  • A while back my boss wanted to be able to track who was imaging which hosts when (managers seem to like tracking things for some reason), so I did a really quick and dirty edit to tie users to the tasks they created. Under /var/www/fog/management/includes/tasks.confirm.include.php:

    This

    [PHP]else if ( $_GET[“direction”] == “down” )
    {
    $imageMembers = null;
    $taskName = “”;
    $blIsGroup = false;
    if ( $_GET[“type”] == “host” )
    {
    $imageMembers = array( getImageMemberFromHostID( $conn, $confirm ) );
    }
    else if ( $_GET[“type”] == “group” )
    {
    $blIsGroup = true;
    $imageMembers = getImageMembersByGroupID( $conn, $confirm );
    }
    [/PHP]

    Became this
    [PHP]else if ( $_GET[“direction”] == “down” )
    {
    $imageMembers = null;
    $taskName = “”;
    $blIsGroup = false;
    if ( $_GET[“type”] == “host” )
    {
    $imageMembers = array( getImageMemberFromHostID( $conn, $confirm ) );
    $taskName = ($currentUser->getUserName() . ": " . $imageMembers[0]->getHostName());
    }
    else if ( $_GET[“type”] == “group” )
    {
    $blIsGroup = true;
    $imageMembers = getImageMembersByGroupID( $conn, $confirm );
    $taskName = ($currentUser->getUserName() . ": " . getGroupNameByID( $conn, $confirm ));
    }
    [/PHP]

    With 0.33 coming down the line, and the complete overhaul of the backend, I was wondering if this is one of those modifications I’ll need to “rewrite” (not that I did much in the way of writing to begin with), or if this might be a new feature included in the source (though perhaps implemented in a less ‘hackey’ way)?



  • I remember seeing that field and wondering why it wasn’t actually called anywhere… but my main focus was getting usernames listed under the Active Tasks page, and it seemed less terrible to just slap the currentUser onto the task name than to write a function to call a single field.


  • Developer

    There is a field called ‘createdBy’ which holds who the Task was created by. Though it’s not displayed in the 0.32 Web UI anywhere.

    In 0.33 you will be able to create a Hook for this; it will be very simple and fast.


 

404
Online

41.8k
Users

12.4k
Topics

116.6k
Posts