Laurent Destailleur 6 年之前
父节点
当前提交
0ca5da055f

+ 3 - 15
htdocs/core/modules/modDataPolicy.class.php

@@ -173,22 +173,10 @@ class modDataPolicy extends DolibarrModules {
         // 'stock'            to add a tab in stock view
         // 'thirdparty'       to add a tab in third party view
         // 'user'             to add a tab in user view
+
+
         // Dictionaries
         $this->dictionaries = array();
-        /* Example:
-          $this->dictionaries=array(
-          'langs'=>'mylangfile@datapolicy',
-          'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"),		// List of tables we want to see into dictonnary editor
-          'tablib'=>array("Table1","Table2","Table3"),													// Label of tables
-          'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'),	// Request to select fields
-          'tabsqlsort'=>array("label ASC","label ASC","label ASC"),																					// Sort order
-          'tabfield'=>array("code,label","code,label","code,label"),																					// List of fields (result of select to show dictionary)
-          'tabfieldvalue'=>array("code,label","code,label","code,label"),																				// List of fields (list of fields to edit a record)
-          'tabfieldinsert'=>array("code,label","code,label","code,label"),																			// List of fields (list of fields for insert)
-          'tabrowid'=>array("rowid","rowid","rowid"),																									// Name of columns with primary key (try to always name it 'rowid')
-          'tabcond'=>array($conf->datapolicy->enabled,$conf->datapolicy->enabled,$conf->datapolicy->enabled)												// Condition to show each dictionary
-          );
-         */
 
 
         // Boxes/Widgets
@@ -199,7 +187,7 @@ class modDataPolicy extends DolibarrModules {
         // Cronjobs (List of cron jobs entries to add when module is enabled)
         // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
         $this->cronjobs = array(
-            0 => array('label' => 'DATAPOLICY Cron', 'jobtype' => 'method', 'class' => '/datapolicy/class/datapolicyCron.class.php', 'objectname' => 'RgpdCron', 'method' => 'exec', 'parameters' => '', 'comment' => 'Comment', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 1, 'test' => true),
+            0 => array('label' => 'DATAPOLICY Cron', 'jobtype' => 'method', 'class' => '/datapolicy/class/datapolicyCron.class.php', 'objectname' => 'DataPolicyCron', 'method' => 'exec', 'parameters' => '', 'comment' => 'Clean data', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 1, 'test' => true),
             //1 => array('label' => 'DATAPOLICY Mailing', 'jobtype' => 'method', 'class' => '/datapolicy/class/datapolicyCron.class.php', 'objectname' => 'RgpdCron', 'method' => 'sendMailing', 'parameters' => '', 'comment' => 'Comment', 'frequency' => 1, 'unitfrequency' => 86400, 'status' => 0, 'test' => true)
         );
         // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true),

+ 0 - 24
htdocs/datapolicy/ChangeLog.md

@@ -1,24 +0,0 @@
-**2.2**
-* Fix link to accept or refuse
-
-**2.1**
-* Change IT translations
-
-**2.0**
-* Add date of agreement
-* Add possibility to send e-mail
-* Save the agreement by e-mail
-
-**1.2**
-* Bug fixed
-
-**1.1**
-* Add some translations
-* Add some type of company
-* Bug fixed
-
-
-**1.0**
-* The end of the beginning
-
-

+ 1 - 1
htdocs/datapolicy/class/datapolicy.class.php

@@ -28,7 +28,7 @@ include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
 /**
  * Class DataPolicy
  */
-Class DataPolicy extends Contact
+Class DataPolicy
 {
 	/**
 	 * getAllContactNotInformed

+ 3 - 0
htdocs/emailcollector/modulebuilder.txt

@@ -0,0 +1,3 @@
+# DO NOT DELETE THIS FILE MANUALLY
+# File to flag module built using official module template.
+# When this file is present into a module directory, you can edit it with the module builder tool. Use ModuleBuilder if you want to delete module. 

+ 36 - 15
htdocs/modulebuilder/index.php

@@ -71,6 +71,11 @@ if (! empty($tmpdir[1]))
 	$dirread=$tmpdir[1];
 	$forceddirread=1;
 }
+if (GETPOST('dirins','alpha'))
+{
+	$dirread = $dirins = GETPOST('dirins','alpha');
+	$forceddirread=1;
+}
 
 $FILEFLAG='modulebuilder.txt';
 
@@ -911,17 +916,31 @@ $dirsincustom=dol_dir_list($dirread, 'directories');
 if (is_array($dirsincustom) && count($dirsincustom) > 0) {
 	foreach ($dirsincustom as $dircustomcursor) {
 		$fullname = $dircustomcursor['fullname'];
-		if (dol_is_file($fullname . '/' . $FILEFLAG)) {
+		if (dol_is_file($fullname . '/' . $FILEFLAG))
+		{
 			// Get real name of module (MyModule instead of mymodule)
-			$descriptorfiles = dol_dir_list($fullname . '/core/modules/', 'files', 0, 'mod.*\.class\.php$');
+			$dirtoscanrel = basename($fullname).'/core/modules/';
+
+			$descriptorfiles = dol_dir_list(dirname($fullname).'/'.$dirtoscanrel, 'files', 0, 'mod.*\.class\.php$');
+			if (empty($descriptorfiles))	// If descriptor not found into module dir, we look into main module dir.
+			{
+				$dirtoscanrel = 'core/modules/';
+				$descriptorfiles = dol_dir_list($fullname.'/../'.$dirtoscanrel, 'files', 0, 'mod'.strtoupper(basename($fullname)).'\.class\.php$');
+			}
 			$modulenamewithcase = '';
+			$moduledescriptorrelpath = '';
+			$moduledescriptorfullpath = '';
+
 			foreach ($descriptorfiles as $descriptorcursor) {
 				$modulenamewithcase = preg_replace('/^mod/', '', $descriptorcursor['name']);
 				$modulenamewithcase = preg_replace('/\.class\.php$/', '', $modulenamewithcase);
+				$moduledescriptorrelpath = $dirtoscanrel.$descriptorcursor['name'];
+				$moduledescriptorfullpath = $descriptorcursor['fullname'];
+				//var_dump($descriptorcursor);
 			}
 			if ($modulenamewithcase)
 			{
-				$listofmodules[$dircustomcursor['name']] = $modulenamewithcase;
+				$listofmodules[$dircustomcursor['name']] = array('modulenamewithcase'=>$modulenamewithcase, 'moduledescriptorrelpath'=> $moduledescriptorrelpath, 'moduledescriptorfullpath'=>$moduledescriptorfullpath);
 			}
 			//var_dump($listofmodules);
 		}
@@ -929,7 +948,7 @@ if (is_array($dirsincustom) && count($dirsincustom) > 0) {
 }
 if ($forceddirread && empty($listofmodules))
 {
-	$listofmodules[strtolower($module)] = $module;
+	$listofmodules[strtolower($module)] = array('modulenamewithcase'=>$module, 'moduledescriptorrelpath'=> 'notyetimplemented', 'moduledescriptorfullpath'=> 'notyetimplemented');
 }
 
 // Show description of content
@@ -983,7 +1002,8 @@ if (! empty($module) && $module != 'initmodule' && $module != 'deletemodule')
 	$modulelowercase=strtolower($module);
 
 	// Load module
-	dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php');
+	$fullpathdirtodescriptor = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
+	dol_include_once($fullpathdirtodescriptor);
 	$class='mod'.$module;
 
 	if (class_exists($class))
@@ -1017,11 +1037,11 @@ $head[$h][1] = $langs->trans("NewModule");
 $head[$h][2] = 'initmodule';
 $h++;
 
-foreach($listofmodules as $tmpmodule => $tmpmodulewithcase)
+foreach($listofmodules as $tmpmodule => $tmpmodulearray)
 {
-	$head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulewithcase.($forceddirread?'@'.$dirread:'');
-	$head[$h][1] = $tmpmodulewithcase;
-	$head[$h][2] = $tmpmodulewithcase;
+	$head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodulearray['modulenamewithcase'].($forceddirread?'@'.$dirread:'');
+	$head[$h][1] = $tmpmodulearray['modulenamewithcase'];
+	$head[$h][2] = $tmpmodulearray['modulenamewithcase'];
 	$h++;
 }
 
@@ -1167,7 +1187,7 @@ elseif (! empty($module))
 
 		if ($tab == 'description')
 		{
-			$pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php';
+			$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
 			$pathtofilereadme = $modulelowercase.'/README.md';
 			$pathtochangelog = $modulelowercase.'/ChangeLog.md';
 
@@ -1877,7 +1897,7 @@ elseif (! empty($module))
 
 		if ($tab == 'menus')
 		{
-			$pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php';
+			$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
 
 			//$menus = $moduleobj->;
 
@@ -2002,7 +2022,7 @@ elseif (! empty($module))
 
 		if ($tab == 'permissions')
 		{
-			$pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php';
+			$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
 
 			//$perms = $moduleobj->;
 
@@ -2132,7 +2152,7 @@ elseif (! empty($module))
 				print $langs->trans("HooksDefDesc").'<br>';
 				print '<br>';
 
-				$pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php';
+				$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
 				print '<span class="fa fa-file-o"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong>';
 				print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
 				print '<br>';
@@ -2277,7 +2297,7 @@ elseif (! empty($module))
 
 		if ($tab == 'cron')
 		{
-			$pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php';
+			$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
 
 			$cronjobs = $moduleobj->cronjobs;
 
@@ -2411,7 +2431,8 @@ elseif (! empty($module))
 			$FILENAMEZIP='';
 
 			// Load module
-			dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php');
+			$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
+			dol_include_once($pathtofile);
 			$class='mod'.$module;
 
 			if (class_exists($class))