Commit 0e37f165 authored by BohdanDmytryshyn's avatar BohdanDmytryshyn
Browse files

Merge branch 'release_4_2' into 'master'

Release 4.2

See merge request !36
parents 8eed8bca 42d7dcb2
......@@ -87,7 +87,7 @@ class CRM_CiviMobileAPI_Api_CiviMobileCustomFields_Get extends CRM_CiviMobileAPI
'name' => $customGroup['name'],
'title' => $customGroup['title'],
'style' => $customGroup['style'],
'weight' => $customGroup['weight'],
'weight' => (int) $customGroup['weight'],
'is_multiple' => $customGroup['is_multiple'],
'custom_fields' => [],
];
......@@ -130,8 +130,12 @@ class CRM_CiviMobileAPI_Api_CiviMobileCustomFields_Get extends CRM_CiviMobileAPI
$availableValues = CRM_CiviMobileAPI_Utils_OptionValue::getGroupValues($customField['option_group_id'], ['is_active' => 1]);
}
foreach ($availableValues as $key => $value) {
$availableValues[$key]['weight'] = (int) $availableValues[$key]['weight'];
}
if ($customField['html_type'] == 'Radio' && $customField['data_type'] == "Boolean") {
$availableValues = ['0','1'];
$availableValues = ['1','0'];
}
$prepareCustomField = [
......@@ -141,10 +145,19 @@ class CRM_CiviMobileAPI_Api_CiviMobileCustomFields_Get extends CRM_CiviMobileAPI
"text_length" => (!empty($customField['text_length'])) ? (int) $customField['text_length'] : "NULL",
"is_view" => $customField['is_view'],
"label" => $customField['label'],
"weight" => (int) $customField['weight'],
"data_type" => $customField['data_type'],
"html_type" => $customField['html_type'],
"is_required" => $customField['is_required'],
"current_value" => $this->getCurrentValue($customFieldId),
"note_columns" => (!empty($customField['note_columns'])) ? (int) $customField['note_columns'] : "",
"note_rows" => (!empty($customField['note_rows'])) ? (int) $customField['note_rows'] : "",
"date_format" => (!empty($customField['date_format'])) ? $customField['date_format'] : "",
"time_format" => (!empty($customField['time_format'])) ? $customField['time_format'] : "",
"start_date_years" => (!empty($customField['start_date_years'])) ? $customField['start_date_years'] : "",
"end_date_years" => (!empty($customField['end_date_years'])) ? $customField['end_date_years'] : "",
"default_currency" => CRM_Core_Config::singleton()->defaultCurrency,
"default_currency_symbol" => CRM_Core_Config::singleton()->defaultCurrencySymbol,
"available_values" => $availableValues
];
......
......@@ -20,45 +20,29 @@ class CRM_CiviMobileAPI_ApiWrapper_GroupContact_Get implements API_Wrapper {
* @param $result
*
* @return array
* @throws API_Exception
*/
public function toApiOutput($apiRequest, $result) {
if (!empty($apiRequest['params']['smart_group']) && $apiRequest['params']['smart_group'] == 1 ) {
try {
$smartGroupResult = civicrm_api3('Group', 'get', [
'sequential' => 1,
"return" => ["title", "description"],
'saved_search_id' => ['IS NOT NULL' => 1],
]);
} catch (CiviCRM_API3_Exception $e) {
throw new \API_Exception(ts("Can not get group info."));
if (empty($apiRequest['params']['contact_id'])) {
throw new api_Exception('Field \'contact_id\' is required field.', 'required_field');
}
$contactCacheObject = new CRM_Contact_DAO_GroupContactCache();
$contactCacheObject->contact_id = $apiRequest['params']['contact_id'];
$contactCacheObject->find();
while ($contactCacheObject->fetch()) {
$groups[] = $contactCacheObject->group_id;
$contact = new CRM_Contact_BAO_Contact();
$contact->id = $apiRequest['params']['contact_id'];
$contactExistence = $contact->find(TRUE);
if (empty($contactExistence)) {
throw new api_Exception('Contact(id=' . $apiRequest['params']['contact_id'] . ') does not exist.', 'contact_does_not_exist');
}
$validatedSmartGroup = [];
foreach ($smartGroupResult['values'] as $value) {
if (in_array($value['id'], $groups)) {
$validatedSmartGroup[] = $value;
}
$smartGroupResult['count'] = count($validatedSmartGroup);
$smartGroupResult['values'] = $validatedSmartGroup;
$value['contact_id'] = $apiRequest['params']['contact_id'];
}
$contactGroups = CRM_Contact_BAO_GroupContactCache::contactGroup($apiRequest['params']['contact_id']);
return $smartGroupResult;
return civicrm_api3_create_success(!empty($contactGroups['group']) ? $contactGroups['group'] : []);
}
else {
foreach ($result['values'] as &$value) {
$value['group_contact_status'] = !empty($apiRequest['params']['status']) ? $apiRequest['params']['status'] : '';
}
return $result;
}
......
......@@ -79,8 +79,7 @@ class CRM_CiviMobileAPI_Install_Entity_CustomField extends CRM_CiviMobileAPI_Ins
'is_view' => 0,
'is_searchable' => 1,
'is_required' => 0,
'is_active' => 1,
'weight' => 2,
'is_active' => 1
]
];
}
......
......@@ -49,7 +49,6 @@ class CRM_CiviMobileAPI_Install_Entity_CustomGroup extends CRM_CiviMobileAPI_Ins
'is_public' => 1,
'table_name' => 'civicrm_contact_settings',
'style' => 'Inline',
'weight' => 1,
'is_active' => 1,
'collapse_display' => 1,
'collapse_adv_display' => 1,
......
......@@ -121,7 +121,11 @@ class CRM_CiviMobileAPI_Utils_Contact {
return false;
}
return CRM_CiviMobileAPI_Utils_File::removeUploadFile($avatarFileName);
if (!empty($avatarFileName)) {
return CRM_CiviMobileAPI_Utils_File::removeUploadFile($avatarFileName);
}
return true;
}
/**
......
......@@ -122,4 +122,25 @@ class CRM_CiviMobileAPI_Utils_Permission {
return false;
}
/**
* Is enough permission tag structure
*/
public static function isEnoughPermissionForGetTagStructure() {
if (CRM_Core_Permission::check('administer CiviCRM')) {
return true;
}
if (CRM_Core_Permission::check('access CiviCRM')
&& (CRM_Core_Permission::check('edit my contact')
|| CRM_Core_Permission::check('view all contacts')
|| CRM_Core_Permission::check('view my contact')
|| CRM_Core_Permission::check('edit all contacts')
)
) {
return true;
}
return false;
}
}
......@@ -8,20 +8,21 @@ The **CiviMobileAPI** extension (`com.agiliway.civimobileapi`) is a CiviCRM comp
[CiviMobile](https://civimobile.org) Features:
- **Graphical Calendar** - all the scheduled information is displayed in a graphical calendar on the dashboard on the mobile app;
- **Contacts** - users can view the list of all contacts in the system, add new contacts and edit contact information. A variety of contact information options is available including several phone numbers, websites, social media profiles, etc. The app supports custom fields that are configured in CiviCRM
- **Graphical Calendar** – all the scheduled information is displayed in a graphical calendar on the dashboard on the mobile app;
- **Contacts** – users can view the list of all contacts in the system, add new contacts and edit contact information. A variety of contact information options is available including several phone numbers, websites, social media profiles, etc. The app supports custom fields that are configured in CiviCRM
- **Groups and Tags** – ability to organize the contacts by adding tags and creating contact groups
- **Membership** – users can access and renew their membership
- **Contributions** – access to the history of all contributions, aggregated total and average payments.
- **Relationships** – users can create a relationship between oneself and other individuals or organizations and optionally set a start date and end date for the relationship
- **Events & Registration** - ability to filter all the available events by type, date or title, check the event description, register yourself or others for the chosen event, view past and future events, share the information about events, and view events’ locations on the map
- **Events & Registration** ability to filter all the available events by type, date or title, check the event description, register yourself or others for the chosen event, view past and future events, share the information about events, and view events’ locations on the map
- **Participants Management & Check-In** - ability to view and manage event participants and their statuses. Additionally, a user can use Check-In functionality to mark participants who have attended an event while an built-in QR scanner will make this process fast and reliable
- **Navigation** - users can switch to map navigation to easily find a direction to the location (e.g. a branch office or an event location)
- **Cases** - grants immediate access to user’s cases details
- **Activities** - allows to access details of user’s activities, their priority statuses and information about other constituents engaged in them
- **Push-notifications** - notifications about the updates in the system are displayed on the dashboard of the mobile phone
- **Working Offline** - can work in the offline mode
- **Navigation** users can switch to map navigation to easily find a direction to the location (e.g. a branch office or an event location)
- **Cases** grants immediate access to user’s cases details
- **Activities** allows to access details of user’s activities, their priority statuses and information about other constituents engaged in them
- **Push-notifications** notifications about the updates in the system are displayed on the dashboard of the mobile phone
- **Working Offline** can work in the offline mode
- **Settings** – users can configurate a set of parameters customizing the view and work of the application
- **7 locales** - currently, supports 7 locales: English, German, French, Italian, Dutch, Hungarian and Ukrainian
- **8 locales** – supports English, German, French, Italian, Dutch, Hungarian, Polish and Ukrainian
More details about how to install CiviMobileAPI extension and start using CiviMobile can be found at official CiviMobile website [https://civimobile.org](https://civimobile.org).
......
......@@ -38,10 +38,15 @@ function civicrm_api3_civi_mobile_contact_create($params) {
}
CRM_CiviMobileAPI_Utils_Contact::removeContactAvatar($params['contact_id']);
$currentCMS = CRM_CiviMobileAPI_Utils_CmsUser::getInstance()->getSystem();
$imageUrl = CRM_Utils_System::url('civicrm/contact/imagefile', ['photo' => $newName], TRUE);
if ($currentCMS == CRM_CiviMobileAPI_Utils_CmsUser::CMS_JOOMLA ) {
$imageUrl = preg_replace('/administrator\//', 'index.php', $imageUrl);
}
civicrm_api3('Contact', 'create', [
'id' => $params['contact_id'],
'image_URL' => CRM_Utils_System::url('civicrm/contact/imagefile', ['photo' => $newName], TRUE),
'image_URL' => $imageUrl,
]);
return civicrm_api3_create_success("Photo was updated", $params);
......
......@@ -229,6 +229,44 @@ function civicrm_api3_civi_mobile_permission_get() {
],
];
$permissions['group'] = [
'view' => [
'all' => $accessToCiviCrm && $viewMyContact && ($viewAllContacts || $editAllContacts) ? 1 : 0,
'my' => $accessToCiviCrm && $viewMyContact ? 1 : 0,
],
'remove' => [
'all' => $accessToCiviCrm && $viewMyContact && $editAllContacts ? 1 : 0,
'my' => $accessToCiviCrm && $viewMyContact && $editAllContacts ? 1 : 0,
],
'rejoin' => [
'all' => $accessToCiviCrm && $viewMyContact && $editAllContacts ? 1 : 0,
'my' => $accessToCiviCrm && $viewMyContact && $editAllContacts ? 1 : 0,
],
'add_to_group' => [
'all' => $accessToCiviCrm && $viewMyContact && $editAllContacts ? 1 : 0,
'my' => $accessToCiviCrm && $viewMyContact && ($editMyContact || $editAllContacts)? 1 : 0,
],
'delete' => [
'all' => $accessToCiviCrm && $viewMyContact && $editAllContacts ? 1 : 0,
'my' => $accessToCiviCrm && $viewMyContact && $editAllContacts ? 1 : 0,
],
];
$permissions['tags'] = [
'view' => [
'all' => $accessToCiviCrm && $viewMyContact && ($viewAllContacts || $editAllContacts) ? 1 : 0,
'my' => $accessToCiviCrm && $viewMyContact ? 1 : 0,
],
'add' => [
'all' => $accessToCiviCrm && $viewMyContact && $editAllContacts ? 1 : 0,
'my' => $accessToCiviCrm && $viewMyContact && ($editMyContact || $editAllContacts)? 1 : 0,
],
'remove' => [
'all' => $accessToCiviCrm && $viewMyContact && $editAllContacts ? 1 : 0,
'my' => $accessToCiviCrm && $viewMyContact && ($editMyContact || $editAllContacts)? 1 : 0,
],
];
$nullObject = CRM_Utils_Hook::$_nullObject;
CRM_Utils_Hook::singleton()
->commonInvoke(1, $permissions, $nullObject, $nullObject, $nullObject, $nullObject, $nullObject, 'civimobile_permission', '');
......
......@@ -9,6 +9,10 @@
* @throws \api_Exception
*/
function civicrm_api3_civi_mobile_tag_structure_get($params) {
if (!CRM_CiviMobileAPI_Utils_Permission::isEnoughPermissionForGetTagStructure()) {
throw new api_Exception('Permission required.', 'permission_required');
}
$result = (new CRM_CiviMobileAPI_Api_CiviMobileTagStructure_Get($params))->getResult();
return civicrm_api3_create_success($result, $params);
......
......@@ -233,6 +233,8 @@ function civimobileapi_civicrm_alterAPIPermissions($entity, $action, &$params, &
($entity == 'civi_mobile_allowed_activity_types' and $action == 'get') ||
($entity == 'civi_mobile_contribution_statistic') ||
($entity == 'state_province' and $action == 'get') ||
($entity == 'civi_mobile_available_contact_group' and $action == 'get') ||
($entity == 'civi_mobile_tag_structure' and $action == 'get') ||
($entity == 'civi_mobile_custom_fields' and $action == 'get')
) {
$params['check_permissions'] = FALSE;
......
......@@ -14,8 +14,8 @@
<url desc="Support">https://agiliway.com</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2019-10-09</releaseDate>
<version>4.1.4</version>
<releaseDate>2019-11-12</releaseDate>
<version>4.2</version>
<develStage>stable</develStage>
<compatibility>
<ver>4.7</ver>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment