Since it is important for me to be able to pre-package the same custom grid, at the moment I found this solution, in the hope that NetMake will allow us to activate it within the ScriptCase environment.
The code I share is simpler than words.
In practice, I add a condition to display the ‘public’ option in the drop-down menu that allows you to save the customization, at the line 890 line approximately :
<?php if (strpos($_SESSION['usr_groups'], '900') !== false) { ?>)
...
<?php } ?>
and the condition that does not allow the deletion of the ‘public’ files, at line 949 approximately:
<?php if ($level != $this->Nm_lang['lang_srch_public'] || strpos($_SESSION['usr_groups'], '900') !== false) { ?>
...
<?php } ?>
In my case I allow the whole management (save and delete in the ‘public’ section) only for users of the ‘900’ group (the global variable ‘usr_groups’ contains the list of groups to which the user belongs, eg’ 700,500 'In my case to the 900 group, and only to the 900, belong the administrators of the entire app that is allowed to manage EVERYTHING! Therefore no company-customer will have users who belong to the group 900!).
To do this I run AFTER THE DEPLOY a small script that ‘searches’ in all the folders where the word ‘grid’ appears (my apps are also identified by the type: form, control, grid, etc. eg xxx_grid_yyyy) the file ‘xxxx_save_grid … php’ and make the substitutions.
The ‘c:_deploy_attuale’ folder is my folder where I deploy the deploy!
This is the simple code of a ‘blank’ type app:
foreach (glob("c:\_deploy_attuale\*grid*") as $dirname) {
$dir1 = $dirname."\\*save_grid*.php";
foreach (glob($dir1) as $filename) {
$txt = file_get_contents($filename);
$subcloseif = "
<?php } ?>"."
";
//
$subopenif1 = "
<?php if (strpos(\$_SESSION['usr_groups'], '900') !== false) { ?>
";
$searched1 = "<option value=\"publico\"><?php echo \"\" . \$this->Nm_lang['lang_srch_public'] . \"\" ?></option>";
$newrow = $subopenif1.$searched1.$subcloseif;
$txt = str_replace($searched1, $newrow, $txt);
//
$subopenif2 = "
<?php if (\$level != \$this->Nm_lang['lang_srch_public'] || strpos(\$_SESSION['usr_groups'], '900') !== false) { ?>
";
$searched2 = "<a href=\"#\" onclick=\"nm_del_grid('<?php echo NM_encode_input(\$save_path); ?>')\" class=\"scGridPageLink\"><?php echo \$this->Nm_lang['lang_btns_dele']; ?></a>";
$newrow = $subopenif2.$searched2.$subcloseif;
$txt = str_replace($searched2, $newrow, $txt);
$txt = str_replace("<option value=\"\"></option>", "", $txt);
file_put_contents($filename, $txt);
}
}
I remain in the hope that NetMake will allow us to be able to activate it within the ScriptCase environment, avoiding this operation too!
Ciao
Enrico