Skip to content

Commit

Permalink
SinergiaCRM 1.7.0 Release merge (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordiSTIC authored Sep 26, 2024
2 parents 9bd5436 + 41e7eb1 commit 616eb62
Show file tree
Hide file tree
Showing 178 changed files with 7,206 additions and 478 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<img width="180px" height="60px" src="https://github.com/SinergiaTIC/SinergiaCRM-SuiteCRM/assets/125350097/af3300d0-1b17-427c-b681-1971d39a1528" align="right" />
</a>

# SinergiaCRM 1.1.0
# SinergiaCRM

![Version (latest by date)](https://img.shields.io/github/v/release/SinergiaTIC/SinergiaCRM?label=Version)
[![Wiki](https://img.shields.io/badge/Information-Wiki-lightgray)](https://wikisuite.sinergiacrm.org)
[![LICENSE](https://img.shields.io/badge/License-AGPL_v3-orange.svg)](./LICENSE.txt)
[![LinkedIn](https://img.shields.io/badge/LinkedIn-0077B5)](https://twitter.com/SinergiaCRM)
Expand Down
39 changes: 23 additions & 16 deletions SticInclude/SinergiaDA.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,14 @@ public function createViews($callUpdateModel = true, $rebuildFilter = 'all')
// add column to index list
$indexesToCreate[] = "{$fieldV['id_name']}";

//Add relate record name
if (in_array($fieldV['module'], ['Contacts', 'Leads'])) {
//Add relate record name
if (in_array($fieldV['module'], ['Contacts', 'Leads']) || (Beanfactory::newBean($fieldV['module'])->field_defs['last_name']) && $fieldV['module'] != 'Users') {
$relatedName = " concat_ws(' ', {$leftJoinAlias}.first_name, {$leftJoinAlias}.last_name) ";
} elseif ($fieldV['module'] == 'Users') {
$relatedName = "{$leftJoinAlias}.user_name";
} else { $relatedName = "{$leftJoinAlias}.name";}
} else {
$relatedName = "{$leftJoinAlias}.name";
}

$fieldSrc .= " IFNULL($relatedName,'') AS {$fieldV['name']}";

Expand Down Expand Up @@ -1727,9 +1729,8 @@ public function getAndSaveUserACL($modules)

// Get list of active users
$res = $db->query("SELECT id,user_name, is_admin FROM users join users_cstm on users.id = users_cstm.id_c WHERE status='Active' AND deleted=0 AND sda_allowed_c=1;");

while ($u = $db->fetchByAssoc($res, false)) {

while ($u = $db->fetchByAssoc($res, false)) {
$allModulesACL = array_intersect_key(ACLAction::getUserActions($u['id'], true), $modules);
foreach ($allModulesACL as $key => $value) {
unset($aclSource);
Expand Down Expand Up @@ -1771,11 +1772,11 @@ public function getAndSaveUserACL($modules)
$userGroupsRes = $db->query("SELECT distinct(name) as 'group' FROM sda_def_user_groups ug WHERE user_name='{$u['user_name']}';");

while ($userGroups = $db->fetchByAssoc($userGroupsRes, false)) {

$crmGroupName = explode('SDA_', $userGroups['group'])[1];

// Verify whether or not the group has access to the module for their roles
$groupHasAccessToModule = groupHasAccess($crmGroupName, $key, 'view');
// Verify whether or not the group or user has access to the module for their roles
$groupHasAccessToModule = groupHasAccess($crmGroupName, $u['id'], $key, 'view');

if ($groupHasAccessToModule) {

Expand All @@ -1788,7 +1789,7 @@ public function getAndSaveUserACL($modules)
'global' => 0,
];

// Additionally we insert a record that allows each user's access to the records in which coinicide
// Additionally we insert a record that allows each user's access to the records in which match
// the user_name with the assigned_user_name field content in each module in which the user has group permission
$userModuleAccessMode["{$u['user_name']}_{$aclSource}_{$userGroups['group']}_private_{$currentTable}"] = [
'user_name' => $u['user_name'],
Expand Down Expand Up @@ -1946,13 +1947,14 @@ public function checkSdaTablesInViews()
}

/**
* Checks if a security group has access to a specific action in a given module.
* Checks if a security group or user has access to a specific action in a given module.
*
* This function determines whether a security group, identified by its name, has the necessary
* This function determines whether a security group, identified by its name, or an user, identified by its id has the necessary
* permissions to perform a specific action in a given module. It looks up the roles associated
* with the group and checks the highest access levels available for those roles.
* with the group or user and checks the highest access levels available for those roles.
*
* @param string $group_name The name of the security group to check.
* @param string $userId The id of the user to check.
* @param string $category The name of the module or category (e.g., 'Accounts', 'Contacts').
* @param string $action The specific action to check (e.g., 'view', 'edit', 'delete').
* @param string $type The type of ACL, defaults to 'module'.
Expand All @@ -1963,7 +1965,7 @@ public function checkSdaTablesInViews()
*
* @throws SQLException If there's an error in executing the SQL queries.
*/
function groupHasAccess($group_name, $category, $action, $type = 'module')
function groupHasAccess($group_name, $userId, $category, $action, $type = 'module')
{
global $db;

Expand All @@ -1981,9 +1983,14 @@ function groupHasAccess($group_name, $category, $action, $type = 'module')

$group_id = $row['id'];

// Get the roles associated with this security group
$query = "SELECT role_id FROM securitygroups_acl_roles
WHERE securitygroup_id = '$group_id' AND deleted = 0";
// Get the roles associated with this security group or user
$query = "SELECT role_id FROM (
SELECT role_id FROM securitygroups_acl_roles
WHERE securitygroup_id = '$group_id' AND deleted = 0
UNION SELECT role_id from acl_roles_users aru
WHERE aru.user_id='$userId' AND deleted=false ) m
LIMIT 1
";
$result = $db->query($query);

$roles = array();
Expand Down
8 changes: 8 additions & 0 deletions SticInclude/js/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ function setEnabledStatus(elementId, clearField) {
} else {
$("#" + elementId, $form)
.prop("readonly", false);
$("#" + elementId, $form)
.prop("disabled", false);
$("#" + elementId, $form).parent().find("button")
.prop("disabled", false);
}
$("#" + elementId, $form)
.closest(".edit-view-row-item")
Expand Down Expand Up @@ -313,6 +317,10 @@ function setDisabledStatus(elementId, clearField) {
} else {
$("#" + elementId, $form)
.prop("readonly", true);
$("#" + elementId, $form)
.prop("disabled", true);
$("#" + elementId, $form).parent().find("button")
.prop("disabled", true);
}
$("#" + elementId, $form)
.closest(".edit-view-row-item")
Expand Down
5 changes: 4 additions & 1 deletion SticInstall/sql/ca/EmailTemplates.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ DELETE FROM email_templates;

INSERT INTO `email_templates` (`id`, `date_entered`, `date_modified`, `modified_user_id`, `created_by`, `published`, `name`, `description`, `subject`, `body`, `body_html`, `deleted`, `assigned_user_id`, `text_only`, `type`) VALUES
('d3b49c38-eeba-b910-2590-5b4069caaac1', NOW(), NOW(), '1', '1', NULL, 'Exemple - Donació', 'Exemple de plantilla de correu electrònic per confirmar i agrair una donació', 'Gràcies per la teva donació!', 'Benvolgut/da $contact_first_name $contact_last_name:\r\n\r\nHem rebut la teva donació de $stic_payments_amount €.\r\n\r\nMoltes gràcies pel teu suport!\r\n\r\n', '<p>Benvolgut/da $contact_first_name $contact_last_name:</p>\n<p>Hem rebut la teva donació de $stic_payments_amount €.</p>\n<p>Moltes gràcies pel teu suport!</p>', 0, '1', 0, 'email'),
('dba65685-d26f-6ecd-802c-5b406983c9b5', NOW(), NOW(), '1', '1', NULL, 'Exemple - Inscripció', 'Exemple de plantilla de correu electrònic per confirmar la inscripció a un esdeveniment', '$stic_events_name: Inscripció confirmada', 'Benvolgut/da $contact_first_name $contact_last_name:\r\n\r\nHem rebut la teva inscripció a $stic_events_name.\r\n\r\nA dia $stic_registrations_registration_date la teva inscripció consta com a $stic_registrations_status.\r\n\r\nEns veiem el $stic_events_start_date!', '<p>Benvolgut/da $contact_first_name $contact_last_name:</p>\n<p>Hem rebut la teva inscripció a $stic_events_name.</p>\n<p>A dia $stic_registrations_registration_date la teva tu inscripció consta com a $stic_registrations_status.</p>\n<p>Ens veiem el $stic_events_start_date!</p>', 0, '1', 0, 'email');
('dba65685-d26f-6ecd-802c-5b406983c9b5', NOW(), NOW(), '1', '1', NULL, 'Exemple - Inscripció', 'Exemple de plantilla de correu electrònic per confirmar la inscripció a un esdeveniment', '$stic_events_name: Inscripció confirmada', 'Benvolgut/da $contact_first_name $contact_last_name:\r\n\r\nHem rebut la teva inscripció a $stic_events_name.\r\n\r\nA dia $stic_registrations_registration_date la teva inscripció consta com a $stic_registrations_status.\r\n\r\nEns veiem el $stic_events_start_date!', '<p>Benvolgut/da $contact_first_name $contact_last_name:</p>\n<p>Hem rebut la teva inscripció a $stic_events_name.</p>\n<p>A dia $stic_registrations_registration_date la teva tu inscripció consta com a $stic_registrations_status.</p>\n<p>Ens veiem el $stic_events_start_date!</p>', 0, '1', 0, 'email'),
('52cdc554-bd90-f8f9-e2e0-66d718ae8fe9', NOW(), NOW(), '1', '1', NULL, 'Exemple - Nova subvenció', 'Exemple de plantilla de correu electrònic per notificar la convocatòria d''una nova subvenció', 'Nova convocatòria de subvenció: $opportunity_name', 'Nova convocatòria de subvenció: $opportunity_name\r\n\r\n$opportunity_stic_additional_information_c\r\nPodeu trobar més informació a: $opportunity_stic_opportunity_url_c', '<p>Nova convocatòria de subvenció: $opportunity_name</p><p></p><p>$opportunity_stic_additional_information_c</p><p>Podeu trobar més informació a: $opportunity_stic_opportunity_url_c</p>', 0, '1', 0, 'notification'),
('9f118e85-13f2-baa9-4ee3-66d80c674dea', NOW(), NOW(), '1', '1', NULL, 'Exemple - Nou esdeveniment', 'Exemple de plantilla de correu electrònic per notificar un nou esdeveniment', 'Nou esdeveniment: $stic_events_name', '$stic_events_name\r\n\r\nData d''inici: $stic_events_start_date\r\nData de finalització: $stic_events_end_date\r\nUbicació: $stic_events_stic_events_fp_event_locations_name', '<p>$stic_events_name</p><p></p><p>Data d''inici: $stic_events_start_date</p><p>Data de finalització: $stic_events_end_date</p><p>Ubicació: $stic_events_stic_events_fp_event_locations_name</p>', 0, '1', 0, 'notification');


-- SuiteCRM Base: Exemples de plantilles de correu electrònic

Expand Down
7 changes: 7 additions & 0 deletions SticInstall/sql/common/FieldsMetadata.sql
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ INSERT INTO `fields_meta_data` (`id`, `custom_module`, `name`) VALUES
('Accountsinc_state_c', 'Accounts', 'inc_state_c'),
('Accountsinc_municipality_c', 'Accounts', 'inc_municipality_c'),
('Accountsinc_town_c', 'Accounts', 'inc_town_c'),
-- Campaigns
('Campaignsparent_id', 'Campaigns', 'parent_id'),
('Campaignsparent_name', 'Campaigns', 'parent_name'),
('Campaignsparent_type', 'Campaigns', 'parent_type'),
('Campaignsstic_notification_prospect_list_names_c', 'Campaigns', 'stic_notification_prospect_list_names_c'),
-- Contacts
('Contactsstic_acquisition_channel_c', 'Contacts', 'stic_acquisition_channel_c'),
('Contactsstic_age_c', 'Contacts', 'stic_age_c'),
Expand Down Expand Up @@ -187,6 +192,8 @@ INSERT INTO `fields_meta_data` (`id`, `custom_module`, `name`) VALUES
('Opportunitiesstic_resolution_date_c', 'Opportunities', 'stic_resolution_date_c'),
('Opportunitiesstic_status_c', 'Opportunities', 'stic_status_c'),
('Opportunitiesstic_type_c', 'Opportunities', 'stic_type_c'),
('Opportunitiesstic_opportunity_url_c', 'Opportunities', 'stic_opportunity_url_c'),
('Opportunitiesstic_additional_information_c', 'Opportunities', 'stic_additional_information_c'),
-- FP_Event_Locations
('FP_Event_Locationsstic_address_county_c','FP_Event_Locations','stic_address_county_c'),
('FP_Event_Locationsstic_address_region_c','FP_Event_Locations','stic_address_region_c'),
Expand Down
Loading

0 comments on commit 616eb62

Please sign in to comment.