Work on a better way to manage modules. All one page. Introduce a way to

choose order of modules family. We should also be able to introduce
filters.
This commit is contained in:
Laurent Destailleur 2015-10-07 07:57:09 +02:00
parent 8d47a307bb
commit 4b103ba8ce
10 changed files with 211 additions and 73 deletions

View File

@ -43,6 +43,21 @@ if (! $user->admin)
$specialtostring=array(0=>'common', 1=>'interfaces', 2=>'other', 3=>'functional', 4=>'marketplace');
$familyinfo=array(
'hr'=>array('position'=>'001', 'label'=>$langs->trans("ModuleFamilyHr")),
'crm'=>array('position'=>'006', 'label'=>$langs->trans("ModuleFamilyCrm")),
'financial'=>array('position'=>'009', 'label'=>$langs->trans("ModuleFamilyFinancial")),
'products'=>array('position'=>'012', 'label'=>$langs->trans("ModuleFamilyProducts")),
'projects'=>array('position'=>'015', 'label'=>$langs->trans("ModuleFamilyProjects")),
'ecm'=>array('position'=>'018', 'label'=>$langs->trans("ModuleFamilyECM")),
'technic'=>array('position'=>'021', 'label'=>$langs->trans("ModuleFamilyTechnic")),
'portal'=>array('position'=>'040', 'label'=>$langs->trans("ModuleFamilyPortal")),
'interface'=>array('position'=>'050', 'label'=>$langs->trans("ModuleFamilyInterface")),
'base'=>array('position'=>'060', 'label'=>$langs->trans("ModuleFamilyBase")),
'other'=>array('position'=>'100', 'label'=>$langs->trans("ModuleFamilyOther")),
);
/*
* Actions
@ -124,22 +139,20 @@ foreach ($modulesdir as $dir)
$objMod = new $modName($db);
$modNameLoaded[$modName]=$dir;
if ($objMod->numero > 0)
if (! $objMod->numero > 0)
{
$j = $objMod->numero;
dol_syslog('a module descriptor must have a numero property', LOG_ERR);
}
else
{
$j = 1000 + $i;
}
$j = $objMod->numero;
$modulequalified=1;
// We discard modules according to features level (PS: if module is activated we always show it)
$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) $modulequalified=0;
if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) $modulequalified=0;
// We discard modules according to property disabled
if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified=0;
// We discard modules according to property disabled
if (! empty($objMod->hidden)) $modulequalified=false;
// Define array $categ with categ with at least one qualified module
@ -147,13 +160,19 @@ foreach ($modulesdir as $dir)
{
$modules[$i] = $objMod;
$filename[$i]= $modName;
$orders[$i] = $objMod->family."_".$j; // Sort by family, then by module number
$special = $objMod->special;
$familykey = $objMod->family;
if ($special == 1) $familykey='interface';
$orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$j; // Sort by family, then by module number
$dirmod[$i] = $dir;
// Set categ[$i]
$special = isset($specialtostring[$objMod->special])?$specialtostring[$objMod->special]:'unknown';
if ($objMod->version == 'development' || $objMod->version == 'experimental') $special='expdev';
if (isset($categ[$special])) $categ[$special]++; // Array of all different modules categories
else $categ[$special]=1;
$specialstring = isset($specialtostring[$special])?$specialtostring[$special]:'unknown';
if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring='expdev';
if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories
else $categ[$specialstring]=1;
$j++;
$i++;
}
@ -197,9 +216,9 @@ print load_fiche_titre($langs->trans("ModulesSetup"),$moreinfo,'title_setup');
// Start to show page
if (empty($mode)) $mode='common';
if ($mode==='common') print $langs->trans("ModulesDesc")."<br>\n";
if ($mode==='other') print $langs->trans("ModulesSpecialDesc")."<br>\n";
if ($mode==='interfaces') print $langs->trans("ModulesInterfaceDesc")."<br>\n";
if ($mode==='functional') print $langs->trans("ModulesJobDesc")."<br>\n";
//if ($mode==='other') print $langs->trans("ModulesSpecialDesc")."<br>\n";
//if ($mode==='interfaces') print $langs->trans("ModulesInterfaceDesc")."<br>\n";
//if ($mode==='functional') print $langs->trans("ModulesJobDesc")."<br>\n";
if ($mode==='marketplace') print $langs->trans("ModulesMarketPlaceDesc")."<br>\n";
if ($mode==='expdev') print $langs->trans("ModuleFamilyExperimental")."<br>\n";
@ -213,11 +232,12 @@ $categidx='common'; // Main
if (! empty($categ[$categidx]))
{
$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$categidx;
$head[$h][1] = $langs->trans("ModulesCommon");
$head[$h][1] = $langs->trans("AvailableModules");
$head[$h][2] = 'common';
$h++;
}
/*
$categidx='other'; // Other
if (! empty($categ[$categidx]))
{
@ -244,6 +264,7 @@ if (! empty($categ[$categidx]))
$head[$h][2] = 'functional';
$h++;
}
*/
$categidx='expdev';
if (! empty($categ[$categidx]))
@ -287,28 +308,19 @@ if ($mode != 'marketplace')
$oldfamily='';
$familylib=array(
'base'=>$langs->trans("ModuleFamilyBase"),
'crm'=>$langs->trans("ModuleFamilyCrm"),
'products'=>$langs->trans("ModuleFamilyProducts"),
'hr'=>$langs->trans("ModuleFamilyHr"),
'projects'=>$langs->trans("ModuleFamilyProjects"),
'financial'=>$langs->trans("ModuleFamilyFinancial"),
'ecm'=>$langs->trans("ModuleFamilyECM"),
'technic'=>$langs->trans("ModuleFamilyTechnic"),
'other'=>$langs->trans("ModuleFamilyOther")
);
foreach ($orders as $key => $value)
{
$tab=explode('_',$value);
$family=$tab[0]; $numero=$tab[1];
$familypos=$tab[0]; $familykey=$tab[1]; $numero=$tab[2];
$modName = $filename[$key];
$objMod = $modules[$key];
$special = $objMod->special;
//print $objMod->name." - ".$key." - ".$objMod->special.' - '.$objMod->version."<br>";
if (($mode != (isset($specialtostring[$objMod->special])?$specialtostring[$objMod->special]:'unknown') && $mode != 'expdev')
//if (($mode != (isset($specialtostring[$special])?$specialtostring[$special]:'unknown') && $mode != 'expdev')
if (($special >= 4 && $mode != 'expdev')
|| ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental')) continue; // Discard if not for current tab
if (! $objMod->getName())
@ -329,28 +341,27 @@ if ($mode != 'marketplace')
}
// Print a separator if we change family
//print "<tr><td>xx".$oldfamily."-".$family."-".$atleastoneforfamily."<br></td><tr>";
//if ($oldfamily && $family!=$oldfamily && $atleastoneforfamily) {
if ($family!=$oldfamily)
//print "<tr><td>xx".$oldfamily."-".$familykey."-".$atleastoneforfamily."<br></td><tr>";
//if ($oldfamily && $familykey!=$oldfamily && $atleastoneforfamily) {
if ($familykey!=$oldfamily)
{
print '<tr class="liste_titre">'."\n";
print '<td colspan="5">';
$familytext=empty($familylib[$family])?$family:$familylib[$family];
$familytext=empty($familyinfo[$familykey]['label'])?$familykey:$familyinfo[$familykey]['label'];
print $familytext;
print "</td>\n";
print '<td align="right">'.$langs->trans("SetupShort").'</td>'."\n";
print "</tr>\n";
$atleastoneforfamily=0;
//print "<tr><td>yy".$oldfamily."-".$family."-".$atleastoneforfamily."<br></td><tr>";
//print "<tr><td>yy".$oldfamily."-".$familykey."-".$atleastoneforfamily."<br></td><tr>";
}
$atleastoneforfamily++;
if ($family!=$oldfamily)
if ($familykey!=$oldfamily)
{
$familytext=empty($familylib[$family])?$family:$familylib[$family];
//print $familytext;
$oldfamily=$family;
$familytext=empty($familyinfo[$familykey]['label'])?$familykey:$familyinfo[$familykey]['label'];
$oldfamily=$familykey;
}
$var=!$var;

View File

@ -35,17 +35,20 @@
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 int Module unique ID
*/
public $numero;
/**
* @var string Module name
*/
public $name;
/**
* @var DoliDb Database handler
*/
public $db;
/**
* @var string Relative path to module style sheet
* @deprecated
* @see module_parts
*/
public $style_sheet = '';
/**
* @var array Paths to create when module is activated
*/
@ -134,16 +137,6 @@ class DolibarrModules // Can not be abstract, because we need to insta
*/
public $error;
/**
* @var int Module unique ID
*/
public $numero;
/**
* @var string Module name
*/
public $name;
/**
* @var string Module version
*/
@ -193,7 +186,15 @@ class DolibarrModules // Can not be abstract, because we need to insta
* @var bool Module is enabled globally (Multicompany support)
*/
public $core_enabled;
/**
* @var string Relative path to module style sheet
* @deprecated
* @see module_parts
*/
public $style_sheet = '';
/**
* Constructor. Define names, constants, directories, boxes, permissions
@ -470,6 +471,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
if ($this->version == 'dolibarr' || $this->version == 'dolibarr_deprecated') return 'core';
if (! empty($this->version) && ! in_array($this->version,array('experimental','development'))) return 'external';
if (! empty($this->editor_name) || ! empty($this->editor_web)) return 'external';
if ($this->numero >= 100000) return 'external';
return 'unknown';
}

View File

@ -45,7 +45,7 @@ class modCashDesk extends DolibarrModules
// Key text used to identify module (for permission, menus, etc...)
$this->rights_class = 'cashdesk';
$this->family = "products";
$this->family = "portal";
// 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";

View File

@ -43,7 +43,7 @@ class modLabel extends DolibarrModules
$this->db = $db;
$this->numero = 60;
$this->family = "other";
$this->family = "technic";
// 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 etiquettes";

View File

@ -45,7 +45,7 @@ class modUser extends DolibarrModules
$this->db = $db;
$this->numero = 0;
$this->family = "base"; // Family for module (or "base" if core module)
$this->family = "hr"; // Family for module (or "base" if core module)
// 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)";

View File

@ -27,7 +27,7 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
/**
* Class to describe a sync supplier web services module
*/
class modSyncSupplierWebServices extends DolibarrModules
class modWebServicesClient extends DolibarrModules
{
/**
@ -38,12 +38,12 @@ class modSyncSupplierWebServices extends DolibarrModules
function __construct($db)
{
$this->db = $db;
$this->numero = 2650;
$this->numero = 2660;
$this->family = "technic";
// 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 client for external supplier web services";
$this->description = "Enable the web service client to call external supplier web services";
$this->version = 'experimental'; // 'experimental' or 'dolibarr' or version
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);

View File

@ -0,0 +1,124 @@
<?php
/* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \defgroup website Module website
* \brief Website module descriptor.
* \file htdocs/core/modules/modWebsite.class.php
* \ingroup website
* \brief Description and activation file for module Website
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
/**
* Class to describe Website module
*/
class modWebsite extends DolibarrModules
{
/**
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
global $langs,$conf;
$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";
// 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";
$this->version = 'development'; // 'experimental' or 'dolibarr' or version
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
$this->special = 0;
// Name of image file used for this module.
$this->picto='globe';
// Data directories to create when module is enabled
$this->dirs = array();
// Config pages
//-------------
$this->config_page_url = array("website.php");
// Dependancies
//-------------
$this->hidden = ! empty($conf->global->WEBSITE_MODULE_DISABLED); // A condition to disable module
$this->depends = array(); // List of modules id that must be enabled if this module is enabled
$this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->conflictwith = array(); // List of modules id this module is in conflict with
$this->langfiles = array("website");
// Constants
//-----------
$this->const = array();
// New pages on tabs
// -----------------
$this->tabs = array();
// Boxes
//------
$this->boxes = array();
// Permissions
$this->rights = array(); // Permission array used by this module
$this->rights_class = 'website';
$r=0;
$this->rights[$r][0] = 10001;
$this->rights[$r][1] = 'Read website content';
$this->rights[$r][3] = 1;
$this->rights[$r][4] = 'read';
$r++;
$this->rights[$r][0] = 10002;
$this->rights[$r][1] = 'Create/modify website content';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'create';
$r++;
$this->rights[$r][0] = 10003;
$this->rights[$r][1] = 'Delete website content';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'delete';
$r++;
// Main menu entries
$r=0;
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'top', // This is a Left menu entry
'titre'=>'Website',
'url'=>'/website/index.php',
'langs'=>'website', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>100,
'enabled'=>'$conf->website->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'$user->rights->website->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'target'=>'',
'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
$r++;
}
}

View File

@ -197,9 +197,7 @@ print '<td>&nbsp;</td>';
print '<td class="liste_titre" align="center">';
print $form->selectarray('status', array('0'=>$langs->trans("No"),'1'=>$langs->trans("Yes")), $status, 1);
print '</td><td class="liste_titre" align="right">';
print '&nbsp;';
print '<input class="liste_titre" type="image" src="'.img_picto($langs->trans("Search"),'search.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '&nbsp; ';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
print '</td>';
print '</tr>';
@ -294,7 +292,7 @@ if (count($object->lines) > 0)
print yn($line->status);
print '</td>';
print '<td align="right">';
print '<td align="right" class="nowrap">';
if ($user->rights->cron->delete)
{
print "<a href=\"".$_SERVER["PHP_SELF"]."?id=".$line->id."&status=".$status."&action=delete\" title=\"".dol_escape_htmltag($langs->trans('CronDelete'))."\">".img_picto($langs->trans('CronDelete'),'delete')."</a> &nbsp;";

View File

@ -32,7 +32,7 @@
-- Visible in misc page
insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_NOT_INSTALLED','1','chaine','Setup is running',1,0);
insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_FEATURES_LEVEL','0','chaine','Level of features to show (0=stable only, 1=stable+experimental, 2=stable+experimental+development',1,0);
insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_FEATURES_LEVEL','0','chaine','Level of features to show: -1=stable+deprecated, 0=stable only (default), 1=stable+experimental, 2=stable+experimental+development',1,0);
insert into llx_const (name, value, type, note, visible, entity) values ('MAILING_LIMIT_SENDBYWEB','25','chaine','Number of targets to defined packet size when sending mass email',1,0);
-- Hidden and common to all entities

View File

@ -285,14 +285,16 @@ ModuleSetup=Module setup
ModulesSetup=Modules setup
ModuleFamilyBase=System
ModuleFamilyCrm=Customer Relation Management (CRM)
ModuleFamilyProducts=Products Management
ModuleFamilyHr=Human Resource Management
ModuleFamilyProducts=Products Management (PM)
ModuleFamilyHr=Human Resource Management (HR)
ModuleFamilyProjects=Projects/Collaborative work
ModuleFamilyOther=Other
ModuleFamilyTechnic=Multi-modules tools
ModuleFamilyExperimental=Experimental modules
ModuleFamilyFinancial=Financial Modules (Accounting/Treasury)
ModuleFamilyECM=Electronic Content Management (ECM)
ModuleFamilyPortal=Web sites and other frontal application
ModuleFamilyInterface=Interfaces with external systems
MenuHandlers=Menu handlers
MenuAdmin=Menu editor
DoNotUseInProduction=Do not use in production
@ -524,12 +526,12 @@ Module2400Name=Agenda
Module2400Desc=Events/tasks and agenda management
Module2500Name=Electronic Content Management
Module2500Desc=Save and share documents
Module2600Name=API services (Web services SOAP)
Module2600Name=API/Web services (SOAP server)
Module2600Desc=Enable the Dolibarr SOAP server providing API services
Module2610Name=API services (Web services REST)
Module2610Name=API/Web services (REST server)
Module2610Desc=Enable the Dolibarr REST server providing API services
Module2650Name=WebServices (client)
Module2650Desc=Enable the Dolibarr web services client (Can be used to push data/requests to external servers. Supplier orders supported only for the moment)
Module2660Name=Call WebServices (SOAP client)
Module2660Desc=Enable the Dolibarr web services client (Can be used to push data/requests to external servers. Supplier orders supported only for the moment)
Module2700Name=Gravatar
Module2700Desc=Use online Gravatar service (www.gravatar.com) to show photo of users/members (found with their emails). Need an internet access
Module2800Desc=FTP Client
@ -1001,6 +1003,7 @@ SystemAreaForAdminOnly=This area is available for administrator users only. None
CompanyFundationDesc=Edit on this page all known information of the company or foundation you need to manage (For this, click on "Modify" button at bottom of page)
DisplayDesc=You can choose each parameter related to the Dolibarr look and feel here
AvailableModules=Available modules
DeprecatedModules=Deprecated modules
ToActivateModule=To activate modules, go on setup Area (Home->Setup->Modules).
SessionTimeOut=Time out for session
SessionExplanation=This number guarantee that session will never expire before this delay, if the session cleaner is done by Internal PHP session cleaner (and nothing else). Internal PHP session cleaner does not guaranty that session will expire just after this delay. It will expire, after this delay, and when the session cleaner is ran, so every <b>%s/%s</b> access, but only during access made by other sessions.<br>Note: on some servers with an external session cleaning mechanism (cron under debian, ubuntu ...), the sessions can be destroyed after a period defined by the default <strong>session.gc_maxlifetime</strong>, no matter what the value entered here.