Browse Source

NEW Introduce property module_position so a module can decide where it
appears into list of modules.

Laurent Destailleur 9 years ago
parent
commit
f5631cac45
33 changed files with 59 additions and 10 deletions
  1. 1 0
      dev/skeletons/modMyModule.class.php
  2. 10 4
      htdocs/admin/modules.php
  3. 15 5
      htdocs/core/modules/DolibarrModules.class.php
  4. 1 0
      htdocs/core/modules/modAccounting.class.php
  5. 1 0
      htdocs/core/modules/modAdherent.class.php
  6. 1 0
      htdocs/core/modules/modAgenda.class.php
  7. 1 0
      htdocs/core/modules/modBanque.class.php
  8. 1 0
      htdocs/core/modules/modCashDesk.class.php
  9. 1 0
      htdocs/core/modules/modCommande.class.php
  10. 1 0
      htdocs/core/modules/modComptabilite.class.php
  11. 1 0
      htdocs/core/modules/modDocumentGeneration.class.php
  12. 1 0
      htdocs/core/modules/modECM.class.php
  13. 1 0
      htdocs/core/modules/modExpedition.class.php
  14. 1 0
      htdocs/core/modules/modExpenseReport.class.php
  15. 1 0
      htdocs/core/modules/modFacture.class.php
  16. 1 0
      htdocs/core/modules/modFournisseur.class.php
  17. 1 0
      htdocs/core/modules/modHoliday.class.php
  18. 1 0
      htdocs/core/modules/modMargin.class.php
  19. 1 0
      htdocs/core/modules/modOauth.class.php
  20. 1 0
      htdocs/core/modules/modOpenSurvey.class.php
  21. 1 0
      htdocs/core/modules/modPrelevement.class.php
  22. 1 0
      htdocs/core/modules/modPrinting.class.php
  23. 1 0
      htdocs/core/modules/modProduct.class.php
  24. 2 0
      htdocs/core/modules/modProductBatch.class.php
  25. 1 0
      htdocs/core/modules/modProjet.class.php
  26. 1 0
      htdocs/core/modules/modPropale.class.php
  27. 1 0
      htdocs/core/modules/modReceiptPrinter.class.php
  28. 2 0
      htdocs/core/modules/modResource.class.php
  29. 1 0
      htdocs/core/modules/modService.class.php
  30. 1 0
      htdocs/core/modules/modSociete.class.php
  31. 1 0
      htdocs/core/modules/modStock.class.php
  32. 1 0
      htdocs/core/modules/modUser.class.php
  33. 2 1
      htdocs/core/modules/modWebsite.class.php

+ 1 - 0
dev/skeletons/modMyModule.class.php

@@ -53,6 +53,7 @@ class modMyModule extends DolibarrModules
 		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
 		// It is used to group modules in module setup page
 		$this->family = "other";
+		$this->module_position = 500;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

+ 10 - 4
htdocs/admin/modules.php

@@ -164,10 +164,15 @@ foreach ($modulesdir as $dir)
 		    					
 		    			            $special = $objMod->special;
 		    			            $familykey = $objMod->family;
+		    			            $moduleposition = ($objMod->module_position?$objMod->module_position:'500');
+		    			            if ($moduleposition == 500 && ($objMod->isCoreOrExternalModule() == 'external'))
+		    			            {
+		    			                $moduleposition = 800;
+		    			            }
 		    			            
 		    			            if ($special == 1) $familykey='interface';
 		    			            
-		    			            $orders[$i]  = $familyinfo[$familykey]['position']."_".$familykey."_".$j;   // Sort by family, then by module number
+		    			            $orders[$i]  = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j;   // Sort by family, then by module position then number
 		    						$dirmod[$i]  = $dir;
 		    			            // Set categ[$i]
 		    						$specialstring = isset($specialtostring[$special])?$specialtostring[$special]:'unknown';
