• Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
  • Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

Tracking which user created which task

Scheduled Pinned Locked Moved Solved
General
2
3
1.5k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B
    BryceZ
    last edited by Jan 10, 2012, 3:06 PM

    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)?

    1 Reply Last reply Reply Quote 0
    • B
      Blackout Developer
      last edited by Jan 11, 2012, 10:29 PM

      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.

      1 Reply Last reply Reply Quote 0
      • B
        BryceZ
        last edited by Jan 11, 2012, 10:53 PM

        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.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          3/3
          Last post

        197

        Online

        12.0k

        Users

        17.3k

        Topics

        155.2k

        Posts
        Copyright © 2012-2024 FOG Project