Merge pull request #25805 from lamrani002/checkBeforereWrite

NEW functionality for Checkin comments begin and end before each actions
This commit is contained in:
Laurent Destailleur
2023-09-05 23:39:58 +02:00
committed by GitHub
4 changed files with 198 additions and 111 deletions

View File

@@ -448,7 +448,34 @@ function dolGetListOfObjectClasses($destdir)
return -1;
}
/**
* function for check if comment begin an end exist in modMyModule class
* @param string $file filename or path
* @param int $number 0 = For Menus,1 = For permissions, 2 = For Dictionaries
* @return int 1 if OK , -1 if KO
*/
function checkExistComment($file, $number)
{
if (!file_exists($file)) {
return -1;
}
$content = file_get_contents($file);
if ($number === 0) {
if (strpos($content, '/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */') !== false && strpos($content, '/* END MODULEBUILDER LEFTMENU MYOBJECT */') !== false) {
return 1;
}
} elseif ($number === 1) {
if (strpos($content, '/* BEGIN MODULEBUILDER PERMISSIONS */') !== false && strpos($content, '/* END MODULEBUILDER PERMISSIONS */') !== false) {
return 1;
}
} elseif ($number == 2) {
if (strpos($content, '/* BEGIN MODULEBUILDER DICTIONARIES */') !== false && strpos($content, '/* END MODULEBUILDER DICTIONARIES */') !== false) {
return 1;
}
}
return -1;
}
/**
* Delete all permissions
*