Skip to content

Commit

Permalink
Merge next into suite 8
Browse files Browse the repository at this point in the history
Merge commit '5fa70e2794a022003561fe1a701be9f4dcba9fc8' into release/8.0.4

# Conflicts:
#	public/legacy/suitecrm_version.php
  • Loading branch information
clemente-raposo committed Mar 1, 2022
2 parents fbf70a5 + 5fa70e2 commit 63b9694
Show file tree
Hide file tree
Showing 47 changed files with 824 additions and 137 deletions.
4 changes: 3 additions & 1 deletion public/legacy/.github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!--- Provide a general summary of the issue in the **Title** above -->
<!--- Before you open an issue, please check if a similar issue already exists or has been closed before. --->
<!--- If you have discovered a security risk please report it by emailing security@suitecrm.com. This will be delivered to the product team who handle security issues. Please don't disclose security bugs publicly until they have been handled by the security team. --->

<!--- Please be aware that as of the 31st January 2022 we no longer support 7.10.x.
New issues referring to 7.10.x will only be valid if applicable to 7.12.x and above.
If your issue is still applicable in 7.12.x, please create the issue following the template below -->
#### Issue
<!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug -->
<!--- Ensure that all code ``` is surrounded ``` by triple back quotes. This can also be done over multiple lines -->
Expand Down
4 changes: 4 additions & 0 deletions public/legacy/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<!--- Provide a general summary of your changes in the Title above -->
<!--- Please be aware that as of the 31st January 2022 we no longer support 7.10.x.
New PRs to hotfix-7.10.x will be invalid. If your fix is still applicable to 7.12.x,
please create the pull request to the hotfix branch accordingly. -->


## Description
<!--- Describe your changes in detail -->
Expand Down
26 changes: 23 additions & 3 deletions public/legacy/Api/V8/JsonApi/Repository/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ public function parseWhere(\SugarBean $bean, array $params)
unset($params['operator']);
}

$params = $this->addDeletedParameter($params);
$deleted = false;
if (isset($params['deleted'])) {
if (isset($params['deleted']['eq'])) {
$deleted = ($params['deleted']['eq'] == 1);
}

unset($params['deleted']);
}

$where = [];
foreach ($params as $field => $expr) {
Expand Down Expand Up @@ -75,12 +82,25 @@ public function parseWhere(\SugarBean $bean, array $params)
}
}

return implode(sprintf(' %s ', $operator), $where);
if (empty($where)) {
return sprintf(
"%s.deleted = '%d'",
$bean->getTableName(),
$deleted
);
}

return sprintf(
"(%s) AND %s.deleted = '%d'",
implode(sprintf(' %s ', $operator), $where),
$bean->getTableName(),
$deleted
);
}

/**
* Only return deleted records if they were explicitly requested
*
* @deprecated
* @param array $params
* @return array
*/
Expand Down
249 changes: 249 additions & 0 deletions public/legacy/ModuleInstall/ExtensionManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
<?php

namespace SuiteCRM\ModuleInstall;

use \LoggerManager;

