Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
justinfreeman (Agileware)
Core
Commits
4bcfd71f
Commit
4bcfd71f
authored
11 years ago
by
eileen
Browse files
Options
Downloads
Patches
Plain Diff
CRM-13234 use translated profile id
parent
effb666a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/v3/Profile.php
+12
-17
12 additions, 17 deletions
api/v3/Profile.php
api/v3/examples/ProfileGetFields.php
+1
-0
1 addition, 0 deletions
api/v3/examples/ProfileGetFields.php
with
13 additions
and
17 deletions
api/v3/Profile.php
+
12
−
17
View file @
4bcfd71f
...
@@ -148,19 +148,21 @@ function _civicrm_api3_profile_get_spec(&$params) {
...
@@ -148,19 +148,21 @@ function _civicrm_api3_profile_get_spec(&$params) {
*/
*/
function
civicrm_api3_profile_submit
(
$params
)
{
function
civicrm_api3_profile_submit
(
$params
)
{
$profileID
=
_civicrm_api3_profile_getProfileID
(
$params
[
'profile_id'
]);
$profileID
=
_civicrm_api3_profile_getProfileID
(
$params
[
'profile_id'
]);
if
(
!
CRM_Core_DAO
::
getFieldValue
(
'CRM_Core_DAO_UFGroup'
,
$params
[
'profile_id'
],
'is_active'
))
{
if
(
!
CRM_Core_DAO
::
getFieldValue
(
'CRM_Core_DAO_UFGroup'
,
$profileID
,
'is_active'
))
{
//@todo declare pseudoconstant & let api do this
throw
new
API_Exception
(
'Invalid value for profile_id'
);
throw
new
API_Exception
(
'Invalid value for profile_id'
);
}
}
$isContactActivityProfile
=
CRM_Core_BAO_UFField
::
checkContactActivityProfileType
(
$
params
[
'
profile
_id'
]
);
$isContactActivityProfile
=
CRM_Core_BAO_UFField
::
checkContactActivityProfileType
(
$profile
ID
);
if
(
CRM_Core_BAO_UFField
::
checkProfileType
(
$
params
[
'
profile
_id'
]
)
&&
!
$isContactActivityProfile
)
{
if
(
!
empty
(
$params
[
'id'
])
&&
CRM_Core_BAO_UFField
::
checkProfileType
(
$profile
ID
)
&&
!
$isContactActivityProfile
)
{
throw
new
API_Exception
(
'
Can not retrieve values for
profiles includ
e fields for
more than one
record type.
'
);
throw
new
API_Exception
(
'
Update
profiles includ
ing
more than one
entity not currently supported
'
);
}
}
$contactParams
=
$activityParams
=
$missingParams
=
array
();
$contactParams
=
$activityParams
=
$missingParams
=
array
();
$profileFields
=
CRM_Core_BAO_UFGroup
::
getFields
(
$
params
[
'
profile
_id'
]
,
$profileFields
=
CRM_Core_BAO_UFGroup
::
getFields
(
$profile
ID
,
FALSE
,
FALSE
,
NULL
,
NULL
,
NULL
,
NULL
,
...
@@ -177,7 +179,7 @@ function civicrm_api3_profile_submit($params) {
...
@@ -177,7 +179,7 @@ function civicrm_api3_profile_submit($params) {
$errors
=
CRM_Profile_Form
::
validateContactActivityProfile
(
$params
[
'activity_id'
],
$errors
=
CRM_Profile_Form
::
validateContactActivityProfile
(
$params
[
'activity_id'
],
$params
[
'contact_id'
],
$params
[
'contact_id'
],
$
params
[
'
profile
_id'
]
$profile
ID
);
);
if
(
!
empty
(
$errors
))
{
if
(
!
empty
(
$errors
))
{
throw
new
API_Exception
(
array_pop
(
$errors
));
throw
new
API_Exception
(
array_pop
(
$errors
));
...
@@ -212,9 +214,8 @@ function civicrm_api3_profile_submit($params) {
...
@@ -212,9 +214,8 @@ function civicrm_api3_profile_submit($params) {
throw
new
API_Exception
(
"Missing required parameters for profile id
{
$params
[
'profile_id'
]
}
: "
.
implode
(
', '
,
$missingParams
));
throw
new
API_Exception
(
"Missing required parameters for profile id
{
$params
[
'profile_id'
]
}
: "
.
implode
(
', '
,
$missingParams
));
}
}
$contactParams
[
'version'
]
=
3
;
$contactParams
[
'contact_id'
]
=
CRM_Utils_Array
::
value
(
'contact_id'
,
$params
);
$contactParams
[
'contact_id'
]
=
CRM_Utils_Array
::
value
(
'contact_id'
,
$params
);
$contactParams
[
'profile_id'
]
=
$
params
[
'
profile
_id'
]
;
$contactParams
[
'profile_id'
]
=
$profile
ID
;
$contactParams
[
'skip_custom'
]
=
1
;
$contactParams
[
'skip_custom'
]
=
1
;
$contactProfileParams
=
civicrm_api3_profile_apply
(
$contactParams
);
$contactProfileParams
=
civicrm_api3_profile_apply
(
$contactParams
);
...
@@ -245,7 +246,7 @@ function civicrm_api3_profile_submit($params) {
...
@@ -245,7 +246,7 @@ function civicrm_api3_profile_submit($params) {
return
civicrm_api3
(
'contact'
,
'create'
,
$profileParams
);
return
civicrm_api3
(
'contact'
,
'create'
,
$profileParams
);
$ufGroupDetails
=
array
();
$ufGroupDetails
=
array
();
$ufGroupParams
=
array
(
'id'
=>
$
params
[
'
profile
_id'
]
);
$ufGroupParams
=
array
(
'id'
=>
$profile
ID
);
CRM_Core_BAO_UFGroup
::
retrieve
(
$ufGroupParams
,
$ufGroupDetails
);
CRM_Core_BAO_UFGroup
::
retrieve
(
$ufGroupParams
,
$ufGroupDetails
);
if
(
isset
(
$profileFields
[
'group'
]))
{
if
(
isset
(
$profileFields
[
'group'
]))
{
...
@@ -325,12 +326,6 @@ function civicrm_api3_profile_set($params) {
...
@@ -325,12 +326,6 @@ function civicrm_api3_profile_set($params) {
*/
*/
function
civicrm_api3_profile_apply
(
$params
)
{
function
civicrm_api3_profile_apply
(
$params
)
{
civicrm_api3_verify_mandatory
(
$params
,
NULL
,
array
(
'profile_id'
));
if
(
!
CRM_Core_DAO
::
getFieldValue
(
'CRM_Core_DAO_UFGroup'
,
$params
[
'profile_id'
],
'is_active'
))
{
return
civicrm_api3_create_error
(
'Invalid value for profile_id'
);
}
$profileFields
=
CRM_Core_BAO_UFGroup
::
getFields
(
$params
[
'profile_id'
],
$profileFields
=
CRM_Core_BAO_UFGroup
::
getFields
(
$params
[
'profile_id'
],
FALSE
,
FALSE
,
NULL
,
NULL
,
...
@@ -577,7 +572,7 @@ function _civicrm_api3_map_profile_fields_to_entity(&$field) {
...
@@ -577,7 +572,7 @@ function _civicrm_api3_map_profile_fields_to_entity(&$field) {
* how we add a a pseudoconstant to this pseudoapi to make that work
* how we add a a pseudoconstant to this pseudoapi to make that work
*/
*/
function
_civicrm_api3_profile_getProfileID
(
$profileID
)
{
function
_civicrm_api3_profile_getProfileID
(
$profileID
)
{
if
(
!
empty
(
$profileID
)
&&
!
strtolower
(
$profileID
)
=
=
'billing'
&&
!
is_numeric
(
$profileID
))
{
if
(
!
empty
(
$profileID
)
&&
strtolower
(
$profileID
)
!
=
'billing'
&&
!
is_numeric
(
$profileID
))
{
$profileID
=
civicrm_api3
(
'uf_group'
,
'getvalue'
,
array
(
'return'
=>
'id'
,
'name'
=>
$profileID
));
$profileID
=
civicrm_api3
(
'uf_group'
,
'getvalue'
,
array
(
'return'
=>
'id'
,
'name'
=>
$profileID
));
}
}
return
$profileID
;
return
$profileID
;
...
@@ -604,7 +599,7 @@ function _civicrm_api3_profile_appendaliases($values, $entity) {
...
@@ -604,7 +599,7 @@ function _civicrm_api3_profile_appendaliases($values, $entity) {
}
}
//special case on membership & contribution - can't see how to handle in a generic way
//special case on membership & contribution - can't see how to handle in a generic way
if
(
in_array
(
$entity
,
array
(
'Membership'
,
'Contribution'
)))
{
if
(
in_array
(
$entity
,
array
(
'Membership'
,
'Contribution'
)))
{
$values
[
'send_receipt'
]
=
array
(
'title'
=>
'Send Receipt'
,
'type'
=>
16
);
$values
[
'send_receipt'
]
=
array
(
'title'
=>
'Send Receipt'
,
'type'
=>
(
int
)
16
);
}
}
return
$values
;
return
$values
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
api/v3/examples/ProfileGetFields.php
+
1
−
0
View file @
4bcfd71f
...
@@ -138,6 +138,7 @@ function profile_getfields_expectedresult(){
...
@@ -138,6 +138,7 @@ function profile_getfields_expectedresult(){
'date_format'
=>
''
,
'date_format'
=>
''
,
'time_format'
=>
''
,
'time_format'
=>
''
,
'name'
=>
'custom_1'
,
'name'
=>
'custom_1'
,
'type'
=>
2
,
),
),
'profile_id'
=>
array
(
'profile_id'
=>
array
(
'api.required'
=>
true
,
'api.required'
=>
true
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment