Skip to content

Commit

Permalink
SuiteCRM 7.12.7 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
jack7anderson7 committed Aug 16, 2022
1 parent 285c554 commit 7b6ac1b
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img width="180px" height="41px" src="https://suitecrm.com/wp-content/uploads/2017/12/logo.png" align="right" />
</a>

# SuiteCRM 7.12.6
# SuiteCRM 7.12.7

[![Build Status](https://travis-ci.org/salesagility/SuiteCRM.svg?branch=hotfix)](https://travis-ci.org/salesagility/SuiteCRM)
[![codecov](https://codecov.io/gh/salesagility/SuiteCRM/branch/hotfix/graph/badge.svg)](https://codecov.io/gh/salesagility/SuiteCRM/branch/hotfix)
Expand Down
67 changes: 36 additions & 31 deletions files.md5

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions include/OutboundEmail/OutboundEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ protected function getValues(&$keys)
*/
public function save()
{
$this->checkSavePermissions();

require_once('include/utils/encryption_utils.php');
if (empty($this->id)) {
$this->id = create_guid();
Expand Down Expand Up @@ -657,4 +659,44 @@ public function getMailerByName($user, $name)

return $this->retrieve($a['id']);
}

/**
* @return void
*/
protected function checkSavePermissions(): void
{
global $log;


$original = null;

if (!empty($this->id)) {
$original = new OutboundEmail();
$original->retrieve($this->id);
}

if (empty($original)) {
$original = $this;
}

$type = $this->type ?? '';

$authenticatedUser = get_authenticated_user();
if ($authenticatedUser === null) {
$log->security("OutboundEmail::checkSavePermissions - not logged in - skipping check");
return;
}

if ($type === 'system' && !is_admin($authenticatedUser)) {
$log->security("OutboundEmail::checkSavePermissions - trying to save a system outbound email with non-admin user");
throw new RuntimeException('Access denied');
}

$oeUserId = $original->user_id ?? '';

if (!empty($oeUserId) && $oeUserId !== $authenticatedUser->id && !is_admin($authenticatedUser)) {
$log->security("OutboundEmail::checkSavePermissions - trying to save a outbound email for another user");
throw new RuntimeException('Access denied');
}
}
}
21 changes: 21 additions & 0 deletions include/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,27 @@ function get_user_name($id)
return (empty($a)) ? '' : $a['user_name'];
}

/**
* Get currently authenticated user
* @return User
*/
function get_authenticated_user(): ?User {
$authenticatedUserId = $_SESSION['authenticated_user_id'] ?? '';

if (empty($authenticatedUserId)){
return null;
}

/** @var User $authenticatedUser */
$authenticatedUser = BeanFactory::getBean('Users', $authenticatedUserId);

if (empty($authenticatedUser)) {
return null;
}

return $authenticatedUser;
}

//TODO Update to use global cache
/**
* get_user_array.
Expand Down
3 changes: 2 additions & 1 deletion modules/Emails/EmailUIAjax.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ function handleSubs($subs, $email, $json, $user = null)
$ie->email = $email;
$json = getJSONobj();

global $current_user;

$showFolders = sugar_unserialize(base64_decode($current_user->getPreference('showFolders', 'Emails')));

if (isset($_REQUEST['emailUIAction'])) {
if (isset($_REQUEST['user']) && $_REQUEST['user']) {
if (isset($_REQUEST['user']) && $_REQUEST['user'] && is_admin($current_user)) {
$cid = $current_user->id;
$current_user = BeanFactory::getBean('Users', $_REQUEST['user']);
} else {
Expand Down
25 changes: 25 additions & 0 deletions modules/Employees/Employee.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,31 @@ public function save($check_notify = false)
}
}

if (!$this->hasSaveAccess()) {
throw new RuntimeException('Not authorized');
}

return parent::save($check_notify);
}

/**
* Check if current user can save the current employee record
* @return bool
*/
protected function hasSaveAccess(): bool
{
global $current_user;

if (empty($this->id)) {
return true;
}

if (empty($current_user->id)) {
return false;
}

$sameUser = $current_user->id === $this->id;

return $sameUser || is_admin($current_user);
}
}
6 changes: 6 additions & 0 deletions modules/Users/GeneratePassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@
// if i need to generate a password (not a link)
$password = $isLink ? '' : User::generatePassword();

$isPasswordGenerationActive = $res['SystemGeneratedPasswordON'] ?? false;
if(!$isLink && empty($isPasswordGenerationActive)) {
echo 'Access Denied';
return;
}

// Create URL
if ($isLink) {
global $timedate;
Expand Down
4 changes: 2 additions & 2 deletions suitecrm_version.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
die('Not A Valid Entry Point');
}

$suitecrm_version = '7.12.6';
$suitecrm_timestamp = '2022-05-19 12:00:00';
$suitecrm_version = '7.12.7';
$suitecrm_timestamp = '2022-08-10 12:00:00';

0 comments on commit 7b6ac1b

Please sign in to comment.