Moved logics to create a portrait in a proc in order to reuse it in other places such as picture retrieval services (e.g. Bach picture retrieval at WU). Turns out we were not doing our homeworks here: when the portrait is created into CR, a cr_child_rel is created. When the portrait was erased though, this was not cleaned up propely, leaving dangling acs_objects with no reference in cr_child_rels table. On busy sites, this can grow in the ten thousands order of magnitude. Changes include also fix for this behavior and tuples cleanup.
fix ad_form definition (moved redirect in after_submit block, ad_return_template at the end of template outside the ad_form) (thanks to Felix Moedritscher)