Forum OpenACS Q&A: Intranet Ticket Bug in 3.2.5 with a fix

Ok.. I am spending a LOT of time working with the intranet module so hopefully shake out any remaing bugs.

If you notice on a project page that the ticket tracker box doesnt show ticket status even when you created a ticket tracker .. well there is a reason. Turns out the name customer means different things to different tables.. and customers in ticket_projects is NOT the CUSTOMER.. anyway.. once I figured out that out there are two fixes

[1] procedure im_project_ticket_project_id is hitting the wrong table (ticket_projects) when it should be querying ticket_project_teams table.. so fix is easy

 
create function im_project_ticket_project_id(integer) 
returns integer as ' 
declare 
	v_group_id	alias for $1; 
	v_project_id	ticket_project_teams.project_id%TYPE; 
BEGIN 
  BEGIN 
    select project_id into v_project_id from ticket_project_teams where team_id = v_group_id; 
 
  END; 
  if v_project_id is null then 
     return 0; 
  else 
     return v_project_id; 
  end if; 
END; 
' language 'plpgsql'; 

The query is also broken in http://kinetx.kinetx.com/intranet/projects/view.tcl as it tries to get ticket_project_id from the proc above (good) AND from the im_projects table (bad) since it is not populated. so remove the second grab.. the query as I fixed it is:

 
set selection [ns_db 0or1row $db " 
select p.*, g.group_name as project_name, g.short_name, p.parent_id, p.customer_id, 
                user_group_name_from_id(p.customer_id) as customer_name, im_project_ticket_project_id(g.group_id) as ticket_project_id, 
                user_group_name_from_id(p.parent_id) as parent_name, 
                user_full_name(p.project_lead_id) as project_lead, project_lead_id,  
                user_full_name(p.supervisor_id) as supervisor, 
                im_proj_type_from_id(p.project_type_id) as project_type,  
                im_proj_status_from_id(p.project_status_id) as project_status 
           from im_projects p, user_groups g 
          where p.group_id=$group_id 
            and p.group_id=g.group_id 
"] 

If someone can be so good as to confirm this and if correct.. add the fixes to the source tree.. I need to get back up on that but might be nice to have a fix in quicker

cheers
Jamie

Collapse
Posted by Roberto Mello on
Jamie, would you please post this at the SDM? It's much easier for us to patch things by following the SDM bug reports than letting bboard messages hang on our inboxes.

Thanks for the fixes.

Collapse
Posted by Chris Hardy on
Hey Jamie! It's nice to see another Intranet Hacker! When I was fixing the entire intranet/new-ticket problem, I thought I had this fixed. I fixed this yesterday as well.. And my solution is a bit different.. All you need to do is to insert

ns_db dml $db "update im_projects set ticket_project_id = $new_id where group_id = $group_id"

into /intranet/projects/ticket-edit.tcl so that the ticket ID is put into the im_projects table, and all should be good and happy.. I do have to admit that I've been very confused and sometimes frustrated with the logic that puts together the intranet package, but I've just been patching how I think things should work.. Let me know what you think!