/**
* Class ExtensionManager
*/
class ExtensionManager
{
/**
* @var array
*/
protected static $moduleList = [];

/**
* @var
*/
protected static $logger;

/**
* Checks if authenticated and dies if not.
*
* @return void
*/
protected static function handleAuth()
{
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
}

/**
* Sets the static module and extension lists.
*
* @return void
*/
protected static function initialise()
{
static::$moduleList = get_module_dir_list();
static::$logger = LoggerManager::getLogger();
}

/**
* Compiles source files for given extension to targeted file applying any given filters.
*
* @param string $extension Name of Extension i.e. 'Language'
* @param string $targetFileName Name of target file
* @param string $filter To filter file names such as language prefixes
* @param bool $applicationOnly Whether or not to only compile application extensions
* @return void
*/
public static function compileExtensionFiles(
$extension,
$targetFileName,
$filter = '',
$applicationOnly = false
) {
static::handleAuth();
static::initialise();

if ($extension === 'Language' && strpos($targetFileName, $filter) !== 0) {
$targetFileName = $filter . $targetFileName;
}

if (!$applicationOnly) {
static::compileModuleExtensions($extension, $targetFileName, $filter);
}

static::compileApplicationExtensions($extension, $targetFileName, $filter);
}

/**
* @param $extension
* @param $targetFileName
* @param string $filter
* @return void
*/
protected static function compileApplicationExtensions(
$extension,
$targetFileName,
$filter = ''
) {
static::$logger->{'debug'}("Merging application files for $targetFileName in $extension");

$extensionContents = '<?php' . PHP_EOL . '// WARNING: The contents of this file are auto-generated' . PHP_EOL;
$extPath = "application/Ext/$extension";
$moduleInstall = "custom/Extension/$extPath";
$shouldSave = false;

if (is_dir($moduleInstall)) {
$dir = dir($moduleInstall);

while ($entry = $dir->read()) {
if (static::shouldSkipFile($entry, $moduleInstall, $filter)) {
continue;
}
$shouldSave = true;
$file = file_get_contents("$moduleInstall/$entry");
$extensionContents .= PHP_EOL . static::removePhpTagsFromString($file);
}
}

if ($shouldSave) {
static::saveFile($extPath, $targetFileName, $extensionContents);
return;
}

static::unlinkFile($extPath, $targetFileName);
}

/**
* @param $extension
* @param $targetFileName
* @param string $filter
* @return void
*/
protected static function compileModuleExtensions(
$extension,
$targetFileName,
$filter = ''
) {
static::$logger->{'debug'}(
self::class . "::compileExtensionFiles() : Merging module files in " .
"custom/Extension/modules/<module>/$extension to custom/modules/<module>/$extension/$targetFileName"
);

foreach (static::$moduleList as $module) {
$extensionContents = '<?php'
. PHP_EOL
. '// WARNING: The contents of this file are auto-generated'
. PHP_EOL;

$extPath = "modules/$module/Ext/$extension";
$moduleInstall = "custom/Extension/$extPath";
$shouldSave = false;

if (is_dir($moduleInstall)) {
$dir = dir($moduleInstall);
$shouldSave = true;
$override = [];

while ($entry = $dir->read()) {
if (static::shouldSkipFile($entry, $moduleInstall, $filter)) {
continue;
}

if (strpos($entry, '_override') === 0) {
$override[] = $entry;
continue;
}

$file = file_get_contents("$moduleInstall/$entry");
static::$logger->{'debug'}(
self::class . "->compileExtensionFiles(): found {$moduleInstall}{$entry}"
);

$extensionContents .= PHP_EOL . static::removePhpTagsFromString($file);
}

foreach ($override as $entry) {
$file = file_get_contents("$moduleInstall/$entry");
$extensionContents .= PHP_EOL . static::removePhpTagsFromString($file);
}
}

if ($shouldSave) {
static::saveFile($extPath, $targetFileName, $extensionContents);
continue;
}

static::unlinkFile($extPath, $targetFileName);
}
}

/**
* @param string $string
* @return string
*/
protected static function removePhpTagsFromString($string)
{
return str_replace(
['<?php', '?>', '<?PHP', '<?'],
'',
$string
);
}

/**
* @param $entry
* @param $moduleInstall
* @param $filter
* @return bool
*/
protected static function shouldSkipFile(
$entry,
$moduleInstall,
$filter
) {
if ($entry === '.' || $entry === '..' || strtolower(substr($entry, -4)) !== '.php') {
return true;
}

if (!is_file("$moduleInstall/$entry")) {
return true;
}

if (!empty($filter) && substr_count($entry, $filter) <= 0) {
return true;
}

return false;
}

/**
* @param string $extPath
* @param string $targetFileName
* @param string $extensionContents
* @return void
*/
protected static function saveFile(
$extPath,
$targetFileName,
$extensionContents
) {
if (!file_exists("custom/$extPath")) {
mkdir_recursive("custom/$extPath", true);
}

$extensionContents .= PHP_EOL;

$out = sugar_fopen("custom/$extPath/$targetFileName", 'wb');
fwrite($out, $extensionContents);
fclose($out);
}

/**
* @param $extPath
* @param $targetFileName
* @return void
*/
protected static function unlinkFile($extPath, $targetFileName)
{
if (file_exists("custom/$extPath/$targetFileName")) {
unlink("custom/$extPath/$targetFileName");
}
}
}
2 changes: 1 addition & 1 deletion public/legacy/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.3
# SuiteCRM 7.12.5

[![LICENSE](https://img.shields.io/github/license/suitecrm/suitecrm.svg)](https://github.com/salesagility/suitecrm/blob/hotfix/LICENSE.txt)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/salesagility/SuiteCRM-Core/issues)
Expand Down
Loading

0 comments on commit 63b9694

Please sign in to comment.