It would be nice to refactor the outliner context menu, but a project of that scale didn't end up fitting into the gsoc. There are some smaller annoyances that this patch addresses.
When opening the context menu with mixed type selection, the menu does not show operators based on the target of the right click. For example, if a modifier and the parent object are selected, a right click on the modifier does not show the modifier context menu, rather it shows the object context menu. The menu type shown should depend on the target of the right click.
This patch modifies the code to only check the data type of the right click rather than iterating over the tree and trying to determine what type of menu to create. For this to work, the active element is now set on right click so the operators called from the context menu know which type of data to operate on.