From 7e43ec036e813a9560a820e6d74b4c8e8e7bcef3 Mon Sep 17 00:00:00 2001 From: juanSTIC Date: Tue, 2 Jan 2024 18:00:06 +0100 Subject: [PATCH] disable main inherit code if there is custom rule --- .../CustomSecurityGroupsInherit.php | 172 +++++++++++------- modules/SecurityGroups/SecurityGroup.php | 168 +++++++++-------- .../stic_Advanced_Security_Groups/Utils.js | 30 +-- .../createRecordTest.php | 8 + .../language/ca_ES.lang.php | 3 +- .../language/en_us.lang.php | 3 +- .../language/es_ES.lang.php | 3 +- .../language/gl_ES.lang.php | 3 +- .../metadata/listviewdefs.php | 12 +- .../stic_Advanced_Security_Groups/vardefs.php | 23 +++ 10 files changed, 263 insertions(+), 162 deletions(-) create mode 100644 modules/stic_Advanced_Security_Groups/createRecordTest.php diff --git a/custom/modules/SecurityGroups/CustomSecurityGroupsInherit.php b/custom/modules/SecurityGroups/CustomSecurityGroupsInherit.php index 6af3946e79d..6751bc248c0 100644 --- a/custom/modules/SecurityGroups/CustomSecurityGroupsInherit.php +++ b/custom/modules/SecurityGroups/CustomSecurityGroupsInherit.php @@ -4,100 +4,147 @@ class CustomSecurityGroupsInherit public function after_save(&$bean, $event, $arguments) { - //return; + if (in_array($bean->module_name, ['SugarFeed'])) { return; } if (!$bean->fetched_row) { global $sugar_config; $rulesBean = self::getModuleRule($bean->module_name); - + if (!empty($rulesBean)) { include_once 'modules/SecurityGroups/SecurityGroup.php'; include_once 'SticInclude/Utils.php'; - // Se aplica la herencia del usuario asignado si está activada + // Check if the inheritance of the assigned user is enabled if ($rulesBean->inherit_assigned == 1) { + // Temporarily enable the inheritance setting $sugar_config['securitysuite_inherit_assigned'] = true; + + // Apply the inheritance logic for the assigned user SecurityGroup::inherit_assigned($bean, false); + + // Reset the inheritance setting to its original state $sugar_config['securitysuite_inherit_assigned'] = false; + } else { + // Check if the inheritance setting is enabled + if ($sugar_config['securitysuite_inherit_assigned'] == true) { + // Log a message indicating that the inheritance rule does not apply + // due to the configuration setting + $GLOBALS['log']->error('Line ' . __LINE__ . ': ' . __METHOD__ . ': ' . + "The variable {sugar_config['securitysuite_inherit_assigned']} " . + "is set to true, indicating that the inheritance rule for the " . + "assigned user defined in the stic_Advanced_Security_Groups module " . + "does not apply"); + } } - - // Se aplica la herencia del usuario creador si está activada + + // Check if the inheritance of the creator is enabled if ($rulesBean->inherit_creator == 1) { + // Temporarily enable the inheritance setting $sugar_config['securitysuite_inherit_creator'] = true; + + // Apply the inheritance logic for the creator SecurityGroup::inherit_creator($bean, false); + + // Reset the inheritance setting to its original state $sugar_config['securitysuite_inherit_creator'] = false; + } else { + // Check if the inheritance setting is enabled + if ($sugar_config['securitysuite_inherit_creator'] == true) { + // Log a message indicating that the inheritance rule does not apply + // due to the configuration setting + $GLOBALS['log']->error('Line ' . __LINE__ . ': ' . __METHOD__ . ': ' . + "The variable {sugar_config['securitysuite_inherit_creator']} " . + "is set to true, indicating that the inheritance rule for the " . + "creator defined in the stic_Advanced_Security_Groups module " . + "does not apply"); + } } - // Se aplica la herencia del registro padre si está activada + // Check if the inheritance of the parent is enabled if ($rulesBean->inherit_parent == 1) { + // Temporarily enable the inheritance setting $sugar_config['securitysuite_inherit_parent'] = true; + + // Apply the inheritance logic for the parent SecurityGroup::inherit_parent($bean, false); + + // Reset the inheritance setting to its original state $sugar_config['securitysuite_inherit_parent'] = false; + } else { + // Check if the inheritance setting is enabled + if ($sugar_config['securitysuite_inherit_parent'] == true) { + // Log a message indicating that the inheritance rule does not apply + // due to the configuration setting + $GLOBALS['log']->info('Line ' . __LINE__ . ': ' . __METHOD__ . ': ' . + "The variablrsos 24/07/2023 11:20 13/07/2023 15:22 +  PROPUESTAS - HE No No No e {sugar_config['securitysuite_inherit_parent']} " . + "is set to true, indicating that the inheritance rule for the " . + "parent defined in the stic_Advanced_Security_Groups module " . + "does not apply"); + } } // Si se han establecido reglas de herencia de algún módulo relacioando la aplicamos - $finalSGtoInherit = array(); - $bean->load_relationship('SecurityGroups'); - - for ($i = 10; $i > 0; $i--) { - $customInherit =''; - $customInherit = $rulesBean->{"inherit_from_modules_".$i}; - - if (!empty($customInherit) && (is_string($bean->$customInherit))) { - $finalSGtoInherit[] = $bean->$customInherit; - } else if (!empty($customInherit)){ - $relatedSG=''; - $customInheritBean = SticUtils::getRelatedBeanObject($bean, $customInherit); - //$GLOBALS['log']->error('Line ' . __LINE__ . ': ' . __METHOD__ . ': relatedField: '.$customInheritBean->id); - if (!empty($customInheritBean->id)){ - $relatedSG = self::getRelatedSG($customInheritBean->id); - foreach ($relatedSG as $relSG){ - $finalSGtoInherit[] = $relSG; - } - } - } + $finalSGtoInherit = array(); + $bean->load_relationship('SecurityGroups'); + + for ($i = 10; $i > 0; $i--) { + $customInherit = ''; + $customInherit = $rulesBean->{"inherit_from_modules_" . $i}; + + if (!empty($customInherit) && (is_string($bean->$customInherit))) { + $finalSGtoInherit[] = $bean->$customInherit; + } else if (!empty($customInherit)) { + $relatedSG = ''; + $customInheritBean = SticUtils::getRelatedBeanObject($bean, $customInherit); + //$GLOBALS['log']->error('Line ' . __LINE__ . ': ' . __METHOD__ . ': relatedField: '.$customInheritBean->id); + if (!empty($customInheritBean->id)) { + $relatedSG = self::getRelatedSG($customInheritBean->id); + foreach ($relatedSG as $relSG) { + $finalSGtoInherit[] = $relSG; + } + } } + } - //$exemptInherit = $rulesBean->non_inherit_from_security_groups; - - $finalExemptInherit = array(); + //$exemptInherit = $rulesBean->non_inherit_from_security_groups; - for ($i = 5; $i > 0; $i--) { - $exemptInherit =''; - $exemptInherit = $rulesBean->{"non_inherit_from_security_groups_".$i}; - if (!empty($exemptInherit)){ - $finalExemptInherit[] = $exemptInherit; - } - } + $finalExemptInherit = array(); + for ($i = 5; $i > 0; $i--) { + $exemptInherit = ''; + $exemptInherit = $rulesBean->{"non_inherit_from_security_groups_" . $i}; + if (!empty($exemptInherit)) { + $finalExemptInherit[] = $exemptInherit; + } + } + if (!empty($finalSGtoInherit)) { + //$finalSGtoInherit = array_unique($finalSGtoInherit); + $finalSGtoInherit = array_unique($finalSGtoInherit); + + if (!empty($finalExemptInherit)) { + $finalExemptInherit = array_unique($finalExemptInherit); + $GLOBALS['log']->debug('Line ' . __LINE__ . ': ' . __METHOD__ . ': exemptInherit: ' . $exemptInherit); + //$finalSGtoInherit.indexOf($exemptInherit); + /*foreach (array_diff($finalSGtoInherit, $finalExemptInherit) as $key) { + unset($finalSGtoInherit[$key]); + }*/ + $finalSGtoInherit = array_diff($finalSGtoInherit, $finalExemptInherit); + } + $GLOBALS['log']->debug('Line ' . __LINE__ . ': ' . __METHOD__ . ': relatedSG: ' . print_r($finalSGtoInherit, true)); - if (!empty($finalSGtoInherit)) { - //$finalSGtoInherit = array_unique($finalSGtoInherit); - $finalSGtoInherit = array_unique($finalSGtoInherit); - - if (!empty($finalExemptInherit)){ - $finalExemptInherit = array_unique($finalExemptInherit); - $GLOBALS['log']->debug('Line ' . __LINE__ . ': ' . __METHOD__ . ': exemptInherit: '.$exemptInherit); - //$finalSGtoInherit.indexOf($exemptInherit); - /*foreach (array_diff($finalSGtoInherit, $finalExemptInherit) as $key) { - unset($finalSGtoInherit[$key]); - }*/ - $finalSGtoInherit= array_diff($finalSGtoInherit, $finalExemptInherit); - } - $GLOBALS['log']->debug('Line ' . __LINE__ . ': ' . __METHOD__ . ': relatedSG: '.print_r($finalSGtoInherit, true)); - - foreach ($finalSGtoInherit as $SG_ID) { - self::setCustomInherit($bean->id, $bean->module_name, $SG_ID); - } - } + foreach ($finalSGtoInherit as $SG_ID) { + self::setCustomInherit($bean->id, $bean->module_name, $SG_ID); + } } } } - + } + /** * Save one securitygroup record * @@ -117,7 +164,7 @@ public static function setCustomInherit($recordId, $moduleName, $securityGroupId /** * Obtener la regla definida para el módulo * - * @param String $moduleName + * @param String $moduleName * @return Object */ public static function getModuleRule($moduleName) @@ -132,10 +179,10 @@ public static function getModuleRule($moduleName) public static function getRelatedSG($relatedID) { global $db; - $relatedIDs= array(); + $relatedIDs = array(); $result = $db->query("SELECT DISTINCT securitygroup_id FROM securitygroups_records sr left join securitygroups sg on sr.securitygroup_id=sg.id WHERE sr.record_id='{$relatedID}' AND sr.deleted=0 AND sg.noninheritable=0"); - foreach($result as $row){ - $relatedIDs[]= $row['securitygroup_id']; + foreach ($result as $row) { + $relatedIDs[] = $row['securitygroup_id']; } return $relatedIDs; } @@ -143,12 +190,11 @@ public static function getRelatedSG($relatedID) public static function checkrelatedField($relatedID, $bean) { global $db; - $relID= ''; + $relID = ''; $relID = $db->getOne("SELECT {$relatedID} FROM contacts_cstm WHERE id_c='{$bean->id}' LIMIT 1"); //$relID = $db->getOne("SELECT id FROM securitygroups WHERE id='{$relatedID}' AND deleted=0 LIMIT 1"); - + return $relID; } } - diff --git a/modules/SecurityGroups/SecurityGroup.php b/modules/SecurityGroups/SecurityGroup.php index 6bdb13489b0..b9d0e5c7dcb 100755 --- a/modules/SecurityGroups/SecurityGroup.php +++ b/modules/SecurityGroups/SecurityGroup.php @@ -188,6 +188,21 @@ public static function groupHasAccess($module, $id, $action = '') public static function inherit($focus, $isUpdate) { global $sugar_config; + + // STIC-CUSTOM JCH 2024-02-02 Do not apply inheritance rules if a custom rule is defined. + // https://github.com/SinergiaTIC/SinergiaCRM/pull/3 + // Check for a custom rule for the module in the database + $customRuleQuery = "SELECT count(*) FROM stic_advanced_security_groups WHERE name='{$focus->module_dir}' AND active=true"; + $customRuleCount = $focus->db->getOne($customRuleQuery); + + // If a custom rule is defined (count is 1), exit the function + // This prevents the application of default inheritance rules + // defined in the SinergiaCRM configuration for this module + if ($customRuleCount == 1) { + return; + } + // END STIC CUSTOM + self::assign_default_groups($focus, $isUpdate); //this must be first because it does not check for dups // STIC custom - JCH - 20221128 - Don't apply assigned user inheritance when saving an existing record // STIC#929 @@ -237,17 +252,17 @@ public static function assign_default_groups($focus, $isUpdate) if ($defaultGroup['module'] == 'All' || $defaultGroup['module'] == $focus->module_dir) { if ($focus->module_dir == 'Users') { $query = 'insert into securitygroups_users(id,date_modified,deleted,securitygroup_id,user_id,noninheritable) ' - . "select distinct '" . create_guid() . "'," . $focus->db->convert( - '', - 'today' - ) . ",0,g.id,'$focus->id',1 " + . "select distinct '" . create_guid() . "'," . $focus->db->convert( + '', + 'today' + ) . ",0,g.id,'$focus->id',1 " . 'from securitygroups g ' . "left join securitygroups_users d on d.securitygroup_id = g.id and d.user_id = '$focus->id' and d.deleted = 0 " . "where d.id is null and g.id = '" . $defaultGroup['securitygroup_id'] . "' and g.deleted = 0 "; } else { $query = 'insert into securitygroups_records(id,securitygroup_id,record_id,module,date_modified,deleted) ' - . "select distinct '" . create_guid() . "',g.id,'$focus->id','$focus->module_dir'," - . $focus->db->convert('', 'today') . ',0 ' + . "select distinct '" . create_guid() . "',g.id,'$focus->id','$focus->module_dir'," + . $focus->db->convert('', 'today') . ',0 ' . 'from securitygroups g ' . "left join securitygroups_records d on d.securitygroup_id = g.id and d.record_id = '$focus->id' and d.module = '$focus->module_dir' and d.deleted = 0 " . "where d.id is null and g.id = '" . $defaultGroup['securitygroup_id'] . "' and g.deleted = 0 "; @@ -286,15 +301,15 @@ public static function inherit_creator($focus, $isUpdate) // STIC-Custom EPS 20230914 When the bean has a different creator than current_user, use the creator specified by the bean // STIC#1220 // $currentUserId = isset($current_user->id) ? $focus->db->quote($current_user->id) : null; - if (isset($focus->created_by) && $focus->created_by!= '') { + if (isset($focus->created_by) && $focus->created_by != '') { $currentUserId = $focus->db->quote($focus->created_by); } else { $currentUserId = isset($current_user->id) ? $focus->db->quote($current_user->id) : null; - } + } // END STIC-Custom - $recordId = $focus->db->quote($focus->id); + $recordId = $focus->db->quote($focus->id); $query .= ",u.securitygroup_id,'$recordId','$focus->module_dir'," - . $focus->db->convert('', 'today') . ',0 ' + . $focus->db->convert('', 'today') . ',0 ' . 'from securitygroups_users u ' . 'inner join securitygroups g on u.securitygroup_id = g.id and g.deleted = 0 and (g.noninheritable is null or g.noninheritable <> 1) ' . "left join securitygroups_records d on d.securitygroup_id = u.securitygroup_id and d.record_id = '$recordId' and d.module = '$focus->module_dir' and d.deleted = 0 " @@ -318,7 +333,7 @@ public static function inherit_assigned($focus, $isUpdate) { global $sugar_config; if (isset($sugar_config['securitysuite_inherit_assigned']) && $sugar_config['securitysuite_inherit_assigned'] == true && $isUpdate == false) { - // END STIC + // END STIC if (!empty($focus->assigned_user_id)) { $assigned_user_id = $focus->db->quote($focus->assigned_user_id); //inherit only for those that support Security Groups @@ -332,9 +347,9 @@ public static function inherit_assigned($focus, $isUpdate) } elseif ($focus->db->dbType == 'mssql') { $query .= ' lower(newid()) '; } - $recordId = $focus->db->quote($focus->id); + $recordId = $focus->db->quote($focus->id); $query .= ",u.securitygroup_id,'$recordId','$focus->module_dir'," - . $focus->db->convert('', 'today') . ',0 ' + . $focus->db->convert('', 'today') . ',0 ' . 'from securitygroups_users u ' . 'inner join securitygroups g on u.securitygroup_id = g.id and g.deleted = 0 and (g.noninheritable is null or g.noninheritable <> 1) ' . "left join securitygroups_records d on d.securitygroup_id = u.securitygroup_id and d.record_id = '$recordId' and d.module = '$focus->module_dir' and d.deleted = 0 " @@ -373,11 +388,11 @@ public static function inherit_parent($focus, $isUpdate) $parent_type = ''; $parent_id = ''; - // STIC-Custom - JCH - 20220503 - Reapply fix parent record inheritance (#259) + // STIC-Custom - JCH - 20220503 - Reapply fix parent record inheritance (#259) // STIC#725 // if (isset($_REQUEST['relate_to']) && isset($_REQUEST['relate_id'])) { if (!empty($_REQUEST['relate_to']) && !empty($_REQUEST['relate_id'])) { - // END STIC + // END STIC //relate_to is not guaranteed to be a module name anymore. //if it isn't load the relationship and find the module name that way if (!in_array($_REQUEST['relate_to'], array_keys($security_modules))) { @@ -389,11 +404,11 @@ public static function inherit_parent($focus, $isUpdate) $focus_module_dir, $focus->db ); - // STIC-Custom - JCH - 20220503 - Reapply fix parent record inheritance (#259) + // STIC-Custom - JCH - 20220503 - Reapply fix parent record inheritance (#259) // STIC#725 // if (isset($rel)) { if (isset($rel_module)) { - // END STIC + // END STIC $parent_type = $rel_module; $parent_id = $_REQUEST['relate_id']; } @@ -402,11 +417,11 @@ public static function inherit_parent($focus, $isUpdate) $parent_id = $_REQUEST['relate_id']; } } - // STIC-Custom - JCH - 20220503 - Reapply fix parent record inheritance (#259) + // STIC-Custom - JCH - 20220503 - Reapply fix parent record inheritance (#259) // STIC#725 // if (isset($_SESSION['portal_id'])) { elseif (isset($_SESSION['portal_id'])) { - // END STIC + // END STIC $parent_id = $_SESSION['user_id']; //soap stores contact id in user_id field $parent_type = 'Contacts'; } @@ -416,7 +431,7 @@ public static function inherit_parent($focus, $isUpdate) // STIC#725 // if ((empty($parent_type) || empty($parent_id)) && isset($_REQUEST['parent_type']) && isset($_REQUEST['parent_id'])) { elseif ((empty($parent_type) || empty($parent_id)) && isset($_REQUEST['parent_type']) && isset($_REQUEST['parent_id'])) { - // END STIC + // END STIC $parent_type = $_REQUEST['parent_type']; $parent_id = $_REQUEST['parent_id']; } @@ -429,20 +444,19 @@ public static function inherit_parent($focus, $isUpdate) $parent_type = $_REQUEST['return_module']; $parent_id = $_REQUEST['return_id']; } - + if (!empty($parent_type) && !empty($parent_id)) { self::inherit_parentQuery( - $focus, - $parent_type, - $parent_id, - $focus_id, + $focus, + $parent_type, + $parent_id, + $focus_id, $focus_module_dir ); - } + } // END STIC //end if parent type/id - /* need to find relate fields...for example for Cases look to see if account_id is set */ //allow inheritance for all relate field types....iterate through and inherit each related field foreach ($focus->field_name_map as $name => $def) { @@ -463,40 +477,40 @@ public static function inherit_parent($focus, $isUpdate) // $focus_module_dir // ); // END STIC - } elseif (isset($_SESSION['portal_id']) && isset($_SESSION[$def['id_name']])) { //soap account - + } elseif (isset($_SESSION['portal_id']) && isset($_SESSION[$def['id_name']])) { + //soap account + $relate_parent_id = $_SESSION[$def['id_name']]; $relate_parent_type = $def['module']; - - // STIC-Custom - JCH - 20220503 - Reapply fix parent record inheritance (#259) - // STIC#725 - // Solved STIC#156 - // If the relationship with the main record is created by code, none of the previous conditions - // will apply but inheritance from parent record should be done, too. - // This solution has been proposed and "approved" in SugarOutfitters SecuritySuite support page - // https://www.sugaroutfitters.com/support/securitysuite/4527 - // self::inherit_parentQuery( - // $focus, - // $relate_parent_type, - // $relate_parent_id, - // $focus_id, - // $focus_module_dir - // ); - // } - // } - // } - - // if (!empty($parent_type) && !empty($parent_id)) { - // self::inherit_parentQuery($focus, $parent_type, $parent_id, $focus_id, $focus_module_dir); - // } //end if parent type/id - } elseif($def['type'] == 'relate' && isset($focus->{$def['id_name']})) { + + // STIC-Custom - JCH - 20220503 - Reapply fix parent record inheritance (#259) + // STIC#725 + // Solved STIC#156 + // If the relationship with the main record is created by code, none of the previous conditions + // will apply but inheritance from parent record should be done, too. + // This solution has been proposed and "approved" in SugarOutfitters SecuritySuite support page + // https://www.sugaroutfitters.com/support/securitysuite/4527 + // self::inherit_parentQuery( + // $focus, + // $relate_parent_type, + // $relate_parent_id, + // $focus_id, + // $focus_module_dir + // ); + // } + // } + // } + + // if (!empty($parent_type) && !empty($parent_id)) { + // self::inherit_parentQuery($focus, $parent_type, $parent_id, $focus_id, $focus_module_dir); + // } //end if parent type/id + } elseif ($def['type'] == 'relate' && isset($focus->{$def['id_name']})) { $relate_parent_id = $focus->{$def['id_name']}; $relate_parent_type = $def['module']; - + } - - if(!empty($relate_parent_id) && !empty($relate_parent_type)) - { + + if (!empty($relate_parent_id) && !empty($relate_parent_type)) { self::inherit_parentQuery( $focus, $relate_parent_type, @@ -505,7 +519,7 @@ public static function inherit_parent($focus, $isUpdate) $focus_module_dir ); } - + // Reset variables $relate_parent_id = ''; $relate_parent_type = ''; @@ -513,7 +527,6 @@ public static function inherit_parent($focus, $isUpdate) } } - } //end if new record } @@ -540,16 +553,16 @@ public static function inherit_parentQuery($focus, $parent_type, $parent_id, $fo $query .= ' lower(newid()) '; } // STIC-Custom - JCH - 20220503 - Reapply fix parent record inheritance (#259) - // STIC#725 - $query .= ",r.securitygroup_id,'$focus_id','$focus_module_dir','" . gmdate('Y-m-d H:i:s') ."'". ',0 ' + // STIC#725 + $query .= ",r.securitygroup_id,'$focus_id','$focus_module_dir','" . gmdate('Y-m-d H:i:s') . "'" . ',0 ' // END STIC - . 'from securitygroups_records r ' - . 'inner join securitygroups g on r.securitygroup_id = g.id and g.deleted = 0 and (g.noninheritable is null or g.noninheritable <> 1) ' - . "left join securitygroups_records d on d.securitygroup_id = r.securitygroup_id and d.record_id = '" - . $focus->db->quote($focus_id) . "' and d.module = '" - . $focus->db->quote($focus_module_dir) . "' and d.deleted = 0 " - . "where d.id is null and r.module = '" . $focus->db->quote($parent_type) . "' " - . "and r.record_id = '" . $focus->db->quote($parent_id) . "' " + . 'from securitygroups_records r ' + . 'inner join securitygroups g on r.securitygroup_id = g.id and g.deleted = 0 and (g.noninheritable is null or g.noninheritable <> 1) ' + . "left join securitygroups_records d on d.securitygroup_id = r.securitygroup_id and d.record_id = '" + . $focus->db->quote($focus_id) . "' and d.module = '" + . $focus->db->quote($focus_module_dir) . "' and d.deleted = 0 " + . "where d.id is null and r.module = '" . $focus->db->quote($parent_type) . "' " + . "and r.record_id = '" . $focus->db->quote($parent_id) . "' " . 'and r.deleted = 0 '; $GLOBALS['log']->debug("SecuritySuite: Inherit from Parent: $query"); $focus->db->query($query, true); @@ -582,8 +595,8 @@ public static function inheritOne($user_id, $record_id, $module) $moduleName = $db->quote($module); if (isset($row) && $row['results'] == 1) { $query = 'insert into securitygroups_records(id,securitygroup_id,record_id,module,date_modified,deleted) ' - . "select distinct '" . create_guid() . "',u.securitygroup_id,'$recordId','$moduleName'," - . $db->convert('', 'today') . ',0 ' + . "select distinct '" . create_guid() . "',u.securitygroup_id,'$recordId','$moduleName'," + . $db->convert('', 'today') . ',0 ' . 'from securitygroups_users u ' . 'inner join securitygroups g on u.securitygroup_id = g.id and g.deleted = 0 and (g.noninheritable is null or g.noninheritable <> 1) ' . "left join securitygroups_records d on d.securitygroup_id = u.securitygroup_id and d.record_id = '$recordId' and d.module = '$moduleName' and d.deleted = 0 " @@ -642,7 +655,7 @@ public static function retrieveDefaultGroups() $default_groups[$row['id']] = array( 'group' => $row['name'], 'module' => $row['module'], - 'securitygroup_id' => $row['securitygroup_id'] + 'securitygroup_id' => $row['securitygroup_id'], ); } @@ -666,7 +679,7 @@ public static function saveDefaultGroup($group_id, $module) } $query .= ",'" . htmlspecialchars($group_id, ENT_QUOTES) . "', '" . htmlspecialchars( $module, - ENT_QUOTES + ENT_QUOTES ) . "'," . $db->convert('', 'today') . ',0 )'; $GLOBALS['log']->debug("SecuritySuite: Save Default Group: $query"); @@ -681,7 +694,7 @@ public static function removeDefaultGroup($default_id) $db = DBManagerFactory::getInstance(); $query = "DELETE FROM securitygroups_default WHERE id = '" . htmlspecialchars($default_id, - ENT_QUOTES | ENT_HTML5) . "' "; + ENT_QUOTES | ENT_HTML5) . "' "; $db->query($query); } @@ -713,7 +726,7 @@ public static function getSecurityModules() } if (isset($app_list_strings['moduleList'][$row['rhs_module']])) { - $security_modules[$row['rhs_module']] = $app_list_strings['moduleList'][$row['rhs_module']];//rost fix + $security_modules[$row['rhs_module']] = $app_list_strings['moduleList'][$row['rhs_module']]; //rost fix } } else { if (in_array($row['lhs_module'], $module_blacklist)) { @@ -760,10 +773,10 @@ public function addGroupToRecord($module, $record_id, $securitygroup_id) } $db = DBManagerFactory::getInstance(); $query = 'insert into securitygroups_records(id,securitygroup_id,record_id,module,date_modified,deleted) ' - . "values( '" . create_guid() . "','" . $securitygroup_id . "','$record_id','$module'," . $db->convert( - '', - 'today' - ) . ',0) '; + . "values( '" . create_guid() . "','" . $securitygroup_id . "','$record_id','$module'," . $db->convert( + '', + 'today' + ) . ',0) '; $GLOBALS['log']->debug("SecuritySuite: addGroupToRecord: $query"); $db->query($query, true); } @@ -919,7 +932,6 @@ public static function getParentGroups($focus) } } - return $parent_groups; } diff --git a/modules/stic_Advanced_Security_Groups/Utils.js b/modules/stic_Advanced_Security_Groups/Utils.js index d7ece02a47b..7ad8b5e7c92 100644 --- a/modules/stic_Advanced_Security_Groups/Utils.js +++ b/modules/stic_Advanced_Security_Groups/Utils.js @@ -17,8 +17,8 @@ switch (viewType()) { $(document).ready(function () { // convert to selectize - $('select[name=name], select#inherit_from_modules, select#non_inherit_from_security_groups').selectize() - + $('select[name=name], select#inherit_from_modules, select#non_inherit_from_security_groups').selectize(); + }) break; case "detail": @@ -26,26 +26,26 @@ switch (viewType()) { case "list": - $(document).ready(function() { - // disable some list menu actions - var selectorsToKeep = ['#massupdate_listview_top', '#export_listview_top', '#delete_listview_top']; - - // remove duplicate massive link which has not a uniq id - $('#actionLinkTop > li > ul > li:nth-child(2) > a#massupdate_listview_top').closest('li').remove(); + $(document).ready(function () { + // disable some list menu actions + var selectorsToKeep = ['#massupdate_listview_top', '#export_listview_top', '#delete_listview_top']; + + // remove duplicate massive link which has not a uniq id + $('#actionLinkTop > li > ul > li:nth-child(2) > a#massupdate_listview_top').closest('li').remove(); - $('ul#actionLinkTop li.sugar_action_button ul li').each(function() { + $('ul#actionLinkTop li.sugar_action_button ul li').each(function () { var containsSelector = false; for (var i = 0; i < selectorsToKeep.length; i++) { - if ($(this).find(selectorsToKeep[i]).length > 0) { - containsSelector = true; - break; - } + if ($(this).find(selectorsToKeep[i]).length > 0) { + containsSelector = true; + break; + } } if (!containsSelector) { - $(this).remove(); + $(this).remove(); } + }); }); -}); diff --git a/modules/stic_Advanced_Security_Groups/createRecordTest.php b/modules/stic_Advanced_Security_Groups/createRecordTest.php new file mode 100644 index 00000000000..86abb64e822 --- /dev/null +++ b/modules/stic_Advanced_Security_Groups/createRecordTest.php @@ -0,0 +1,8 @@ +name=rand(); +$bean->assigned_user_id=2; +$bean->save(); + +SugarApplication::redirect("index.php?module={$_REQUEST['modulo']}&action=detailview&record={$bean->id}"); \ No newline at end of file diff --git a/modules/stic_Advanced_Security_Groups/language/ca_ES.lang.php b/modules/stic_Advanced_Security_Groups/language/ca_ES.lang.php index 6ae7647256d..1a238e8c0a4 100644 --- a/modules/stic_Advanced_Security_Groups/language/ca_ES.lang.php +++ b/modules/stic_Advanced_Security_Groups/language/ca_ES.lang.php @@ -78,6 +78,7 @@ 'LBL_MODULO' => 'modulo', 'LBL_RULES' => 'Reglas de herencia', 'LBL_MODULE' => 'module', + 'LBL_ACTIVE' => 'Activo', 'LBL_INHERIT_ASSIGNED' => 'Usuario asignado', 'LBL_INHERIT_PARENT' => 'Heredar del registro padre', 'LBL_INHERIT_CREATOR' => 'Heredar del usuario creador', @@ -85,7 +86,7 @@ 'LBL_INHERIT_FROM_MODULES' => 'custom rules module', 'LBL_CUSTOM_RULES_PATH' => 'custom rules field', 'LBL_INHERIT_CUSTOM' => 'Heredar de un módulo y campo especifico', - 'LBL_INHERIT_FROM_MODULES' => 'Relación a través de la que hereda', + 'LBL_INHERIT_FROM_MODULES' => 'Relaciones a través de las que hereda', 'LBL_NON_INHERIT_FROM_SECURITY_GROUPS' => 'GS no heredable', 'LBL_COMMENTS' => 'Observaciones', ); \ No newline at end of file diff --git a/modules/stic_Advanced_Security_Groups/language/en_us.lang.php b/modules/stic_Advanced_Security_Groups/language/en_us.lang.php index cd1e3ca5b2e..2d07c1ed9f0 100644 --- a/modules/stic_Advanced_Security_Groups/language/en_us.lang.php +++ b/modules/stic_Advanced_Security_Groups/language/en_us.lang.php @@ -78,11 +78,12 @@ 'LBL_MODULO' => 'modulo', 'LBL_RULES' => 'Reglas de herencia', 'LBL_MODULE' => 'module', + 'LBL_ACTIVE' => 'Active', 'LBL_INHERIT_ASSIGNED' => 'Usuario asignado', 'LBL_INHERIT_PARENT' => 'Heredar del registro padre', 'LBL_INHERIT_CREATOR' => 'Heredar del usuario creador', 'LBL_INHERIT_CUSTOM_RULES' => 'Reglas de herencia personalizadas', - 'LBL_INHERIT_FROM_MODULES' => 'Relación a través de la que hereda', + 'LBL_INHERIT_FROM_MODULES' => 'Relaciones a través de las que hereda', 'LBL_NON_INHERIT_FROM_SECURITY_GROUPS' => 'GS no heredable', 'LBL_INHERIT_CUSTOM' => 'Heredar de un módulo y campo especifico', ); \ No newline at end of file diff --git a/modules/stic_Advanced_Security_Groups/language/es_ES.lang.php b/modules/stic_Advanced_Security_Groups/language/es_ES.lang.php index e943da05f0c..d2380502dad 100644 --- a/modules/stic_Advanced_Security_Groups/language/es_ES.lang.php +++ b/modules/stic_Advanced_Security_Groups/language/es_ES.lang.php @@ -78,11 +78,12 @@ 'LBL_MODULO' => 'Módulo', 'LBL_RULES' => 'Reglas de herencia aplicables', 'LBL_MODULE' => 'Módulo', + 'LBL_ACTIVE' => 'Activo', 'LBL_INHERIT_ASSIGNED' => 'Heredar del usuario asignado', 'LBL_INHERIT_PARENT' => 'Heredar del registro padre', 'LBL_INHERIT_CREATOR' => 'Heredar del usuario creador', 'LBL_INHERIT_CUSTOM_RULES' => 'Reglas de herencia personalizadas', - 'LBL_INHERIT_FROM_MODULES' => 'Relación a través de la que hereda', + 'LBL_INHERIT_FROM_MODULES' => 'Relaciones a través de las que hereda', 'LBL_NON_INHERIT_FROM_SECURITY_GROUPS' => 'GS no heredable', 'LBL_INHERIT_CUSTOM' => 'Heredar de un módulo y campo especifico', 'LBL_EDITVIEW_PANEL1' => 'Reglas de herencia custom', diff --git a/modules/stic_Advanced_Security_Groups/language/gl_ES.lang.php b/modules/stic_Advanced_Security_Groups/language/gl_ES.lang.php index 65aa60b6a0c..1ef83d81341 100644 --- a/modules/stic_Advanced_Security_Groups/language/gl_ES.lang.php +++ b/modules/stic_Advanced_Security_Groups/language/gl_ES.lang.php @@ -78,11 +78,12 @@ 'LBL_MODULO' => 'Módulo', 'LBL_RULES' => 'Reglas de herencia aplicables', 'LBL_MODULE' => 'Módulo', + 'LBL_ACTIVE' => 'Activo', 'LBL_INHERIT_ASSIGNED' => 'Heredar del usuario asignado', 'LBL_INHERIT_PARENT' => 'Heredar del registro padre', 'LBL_INHERIT_CREATOR' => 'Heredar del usuario creador', 'LBL_INHERIT_CUSTOM_RULES' => 'Reglas de herencia personalizadas', - 'LBL_INHERIT_FROM_MODULES' => 'Relación a través de la que hereda', + 'LBL_INHERIT_FROM_MODULES' => 'Relaciones a través de las que hereda', 'LBL_NON_INHERIT_FROM_SECURITY_GROUPS' => 'GS no heredable', 'LBL_INHERIT_CUSTOM' => 'Heredar de un módulo y campo especifico', 'LBL_EDITVIEW_PANEL1' => 'Reglas de herencia custom', diff --git a/modules/stic_Advanced_Security_Groups/metadata/listviewdefs.php b/modules/stic_Advanced_Security_Groups/metadata/listviewdefs.php index a7d62739864..bcf4daacaab 100644 --- a/modules/stic_Advanced_Security_Groups/metadata/listviewdefs.php +++ b/modules/stic_Advanced_Security_Groups/metadata/listviewdefs.php @@ -14,9 +14,17 @@ 'label' => 'LBL_NAME_LBL', 'default' => true, 'link' => true, - + ), - 'INHERIT_ASSIGNED' => array( + 'ACTIVE' => array( + 'type' => 'bool', + 'align' => 'center', + 'default' => true, + 'studio' => 'visible', + 'label' => 'LBL_ACTIVE', + 'width' => '10%', + ), + 'INHERIT_ASSIGNED' => array( 'type' => 'bool', 'align' => 'center', 'default' => true, diff --git a/modules/stic_Advanced_Security_Groups/vardefs.php b/modules/stic_Advanced_Security_Groups/vardefs.php index 41a7c6a4e84..7801b11d90b 100644 --- a/modules/stic_Advanced_Security_Groups/vardefs.php +++ b/modules/stic_Advanced_Security_Groups/vardefs.php @@ -115,6 +115,29 @@ 'reportable' => false, 'size' => '20', ), + 'active' => array( + 'required' => false, + 'name' => 'active', + 'vname' => 'LBL_ACTIVE', + 'type' => 'bool', + 'no_default' => false, + 'massupdate' => 1, + 'inline_edit' => 1, + 'comments' => '', + 'help' => '', + 'importable' => 'false', + 'duplicate_merge' => 'disabled', + 'duplicate_merge_dom_value' => '2', + 'audited' => false, + 'reportable' => true, + 'unified_search' => false, + 'merge_filter' => 'enabled', + 'popupHelp' => 'LBL_ACTIVE_HELP', + 'studio' => array( + 'quickcreate' => false, + 'editview' => false, + ), + ), 'inherit_from_modules' => array( 'audited' => false, 'comments' => '',