Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Extensions
civimobileapi
Commits
672f2510
Commit
672f2510
authored
Feb 09, 2021
by
BohdanDmytryshyn
Browse files
Merge branch 'release_5_5_2_1' into 'master'
Release 5.5.2.1 See merge request
!52
parents
f9a7afe5
4491af69
Changes
6
Hide whitespace changes
Inline
Side-by-side
CRM/CiviMobileAPI/Api/CiviMobileSurveyRespondent/Get.php
View file @
672f2510
...
...
@@ -147,6 +147,7 @@ class CRM_CiviMobileAPI_Api_CiviMobileSurveyRespondent_Get extends CRM_CiviMobil
'sequential'
=>
1
,
'profile_id'
=>
$contactProfile
[
'uf_group_id'
],
'contact_id'
=>
$contact
[
'id'
],
'activity_id'
=>
$activity
[
'id'
]
])[
'values'
];
foreach
(
array_keys
(
$fields
)
as
$field
)
{
...
...
CRM/CiviMobileAPI/ApiWrapper/Contribution.php
View file @
672f2510
...
...
@@ -13,6 +13,12 @@ class CRM_CiviMobileAPI_ApiWrapper_Contribution implements API_Wrapper {
* @return array
*/
public
function
fromApiInput
(
$apiRequest
)
{
if
(
!
empty
(
$apiRequest
[
'params'
][
'return'
]))
{
if
(
is_string
(
$apiRequest
[
'params'
][
'return'
]))
{
$apiRequest
[
'params'
][
'return'
]
=
explode
(
','
,
$apiRequest
[
'params'
][
'return'
]);
}
$apiRequest
[
'params'
][
'return'
]
=
array_unique
(
array_merge
(
$apiRequest
[
'params'
][
'return'
],
[
'currency'
,
'financial_type_id'
]));
}
return
$apiRequest
;
}
...
...
@@ -25,6 +31,10 @@ class CRM_CiviMobileAPI_ApiWrapper_Contribution implements API_Wrapper {
* @return array
*/
public
function
toApiOutput
(
$apiRequest
,
$result
)
{
if
(
is_string
(
$apiRequest
[
'params'
][
'return'
]))
{
$apiRequest
[
'params'
][
'return'
]
=
explode
(
','
,
$apiRequest
[
'params'
][
'return'
]);
}
$result
=
$this
->
fillFinancialTypeName
(
$apiRequest
,
$result
);
$result
=
$this
->
fillFormatTotalAmount
(
$apiRequest
,
$result
);
...
...
@@ -39,7 +49,7 @@ class CRM_CiviMobileAPI_ApiWrapper_Contribution implements API_Wrapper {
* @return Boolean - TRUE if the api result is from version 3.
*/
private
static
function
isApiVersion3
(
$result
)
{
if
(
is_array
(
$result
)
&&
$result
[
'version'
]
==
3
)
{
if
(
is_array
(
$result
)
&&
isset
(
$result
[
'version'
])
&&
$result
[
'version'
]
==
3
)
{
return
TRUE
;
}
return
FALSE
;
...
...
@@ -56,14 +66,12 @@ class CRM_CiviMobileAPI_ApiWrapper_Contribution implements API_Wrapper {
return
$result
;
}
if
(
empty
(
$apiRequest
[
'params'
][
'return'
])
||
(
!
is_array
(
$apiRequest
[
'params'
][
'return'
])
&&
stristr
(
$apiRequest
[
'params'
][
'return'
],
'financial_type_name'
)
!==
FALSE
||
in_array
(
'financial_type_name'
,
$apiRequest
[
'params'
][
'return'
])))
{
if
(
$apiRequest
[
'action'
]
==
'getsingle'
)
{
$result
[
'financial_type_name'
]
=
$this
->
getFinancialTypeName
(
$result
);
}
else
if
(
$apiRequest
[
'action'
]
==
'get'
)
{
foreach
(
$result
[
'values'
]
as
&
$contribution
)
{
$contribution
[
'financial_type_name'
]
=
$this
->
getFinancialTypeName
(
$contribution
);
}
if
(
!
empty
(
$apiRequest
[
'params'
][
'return'
])
&&
in_array
(
'financial_type_name'
,
$apiRequest
[
'params'
][
'return'
])
&&
$apiRequest
[
'action'
]
==
'get'
)
{
foreach
(
$result
[
'values'
]
as
&
$contribution
)
{
$contribution
[
'financial_type_name'
]
=
$this
->
getFinancialTypeName
(
$contribution
);
}
}
...
...
@@ -81,14 +89,12 @@ class CRM_CiviMobileAPI_ApiWrapper_Contribution implements API_Wrapper {
return
$result
;
}
if
(
empty
(
$apiRequest
[
'params'
][
'return'
])
||
(
!
is_array
(
$apiRequest
[
'params'
][
'return'
])
&&
stristr
(
$apiRequest
[
'params'
][
'return'
],
'total_amount'
)
!==
FALSE
||
in_array
(
'total_amount'
,
$apiRequest
[
'params'
][
'return'
])))
{
if
(
$apiRequest
[
'action'
]
==
'getsingle'
)
{
$result
[
'format_total_amount'
]
=
CRM_Utils_Money
::
format
(
$result
[
'total_amount'
],
$result
[
'currency'
]);
}
else
if
(
$apiRequest
[
'action'
]
==
'get'
)
{
foreach
(
$result
[
'values'
]
as
&
$contribution
)
{
$contribution
[
'format_total_amount'
]
=
CRM_Utils_Money
::
format
(
$contribution
[
'total_amount'
],
$contribution
[
'currency'
]);
}
if
(
!
empty
(
$apiRequest
[
'params'
][
'return'
])
&&
in_array
(
'total_amount'
,
$apiRequest
[
'params'
][
'return'
])
&&
$apiRequest
[
'action'
]
==
'get'
)
{
foreach
(
$result
[
'values'
]
as
&
$contribution
)
{
$contribution
[
'format_total_amount'
]
=
CRM_Utils_Money
::
format
(
$contribution
[
'total_amount'
],
$contribution
[
'currency'
]);
}
}
...
...
@@ -103,8 +109,7 @@ class CRM_CiviMobileAPI_ApiWrapper_Contribution implements API_Wrapper {
private
function
getFinancialTypeName
(
$contribution
)
{
if
(
!
empty
(
$contribution
[
'financial_type_id'
]))
{
return
CRM_Core_DAO
::
getFieldValue
(
'CRM_Financial_DAO_FinancialType'
,
$contribution
[
'financial_type_id'
],
'name'
);
}
else
{
}
else
{
$financialTypeId
=
CRM_Core_DAO
::
getFieldValue
(
'CRM_Contribute_DAO_Contribution'
,
$contribution
[
'id'
],
'financial_type_id'
);
return
CRM_Core_DAO
::
getFieldValue
(
'CRM_Financial_DAO_FinancialType'
,
$financialTypeId
,
'name'
);
...
...
CRM/CiviMobileAPI/ApiWrapper/Participant/Get.php
View file @
672f2510
...
...
@@ -33,27 +33,41 @@ class CRM_CiviMobileAPI_ApiWrapper_Participant_Get implements API_Wrapper {
}
$activeParam
=
!
empty
(
$apiRequest
[
'params'
][
'status_active'
])
?
$apiRequest
[
'params'
][
'status_active'
]
:
null
;
$customQrCode
=
"custom_"
.
CRM_CiviMobileAPI_Utils_CustomField
::
getId
(
CRM_CiviMobileAPI_Install_Entity_CustomGroup
::
QR_CODES
,
CRM_CiviMobileAPI_Install_Entity_CustomField
::
QR_CODE
);
$contactIds
=
[];
$participantStatusTypesIds
=
[];
foreach
(
$result
[
'values'
]
as
$key
=>
$value
)
{
$contactIds
[]
=
$value
[
'contact_id'
];
$participantStatusTypesIds
[]
=
$value
[
'participant_status_id'
];
}
if
(
!
empty
(
$contactIds
))
{
$contacts
=
civicrm_api3
(
'Contact'
,
'get'
,
[
'return'
=>
[
"image_URL"
],
'id'
=>
[
'IN'
=>
$contactIds
],
'options'
=>
[
'limit'
=>
0
],
])[
'values'
];
}
else
{
$contacts
=
[];
}
if
(
$activeParam
==
1
&&
!
empty
(
$participantStatusTypesIds
))
{
$participantStatusTypes
=
civicrm_api3
(
'ParticipantStatusType'
,
'get'
,
[
'id'
=>
[
'IN'
=>
array_unique
(
$participantStatusTypesIds
)],
'options'
=>
[
'limit'
=>
0
],
])[
'values'
];
}
else
{
$participantStatusTypes
=
[];
}
foreach
(
$result
[
'values'
]
as
$key
=>
&
$value
)
{
try
{
$imageUrl
=
civicrm_api3
(
'Contact'
,
'getvalue'
,
[
'return'
=>
"image_URL"
,
'id'
=>
$value
[
'contact_id'
],
]);
}
catch
(
CiviCRM_API3_Exception
$e
)
{
throw
new
\
API_Exception
(
E
::
ts
(
"Something wrong with getting img url of contact: "
.
$e
->
getMessage
()));
}
$imageUrl
=
!
empty
(
$contacts
[
$value
[
'contact_id'
]])
?
$contacts
[
$value
[
'contact_id'
]][
'image_URL'
]
:
''
;
if
(
$activeParam
==
1
)
{
try
{
$statusInfo
=
civicrm_api3
(
'ParticipantStatusType'
,
'getsingle'
,
[
'sequential'
=>
1
,
'return'
=>
[
"is_active"
],
'id'
=>
$value
[
'participant_status_id'
]
]);
}
catch
(
CiviCRM_API3_Exception
$e
)
{
$statusInfo
=
[];
}
$statusInfo
=
!
empty
(
$participantStatusTypes
[
$value
[
'participant_status_id'
]])
?
$participantStatusTypes
[
$value
[
'participant_status_id'
]]
:
[];
if
(
!
empty
(
$statusInfo
)
&&
$statusInfo
[
'is_active'
]
!=
1
)
{
unset
(
$result
[
'values'
][
$key
]);
...
...
@@ -61,10 +75,8 @@ class CRM_CiviMobileAPI_ApiWrapper_Participant_Get implements API_Wrapper {
}
}
$customQrCode
=
"custom_"
.
CRM_CiviMobileAPI_Utils_CustomField
::
getId
(
CRM_CiviMobileAPI_Install_Entity_CustomGroup
::
QR_CODES
,
CRM_CiviMobileAPI_Install_Entity_CustomField
::
QR_CODE
);
$value
[
'qr_token'
]
=
!
empty
(
$value
[
$customQrCode
])
?
$value
[
$customQrCode
]
:
''
;
$value
[
'image_URL'
]
=
!
empty
(
$imageUrl
)
?
$imageUrl
:
''
;
$value
[
'image_URL'
]
=
$imageUrl
;
}
$result
[
'values'
]
=
array_values
(
$result
[
'values'
]);
...
...
CRM/CiviMobileAPI/Utils/VersionController.php
View file @
672f2510
...
...
@@ -11,34 +11,14 @@ class CRM_CiviMobileAPI_Utils_VersionController {
private
static
$instance
;
/**
*
Major v
ersion of current extension
*
V
ersion of current extension
*/
private
$current
Major
Version
=
0
;
private
$currentVersion
=
'0.0.0'
;
/**
*
Minor version of current extension
*
Version of extension in remote repository
*/
private
$currentMinorVersion
=
0
;
/**
* Patch version of current extension
*/
private
$currentPatchVersion
=
0
;
/**
* Latest major version of extension in remote repository
*/
private
$latestMajorVersion
=
0
;
/**
* Latest minor version of extension in remote repository
*/
private
$latestMinorVersion
=
0
;
/**
* Latest patch version of extension in remote repository
*/
private
$latestPatchVersion
=
0
;
private
$latestVersion
=
'0.0.0'
;
/**
* Is sets version from repository
...
...
@@ -56,10 +36,7 @@ class CRM_CiviMobileAPI_Utils_VersionController {
* Sets version from current extension
*/
public
function
setVersionFromExtension
()
{
$currentVersion
=
$this
->
parseVersion
(
$this
->
getCurrentVersion
());
$this
->
currentMajorVersion
=
$currentVersion
[
'major'
];
$this
->
currentMinorVersion
=
$currentVersion
[
'minor'
];
$this
->
currentPatchVersion
=
$currentVersion
[
'patch'
];
$this
->
currentVersion
=
$this
->
getCurrentVersion
();
}
/**
...
...
@@ -70,50 +47,10 @@ class CRM_CiviMobileAPI_Utils_VersionController {
return
;
}
$latestVersion
=
$this
->
parseVersion
(
$this
->
getLatestVersion
());
$this
->
latestMajorVersion
=
$latestVersion
[
'major'
];
$this
->
latestMinorVersion
=
$latestVersion
[
'minor'
];
$this
->
latestPatchVersion
=
$latestVersion
[
'patch'
];
$this
->
latestVersion
=
$this
->
getLatestVersion
();
$this
->
isSetVersionFromRepository
=
true
;
}
/**
* Parse version
*
* @param $versionString
*
* @return array
*/
private
function
parseVersion
(
$versionString
)
{
$version
=
[
'major'
=>
0
,
'minor'
=>
0
,
'patch'
=>
0
,
];
$versionString
=
trim
(
trim
((
string
)
$versionString
,
'v'
));
if
(
empty
(
$versionString
))
{
return
$version
;
}
$splitVersion
=
explode
(
'.'
,
$versionString
);
if
(
isset
(
$splitVersion
[
0
]))
{
$version
[
'major'
]
=
(
int
)
$splitVersion
[
0
];
}
if
(
isset
(
$splitVersion
[
1
]))
{
$version
[
'minor'
]
=
(
int
)
$splitVersion
[
1
];
}
if
(
isset
(
$splitVersion
[
2
]))
{
$version
[
'patch'
]
=
(
int
)
$splitVersion
[
2
];
}
return
$version
;
}
/**
* Gets current version of extension
*
...
...
@@ -163,22 +100,7 @@ class CRM_CiviMobileAPI_Utils_VersionController {
public
function
isCurrentVersionLowerThanRepositoryVersion
()
{
$this
->
setVersionFromRepository
();
if
(
$this
->
getCurrentMajorVersion
()
<
$this
->
getLatestMajorVersion
())
{
return
true
;
}
if
((
$this
->
getCurrentMajorVersion
()
==
$this
->
getLatestMajorVersion
())
&&
(
$this
->
getCurrentMinorVersion
()
<
$this
->
getLatestMinorVersion
()))
{
return
true
;
}
if
((
$this
->
getCurrentMajorVersion
()
==
$this
->
getLatestMajorVersion
())
&&
(
$this
->
getCurrentMinorVersion
()
==
$this
->
getLatestMinorVersion
())
&&
(
$this
->
getCurrentPatchVersion
()
<
$this
->
getLatestPatchVersion
()))
{
return
true
;
}
return
false
;
return
version_compare
(
$this
->
currentVersion
,
$this
->
latestVersion
,
'<'
);
}
/**
...
...
@@ -200,7 +122,7 @@ class CRM_CiviMobileAPI_Utils_VersionController {
*/
public
function
getLatestFullVersion
()
{
$this
->
setVersionFromRepository
();
return
$this
->
getLatestMajorVersion
()
.
'.'
.
$this
->
getLatestMinorVersion
()
.
'.'
.
$this
->
getLatestPatch
Version
()
;
return
$this
->
latest
Version
;
}
/**
...
...
@@ -209,52 +131,7 @@ class CRM_CiviMobileAPI_Utils_VersionController {
* @return string
*/
public
function
getCurrentFullVersion
()
{
return
$this
->
getCurrentMajorVersion
()
.
'.'
.
$this
->
getCurrentMinorVersion
()
.
'.'
.
$this
->
getCurrentPatchVersion
();
}
/**
* @return int
*/
public
function
getCurrentMajorVersion
()
{
return
$this
->
currentMajorVersion
;
}
/**
* @return int
*/
public
function
getCurrentMinorVersion
()
{
return
$this
->
currentMinorVersion
;
}
/**
* @return int
*/
public
function
getCurrentPatchVersion
()
{
return
$this
->
currentPatchVersion
;
}
/**
* @return int
*/
public
function
getLatestMajorVersion
()
{
$this
->
setVersionFromRepository
();
return
$this
->
latestMajorVersion
;
}
/**
* @return int
*/
public
function
getLatestMinorVersion
()
{
$this
->
setVersionFromRepository
();
return
$this
->
latestMinorVersion
;
}
/**
* @return mixed
*/
public
function
getLatestPatchVersion
()
{
$this
->
setVersionFromRepository
();
return
$this
->
latestPatchVersion
;
return
$this
->
currentVersion
;
}
private
function
__clone
()
{}
...
...
civimobileapi.php
View file @
672f2510
...
...
@@ -160,7 +160,7 @@ function civimobileapi_civicrm_apiWrappers(&$wrappers, $apiRequest) {
elseif
(
$apiRequest
[
'entity'
]
==
'Note'
&&
$apiRequest
[
'action'
]
==
'get'
)
{
$wrappers
[]
=
new
CRM_CiviMobileAPI_ApiWrapper_Note
();
}
elseif
(
$apiRequest
[
'entity'
]
==
'Contribution'
&&
(
$apiRequest
[
'action'
]
==
'getsingle'
||
$apiRequest
[
'action'
]
==
'get'
)
)
{
elseif
(
$apiRequest
[
'entity'
]
==
'Contribution'
&&
$apiRequest
[
'action'
]
==
'get'
)
{
$wrappers
[]
=
new
CRM_CiviMobileAPI_ApiWrapper_Contribution
();
}
elseif
(
$apiRequest
[
'entity'
]
==
'Membership'
)
{
...
...
@@ -717,3 +717,16 @@ function civimobileapi_civicrm_postSave_civicrm_activity($dao) {
]);
}
}
function
civimobileapi_civicrm_preProcess
(
$formName
,
&
$form
)
{
if
(
$formName
==
'CRM_Activity_Form_Activity'
||
$formName
==
'CRM_Custom_Form_CustomDataByType'
)
{
$groupTree
=
$form
->
getVar
(
'_groupTree'
);
foreach
(
$groupTree
as
$key
=>
$customGroup
)
{
if
(
$customGroup
[
'name'
]
==
CRM_CiviMobileAPI_Install_Entity_CustomGroup
::
SURVEY
)
{
unset
(
$groupTree
[
$key
]);
}
}
$form
->
setVar
(
'_groupTree'
,
$groupTree
);
}
}
info.xml
View file @
672f2510
...
...
@@ -14,8 +14,8 @@
<url
desc=
"Support"
>
https://civimobile.org
</url>
<url
desc=
"Licensing"
>
http://www.gnu.org/licenses/agpl-3.0.html
</url>
</urls>
<releaseDate>
2021-02-0
1
</releaseDate>
<version>
5.5.2
</version>
<releaseDate>
2021-02-0
9
</releaseDate>
<version>
5.5.2
.1
</version>
<compatibility>
<ver>
4.7
</ver>
<ver>
5.20
</ver>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment