function add_prospects_to_prospect_list($query,$parent_module,$parent_type,$parent_id,$child_id,$link_attribute,$link_type) { $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:'.$query); $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:'.$parent_module); $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:'.$parent_type); $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:'.$parent_id); $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:'.$child_id); $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:'.$link_attribute); $GLOBALS['log']->debug('add_prospects_to_prospect_list:parameters:'.$link_type); if (!class_exists($parent_type)) { require_once('modules/'.$parent_module.'/'.$parent_type.'.php'); } $focus = new $parent_type(); $focus->retrieve($parent_id); //if link_type is default then load relationship once and add all the child ids. $relationship_attribute=$link_attribute; //find all prospects based on the query $db = & PearDatabase::getInstance(); $result=$db->query($query); while(($row=$db->fetchByAssoc($result)) != null) { $GLOBALS['log']->debug('target_id'.$row[$child_id]); if ($link_type != 'default') { $relationship_attribute=strtolower($row[$link_attribute]); } $GLOBALS['log']->debug('add_prospects_to_prospect_list:relationship_attribute:'.$relationship_attribute); //load relationship for the first time or on change of relationship atribute. if (empty($focus->$relationship_attribute)) { $focus->load_relationship($relationship_attribute); } //add $focus->$relationship_attribute->add($row[$child_id]); } }