mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 14:58:43 +02:00
WIP symbolic links
This commit is contained in:
@@ -187,19 +187,6 @@ class MFCompiler
|
||||
return $this->aLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool if flag is present true, false otherwise
|
||||
*
|
||||
* @uses \file_exists()
|
||||
* @uses USE_SYMBOLIC_LINKS_FILE_PATH
|
||||
*
|
||||
* @since 3.0.0 N°4092
|
||||
*/
|
||||
public static function IsUseSymbolicLinksFlagPresent(): bool
|
||||
{
|
||||
return (file_exists(static::USE_SYMBOLIC_LINKS_FILE_PATH));
|
||||
}
|
||||
|
||||
/**
|
||||
* This is to check if the functionality can be used. As this is really only useful for developers,
|
||||
* this is strictly limited and not available on any iTop instance !
|
||||
@@ -214,17 +201,22 @@ class MFCompiler
|
||||
*
|
||||
* @since 3.0.0 N°4092
|
||||
*/
|
||||
public static function CanUseSymbolicLinksFlagBeUsed(): bool
|
||||
public static function CanUseSymbolicLinks(): bool
|
||||
{
|
||||
if (false === utils::IsDevelopmentEnvironment()) {
|
||||
return false;
|
||||
}
|
||||
return utils::IsDevelopmentEnvironment();
|
||||
}
|
||||
|
||||
if (false === function_exists('symlink')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
/**
|
||||
* @return bool if flag is present true, false otherwise
|
||||
*
|
||||
* @uses \file_exists()
|
||||
* @uses USE_SYMBOLIC_LINKS_FILE_PATH
|
||||
*
|
||||
* @since 3.0.0 N°4092
|
||||
*/
|
||||
public static function UseSymbolicLinks(): bool
|
||||
{
|
||||
return (file_exists(static::USE_SYMBOLIC_LINKS_FILE_PATH));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,7 +228,7 @@ class MFCompiler
|
||||
*/
|
||||
public static function SetUseSymbolicLinksFlag(bool $bUseSymbolicLinks): void
|
||||
{
|
||||
$bIsUseSymlinksFlagPresent = (static::IsUseSymbolicLinksFlagPresent());
|
||||
$bIsUseSymlinksFlagPresent = self::UseSymbolicLinks();
|
||||
|
||||
if ($bUseSymbolicLinks) {
|
||||
if ($bIsUseSymlinksFlagPresent) {
|
||||
@@ -283,7 +275,7 @@ class MFCompiler
|
||||
{
|
||||
if (is_null($bUseSymbolicLinks)) {
|
||||
$bUseSymbolicLinks = false;
|
||||
if (self::CanUseSymbolicLinksFlagBeUsed() && self::IsUseSymbolicLinksFlagPresent()) {
|
||||
if (self::CanUseSymbolicLinks() && self::UseSymbolicLinks()) {
|
||||
// We are only overriding the useSymLinks option if the consumer didn't specify anything
|
||||
// The toolkit always send this parameter for example, but not the Designer Connector
|
||||
$bUseSymbolicLinks = true;
|
||||
|
||||
@@ -98,6 +98,7 @@ abstract class AbstractWizStepInstall extends WizardStep
|
||||
'old_addon' => $this->oWizard->GetParameter('old_addon', false), // whether or not to use the "old" userrights profile addon
|
||||
'options' => json_decode($this->oWizard->GetParameter('misc_options', '[]'), true),
|
||||
'mysql_bindir' => $this->oWizard->GetParameter('mysql_bindir'),
|
||||
'use-symbolic-links' => $this->oWizard->GetParameter('use-symbolic-links', MFCompiler::UseSymbolicLinks()),
|
||||
];
|
||||
|
||||
if ($sBackupDestination != '') {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Application\WebPage\WebPage;
|
||||
|
||||
/**
|
||||
@@ -29,24 +30,13 @@ abstract class AbstractWizStepMiscParams extends WizardStep
|
||||
*/
|
||||
final protected function AddUseSymlinksFlagOption(WebPage $oPage): void
|
||||
{
|
||||
if (MFCompiler::CanUseSymbolicLinksFlagBeUsed()) {
|
||||
$sChecked = (MFCompiler::IsUseSymbolicLinksFlagPresent()) ? ' checked' : '';
|
||||
if (MFCompiler::CanUseSymbolicLinks()) {
|
||||
$sChecked = $this->oWizard->GetParameter('use-symbolic-links', MFCompiler::UseSymbolicLinks()) ? ' checked ' : '';
|
||||
|
||||
$oPage->add('<fieldset>');
|
||||
$oPage->add('<legend>Dev parameters</legend>');
|
||||
$oPage->p('<input id="use-symbolic-links" type="checkbox"'.$sChecked.'><label for="use-symbolic-links"> Create symbolic links instead of creating a copy in env-production (useful for debugging extensions)');
|
||||
$oPage->p('<input id="use-symbolic-links" name="use-symbolic-links" type="checkbox"'.$sChecked.'><label for="use-symbolic-links"> Create symbolic links instead of creating a copy in env-production (useful for debugging extensions)');
|
||||
$oPage->add('</fieldset>');
|
||||
$oPage->add_ready_script(
|
||||
<<<'JS'
|
||||
$("#use-symbolic-links").on("click", function() {
|
||||
var $this = $(this),
|
||||
bUseSymbolicLinks = $this.prop("checked");
|
||||
var sAuthent = $('#authent_token').val();
|
||||
var oAjaxParams = { operation: 'toggle_use_symbolic_links', bUseSymbolicLinks: bUseSymbolicLinks, authent: sAuthent};
|
||||
$.post(GetAbsoluteUrlAppRoot()+'setup/ajax.dataloader.php', oAjaxParams);
|
||||
});
|
||||
JS
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Application\WebPage\WebPage;
|
||||
|
||||
/**
|
||||
@@ -38,6 +39,7 @@ class WizStepUpgradeMiscParams extends AbstractWizStepMiscParams
|
||||
{
|
||||
$this->oWizard->SaveParameter('application_url', '');
|
||||
$this->oWizard->SaveParameter('graphviz_path', '');
|
||||
$this->oWizard->SaveParameter('use-symbolic-links', MFCompiler::UseSymbolicLinks());
|
||||
$this->oWizard->SaveParameter('force-uninstall', false);
|
||||
return new WizardState(WizStepModulesChoice::class, 'start_upgrade');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user