function inherit_parent(&$focus, $isUpdate) { global $sugar_config; //new record or if update from soap api for cases or bugs //TEST FOR PORTAL NOTES //if((!$isUpdate || ($isUpdate && !empty($focus->note_id) && ($focus->object_name == "Case" || $focus->object_name == "Bug"))) if (!$isUpdate && isset($sugar_config['securitysuite_inherit_parent']) && $sugar_config['securitysuite_inherit_parent'] == true) { $focus_module_dir = $focus->module_dir; $focus_id = $focus->id; //inherit only for those that support Security Groups $groupFocus = new SecurityGroup(); $security_modules = $groupFocus->getSecurityModules(); //if(!in_array($focus_module_dir,$security_modules)) { if (!in_array($focus_module_dir, array_keys($security_modules))) { //rost fix2 return; //don't inherit for this module } //from subpanel //PHP Notice error fix $parent_type = ""; $parent_id = ""; if (isset($_REQUEST['relate_to']) && isset($_REQUEST['relate_id'])) { //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))) { //check to see if relate_to is the relationship name require_once 'modules/Relationships/Relationship.php'; $rel_module = Relationship::get_other_module($_REQUEST['relate_to'], $focus_module_dir, $focus->db); if (isset($rel)) { $parent_type = $rel_module; $parent_id = $_REQUEST['relate_id']; } } else { $parent_type = $_REQUEST['relate_to']; $parent_id = $_REQUEST['relate_id']; } } if (isset($_SESSION['portal_id'])) { $parent_id = $_SESSION['user_id']; //soap stores contact id in user_id field $parent_type = "Contacts"; } //from activity type creation if ((empty($parent_type) || empty($parent_id)) && isset($_REQUEST['parent_type']) && isset($_REQUEST['parent_id'])) { $parent_type = $_REQUEST['parent_type']; $parent_id = $_REQUEST['parent_id']; } //full form from subpanel if ((empty($parent_type) || empty($parent_id)) && isset($_REQUEST['return_module']) && isset($_REQUEST['return_id'])) { $parent_type = $_REQUEST['return_module']; $parent_id = $_REQUEST['return_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 //if(empty($parent_type) || empty($parent_id)) { foreach ($focus->field_name_map as $name => $def) { if ($def['type'] == 'relate' && isset($def['id_name']) && isset($def['module']) && strtolower($def['module']) != "users") { if (isset($_REQUEST[$def['id_name']])) { $relate_parent_id = $_REQUEST[$def['id_name']]; $relate_parent_type = $def['module']; SecurityGroup::inherit_parentQuery($focus, $relate_parent_type, $relate_parent_id, $focus_id, $focus_module_dir); } else { if (isset($_SESSION['portal_id']) && isset($_SESSION[$def['id_name']])) { //catch soap account $relate_parent_id = $_SESSION[$def['id_name']]; $relate_parent_type = $def['module']; SecurityGroup::inherit_parentQuery($focus, $relate_parent_type, $relate_parent_id, $focus_id, $focus_module_dir); } } } } //} if (!empty($parent_type) && !empty($parent_id)) { // && $parent_type != "Emails" && $parent_type != "Meetings") { SecurityGroup::inherit_parentQuery($focus, $parent_type, $parent_id, $focus_id, $focus_module_dir); } //end if parent type/id } //end if new record }
public function testinherit_parentQuery() { //unset and reconnect Db to resolve mysqli fetch exeception global $db; unset($db->database); $db->checkConnection(); $account = new Account(); $account->id = 1; //execute the method and test if it works and does not throws an exception. try { SecurityGroup::inherit_parentQuery($account, 'Accounts', 1, 1, $account->module_dir); $this->assertTrue(true); } catch (Exception $e) { $this->fail(); } }