Beispiel #1
0
 public static function buildMyEmmaFieldList($account_id)
 {
     $account = civicrm_api3('MyEmmaAccount', 'getsingle', array('id' => $account_id));
     if (!$account) {
         throw new Exception('Account not found');
     }
     $emma = new CRM_Myemma_Emma($account['account_id'], $account['public_key'], $account['private_key'], false);
     $return = array('email' => ts('E-mail'));
     $fields = json_decode($emma->myFields());
     foreach ($fields as $field) {
         $return[$field->shortcut_name] = $field->display_name;
     }
     return $return;
 }
function civicrm_api3_my_emma_account_Testconnection($params)
{
    if (!isset($params['id'])) {
        return civicrm_api3_create_error(ts('No ID given'));
    }
    $account = civicrm_api3('MyEmmaAccount', 'getsingle', array('id' => $params['id']));
    if (!$account) {
        return civicrm_api3_create_error(ts('Account not found'));
    }
    try {
        $emma = new CRM_Myemma_Emma($account['account_id'], $account['public_key'], $account['private_key'], false);
        $emma->myGroups();
        return civicrm_api3_create_success(array('msg' => ts('Successfully connected to my Emma')));
    } catch (Exception $e) {
        throw $e;
        return civicrm_api3_create_error(ts('Could not connect to MyEmma'));
    }
}