Commit dab879c2 authored by BohdanDmytryshyn's avatar BohdanDmytryshyn
Browse files

Release 5.1.0

parent b641e3a7
......@@ -12,7 +12,7 @@ class CRM_CiviMobileAPI_Api_CiviMobileAvailableContactGroup_Get extends CRM_Civi
*/
public function getResult() {
$availableGroups = [];
$groups = $this->getGroups();
$groups = $this->getGroups($this->validParams['is_hidden']);
$contactGroupIds = $this->getContactGroups($this->validParams['contact_id']);
foreach ($groups as $group) {
......@@ -40,22 +40,35 @@ class CRM_CiviMobileAPI_Api_CiviMobileAvailableContactGroup_Get extends CRM_Civi
throw new api_Exception('Contact(id=' . $params['contact_id'] . ') does not exist.', 'contact_does_not_exist');
}
return ['contact_id' => $params['contact_id']];
if (!isset($params['is_hidden'])) {
$params['is_hidden'] = NULL;
}
return [
'contact_id' => $params['contact_id'],
'is_hidden' => $params['is_hidden']
];
}
/**
* Gets active simple groups
*/
private function getGroups() {
private function getGroups($isHidden) {
$groupsParams = [
'sequential' => 1,
'is_active' => 1,
'saved_search_id' => ['IS NULL' => 1],
'options' => ['limit' => 0],
'return' => ['name', 'title', 'id'],
];
if (!is_null($isHidden)) {
$groupsParams['is_hidden'] = $isHidden;
}
$groups = [];
try {
$groupsData = civicrm_api3('Group', 'get', [
'sequential' => 1,
'is_active' => 1,
'saved_search_id' => ['IS NULL' => 1],
'options' => ['limit' => 0],
'return' => ['name', 'title', 'id'],
]);
$groupsData = civicrm_api3('Group', 'get', $groupsParams);
} catch (CiviCRM_API3_Exception $e) {
return $groups;
}
......
......@@ -76,13 +76,15 @@ class CRM_CiviMobileAPI_Authentication_Login {
* Sends response to user
*/
private function sendResponse() {
$restPath = new CRM_CiviMobileAPI_Utils_RestPath();
$this->responseData['values'] = [
'api_key' => $this->getUserApiKey(),
'key' => $this->getSiteKey(),
'id' => $this->civiContact->id,
'display_name' => $this->civiContact->display_name,
'cms' => CRM_CiviMobileAPI_Utils_CmsUser::getInstance()->getSystem(),
'rest_path' => (new CRM_CiviMobileAPI_Utils_RestPath())->get(),
'rest_path' => $restPath->get(),
'absolute_rest_url' => $restPath->getAbsoluteUrl(),
'site_name' => CRM_CiviMobileAPI_Utils_Extension::getSiteName(),
];
......@@ -110,7 +112,7 @@ class CRM_CiviMobileAPI_Authentication_Login {
*
* @return bool|string
*/
private function setApiKey($uid) {
public static function setApiKey($uid) {
try {
$bytes = openssl_random_pseudo_bytes(10);
$api_key = bin2hex($bytes);
......
......@@ -117,14 +117,14 @@ class CRM_CiviMobileAPI_Calendar_Handler {
FROM civicrm_event
LEFT JOIN civicrm_participant ON civicrm_participant.event_id = civicrm_event.id
LEFT JOIN `civicrm_option_group` AS event_type_group ON event_type_group.name = \'event_type\'
LEFT JOIN `civicrm_option_value` AS event_type_value ON (event_type_value.option_group_id = event_type_group.id
LEFT JOIN `civicrm_option_value` AS event_type_value ON (event_type_value.option_group_id = event_type_group.id
AND civicrm_event.event_type_id = event_type_value.value )
WHERE civicrm_event.is_active = 1
WHERE civicrm_event.is_active = 1
AND civicrm_event.is_template = 0
AND ( civicrm_event.created_id = %1 OR civicrm_participant.contact_id = %1)
AND (
civicrm_event.start_date BETWEEN %2 AND %3
OR civicrm_event.end_date BETWEEN %2 AND %3
civicrm_event.start_date BETWEEN %2 AND %3
OR civicrm_event.end_date BETWEEN %2 AND %3
OR "%2" BETWEEN civicrm_event.start_date AND civicrm_event.end_date
)
';
......@@ -177,7 +177,7 @@ class CRM_CiviMobileAPI_Calendar_Handler {
public function getCases() {
$result = [];
$query = '
SELECT
SELECT
civicrm_case.id AS id,
civicrm_case_activity.activity_id AS activity_id,
civicrm_case.subject AS case_title,
......@@ -187,26 +187,26 @@ class CRM_CiviMobileAPI_Calendar_Handler {
CONCAT(COALESCE(civicrm_activity.subject,civicrm_case.subject,"")," (",civicrm_option_value.name,")") AS title,
civicrm_activity.activity_date_time AS start,
DATE_ADD(civicrm_activity.activity_date_time, INTERVAL COALESCE (civicrm_activity.duration, 30) MINUTE) AS end
FROM civicrm_case
FROM civicrm_case
JOIN civicrm_case_contact ON civicrm_case_contact.case_id = civicrm_case.id
JOIN civicrm_case_activity ON civicrm_case_activity.case_id = civicrm_case.id
JOIN civicrm_activity ON civicrm_activity.id = civicrm_case_activity.activity_id
JOIN civicrm_option_value ON civicrm_activity.activity_type_id = civicrm_option_value.value
JOIN civicrm_option_group ON civicrm_option_group.id = civicrm_option_value.option_group_id
AND civicrm_option_group.name = "activity_type" AND civicrm_option_value.component_id IS NOT NULL
JOIN civicrm_option_group ON civicrm_option_group.id = civicrm_option_value.option_group_id
AND civicrm_option_group.name = "activity_type"
JOIN civicrm_case_type ON civicrm_case_type.id = civicrm_case.case_type_id
WHERE civicrm_case_contact.contact_id = %1
AND civicrm_case.is_deleted=0 AND civicrm_activity.is_deleted=0
AND (
(
civicrm_activity.activity_date_time >= %2
AND COALESCE (DATE_ADD(civicrm_activity.activity_date_time, INTERVAL COALESCE (civicrm_activity.duration, 30) MINUTE), civicrm_activity.activity_date_time) <= %3
civicrm_activity.activity_date_time >= %2
AND COALESCE (DATE_ADD(civicrm_activity.activity_date_time, INTERVAL COALESCE (civicrm_activity.duration, 30) MINUTE), civicrm_activity.activity_date_time) <= %3
)
OR
OR
(
%2 BETWEEN civicrm_activity.activity_date_time
%2 BETWEEN civicrm_activity.activity_date_time
AND COALESCE (DATE_ADD(civicrm_activity.activity_date_time, INTERVAL COALESCE (civicrm_activity.duration, 30) MINUTE),civicrm_activity.activity_date_time)
)
)
......@@ -275,23 +275,23 @@ class CRM_CiviMobileAPI_Calendar_Handler {
activity_type_value.label AS activity_type_label,
civicrm_activity.activity_date_time AS start,
DATE_ADD(civicrm_activity.activity_date_time, INTERVAL COALESCE (civicrm_activity.duration, 30) MINUTE) AS end
FROM civicrm_activity
JOIN civicrm_activity_contact ON civicrm_activity_contact.activity_id = civicrm_activity.id
LEFT JOIN civicrm_case_activity ON civicrm_case_activity.activity_id = civicrm_activity.id
LEFT JOIN `civicrm_option_group` AS activity_type_group ON activity_type_group.name = "activity_type"
LEFT JOIN `civicrm_option_value` AS activity_type_value
LEFT JOIN `civicrm_option_value` AS activity_type_value
ON (activity_type_value.option_group_id = activity_type_group.id AND civicrm_activity.activity_type_id = activity_type_value.value )
WHERE civicrm_activity_contact.contact_id = %1
AND (civicrm_activity.activity_date_time > %2
WHERE civicrm_activity_contact.contact_id = %1
AND (civicrm_activity.activity_date_time > %2
AND civicrm_activity.activity_date_time < %3) AND civicrm_case_activity.activity_id IS NULL
AND civicrm_activity.is_deleted = 0
AND civicrm_activity.is_deleted = 0
AND activity_type_id IN (
SELECT civicrm_option_value.value FROM civicrm_option_value
JOIN civicrm_option_group ON civicrm_option_group.id = civicrm_option_value.option_group_id
WHERE civicrm_option_group.name = "activity_type"
WHERE civicrm_option_group.name = "activity_type"
AND civicrm_option_value.component_id IS NULL
)
';
......
......@@ -35,6 +35,16 @@ class CRM_CiviMobileAPI_Form_Settings extends CRM_Core_Form {
$serverKeyInValidMessage = ts('Your Server Key is invalid. Please enter valid Server Key.');
}
$enabledComponents = CRM_CiviMobileAPI_Utils_CiviCRM::getEnabledComponents();
$possibleItemsToDisplayInPublicArea = [];
if (Civi::settings()->get('civimobile_is_showed_news')) {
$possibleItemsToDisplayInPublicArea[] = 'News';
}
if (in_array('CiviEvent', $enabledComponents)) {
$possibleItemsToDisplayInPublicArea[] = 'Events';
}
$this->assign('isWritable', CRM_CiviMobileAPI_Utils_Extension::directoryIsWritable());
$this->assign('serverKeyValidMessage', $serverKeyValidMessage);
$this->assign('serverKeyInValidMessage', $serverKeyInValidMessage);
......@@ -46,6 +56,10 @@ class CRM_CiviMobileAPI_Form_Settings extends CRM_Core_Form {
$this->assign('currentExtensionPath', $currentExtensionPath);
$this->assign('isCorrectExtensionName', $isCorrectExtensionName);
$this->assign('correctExtensionName', CRM_CiviMobileAPI_ExtensionUtil::LONG_NAME);
$this->assign('defaultRssFeedUrl', CRM_CiviMobileAPI_Utils_Cms::getCmsRssUrl());
$this->assign('possibleItemsToDisplayInPublicArea', implode(', ', $possibleItemsToDisplayInPublicArea));
CRM_Core_Resources::singleton()->addStyleFile('com.agiliway.civimobileapi', 'css/civimobileapiSettings.css', 200, 'html-header');
}
/**
......@@ -56,7 +70,28 @@ class CRM_CiviMobileAPI_Form_Settings extends CRM_Core_Form {
if (!empty($params['_qf_Settings_submit'])) {
$this->addFormRule([CRM_CiviMobileAPI_Form_Settings::class, 'validateToken']);
} elseif (!empty($params['_qf_Settings_upload'])) {
$this->addFormRule([CRM_CiviMobileAPI_Form_Settings::class, 'validateNewsSettings']);
}
}
/**
* Validate news settings
* Uses on form validation
*
* @param $values
* @return array|bool
*/
public static function validateNewsSettings($values) {
$errors = [];
if (isset($values['civimobile_is_showed_news'])
&& $values['civimobile_is_showed_news'] == 1
&& empty($values['civimobile_news_rss_feed_url'])
) {
$errors['civimobile_news_rss_feed_url'] = ts('Field can not be empty.');
}
return empty($errors) ? TRUE : $errors;
}
/**
......@@ -108,11 +143,15 @@ class CRM_CiviMobileAPI_Form_Settings extends CRM_Core_Form {
$this->addElement('text', 'civimobile_server_key', ts('Server key'));
$this->addElement('checkbox', 'civimobile_auto_update', ts('Automatically keep the extension up to date'));
$this->addElement('checkbox', 'civimobile_is_allow_public_info_api', ts('Enable CiviMobile for Anonymous users'));
$this->addElement('checkbox', 'civimobile_is_allow_public_website_url_qrcode', ts('Show a Website URL QR-code for Anonymous users'));
$this->addElement('radio', 'civimobile_site_name_to_use', NULL, ts('Use CMS site name'), 'cms_site_name');
$this->addElement('radio', 'civimobile_site_name_to_use', NULL, ts('Use custom site name'), 'custom_site_name');
$this->addElement('text', 'civimobile_custom_site_name', ts('Site name'));
$this->addElement('checkbox', 'civimobile_is_allow_public_info_api', ts('Show Public area'));
$this->addElement('checkbox', 'civimobile_is_showed_news', ts('Show News'));
$this->addElement('text', 'civimobile_news_rss_feed_url', ts('News RSS feed URL'));
$this->addElement('text', 'civimobile_firebase_key', ts('Firebase key'));
$this->addElement('checkbox', 'civimobile_is_custom_app', ts('Do you have custom application?'));
$buttons = [
[
......@@ -171,19 +210,30 @@ class CRM_CiviMobileAPI_Form_Settings extends CRM_Core_Form {
else {
Civi::settings()->set('civimobile_auto_update', 0);
}
if (!isset($params['civimobile_is_allow_public_info_api'])) {
$params['civimobile_is_allow_public_info_api'] = 0;
}
if (!isset($params['civimobile_is_allow_public_website_url_qrcode'])) {
$params['civimobile_is_allow_public_website_url_qrcode'] = 0;
}
if (!isset($params['civimobile_custom_site_name'])) {
$params['civimobile_custom_site_name'] = '';
}
Civi::settings()->set('civimobile_is_allow_public_info_api', $params['civimobile_is_allow_public_info_api']);
if(!isset($params['civimobile_is_showed_news'])) {
$params['civimobile_is_showed_news'] = 0;
}
if (!isset($params['civimobile_is_custom_app'])) {
$params['civimobile_is_custom_app'] = 0;
}
if (!isset($params['civimobile_is_allow_public_info_api'])) {
$params['civimobile_is_allow_public_info_api'] = 0;
}
Civi::settings()->set('civimobile_is_custom_app', $params['civimobile_is_custom_app']);
Civi::settings()->set('civimobile_firebase_key', $params['civimobile_firebase_key']);
Civi::settings()->set('civimobile_is_allow_public_website_url_qrcode', $params['civimobile_is_allow_public_website_url_qrcode']);
Civi::settings()->set('civimobile_site_name_to_use', $params['civimobile_site_name_to_use']);
Civi::settings()->set('civimobile_custom_site_name', $params['civimobile_custom_site_name']);
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']);
CRM_Core_Session::singleton()->setStatus(ts('CiviMobile settings updated'), ts('CiviMobile Settings'), 'success');
}
}
......@@ -196,10 +246,14 @@ class CRM_CiviMobileAPI_Form_Settings extends CRM_Core_Form {
$defaults['civimobile_auto_update'] = Civi::settings()->get('civimobile_auto_update');
$defaults['civimobile_server_key'] = Civi::settings()->get('civimobile_server_key');
$defaults['civimobile_is_allow_public_info_api'] = CRM_CiviMobileAPI_Utils_Extension::isAllowPublicInfoApi();
$defaults['civimobile_is_allow_public_website_url_qrcode'] = CRM_CiviMobileAPI_Utils_Extension::isAllowPublicWebisteURLQRCode();
$defaults['civimobile_site_name_to_use'] = (!empty(Civi::settings()->get('civimobile_site_name_to_use'))) ? Civi::settings()->get('civimobile_site_name_to_use') : 'cms_site_name' ;
$defaults['civimobile_custom_site_name'] = Civi::settings()->get('civimobile_custom_site_name');
$defaults['civimobile_is_allow_public_info_api'] = Civi::settings()->get('civimobile_is_allow_public_info_api');
$defaults['civimobile_is_showed_news'] = Civi::settings()->get('civimobile_is_showed_news');
$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();
return $defaults;
}
......
<?php
class CRM_CiviMobileAPI_Page_Checklist extends CRM_Core_Page {
/**
* @return mixed
*/
public function run() {
$checklist = new CRM_CiviMobileAPI_Utils_Checklist();
$checklist->checkAllAvailableItems();
$currentContact = CRM_Contact_BAO_Contact::findById(CRM_Core_Session::singleton()->getLoggedInContactID());
$apiKey = $currentContact->api_key ? $currentContact->api_key : CRM_CiviMobileAPI_Authentication_Login::setApiKey($currentContact->id);
$paramsToRest = 'entity=CiviMobileSystem&action=get&api_key=' . $apiKey . '&key=' . CIVICRM_SITE_KEY . '&json={"sequential":1}';
$authUrl = CRM_Utils_System::url('civicrm/civimobile/auth', NULL, TRUE);
$restPathUrl = self::concatenateUrl(
str_replace("/administrator/", "", CIVICRM_UF_BASEURL) . substr((new CRM_CiviMobileAPI_Utils_RestPath())->get(),1),
$paramsToRest);
$restUrl = self::concatenateUrl((new CRM_CiviMobileAPI_Utils_RestPath())->getAbsoluteUrl(), $paramsToRest);
$this->assign([
'authUrl' => $authUrl,
'restPathUrl' => $restPathUrl,
'restUrl' => $restUrl,
'checklist_params' => $checklist->getCheckedItemsResult(),
'system_info' => $checklist->getSystemInfoReport()
]);
CRM_Core_Resources::singleton()->addStyleFile('com.agiliway.civimobileapi', 'css/civimobileapiChecklist.css', 200, 'html-header');
return parent::run();
}
/**
* @param $url
* @param $params
* @return string
*/
private static function concatenateUrl($url, $params) {
if (strpos($url,'?')) {
$url .= '&';
} else {
$url .= '?';
}
return $url . $params;
}
}
......@@ -13,7 +13,7 @@ class CRM_CiviMobileAPI_Page_PublicApi_Api extends CRM_CiviMobileAPI_Page_Public
'availableActions' => [
[
'actionName' => 'get',
'actionPermissions' => ['access CiviCRM', 'access CiviEvent', 'view event info'],
'actionPermissions' => ['view event info'],
'availableParams' => [
'id',
'event_start_date',
......@@ -48,6 +48,26 @@ class CRM_CiviMobileAPI_Page_PublicApi_Api extends CRM_CiviMobileAPI_Page_Public
'is_show_location',
'currency_symbol',
'currency',
'max_participants',
'is_share',
'registration_start_date',
'registration_end_date',
'is_map',
'loc_block_id',
'loc_block_id.email_id.email',
'loc_block_id.email_2_id.email',
'loc_block_id.phone_id.phone',
'loc_block_id.phone_2_id.phone',
'loc_block_id.phone_id.phone_type_id.label',
'loc_block_id.phone_2_id.phone_type_id.label',
'loc_block_id.address_id.country_id.name',
'loc_block_id.address_id.state_province_id.name',
'loc_block_id.address_id.city',
'loc_block_id.address_id.street_address',
'loc_block_id.address_id.postal_code',
'loc_block_id.address_id.geo_code_1',
'loc_block_id.address_id.geo_code_2',
'url'
],
'middleware' => [
[
......@@ -63,7 +83,12 @@ class CRM_CiviMobileAPI_Page_PublicApi_Api extends CRM_CiviMobileAPI_Page_Public
'method' => 'showOnlyPublicEvents',
]
],
'transforms' => []
'transforms' => [
[
'class' => 'CRM_CiviMobileAPI_Page_PublicApi_Transform',
'method' => 'addEventUrl',
]
]
]
]
],
......@@ -72,7 +97,7 @@ class CRM_CiviMobileAPI_Page_PublicApi_Api extends CRM_CiviMobileAPI_Page_Public
'availableActions' => [
[
'actionName' => 'get',
'actionPermissions' => [],
'actionPermissions' => ['view event info'],
'availableParams' => [
'option_group_id',
'return',
......@@ -108,7 +133,7 @@ class CRM_CiviMobileAPI_Page_PublicApi_Api extends CRM_CiviMobileAPI_Page_Public
'availableActions' => [
[
'actionName' => 'get',
'actionPermissions' => ['access CiviCRM', 'access CiviEvent', 'view event info'],
'actionPermissions' => ['view event info'],
'availableParams' => [
'event_id',
'return',
......@@ -137,7 +162,7 @@ class CRM_CiviMobileAPI_Page_PublicApi_Api extends CRM_CiviMobileAPI_Page_Public
'availableActions' => [
[
'actionName' => 'get',
'actionPermissions' => ['access CiviCRM', 'access CiviEvent', 'view event info', 'view event participants'],
'actionPermissions' => ['view event info', 'view event participants'],
'availableParams' => [
'event_id',
'return',
......@@ -172,7 +197,7 @@ class CRM_CiviMobileAPI_Page_PublicApi_Api extends CRM_CiviMobileAPI_Page_Public
'availableActions' => [
[
'actionName' => 'get',
'actionPermissions' => ['access CiviCRM', 'access CiviEvent', 'view event info', 'view event participants'],
'actionPermissions' => ['view event info', 'view event participants'],
'availableParams' => [
'id',
'return',
......@@ -203,7 +228,7 @@ class CRM_CiviMobileAPI_Page_PublicApi_Api extends CRM_CiviMobileAPI_Page_Public
'availableActions' => [
[
'actionName' => 'create',
'actionPermissions' => ['access CiviCRM', 'access CiviEvent', 'view event info', 'register for events', 'profile listings and forms'],
'actionPermissions' => ['view event info', 'register for events', 'profile create'],
'availableParams' => [
'last_name',
'first_name',
......@@ -232,7 +257,7 @@ class CRM_CiviMobileAPI_Page_PublicApi_Api extends CRM_CiviMobileAPI_Page_Public
],
[
'actionName' => 'get_ticket',
'actionPermissions' => ['access CiviCRM', 'access CiviEvent', 'view event info'],
'actionPermissions' => ['view event info'],
'availableParams' => [
'public_key',
],
......@@ -289,7 +314,7 @@ class CRM_CiviMobileAPI_Page_PublicApi_Api extends CRM_CiviMobileAPI_Page_Public
'availableActions' => [
[
'actionName' => 'get',
'actionPermissions' => ['access CiviCRM', 'access CiviEvent', 'view event info', 'register for events'],
'actionPermissions' => ['view event info', 'register for events'],
'availableParams' => [
'event_id',
'contact_id',
......
<?php
class CRM_CiviMobileAPI_Page_PublicApi_Transform {
/**
* Adds 'event_type_label' to result of api by 'event_type_id'
*
* @param $apiResult
* @param $params
*
* @return mixed
*/
public static function addEventTypeLabel($apiResult) {
if (empty($apiResult)) {
return $apiResult;
}
foreach ($apiResult as $key => $apiResultItem) {
$apiResult[$key]['event_type_label'] = 'Event Type Label';
}
return $apiResult;
}
}
......@@ -2,4 +2,23 @@
class CRM_CiviMobileAPI_Page_PublicApi_Transform {
/**
* Adds 'url' to result
*
* @param $apiResult
*
* @return mixed
*/
public static function addEventUrl($apiResult) {
if (empty($apiResult)) {
return $apiResult;
}
foreach ($apiResult as $key => $apiResultItem) {
$apiResult[$key]['url'] = CRM_Utils_System::url('civicrm/event/info', 'id=' . $apiResultItem['id'], true);
}
return $apiResult;
}
}
......@@ -15,6 +15,13 @@ class CRM_CiviMobileAPI_Page_PublicSettings extends CRM_Core_Page {
public function run() {
if (CRM_CiviMobileAPI_Authentication_AuthenticationHelper::isRequestValid()) {
$currentCMS = CRM_CiviMobileAPI_Utils_CmsUser::getInstance()->getSystem();
if ($currentCMS == CRM_CiviMobileAPI_Utils_CmsUser::CMS_DRUPAL7) {
module_load_include('pages.inc', 'user');
user_logout_current_user();
}
$settings = [
'is_allow_public_info_api' => CRM_CiviMobileAPI_Utils_Extension::isAllowPublicInfoApi(),
'is_allow_public_website_url_qrcode' => CRM_CiviMobileAPI_Utils_Extension::isAllowPublicWebisteURLQRCode(),
......@@ -24,8 +31,11 @@ class CRM_CiviMobileAPI_Page_PublicSettings extends CRM_Core_Page {
'crm_version' => CRM_Utils_System::version(),
'civicrm_enable_components' => CRM_CiviMobileAPI_Utils_CiviCRM::getEnabledComponents(),
'ext_version' => CRM_CiviMobileAPI_Utils_VersionController::getInstance()->getCurrentFullVersion(),
'is_allow_cms_registration' => CRM_CiviMobileAPI_Utils_Extension::isAllowCmsRegistration(),
'is_civimobile_ext_has_right_folder_name' => (int) CRM_CiviMobileAPI_Utils_Extension::hasExtensionRightFolderName(),
'is_allow_cms_registration' => CRM_CiviMobileAPI_Utils_Extension::isAllowCmsRegistration(),
'is_showed_events_in_public_area' => CRM_CiviMobileAPI_Utils_Extension::isShowedEventsInPublicArea(),
'is_showed_news_in_public_area' => CRM_CiviMobileAPI_Utils_Extension::isShowedNewsInPublicArea(),
'news_rss_feed_url' => CRM_CiviMobileAPI_Utils_Extension::newsRssFeedUrl(),
'cms_registration_requirements' => [
'min_password_length' => CMSRegistration::minPasswordLength(),
'max_password_length' => CMSRegistration::maxPasswordLength(),
......
......@@ -6,6 +6,7 @@ class CRM_CiviMobileAPI_PushNotification_Helper {
* Url to Firebase Cloud Massaging
*/
const FCM_URL = 'https://push.civimobile.org/rest.php';
const FIREBASE_URL = 'https://fcm.googleapis.com/fcm/send';
/**
* Sends push notification
......@@ -18,11 +19,13 @@ class CRM_CiviMobileAPI_PushNotification_Helper {
* @return bool|mixed
*/
public static function sendPushNotification(array $contactsIDs, $title, $text, $data) {
$isCustomApp = Civi::settings()->get('civimobile_is_custom_app');
$contactsTokens = self::getContactsToken($contactsIDs);
if (empty($contactsTokens) || empty($contactsIDs)) {
return FALSE;
}
$config = &CRM_Core_Config::singleton();
$baseUrl = $config->userFrameworkBaseURL;
......@@ -42,7 +45,7 @@ class CRM_CiviMobileAPI_PushNotification_Helper {
$requestHeader = [
'Content-Type:application/json',
'Site-Name:' . $baseUrl,
'Authorization:' . Civi::settings()->get('civimobile_server_key'),
'Authorization:' . (($isCustomApp) ? 'key=' . Civi::settings()->get('civimobile_firebase_key') : Civi::settings()->get('civimobile_server_key')),
];
$nullObject = CRM_Utils_Hook::$_nullObject;
......@@ -50,7 +53,7 @@ class CRM_CiviMobileAPI_PushNotification_Helper {
->commonInvoke(2, $notificationBody, $requestHeader, $nullObject, $nullObject, $nullObject, $nullObject, 'civimobile_send_push', '');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, self::FCM_URL);
curl_setopt($ch, CURLOPT_URL, (($isCustomApp) ? self::FIREBASE_URL : self::FCM_URL));
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeader);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
......
......@@ -113,7 +113,6 @@ class CRM_CiviMobileAPI_Upgrader extends CRM_CiviMobileAPI_Upgrader_Base {
CRM_CiviMobileAPI_Install_Install::uninstall();
$this->uninstallPushNotificationCustomGroup();
CRM_CiviMobileAPI_Utils_CustomGroup::delete(CRM_CiviMobileAPI_Install_Entity_CustomGroup::CONTACT_SETTINGS);
Civi::settings()->set('civimobile_is_allow_public_info_api', 0);
}
/**
......
......@@ -146,6 +146,12 @@ class CRM_CiviMobileAPI_Utils_CaseRole {
* Sets clients and unassigned role
*/
private function setClientAndUnsignedRoles() {
foreach ($this->caseRelationships as $rel) {
if (isset($this->caseRoles[$rel['relation_type'] . '_' . $rel['relationship_direction']])) {
unset($this->caseRoles[$rel['relation_type'] . '_' . $rel['relationship_direction']]);
}
}
foreach ($this->caseRoles as $id => $value) {
if ($id != "client") {
......
<?php
class CRM_CiviMobileAPI_Utils_Checklist {