Import from SVN (r45945, r596)
[civicrm-core.git] / api / v3 / Generic / Getactions.php
CommitLineData
6a488035
TO
1<?php
2// $Id$
3
4function civicrm_api3_generic_getActions($params) {
5 civicrm_api3_verify_mandatory($params, NULL, array('entity'));
6 $r = civicrm_api('Entity', 'Get', array('version' => 3));
7 $entity = CRM_Utils_String::munge($params['entity']);
8 if (!in_array($entity, $r['values'])) {
9 return civicrm_api3_create_error("Entity " . $entity . " invalid. Use api.entity.get to have the list", array('entity' => $r['values']));
10 }
11 _civicrm_api_loadEntity($entity);
12
13 $functions = get_defined_functions();
14 $actions = array();
15 $prefix = 'civicrm_api3_' . strtolower($entity) . '_';
16 $prefixGeneric = 'civicrm_api3_generic_';
17 foreach ($functions['user'] as $fct) {
18 if (strpos($fct, $prefix) === 0) {
19 $actions[] = substr($fct, strlen($prefix));
20 }
21 elseif (strpos($fct, $prefixGeneric) === 0) {
22 $actions[] = substr($fct, strlen($prefixGeneric));
23 }
24 }
25 return civicrm_api3_create_success($actions);
26}