mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-08-29 08:17:18 +08:00
b065977c61 SuiteCRM 7.12.5 Release fd07950be0 Fix #8366 - V8 API Filtering W/ OR Operator Chained Conditions f8504d0a42 Fix #9445 - More than 10 tabs in a views creates a loop ec3c758b49 Fix #9451 - Missing duplicate merge filter options in Studio 3739e28428 Fix #9468 - Adding Security Suite subpanels to new custom modules 0742615e61 Fix #9427 - Adding missing help popup help strings in Studio c79a3a6109 Add accessors for the Results, Query fields in SearchResultsController a507575097 Fix #4075 - No way to add email signature after adding email template 9b8f5b46b2 Fix #9480 - Slow to load imap mailbox with a million email records 8184b82060 Fixed #2857 - No dynamic refreshing in dashboard ece5919449 Fix #9508 - Legacy search fields are incorrect size 5699ad47ff Fix #9478 - Update GitHub Templates 37d54ca1ab SuiteCRM 7.12.4 Release 5a7f66f1fc Fix #9482 - Update list of modules to normalize 1807751e16 Fix #9482 - Only save update fields on utf encoding repair 08c5a32e07 Fix #9482 - Add partial bean save a25efff51f Fix #7842 - Do not reset email addresses list upon saving 4e5b509a30 Add ExtensionManager with static method to compile ext files 77b2940fd9 Fix #9061 - Custom Labels can't be overwritten in Studio 2f40449702 Fix #9496 - Cannot save dropdown values 32c6e4a04b Merge next into suite 8 2812bd315a [Legacy] Fix user wizard finish screen re-direction 9dc1a2f017 [Legacy] User Wizard Styling Fixes 0b91cb9a53 [Legacy] Event Delegates Selector Box Styling Fixes 32d7408e93 [Legacy] Add New Task Modal Styling Fixes e121b602da [Legacy] Workflow Styling Fixes 86ef0fae66 [Legacy] Projects Resource Panel Styling Fixes 56eb694629 [Legacy] map legacy to front-end user action called wizard 4c7ff07fcc [Legacy] Rescheduler Popup Styling Fixes 1b76260971 [Legacy] Project Gantt Chart Delete Button Styling Fixes 09959f1078 [Legacy] Configuration Settings Styling Fixes 711ded6a70 [Legacy] Notes modules styling fixes a0aa6affc8 [Legacy] Calls Module Styling Fixes a468cede8b [Legacy] AdminPanel Border Radius Styling Fixes bfc8a443b7 [Legacy] Bump version to 8.0.1 git-subtree-dir: public/legacy git-subtree-split: b065977c6116e68cea907dc099205d0b32ac99f4
249 lines
6.8 KiB
PHP
249 lines
6.8 KiB
PHP
<?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");
|
|
}
|
|
}
|
|
}
|