/** * Get all parties with a given roles */ public static function find_by_role($entity_data, $role) { $search_results = array(); // Get the role $role_type = EntityAPI::get_by_code('roletype', strtoupper($role)); // Process only if we got a valid response from the call above if (isset($role_type['id']) && isset($role_type['entity_code'])) { $party_ids = array(); // Search for all the party role type associations with the given role $party_roles = EntityAPI::find_by_criteria('partyrole', array('role' => $role_type['id'])); // Loop throug all the return party roles // and push the party id into list of parties foreach ($party_roles as $party_role) { array_push($party_ids, $party_role['party']); } // Doing all this shit cause I am not good at SQL :-( if (!empty($party_ids)) { $results = EntityAPI::find_by_ids_and_criteria('party', $party_ids); foreach ($results as $key => $party_data) { foreach ($party_roles as $party_role) { if ($party_data['id'] == $party_role['party']) { array_push($search_results, $party_data); } } } } } return $search_results; }
/** * */ public static function find_child_entities_ajax() { if (!isset($_POST['artifact']) || !isset($_POST['parent_id']) || !isset($_POST['parent_field_name'])) { return array(); } $parent_id = EntityRequestUtils::get_query_string_field('parent_id'); $artifact_name = EntityRequestUtils::get_query_string_field('artifact'); $parent_field_name = EntityRequestUtils::get_query_string_field('parent_field_name'); $search_results = EntityAPI::find_by_criteria($artifact_name, array($parent_field_name => $parent_id)); ArtficatAjaxRequestProcessorUtils::do_after_ajax_find(EntityAPIUtils::init_entity_data($artifact_name), $search_results); }