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
90081c6d
Commit
90081c6d
authored
May 17, 2021
by
BohdanDmytryshyn
Browse files
Merge branch 'release_5_6_0' into 'master'
Release 5.6.0 See merge request
!53
parents
672f2510
722f8488
Changes
26
Hide whitespace changes
Inline
Side-by-side
CRM/CiviMobileAPI/Api/CiviMobileParticipantPaymentLink/Get.php
View file @
90081c6d
...
...
@@ -50,6 +50,8 @@ class CRM_CiviMobileAPI_Api_CiviMobileParticipantPaymentLink_Get extends CRM_Civ
}
elseif
(
$currentCMS
==
CRM_CiviMobileAPI_Utils_CmsUser
::
CMS_DRUPAL8
)
{
$absoluteUrl
=
CRM_Utils_System
::
url
(
'civicrm/event/register'
,
'id='
.
$this
->
validParams
[
'event_id'
]
.
'&reset=1&cmbHash='
.
$cmbHash
,
TRUE
,
NULL
,
FALSE
);
$url
=
'/'
.
str_replace
(
$config
->
userFrameworkBaseURL
,
""
,
$absoluteUrl
);
}
elseif
(
$currentCMS
==
CRM_CiviMobileAPI_Utils_CmsUser
::
CMS_WORDPRESS
)
{
$url
=
wp_make_link_relative
(
$url
);
}
$result
[
'link'
]
=
html_entity_decode
(
$url
);
...
...
@@ -64,11 +66,6 @@ class CRM_CiviMobileAPI_Api_CiviMobileParticipantPaymentLink_Get extends CRM_Civ
* @throws api_Exception
*/
protected
function
getValidParams
(
$params
)
{
$currentCMS
=
CRM_CiviMobileAPI_Utils_CmsUser
::
getInstance
()
->
getSystem
();
if
(
$currentCMS
==
CRM_CiviMobileAPI_Utils_CmsUser
::
CMS_JOOMLA
)
{
throw
new
api_Exception
(
E
::
ts
(
'Joomla does not support that functionality'
),
'joomla_does_not_support_that_functionality'
);
}
$eventId
=
(
int
)
$params
[
'event_id'
];
$contactId
=
(
int
)
$params
[
'contact_id'
];
$selPriceSet
=
((
is_array
(
$params
[
'price_set'
]))
?
$params
[
'price_set'
]
:
json_decode
(
$params
[
'price_set'
],
true
));
...
...
CRM/CiviMobileAPI/ApiWrapper/Event.php
View file @
90081c6d
...
...
@@ -34,22 +34,7 @@ class CRM_CiviMobileAPI_ApiWrapper_Event implements API_Wrapper {
if
(
$apiRequest
[
'action'
]
==
'getsingle'
)
{
$result
[
'url'
]
=
CRM_Utils_System
::
url
(
'civicrm/event/info'
,
'id='
.
$result
[
'id'
],
true
);
if
(
!
empty
(
$result
[
'creator_id'
]))
{
$result
[
$isQrUsedAlias
]
=
(
isset
(
$result
[
$isQrUsedFieldName
]))
?
$result
[
$isQrUsedFieldName
]
:
NULL
;
$result
[
'is_user_'
.
CRM_CiviMobileAPI_Utils_Permission
::
CAN_CHECK_IN_ON_EVENT
]
=
(
int
)
CRM_Core_Permission
::
check
(
CRM_CiviMobileAPI_Utils_Permission
::
CAN_CHECK_IN_ON_EVENT
);
$result
[
'is_user_can_manage_participant'
]
=
(
int
)
CRM_CiviMobileAPI_Utils_Permission
::
isUserCanManageParticipant
(
$result
[
'creator_id'
]);
}
if
(
isset
(
$result
[
'currency'
]))
{
if
(
!
empty
(
$result
[
'currency'
]))
{
$result
[
'currency_symbol'
]
=
CRM_CiviMobileAPI_Utils_Currency
::
getSymbolByName
(
$result
[
'currency'
]);
}
else
{
$result
[
'currency_symbol'
]
=
''
;
}
}
else
{
$result
[
'currency'
]
=
''
;
$result
[
'currency_symbol'
]
=
''
;
}
$result
[
'registered_participants_count'
]
=
CRM_Event_BAO_Event
::
getParticipantCount
(
$result
[
'id'
],
FALSE
,
FALSE
,
FALSE
,
FALSE
);
}
if
(
$apiRequest
[
'action'
]
==
'get'
&&
!
empty
(
$result
[
'values'
]))
{
...
...
CRM/CiviMobileAPI/ApiWrapper/Membership/Get.php
View file @
90081c6d
...
...
@@ -25,6 +25,10 @@ class CRM_CiviMobileAPI_ApiWrapper_Membership_Get 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
->
fillAdditionalInfo
(
$apiRequest
,
$result
);
$result
=
$this
->
fillRelatedCount
(
$apiRequest
,
$result
);
$result
=
$this
->
fillByRelationship
(
$apiRequest
,
$result
);
...
...
@@ -42,7 +46,10 @@ class CRM_CiviMobileAPI_ApiWrapper_Membership_Get implements API_Wrapper {
*/
private
function
fillAdditionalInfo
(
$apiRequest
,
$result
)
{
if
(
$apiRequest
[
'action'
]
==
'getsingle'
)
{
if
(
empty
(
$apiRequest
[
'params'
][
'return'
])
||
stristr
(
$apiRequest
[
'params'
][
'return'
],
'renewal_amount'
)
!==
false
)
{
if
(
empty
(
$apiRequest
[
'params'
][
'return'
])
||
in_array
(
'renewal_amount'
,
$apiRequest
[
'params'
][
'return'
])
||
in_array
(
'format_renewal_amount'
,
$apiRequest
[
'params'
][
'return'
])
)
{
$result
+=
$this
->
getAdditionalInfo
(
$result
,
$apiRequest
);
}
}
...
...
@@ -66,10 +73,6 @@ class CRM_CiviMobileAPI_ApiWrapper_Membership_Get implements API_Wrapper {
* @return array
*/
private
function
getAdditionalInfo
(
$membership
,
$apiRequest
)
{
if
(
!
empty
(
$apiRequest
[
'params'
][
'return'
])
&&
is_array
(
$apiRequest
[
'params'
][
'return'
]))
{
return
[];
}
$config
=
CRM_Core_Config
::
singleton
();
$additionalInfo
=
[];
...
...
@@ -86,14 +89,17 @@ class CRM_CiviMobileAPI_ApiWrapper_Membership_Get implements API_Wrapper {
}
catch
(
Exception
$e
)
{}
}
if
(
empty
(
$apiRequest
[
'params'
][
'return'
])
||
stristr
(
$apiRequest
[
'params'
][
'return'
],
'renewal_amount'
)
!==
false
)
{
if
(
empty
(
$apiRequest
[
'params'
][
'return'
])
||
in_array
(
'renewal_amount'
,
$apiRequest
[
'params'
][
'return'
])
||
in_array
(
'format_renewal_amount'
,
$apiRequest
[
'params'
][
'return'
])
)
{
$membershipTypeId
=
!
empty
(
$membership
[
'membership_type_id'
])
?
$membership
[
'membership_type_id'
]
:
CRM_Core_DAO
::
getFieldValue
(
'CRM_Member_DAO_Membership'
,
$membership
[
'id'
],
'membership_type_id'
);
$additionalInfo
[
'renewal_amount'
]
=
CRM_Core_DAO
::
getFieldValue
(
'CRM_Member_DAO_MembershipType'
,
$membershipTypeId
,
'minimum_fee'
)
?:
0
;
$additionalInfo
[
'format_renewal_amount'
]
=
CRM_Utils_Money
::
format
(
$additionalInfo
[
'renewal_amount'
],
$config
->
defaultCurrency
);
}
if
(
empty
(
$apiRequest
[
'params'
][
'return'
])
||
stristr
(
$apiRequest
[
'params'
][
'return'
]
,
'can_renewal'
)
!==
false
)
{
if
(
empty
(
$apiRequest
[
'params'
][
'return'
])
||
in_array
(
'can_renewal'
,
$apiRequest
[
'params'
][
'return'
]
)
)
{
$additionalInfo
[
'can_renewal'
]
=
!
CRM_Core_DAO
::
getFieldValue
(
'CRM_Member_DAO_Membership'
,
$membership
[
'id'
],
'owner_membership_id'
)
?
1
:
0
;
}
...
...
@@ -110,11 +116,7 @@ class CRM_CiviMobileAPI_ApiWrapper_Membership_Get implements API_Wrapper {
* @return array
*/
private
function
fillRelatedCount
(
$apiRequest
,
$result
)
{
if
(
!
empty
(
$apiRequest
[
'params'
][
'return'
])
&&
is_array
(
$apiRequest
[
'params'
][
'return'
]))
{
return
$result
;
}
if
(
!
(
empty
(
$apiRequest
[
'params'
][
'return'
])
||
stristr
(
$apiRequest
[
'params'
][
'return'
],
'related_count'
)
!==
false
))
{
if
(
!
(
empty
(
$apiRequest
[
'params'
][
'return'
])
||
in_array
(
'related_count'
,
$apiRequest
[
'params'
][
'return'
])))
{
return
$result
;
}
...
...
@@ -168,11 +170,7 @@ class CRM_CiviMobileAPI_ApiWrapper_Membership_Get implements API_Wrapper {
* @return mixed
*/
private
function
fillByRelationship
(
$apiRequest
,
$result
)
{
if
(
!
empty
(
$apiRequest
[
'params'
][
'return'
])
&&
is_array
(
$apiRequest
[
'params'
][
'return'
]))
{
return
$result
;
}
if
(
!
(
empty
(
$apiRequest
[
'params'
][
'return'
])
||
stristr
(
$apiRequest
[
'params'
][
'return'
],
'by_relationship_contact_id'
)
!==
false
))
{
if
(
!
(
empty
(
$apiRequest
[
'params'
][
'return'
])
||
in_array
(
'by_relationship_contact_id'
,
$apiRequest
[
'params'
][
'return'
])))
{
return
$result
;
}
...
...
CRM/CiviMobileAPI/ApiWrapper/Participant/Create.php
View file @
90081c6d
...
...
@@ -26,7 +26,7 @@ class CRM_CiviMobileAPI_ApiWrapper_Participant_Create implements API_Wrapper {
$participant
->
event_id
=
$apiRequest
[
'params'
][
'event_id'
];
$participantExist
=
$participant
->
find
(
TRUE
);
if
(
!
empty
(
$participantExist
))
{
if
(
!
empty
(
$participantExist
)
&&
empty
(
$apiRequest
[
'params'
][
'id'
])
)
{
throw
new
api_Exception
(
E
::
ts
(
'This contact has already been assigned to this event.'
),
'contact_already_registered'
);
}
...
...
CRM/CiviMobileAPI/ApiWrapper/Participant/Get.php
View file @
90081c6d
...
...
@@ -41,7 +41,9 @@ class CRM_CiviMobileAPI_ApiWrapper_Participant_Get implements API_Wrapper {
$participantStatusTypesIds
=
[];
foreach
(
$result
[
'values'
]
as
$key
=>
$value
)
{
$contactIds
[]
=
$value
[
'contact_id'
];
$participantStatusTypesIds
[]
=
$value
[
'participant_status_id'
];
if
(
!
empty
(
$value
[
'participant_status_id'
]))
{
$participantStatusTypesIds
[]
=
$value
[
'participant_status_id'
];
}
}
if
(
!
empty
(
$contactIds
))
{
...
...
@@ -63,6 +65,7 @@ class CRM_CiviMobileAPI_ApiWrapper_Participant_Get implements API_Wrapper {
$participantStatusTypes
=
[];
}
$currentCMS
=
CRM_CiviMobileAPI_Utils_CmsUser
::
getInstance
()
->
getSystem
();
foreach
(
$result
[
'values'
]
as
$key
=>
&
$value
)
{
$imageUrl
=
!
empty
(
$contacts
[
$value
[
'contact_id'
]])
?
$contacts
[
$value
[
'contact_id'
]][
'image_URL'
]
:
''
;
...
...
@@ -75,8 +78,19 @@ class CRM_CiviMobileAPI_ApiWrapper_Participant_Get implements API_Wrapper {
}
}
$displayImageUrl
=
''
;
if
(
!
empty
(
$value
[
$customQrCode
]))
{
$photoName
=
'participantId_'
.
$value
[
'participant_id'
]
.
'.png'
;
$displayImageUrl
=
CRM_Utils_System
::
url
(
'civicrm/civimobile/file'
,
[
'photo'
=>
$photoName
],
TRUE
,
NULL
,
FALSE
);
if
(
$currentCMS
==
CRM_CiviMobileAPI_Utils_CmsUser
::
CMS_JOOMLA
)
{
$displayImageUrl
=
preg_replace
(
'/administrator\//'
,
'index.php'
,
$displayImageUrl
);
}
}
$value
[
'qr_token'
]
=
!
empty
(
$value
[
$customQrCode
])
?
$value
[
$customQrCode
]
:
''
;
$value
[
'image_URL'
]
=
$imageUrl
;
$value
[
'display_image_URL'
]
=
$displayImageUrl
;
}
$result
[
'values'
]
=
array_values
(
$result
[
'values'
]);
...
...
CRM/CiviMobileAPI/ApiWrapper/Relationship/Get.php
View file @
90081c6d
...
...
@@ -25,6 +25,19 @@ class CRM_CiviMobileAPI_ApiWrapper_Relationship_Get implements API_Wrapper {
* @return array
*/
public
function
toApiOutput
(
$apiRequest
,
$result
)
{
if
(
!
empty
(
$apiRequest
[
'params'
][
'contact_id_b'
]))
{
$relationship
=
new
CRM_Contact_DAO_Relationship
();
$relationship
->
is_active
=
1
;
$relationship
->
contact_id_b
=
$apiRequest
[
'params'
][
'contact_id_b'
];
$relationship
->
selectAdd
();
$relationship
->
selectAdd
(
'contact_id_b, is_active'
);
$relationship
->
find
(
TRUE
);
$result
[
'total_count'
]
=
$relationship
->
count
();
}
return
$result
;
}
...
...
CRM/CiviMobileAPI/Form/Dashboard.php
View file @
90081c6d
<?php
use
CRM_CiviMobileAPI_ExtensionUtil
as
E
;
/*--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2017 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+-------------------------------------------------------------------*/
class
CRM_CiviMobileAPI_Form_Dashboard
extends
CRM_Core_Form
{
...
...
@@ -41,6 +18,8 @@ class CRM_CiviMobileAPI_Form_Dashboard extends CRM_Core_Form {
}
$this
->
add
(
'hidden'
,
'cid'
,
$cid
);
$this
->
assign
(
'isLoggedInContactForm'
,
CRM_Core_Session
::
singleton
()
->
getLoggedInContactID
()
==
$cid
);
}
/**
...
...
@@ -50,14 +29,23 @@ class CRM_CiviMobileAPI_Form_Dashboard extends CRM_Core_Form {
*/
public
function
buildQuickForm
()
{
parent
::
buildQuickForm
();
$cid
=
CRM_Utils_Request
::
retrieve
(
'cid'
,
'Integer'
);
$logoutBtnAttrs
=
[];
if
(
!
CRM_CiviMobileAPI_Utils_Contact
::
isContactHasApiKey
(
$cid
))
{
$logoutBtnAttrs
[
'disabled'
]
=
'disabled'
;
}
$this
->
addButtons
([
[
'type'
=>
'submit'
,
'name'
=>
E
::
ts
(
'Logout from mobile'
),
'isDefault'
=>
TRUE
,
'js'
=>
$logoutBtnAttrs
]
]);
$this
->
addElement
(
'checkbox'
,
'civimobile_show_qr_popup'
,
E
::
ts
(
'Show a Website URL QR-code for me'
));
}
/**
...
...
@@ -69,4 +57,15 @@ class CRM_CiviMobileAPI_Form_Dashboard extends CRM_Core_Form {
CRM_CiviMobileAPI_Utils_Contact
::
logoutFromMobile
(
$params
[
'cid'
]);
}
/**
* Set defaults for form.
*/
public
function
setDefaultValues
()
{
$defaults
=
[];
$defaults
[
'civimobile_show_qr_popup'
]
=
!
$_COOKIE
[
"civimobile_popup_close"
];
return
$defaults
;
}
}
CRM/CiviMobileAPI/Form/Settings.php
View file @
90081c6d
...
...
@@ -77,6 +77,7 @@ class CRM_CiviMobileAPI_Form_Settings extends CRM_Core_Form {
$this
->
addFormRule
([
CRM_CiviMobileAPI_Form_Settings
::
class
,
'validateToken'
]);
}
elseif
(
!
empty
(
$params
[
'_qf_Settings_upload'
]))
{
$this
->
addFormRule
([
CRM_CiviMobileAPI_Form_Settings
::
class
,
'validateNewsSettings'
]);
$this
->
addFormRule
([
CRM_CiviMobileAPI_Form_Settings
::
class
,
'validatePushNotificationSettings'
]);
}
}
...
...
@@ -99,6 +100,19 @@ class CRM_CiviMobileAPI_Form_Settings extends CRM_Core_Form {
return
empty
(
$errors
)
?
TRUE
:
$errors
;
}
public
static
function
validatePushNotificationSettings
(
$values
)
{
if
(
!
is_numeric
(
$values
[
"civimobile_push_notification_lifetime"
]))
{
$errors
[
"civimobile_push_notification_lifetime"
]
=
E
::
ts
(
'Value must be integer!'
);
}
if
(
$values
[
"civimobile_push_notification_lifetime"
]
<
0
)
{
$errors
[
"civimobile_push_notification_lifetime"
]
=
E
::
ts
(
'Value cannot be negative!'
);
}
if
(
$values
[
"civimobile_push_notification_lifetime"
]
>
90
)
{
$errors
[
"civimobile_push_notification_lifetime"
]
=
E
::
ts
(
'Value cannot be greater than 90!'
);
}
return
empty
(
$errors
)
?
TRUE
:
$errors
;
}
/**
* Validates token
*
...
...
@@ -157,6 +171,7 @@ class CRM_CiviMobileAPI_Form_Settings extends CRM_Core_Form {
$this
->
addElement
(
'text'
,
'civimobile_news_rss_feed_url'
,
E
::
ts
(
'News RSS feed URL'
));
$this
->
addElement
(
'text'
,
'civimobile_firebase_key'
,
E
::
ts
(
'Firebase key'
));
$this
->
addElement
(
'checkbox'
,
'civimobile_is_custom_app'
,
E
::
ts
(
'Do you have custom application?'
));
$this
->
addElement
(
'text'
,
'civimobile_push_notification_lifetime'
,
E
::
ts
(
'Life time for push notification messages'
));
$buttons
=
[
[
...
...
@@ -230,6 +245,9 @@ class CRM_CiviMobileAPI_Form_Settings extends CRM_Core_Form {
if
(
!
isset
(
$params
[
'civimobile_is_allow_public_info_api'
]))
{
$params
[
'civimobile_is_allow_public_info_api'
]
=
0
;
}
if
(
!
isset
(
$params
[
'civimobile_push_notification_lifetime'
]))
{
$params
[
'civimobile_push_notification_lifetime'
]
=
CRM_CiviMobileAPI_BAO_PushNotificationMessages
::
LIFE_TIME_IN_DAYS
;
}
Civi
::
settings
()
->
set
(
'civimobile_is_custom_app'
,
$params
[
'civimobile_is_custom_app'
]);
Civi
::
settings
()
->
set
(
'civimobile_firebase_key'
,
$params
[
'civimobile_firebase_key'
]);
...
...
@@ -239,6 +257,7 @@ class CRM_CiviMobileAPI_Form_Settings extends CRM_Core_Form {
Civi
::
settings
()
->
set
(
'civimobile_is_allow_public_info_api'
,
$params
[
'civimobile_is_allow_public_info_api'
]);
Civi
::
settings
()
->
set
(
'civimobile_is_showed_news'
,
$params
[
'civimobile_is_showed_news'
]);
Civi
::
settings
()
->
set
(
'civimobile_news_rss_feed_url'
,
$params
[
'civimobile_news_rss_feed_url'
]);
Civi
::
settings
()
->
set
(
"civimobile_push_notification_lifetime"
,
$params
[
'civimobile_push_notification_lifetime'
]);
CRM_Core_Session
::
singleton
()
->
setStatus
(
E
::
ts
(
'CiviMobile settings updated'
),
E
::
ts
(
'CiviMobile Settings'
),
'success'
);
}
}
...
...
@@ -248,6 +267,7 @@ class CRM_CiviMobileAPI_Form_Settings extends CRM_Core_Form {
*/
public
function
setDefaultValues
()
{
$defaults
=
[];
$pushNotificationLifetime
=
Civi
::
settings
()
->
get
(
'civimobile_push_notification_lifetime'
);
$defaults
[
'civimobile_auto_update'
]
=
Civi
::
settings
()
->
get
(
'civimobile_auto_update'
);
$defaults
[
'civimobile_server_key'
]
=
Civi
::
settings
()
->
get
(
'civimobile_server_key'
);
...
...
@@ -259,6 +279,8 @@ class CRM_CiviMobileAPI_Form_Settings extends CRM_Core_Form {
$defaults
[
'civimobile_news_rss_feed_url'
]
=
CRM_CiviMobileAPI_Utils_Extension
::
newsRssFeedUrl
();
$defaults
[
'civimobile_firebase_key'
]
=
Civi
::
settings
()
->
get
(
'civimobile_firebase_key'
);
$defaults
[
'civimobile_is_custom_app'
]
=
CRM_CiviMobileAPI_Utils_Extension
::
isCustomApp
();
$defaults
[
'civimobile_push_notification_lifetime'
]
=
isset
(
$pushNotificationLifetime
)
?
(
int
)
$pushNotificationLifetime
:
CRM_CiviMobileAPI_BAO_PushNotificationMessages
::
LIFE_TIME_IN_DAYS
;
return
$defaults
;
}
...
...
CRM/CiviMobileAPI/Hook/BuildForm/ContributionPayment.php
View file @
90081c6d
...
...
@@ -23,8 +23,6 @@ class CRM_CiviMobileAPI_Hook_BuildForm_ContributionPayment {
}
if
(
$session
->
get
(
'contribution_is_civimobile'
)
&&
in_array
(
$formName
,
$customizeForms
))
{
CRM_CiviMobileAPI_Authentication_AuthenticationHelper
::
authenticateContact
();
$this
->
customizeContributionPayment
();
}
...
...
CRM/CiviMobileAPI/Hook/BuildForm/Register.php
View file @
90081c6d
...
...
@@ -39,6 +39,8 @@ class CRM_CiviMobileAPI_Hook_BuildForm_Register {
if
(
$tmpData
=
CRM_CiviMobileAPI_BAO_CivimobileEventPaymentInfo
::
getByHash
(
$cmbHash
))
{
$priceSet
=
json_decode
(
$tmpData
[
'price_set'
],
true
);
$personalFields
=
$this
->
findPersonalFields
(
$tmpData
);
$billingFields
=
$this
->
findBillingFields
(
$tmpData
);
$billingLocationID
=
CRM_Core_BAO_LocationType
::
getBilling
();
if
(
$form
->
elementExists
(
'first_name'
))
{
$element
=
$form
->
getElement
(
'first_name'
);
...
...
@@ -58,6 +60,48 @@ class CRM_CiviMobileAPI_Hook_BuildForm_Register {
}
}
if
(
!
empty
(
$billingFields
))
{
if
(
$form
->
elementExists
(
'billing_first_name'
))
{
$element
=
$form
->
getElement
(
'billing_first_name'
);
$element
->
setValue
(
$personalFields
[
'first_name'
]);
}
if
(
$form
->
elementExists
(
'billing_middle_name'
))
{
$element
=
$form
->
getElement
(
'billing_middle_name'
);
$element
->
setValue
(
$personalFields
[
'middle_name'
]);
}
if
(
$form
->
elementExists
(
'billing_last_name'
))
{
$element
=
$form
->
getElement
(
'billing_last_name'
);
$element
->
setValue
(
$personalFields
[
'last_name'
]);
}
if
(
$form
->
elementExists
(
"billing_street_address-
{
$billingLocationID
}
"
))
{
$element
=
$form
->
getElement
(
"billing_street_address-
{
$billingLocationID
}
"
);
$element
->
setValue
(
$billingFields
[
'street_address'
]);
}
if
(
$form
->
elementExists
(
"billing_city-
{
$billingLocationID
}
"
))
{
$element
=
$form
->
getElement
(
"billing_city-
{
$billingLocationID
}
"
);
$element
->
setValue
(
$billingFields
[
'city'
]);
}
if
(
$form
->
elementExists
(
"billing_country_id-
{
$billingLocationID
}
"
))
{
$element
=
$form
->
getElement
(
"billing_country_id-
{
$billingLocationID
}
"
);
$element
->
setValue
(
$billingFields
[
'country_id'
]);
}
if
(
$form
->
elementExists
(
"billing_state_province_id-
{
$billingLocationID
}
"
))
{
$element
=
$form
->
getElement
(
"billing_state_province_id-
{
$billingLocationID
}
"
);
$element
->
setValue
(
$billingFields
[
'state_province_id'
]);
}
if
(
$form
->
elementExists
(
"billing_postal_code-
{
$billingLocationID
}
"
))
{
$element
=
$form
->
getElement
(
"billing_postal_code-
{
$billingLocationID
}
"
);
$element
->
setValue
(
$billingFields
[
'state_province_id'
]);
}
}
$this
->
setValuesToPriceSet
(
$priceSet
,
$form
);
$session
->
set
(
'cmbHash'
,
$cmbHash
);
}
else
{
...
...
@@ -156,7 +200,7 @@ class CRM_CiviMobileAPI_Hook_BuildForm_Register {
if
(
$contactId
)
{
try
{
$contact
=
civicrm_api3
(
'Contact'
,
'getsingle'
,
[
'return'
=>
[
"first_name"
,
"last_name"
],
'return'
=>
[
"first_name"
,
"last_name"
,
"middle_name"
],
'sequential'
=>
1
,
'id'
=>
$contactId
]);
...
...
@@ -177,20 +221,57 @@ class CRM_CiviMobileAPI_Hook_BuildForm_Register {
$firstName
=
$contact
[
'first_name'
];
$lastName
=
$contact
[
'last_name'
];
$middleName
=
$contact
[
'middle_name'
];
if
(
isset
(
$contactsEmail
[
'email'
]))
{
$email
=
$contactsEmail
[
'email'
];
}
}
else
{
$firstName
=
$tmpData
[
'first_name'
];
$lastName
=
$tmpData
[
'last_name'
];
$middleName
=
''
;
$email
=
$tmpData
[
'email'
];
}
return
[
'first_name'
=>
$firstName
,
'last_name'
=>
$lastName
,
'middle_name'
=>
$middleName
,
'email'
=>
$email
,
];
}
/**
* @param $tmpData
* @return array
*/
private
function
findBillingFields
(
$tmpData
)
{
$contactId
=
$tmpData
[
'contact_id'
];
if
(
$contactId
)
{
try
{
$contactsAddress
=
civicrm_api3
(
'Address'
,
'getsingle'
,
[
'sequential'
=>
1
,
'contact_id'
=>
$contactId
,
'is_billing'
=>
1
,
]);
}
catch
(
CiviCRM_API3_Exception
$e
)
{
return
[];
}
$streetAddress
=
isset
(
$contactsAddress
[
'street_address'
])
?
$contactsAddress
[
'street_address'
]
:
''
;
$city
=
isset
(
$contactsAddress
[
'city'
])
?
$contactsAddress
[
'city'
]
:
''
;
$countryId
=
isset
(
$contactsAddress
[
'country_id'
])
?
$contactsAddress
[
'country_id'
]
:
NULL
;
$stateProvinceId
=
isset
(
$contactsAddress
[
'state_province_id'
])
?
$contactsAddress
[
'state_province_id'
]
:
NULL
;
$postalCode
=
isset
(
$contactsAddress
[
'postal_code'
])
?
$contactsAddress
[
'postal_code'
]
:
NULL
;
return
[
'street_address'
=>
$streetAddress
,
'city'
=>
$city
,
'country_id'
=>
$countryId
,
'state_province_id'
=>
$stateProvinceId
,
'postal_code'
=>
$postalCode
,
];
}
}
}
CRM/CiviMobileAPI/Hook/Pre/ContributionPayment.php
0 → 100644
View file @
90081c6d
<?php
class
CRM_CiviMobileAPI_Hook_Pre_ContributionPayment
{
public
function
run
()
{
if
(
!
CRM_Utils_System
::
authenticateKey
(
FALSE
))
{
Civi
::
log
()
->
warning
(
"Contributor's authorization failed: Failed to authenticate key"
);
return
;
}
$store
=
NULL
;
$apiKey
=
CRM_Utils_Request
::
retrieve
(
'api_key'
,
'String'
,
$store
,
FALSE
,
NULL
,
'REQUEST'
);
if
(
empty
(
$apiKey
))
{
Civi
::
log
()
->
warning
(
"Contributor's authorization failed: Mandatory param 'api_key' (user key) missing"
);
return
;
}
$contactId
=
CRM_Core_DAO
::
getFieldValue
(
'CRM_Contact_DAO_Contact'
,
$apiKey
,
'id'
,
'api_key'
);
if
(
!
empty
(
$contactId
))
{
$session
=
CRM_Core_Session
::
singleton
();
$session
->
set
(
'userID'
,
$contactId
);
}
else
{
Civi
::
log
()
->
warning
(
"Contributor's authorization failed: No CMS user associated with given api-key"
);
}
}
}
CRM/CiviMobileAPI/Page/File.php
0 → 100644
View file @
90081c6d
<?php
/**
* Provides the ability to view images that use for display QR code
*/
class
CRM_CiviMobileAPI_Page_File
extends
CRM_Core_Page
{
/**
* Open file by URL
*/
public
function
run
()
{
$filename
=
$_GET
[
'photo'
];
$uploadDirPath
=
CRM_CiviMobileAPI_Utils_File
::
getUploadDirPath
();
$file
=
$uploadDirPath
.
$filename
;
if
(
!
file_exists
(
$file
))
{
return
;
}
if
(
!
is_readable
(
$file
))
{
return
;
}
$fileExtension
=
strtolower
(
pathinfo
(
$file
,
PATHINFO_EXTENSION
));
$mimeType
=
'image/'
.
(
$fileExtension
==
'png'
?
'png'
:
$fileExtension
);
$ttl
=
43200
;
CRM_Utils_System
::
setHttpHeader
(
'Expires'
,
gmdate
(
'D, d M Y H:i:s \G\M\T'
,
CRM_Utils_Time
::
getTimeRaw
()
+
$ttl
));
CRM_Utils_System
::
setHttpHeader
(
"Content-Type"
,
$mimeType
);
CRM_Utils_System
::
setHttpHeader
(
"Content-Disposition"
,
"inline; filename=
\"
"
.
basename
(
$file
)
.
"
\"
"
);
CRM_Utils_System
::
setHttpHeader
(
"Cache-Control"
,
"max-age=
$ttl
, public"
);
CRM_Utils_System
::
setHttpHeader
(
'Pragma'
,
'public'
);
readfile
(
$file
);
CRM_Utils_System
::
civiExit
();
}
}
CRM/CiviMobileAPI/Page/PublicApi/Api.php
View file @
90081c6d
...
...
@@ -250,10 +250,6 @@ class CRM_CiviMobileAPI_Page_PublicApi_Api extends CRM_CiviMobileAPI_Page_Public
'class'
=>
'CRM_CiviMobileAPI_Page_PublicApi_Middleware'
,
'method'
=>
'isAllowPublicInfoApi'
,
],
[
'class'
=>
'CRM_CiviMobileAPI_Page_PublicApi_Middleware'
,
'method'
=>
'forbiddenForJoomla'
,
],
],
'transforms'
=>
[]
],
...
...
@@ -334,10 +330,6 @@ class CRM_CiviMobileAPI_Page_PublicApi_Api extends CRM_CiviMobileAPI_Page_Public
'class'
=>
'CRM_CiviMobileAPI_Page_PublicApi_Middleware'
,
'method'
=>
'isAllowPublicInfoApi'
,
],
[
'class'
=>
'CRM_CiviMobileAPI_Page_PublicApi_Middleware'
,
'method'
=>
'forbiddenForJoomla'
,
],
],
'transforms'
=>
[]
]
...
...
CRM/CiviMobileAPI/PushNotification/SaveMessageHelper.php
View file @
90081c6d
...
...
@@ -15,6 +15,11 @@ class CRM_CiviMobileAPI_PushNotification_SaveMessageHelper {
* @return bool
*/
public
static
function
saveMessages
(
$listOfContactsID
,
$objID
,
$objType
,
$title
=
NULL
,
$text
=
NULL
,
$data
=
NULL
)
{
$pushNotificationLifetime
=
Civi
::
settings
()
->
get
(
"civimobile_push_notification_lifetime"
);
if
(
isset
(
$pushNotificationLifetime
)
&&
$pushNotificationLifetime
==
0
)
{
return
FALSE
;
}
foreach
(
$listOfContactsID
as
$contactId
)
{
$paramsForInsert
=
[
'contact_id'
=>
$contactId
,
...
...
CRM/CiviMobileAPI/Utils/HookInvoker.php
View file @
90081c6d
...
...
@@ -16,7 +16,7 @@ class CRM_CiviMobileAPI_Utils_HookInvoker {
if
(
version_compare
(
CRM_Utils_System
::
version
(),
'4.5'
,
'<'
))
{
return
CRM_Utils_Hook
::
singleton
()
->
invoke
(
1
,
$params
,
$null
,
$null
,
$null
,
$null
,
'civimobileapi_qrCodeBlockParams'
);
}
else
{
return
CRM_Utils_Hook
::
singleton
()
->
invoke
(
1
,
$params
,
$null
,
$null
,
$null
,
$null
,
$null
,
'civimobileapi_qrCodeBlockParams'
);
return
CRM_Utils_Hook
::
singleton
()
->
invoke
(
[
1
]
,
$params
,
$null
,
$null
,
$null
,
$null
,
$null
,
'civimobileapi_qrCodeBlockParams'
);
}
}
...
...
api/v3/CiviMobileParticipant.php
View file @
90081c6d
...
...
@@ -14,6 +14,26 @@ function civicrm_api3_civi_mobile_participant_get($params) {
throw
new
api_Exception
(
'You don`t have enough permissions.'
,
'do_not_have_enough_permissions'
);