mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Try to move tmp dir
This commit is contained in:
parent
6c57afab48
commit
f711144428
4
.github/workflows/phpstan.yml
vendored
4
.github/workflows/phpstan.yml
vendored
|
|
@ -44,7 +44,7 @@ jobs:
|
|||
- name: Restore phpstan cache
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: ./tmp
|
||||
path: ./github/tmp
|
||||
key: "phpstan-cache-PR-${{ matrix.php-version }}-${{ github.run_id }}"
|
||||
restore-keys: |
|
||||
phpstan-cache-PR-${{ matrix.php-version }}-
|
||||
|
|
@ -57,5 +57,5 @@ jobs:
|
|||
uses: actions/cache/save@v3
|
||||
if: always()
|
||||
with:
|
||||
path: ./tmp
|
||||
path: ./github/tmp
|
||||
key: "phpstan-cache-PR-${{ matrix.php-version }}-${{ github.run_id }}"
|
||||
|
|
|
|||
|
|
@ -15,5 +15,6 @@ if (!defined("NOSESSION")) {
|
|||
if (!defined("NOHTTPSREDIRECT")) {
|
||||
define("NOHTTPSREDIRECT", '1');
|
||||
}
|
||||
|
||||
global $conf, $langs, $user, $db;
|
||||
include_once __DIR__ . '/../../htdocs/main.inc.php';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
// Defined some constants and load Dolibarr env to reduce PHPStan bootstrap that fails to load a lot of things.
|
||||
define('DOL_DOCUMENT_ROOT', __DIR__ . '/../../htdocs');
|
||||
define('DOL_DATA_ROOT', __DIR__ . '/../../documents');
|
||||
|
|
@ -9,5 +10,6 @@ define('MAIN_DB_PREFIX', 'llx_');
|
|||
// Load the main.inc.php file to have functions env defined
|
||||
define("NOLOGIN", '1');
|
||||
define("NOHTTPSREDIRECT", '1');
|
||||
|
||||
global $conf, $db, $langs, $user;
|
||||
// include_once DOL_DOCUMENT_ROOT . '/../../htdocs/main.inc.php';
|
||||
|
|
|
|||
|
|
@ -295,4 +295,133 @@ class MailingTargets // This can't be abstract as it is used for some method
|
|||
|
||||
$this->update_nb($mailing_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return list of widget. Function used by admin page htdoc/admin/widget.
|
||||
* List is sorted by widget filename so by priority to run.
|
||||
*
|
||||
* @param array $forcedir null=All default directories. This parameter is used by modulebuilder module only.
|
||||
* @return array Array list of widget
|
||||
*/
|
||||
public static function getEmailingSelectorsList($forcedir = null)
|
||||
{
|
||||
global $langs, $db;
|
||||
|
||||
$files = array();
|
||||
$fullpath = array();
|
||||
$relpath = array();
|
||||
$iscoreorexternal = array();
|
||||
$modules = array();
|
||||
$orders = array();
|
||||
$i = 0;
|
||||
|
||||
$dirwidget = array('/core/emailings/'); // $conf->modules_parts['emailings'] is not required
|
||||
if (is_array($forcedir)) {
|
||||
$dirwidget = $forcedir;
|
||||
}
|
||||
|
||||
foreach ($dirwidget as $reldir) {
|
||||
$dir = dol_buildpath($reldir, 0);
|
||||
$newdir = dol_osencode($dir);
|
||||
|
||||
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call)
|
||||
if (!is_dir($newdir)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$handle = opendir($newdir);
|
||||
if (is_resource($handle)) {
|
||||
while (($file = readdir($handle)) !== false) {
|
||||
$reg = array();
|
||||
if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/', $file, $reg)) {
|
||||
if (preg_match('/\.back$/', $file) || preg_match('/^(.+)\.disabled\.php/', $file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$part1 = $reg[1];
|
||||
|
||||
$modName = ucfirst($reg[1]);
|
||||
//print "file=$file"; print "modName=$modName"; exit;
|
||||
if (in_array($modName, $modules)) {
|
||||
$langs->load("errors");
|
||||
print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateWidget", $modName, "").'</div>';
|
||||
} else {
|
||||
try {
|
||||
include_once $newdir.'/'.$file;
|
||||
} catch (Exception $e) {
|
||||
print $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
$files[$i] = $file;
|
||||
$fullpath[$i] = $dir.'/'.$file;
|
||||
$relpath[$i] = preg_replace('/^\//', '', $reldir).'/'.$file;
|
||||
$iscoreorexternal[$i] = ($reldir == '/core/boxes/' ? 'internal' : 'external');
|
||||
$modules[$i] = $modName;
|
||||
$orders[$i] = $part1; // Set sort criteria value
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
//echo "<pre>";print_r($modules);echo "</pre>";
|
||||
|
||||
asort($orders);
|
||||
|
||||
$widget = array();
|
||||
$j = 0;
|
||||
|
||||
// Loop on each widget
|
||||
foreach ($orders as $key => $value) {
|
||||
$modName = $modules[$key];
|
||||
if (empty($modName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!class_exists($modName)) {
|
||||
print 'Error: A widget file was found but its class "'.$modName.'" was not found.'."<br>\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$objMod = new $modName($db);
|
||||
if (is_object($objMod)) {
|
||||
// Define disabledbyname and disabledbymodule
|
||||
$disabledbyname = 0;
|
||||
$disabledbymodule = 0; // TODO Set to 2 if module is not enabled
|
||||
$module = '';
|
||||
|
||||
// Check if widget file is disabled by name
|
||||
if (preg_match('/NORUN$/i', $files[$key])) {
|
||||
$disabledbyname = 1;
|
||||
}
|
||||
|
||||
// We set info of modules
|
||||
$widget[$j]['picto'] = (empty($objMod->picto) ? (empty($objMod->boximg) ? img_object('', 'generic') : $objMod->boximg) : img_object('', $objMod->picto));
|
||||
$widget[$j]['file'] = $files[$key];
|
||||
$widget[$j]['fullpath'] = $fullpath[$key];
|
||||
$widget[$j]['relpath'] = $relpath[$key];
|
||||
$widget[$j]['iscoreorexternal'] = $iscoreorexternal[$key];
|
||||
$widget[$j]['version'] = empty($objMod->version) ? '' : $objMod->version;
|
||||
$widget[$j]['status'] = img_picto($langs->trans("Active"), 'tick');
|
||||
if ($disabledbyname > 0 || $disabledbymodule > 1) {
|
||||
$widget[$j]['status'] = '';
|
||||
}
|
||||
|
||||
$text = '<b>'.$langs->trans("Description").':</b><br>';
|
||||
$text .= $objMod->boxlabel.'<br>';
|
||||
$text .= '<br><b>'.$langs->trans("Status").':</b><br>';
|
||||
if ($disabledbymodule == 2) {
|
||||
$text .= $langs->trans("WidgetDisabledAsModuleDisabled", $module).'<br>';
|
||||
}
|
||||
|
||||
$widget[$j]['info'] = $text;
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
|
||||
return $widget;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,3 +183,7 @@ DictionaryDeleted=Dictionary <b>%s</b> removed successfully
|
|||
PropertyModuleUpdated=Property <b>%s</b> has been update successfully
|
||||
InfoForApiFile=* When you generate file for the first time then all methods will be created <strong>for each object.</strong><br>* When you click in <strong>remove</strong> you just remove all methods for the <strong>selected object</strong>.
|
||||
SetupFile=Page for module setup
|
||||
EmailingSelectors=Emailings selectors
|
||||
EmailingSelectorDesc=You can generate and edit here the class files to provide new email target selectors for the mass emailing module
|
||||
EmailingSelectorFile=Emails selector file
|
||||
NoEmailingSelector=No emails selector file
|
||||
|
|
@ -3299,6 +3299,7 @@ if ($module == 'initmodule') {
|
|||
$countMenus = count($moduleobj->menu);
|
||||
$countTriggers = countItemsInDirectory(dol_buildpath($modulelowercase, 0)."/core/triggers");
|
||||
$countWidgets = countItemsInDirectory(dol_buildpath($modulelowercase, 0)."/core/boxes");
|
||||
$countEmailingSelectors = countItemsInDirectory(dol_buildpath($modulelowercase, 0)."/core/emailings");
|
||||
$countCss = countItemsInDirectory(dol_buildpath($modulelowercase, 0)."/css");
|
||||
$countJs = countItemsInDirectory(dol_buildpath($modulelowercase, 0)."/js");
|
||||
$countCLI = countItemsInDirectory(dol_buildpath($modulelowercase, 0)."/scripts");
|
||||
|
|
@ -3357,6 +3358,11 @@ if ($module == 'initmodule') {
|
|||
$head2[$h][2] = 'widgets';
|
||||
$h++;
|
||||
|
||||
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=emailings&module='.$module.($forceddirread ? '@'.$dirread : '');
|
||||
$head2[$h][1] = ($countEmailingSelectors <= 0 ? $langs->trans("EmailingSelectors") : $langs->trans("EmailingSelectors").'<span class="marginleftonlyshort badge">'.$countEmailingSelectors."</span>");
|
||||
$head2[$h][2] = 'emailings';
|
||||
$h++;
|
||||
|
||||
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=exportimport&module='.$module.($forceddirread ? '@'.$dirread : '');
|
||||
$head2[$h][1] = $langs->trans("Export").'-'.$langs->trans("Import");
|
||||
$head2[$h][2] = 'exportimport';
|
||||
|
|
@ -5937,6 +5943,58 @@ if ($module == 'initmodule') {
|
|||
}
|
||||
}
|
||||
|
||||
if ($tab == 'emailings') {
|
||||
print '<!-- tab=emailings -->'."\n";
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
|
||||
|
||||
$emailingselectors = MailingTargets::getEmailingSelectorsList(array('/'.strtolower($module).'/core/mailings'));
|
||||
|
||||
if ($action != 'editfile' || empty($file)) {
|
||||
print '<span class="opacitymedium">'.$langs->trans("EmailingSelectorDesc").'</span><br>';
|
||||
print '<br>';
|
||||
|
||||
print '<table>';
|
||||
if (!empty($emailingselectors)) {
|
||||
foreach ($emailingselectors as $emailingselector) {
|
||||
$pathtofile = $emailingselector['relpath'];
|
||||
|
||||
print '<tr><td><span class="fa fa-file-o"></span> '.$langs->trans("EmailingSelectorFile").' : <strong class="wordbreak">'.$pathtofile.'</strong>';
|
||||
print '</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?tab='.urlencode($tab).'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&token='.newToken().'&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '</td><td><a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?tab='.urlencode($tab).'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=confirm_removefile&token='.newToken().'&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Delete"), 'delete').'</a></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
} else {
|
||||
print '<tr><td><span class="fa fa-file-o"></span> '.$langs->trans("EmailingSelectorFile").' : <span class="opacitymedium">'.$langs->trans("NoEmailingSelector").'</span>';
|
||||
print '</td><td><a href="'.$_SERVER['PHP_SELF'].'?tab='.urlencode($tab).'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=initemailing&token='.newToken().'&format=php">'.img_picto('Generate', 'generate', 'class="paddingleft"').'</a>';
|
||||
print '</td></tr>';
|
||||
}
|
||||
print '</table>';
|
||||
} else {
|
||||
$fullpathoffile = dol_buildpath($file, 0);
|
||||
|
||||
$content = file_get_contents($fullpathoffile);
|
||||
|
||||
// New module
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="savefile">';
|
||||
print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">';
|
||||
print '<input type="hidden" name="tab" value="'.$tab.'">';
|
||||
print '<input type="hidden" name="module" value="'.$module.'">';
|
||||
|
||||
$doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
|
||||
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ? GETPOST('format', 'aZ09') : 'html'));
|
||||
print '<br>';
|
||||
print '<center>';
|
||||
print '<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
|
||||
print '</center>';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($tab == 'exportimport') {
|
||||
print '<!-- tab=exportimport -->'."\n";
|
||||
$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
parameters:
|
||||
bootstrapFiles:
|
||||
- build/phpstan/bootstrap_action.php
|
||||
tmpDir: ./build/phpstan/tmp
|
||||
tmpDir: ./github/tmp
|
||||
parallel:
|
||||
jobSize: 20
|
||||
processTimeout: 600.0
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user