@@ -312,7 +317,7 @@ if ($mode != 'marketplace')
     foreach ($orders as $key => $value)
     {
         $tab=explode('_',$value);
-        $familypos=$tab[0]; $familykey=$tab[1]; $numero=$tab[2];
+        $familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$tab[3];
 
         $modName = $filename[$key];
     	$objMod  = $modules[$key];
@@ -426,12 +431,13 @@ if ($mode != 'marketplace')
         	}
         	else
         	{
-        		print '<a class="reposition" href="modules.php?id='.$objMod->numero.'&amp;action=reset&amp;value=' . $modName . '&amp;mode=' . $mode . '">';
+        		print '<a class="reposition" href="modules.php?id='.$objMod->numero.'&amp;module_position='.$module_position.'&amp;action=reset&amp;value=' . $modName . '&amp;mode=' . $mode . '">';
         		print img_picto($langs->trans("Activated"),'switch_on');
         		print '</a>';
         	}
         	print '</td>'."\n";
 
+        	// Config link
         	if (! empty($objMod->config_page_url) && !$disableSetup)
         	{
         		if (is_array($objMod->config_page_url))
@@ -489,7 +495,7 @@ if ($mode != 'marketplace')
         	else
         	{
 	        	// Module non actif
-	        	print '<a class="reposition" href="modules.php?id='.$objMod->numero.'&amp;action=set&amp;value=' . $modName . '&amp;mode=' . $mode . '">';
+	        	print '<a class="reposition" href="modules.php?id='.$objMod->numero.'&amp;module_position='.$module_position.'&amp;action=set&amp;value=' . $modName . '&amp;mode=' . $mode . '">';
 	        	print img_picto($langs->trans("Disabled"),'switch_off');
 	        	print "</a>\n";
         	}

+ 15 - 5
htdocs/core/modules/DolibarrModules.class.php

@@ -34,21 +34,31 @@
  */
 class DolibarrModules           // Can not be abstract, because we need to instantiant it into unActivateModule to be able to disable a module whose files were removed.
 {
+    /**
+     * @var DoliDb Database handler
+     */
+    public $db;
+
     /**
      * @var int Module unique ID
      */
     public $numero;
 
+    /**
+     * @var string Family
+     */
+    public $family;
+    
+    /**
+     * @var int module_position
+     */
+    public $module_position=500;
+    
     /**
      * @var string Module name
      */
     public $name;
 
-	/**
-     * @var DoliDb Database handler
-     */
-    public $db;
-
     /**
      * @var array Paths to create when module is activated
      */

+ 1 - 0
htdocs/core/modules/modAccounting.class.php

@@ -44,6 +44,7 @@ class modAccounting extends DolibarrModules
 		$this->numero = 50400;
 
 		$this->family = "financial";
+		$this->module_position = 610;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i', '', get_class($this));
 		$this->description = "Advanced accounting management";

+ 1 - 0
htdocs/core/modules/modAdherent.class.php

@@ -49,6 +49,7 @@ class modAdherent extends DolibarrModules
         $this->numero = 310;
 
         $this->family = "hr";
+        $this->module_position = 20;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
         $this->description = "Management of members of a foundation or association";

+ 1 - 0
htdocs/core/modules/modAgenda.class.php

@@ -50,6 +50,7 @@ class modAgenda extends DolibarrModules
 		$this->numero = 2400;
 
 		$this->family = "projects";
+		$this->module_position = 15;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Gestion de l'agenda et des actions";

+ 1 - 0
htdocs/core/modules/modBanque.class.php

@@ -49,6 +49,7 @@ class modBanque extends DolibarrModules
 		$this->numero = 85;
 
 		$this->family = "financial";
+		$this->module_position = 510;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Gestion des comptes financiers de type Comptes bancaires ou postaux";

+ 1 - 0
htdocs/core/modules/modCashDesk.class.php

@@ -46,6 +46,7 @@ class modCashDesk extends DolibarrModules
 		$this->rights_class = 'cashdesk';
 
 		$this->family = "portal";
+		$this->module_position = 10;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "CashDesk module";

+ 1 - 0
htdocs/core/modules/modCommande.class.php

@@ -51,6 +51,7 @@ class modCommande extends DolibarrModules
 		$this->numero = 25;
 
 		$this->family = "crm";
+		$this->module_position = 30;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Gestion des commandes clients";

+ 1 - 0
htdocs/core/modules/modComptabilite.class.php

@@ -48,6 +48,7 @@ class modComptabilite extends DolibarrModules
 		$this->numero = 10;
 
 		$this->family = "financial";
+		$this->module_position = 600;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Gestion sommaire de comptabilite";

+ 1 - 0
htdocs/core/modules/modDocumentGeneration.class.php

@@ -45,6 +45,7 @@ class modDocumentGeneration extends DolibarrModules
 		$this->numero = 1520;
 
 		$this->family = "technic";
+		$this->module_position = 10000;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Direct mail document generation";

+ 1 - 0
htdocs/core/modules/modECM.class.php

@@ -48,6 +48,7 @@ class modECM extends DolibarrModules
 		// Family can be 'crm','financial','hr','projects','product','ecm','technic','other'
 		// It is used to sort modules in module setup page
 		$this->family = "ecm";
+		$this->module_position = 10;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		// Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value)

+ 1 - 0
htdocs/core/modules/modExpedition.class.php

@@ -49,6 +49,7 @@ class modExpedition extends DolibarrModules
 		$this->numero = 80;
 
 		$this->family = "crm";
+		$this->module_position = 40;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Gestion des expeditions";

+ 1 - 0
htdocs/core/modules/modExpenseReport.class.php

@@ -52,6 +52,7 @@ class modExpenseReport extends DolibarrModules
 		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
 		// It is used to group modules in module setup page
 		$this->family = "hr";
+		$this->module_position = 40;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

+ 1 - 0
htdocs/core/modules/modFacture.class.php

@@ -48,6 +48,7 @@ class modFacture extends DolibarrModules
 		$this->numero = 30;
 
 		$this->family = "financial";
+		$this->module_position = 10;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Gestion des factures";

+ 1 - 0
htdocs/core/modules/modFournisseur.class.php

@@ -48,6 +48,7 @@ class modFournisseur extends DolibarrModules
 		$this->numero = 40;
 
 		$this->family = "products";
+		$this->module_position = 10;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Gestion des fournisseurs";

+ 1 - 0
htdocs/core/modules/modHoliday.class.php

@@ -53,6 +53,7 @@ class modHoliday extends DolibarrModules
 		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
 		// It is used to group modules in module setup page
 		$this->family = "hr";
+		$this->module_position = 30;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

+ 1 - 0
htdocs/core/modules/modMargin.class.php

@@ -48,6 +48,7 @@ class modMargin extends DolibarrModules
 		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
 		// It is used to group modules in module setup page
 		$this->family = "financial";
+		$this->module_position = 550;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

+ 1 - 0
htdocs/core/modules/modOauth.class.php

@@ -47,6 +47,7 @@ class modOauth extends DolibarrModules
         // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
         // It is used to group modules in module setup page
         $this->family = "technic";
+        $this->module_position = 510;
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
         $this->name = preg_replace('/^mod/i','',get_class($this));
         // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

+ 1 - 0
htdocs/core/modules/modOpenSurvey.class.php

@@ -52,6 +52,7 @@ class modOpenSurvey extends DolibarrModules
 		// Family can be 'crm','financial','hr','projects','product','technic','other'
 		// It is used to group modules in module setup page
 		$this->family = "projects";
+		$this->module_position = 40;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		// Module description used if translation string 'ModuleXXXDesc' not found (XXX is value MyModule)

+ 1 - 0
htdocs/core/modules/modPrelevement.class.php

@@ -48,6 +48,7 @@ class modPrelevement extends DolibarrModules
 		$this->numero = 57;
 
 		$this->family = "financial";
+		$this->module_position = 520;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Gestion des Prelevements";

+ 1 - 0
htdocs/core/modules/modPrinting.class.php

@@ -47,6 +47,7 @@ class modPrinting extends DolibarrModules
         // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
         // It is used to group modules in module setup page
         $this->family = "technic";
+        $this->module_position = 520;
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
         $this->name = preg_replace('/^mod/i','',get_class($this));
 		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

+ 1 - 0
htdocs/core/modules/modProduct.class.php

@@ -50,6 +50,7 @@ class modProduct extends DolibarrModules
 		$this->numero = 50;
 
 		$this->family = "products";
+		$this->module_position = 20;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Gestion des produits";

+ 2 - 0
htdocs/core/modules/modProductBatch.class.php

@@ -46,6 +46,8 @@ class modProductBatch extends DolibarrModules
 		$this->numero = 39000;
 
 		$this->family = "products";
+		$this->module_position = 45;
+		
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Batch number, eat-by and sell-by date management module";
 

+ 1 - 0
htdocs/core/modules/modProjet.class.php

@@ -50,6 +50,7 @@ class modProjet extends DolibarrModules
 		$this->numero = 400;
 
 		$this->family = "projects";
+		$this->module_position = 10;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Gestion des projets";

+ 1 - 0
htdocs/core/modules/modPropale.class.php

@@ -49,6 +49,7 @@ class modPropale extends DolibarrModules
 		$this->numero = 20;
 
 		$this->family = "crm";
+		$this->module_position = 20;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Gestion des propositions commerciales";

+ 1 - 0
htdocs/core/modules/modReceiptPrinter.class.php

@@ -47,6 +47,7 @@ class modReceiptPrinter extends DolibarrModules
         // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
         // It is used to group modules in module setup page
         $this->family = "technic";
+        $this->module_position = 530;
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
         $this->name = preg_replace('/^mod/i','',get_class($this));
         // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)

+ 2 - 0
htdocs/core/modules/modResource.class.php

@@ -47,12 +47,14 @@ class modResource extends DolibarrModules
 		// Use a free id here
 		// (See in Home -> System information -> Dolibarr for list of used modules id).
 		$this->numero = 63000;
+		
 		// Key text used to identify module (for permissions, menus, etc...)
 		$this->rights_class = 'resource';
 
 		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
 		// It is used to group modules in module setup page
 		$this->family = "projects";
+		$this->module_position = 20;
 		// Module label (no space allowed)
 		// used if translation string 'ModuleXXXName' not found
 		// (where XXX is value of numeric property 'numero' of module)

+ 1 - 0
htdocs/core/modules/modService.class.php

@@ -48,6 +48,7 @@ class modService extends DolibarrModules
 		$this->numero = 53;
 
 		$this->family = "products";
+		$this->module_position = 30;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Gestion des services";

+ 1 - 0
htdocs/core/modules/modSociete.class.php

@@ -49,6 +49,7 @@ class modSociete extends DolibarrModules
 		$this->numero = 1;
 
 		$this->family = "crm";
+		$this->module_position = 10;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Gestion des societes et contacts";

+ 1 - 0
htdocs/core/modules/modStock.class.php

@@ -48,6 +48,7 @@ class modStock extends DolibarrModules
 		$this->numero = 52;
 
 		$this->family = "products";
+		$this->module_position = 40;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Gestion des stocks";

+ 1 - 0
htdocs/core/modules/modUser.class.php

@@ -46,6 +46,7 @@ class modUser extends DolibarrModules
 		$this->numero = 0;
 
 		$this->family = "hr";		// Family for module (or "base" if core module)
+		$this->module_position = 10;
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
 		$this->name = preg_replace('/^mod/i','',get_class($this));
 		$this->description = "Gestion des utilisateurs (requis)";

+ 2 - 1
htdocs/core/modules/modWebsite.class.php

@@ -42,10 +42,11 @@ class modWebsite extends DolibarrModules
 
         $this->db = $db;
         $this->numero = 10000;
-
+        
 		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
 		// It is used to group modules in module setup page
         $this->family = "portal";
+        $this->module_position = 20;
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
         $this->name = preg_replace('/^mod/i','',get_class($this));
         $this->description = "Enable the public website with CMS features";