Merge pull request #19261 from aspangaro/15a29

Clean module HRM
This commit is contained in:
Laurent Destailleur 2021-10-31 13:39:10 +01:00 committed by GitHub
commit 598508af41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 78 additions and 87 deletions

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr> /* Copyright (C) 2015-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -13,25 +13,27 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
* or see https://www.gnu.org/
*/ */
/** /**
* \file htdocs/core/modules/modHRM.class.php * \defgroup HRM Module hrm
* \ingroup HRM * \file htdocs/core/modules/modHRM.class.php
* \brief Description and activation file for the module HRM * \ingroup HRM
* \brief Description and activation file for the module HRM
*/ */
include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php"; include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php";
/** /**
* Class to describe and activate the HRM module * Description and activation class for module HRM
*/ */
class modHRM extends DolibarrModules class modHRM extends DolibarrModules
{ {
/** /**
* Constructor. * Constructor. Define names, constants, directories, boxes, permissions
* Define names, constants, directories, boxes, permissions
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
@ -39,34 +41,27 @@ class modHRM extends DolibarrModules
$this->db = $db; $this->db = $db;
// Id for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
$this->numero = 4000; $this->numero = 4000;
// Key text used to identify module (for permissions, menus, etc...)
$this->rights_class = 'hrm'; $this->rights_class = 'hrm';
// 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->family = "hr";
$this->module_position = '50'; $this->module_position = '50';
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of 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->name = preg_replace('/^mod/i', '', get_class($this));
// Module description, used if translation string 'ModulehrmDesc' not found (hrm is name of module). // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
$this->description = "hrm Description product "; $this->description = "HRM";
// Used only if file README.md and README-LL.md not found. // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->descriptionlong = "hrm Description long"; $this->version = 'development';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
// Author
$this->editor_name = 'Editor name';
$this->editor_url = 'https://www.example.com';
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
$this->version = '1.0';
// Url to the file with your last numberversion of this module
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
// Key used in llx_const table to save module status enabled/disabled (where HRMTEST is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Name of image file used for this module. // Name of image file used for this module.
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
// To use a supported fa-xxx css style of font awesome, use this->picto='xxx'
$this->picto = 'hrm'; $this->picto = 'hrm';
// Define some features supported by module (triggers, login, substitutions, menus, css, etc...) // Define some features supported by module (triggers, login, substitutions, menus, css, etc...)
@ -110,32 +105,20 @@ class modHRM extends DolibarrModules
$this->config_page_url = array("hrm.php"); $this->config_page_url = array("hrm.php");
// Dependencies // Dependencies
// A condition to hide module $this->hidden = false; // A condition to hide module
$this->hidden = false; $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
// List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) $this->requiredby = array(); // List of module ids to disable if this one is disabled
$this->depends = array(); $this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) $this->phpmin = array(5, 6); // Minimum version of PHP required by module
$this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) $this->need_dolibarr_version = array(11, 0); // Minimum version of Dolibarr required by module
// The language file dedicated to your module
$this->langfiles = array("hrm"); $this->langfiles = array("hrm");
// Prerequisites
$this->phpmin = array(5, 6); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(11, -3); // Minimum version of Dolibarr required by module
// Messages at activation
$this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
$this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
//$this->automatic_activation = array('FR'=>'HrmTestWasAutomaticallyActivatedBecauseOfYourCountryChoice');
//$this->always_enabled = true; // If true, can't be disabled
// Constants // Constants
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),
// Example: $this->const=array(1 => array('HRMTEST_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
// 2 => array('HRMTEST_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) // 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0)
// ); $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities')
$this->const = array(); $r = 0;
if (!isset($conf->hrm) || !isset($conf->hrm->enabled)) { if (!isset($conf->hrm) || !isset($conf->hrm->enabled)) {
@ -207,67 +190,78 @@ class modHRM extends DolibarrModules
// ), // ),
); );
// Permissions provided by this module
$this->rights = array(); // Permissions
$this->rights = array(); // Permission array used by this module
$r = 0; $r = 0;
// Add here entries to declare new permissions
/* BEGIN MODULEBUILDER PERMISSIONS */
// Skill / Job / Position // Skill / Job / Position
$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) $this->rights[$r][0] = 4010; // Permission id (must not be already used)
$this->rights[$r][1] = $langs->trans('ReadSkillJobPosition'); // Permission label $this->rights[$r][1] = 'Read skill/job/position'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'all'; $this->rights[$r][4] = 'all';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->read) $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->read)
$r++; $r++;
$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->trans('CreateUpdateSkillJobPosition'); // Permission label $this->rights[$r][0] = 4011; // Permission id (must not be already used)
$this->rights[$r][1] = 'Create/modify skill/job/position'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'all'; $this->rights[$r][4] = 'all';
$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->write) $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->write)
$r++; $r++;
$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->trans('DeleteSkillJobPosition'); // Permission label $this->rights[$r][0] = 4012; // Permission id (must not be already used)
$this->rights[$r][1] = 'Delete skill/job/position'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'all'; $this->rights[$r][4] = 'all';
$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->delete) $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->delete)
$r++; $r++;
//Eval // Evaluation
$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) $this->rights[$r][0] = 4020; // Permission id (must not be already used)
$this->rights[$r][1] = $langs->trans('ReadEval'); // Permission label $this->rights[$r][1] = 'Read evaluation'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'evaluation'; $this->rights[$r][4] = 'evaluation';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->read) $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->read)
$r++; $r++;
$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->trans('CreateUpdateEval'); // Permission label $this->rights[$r][0] = 4021; // Permission id (must not be already used)
$this->rights[$r][1] = 'Create/modify evaluation'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'evaluation'; $this->rights[$r][4] = 'evaluation';
$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->write) $this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->write)
$r++; $r++;
$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->trans('ValidateEval'); // Permission label $this->rights[$r][0] = 4022; // Permission id (must not be already used)
$this->rights[$r][1] = 'Validate evaluation'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'evaluation'; $this->rights[$r][4] = 'evaluation';
$this->rights[$r][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->write) $this->rights[$r][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->write)
$r++; $r++;
$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
$this->rights[$r][1] = $langs->trans('DeleteEval'); // Permission label $this->rights[$r][0] = 4023; // Permission id (must not be already used)
$this->rights[$r][1] = 'Delete evaluation'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'evaluation'; $this->rights[$r][4] = 'evaluation';
$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->delete) $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->delete)
$r++; $r++;
// Comparison // Comparison
$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used) $this->rights[$r][0] = 4030; // Permission id (must not be already used)
$this->rights[$r][1] = $langs->trans('SeeComparisonMenu'); // Permission label $this->rights[$r][1] = 'See comparison menu'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'compare'; $this->rights[$r][4] = 'compare';
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->delete) $this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->hrm->poste->delete)
$r++; $r++;
} }
/** /**
* Function called when module is enabled. * Function called when module is enabled.
* The init function add constants, boxes, permissions and menus * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* (defined in constructor) into Dolibarr database. * It also creates data directories
* It also creates data directories
* *
* @param string $options Enabling module ('', 'noboxes') * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes')
* @return int if OK, 0 if KO * @return int 1 if OK, 0 if KO
*/ */
public function init($options = '') public function init($options = '')
{ {

View File

@ -961,6 +961,14 @@ Permission4001=See employees
Permission4002=Create employees Permission4002=Create employees
Permission4003=Delete employees Permission4003=Delete employees
Permission4004=Export employees Permission4004=Export employees
Permission4010=Read skill/job/position
Permission4011=Create/modify skill/job/position
Permission4012=Delete skill/job/position
Permission4020=Read evaluation
Permission4021=Create/modify evaluation
Permission4022=Validate evaluation
Permission4023=Delete evaluation
Permission4030=See comparison menu
Permission10001=Read website content Permission10001=Read website content
Permission10002=Create/modify website content (html and javascript content) Permission10002=Create/modify website content (html and javascript content)
Permission10003=Create/modify website content (dynamic php code). Dangerous, must be reserved to restricted developers. Permission10003=Create/modify website content (dynamic php code). Dangerous, must be reserved to restricted developers.

View File

@ -19,12 +19,9 @@ Employees=Employees
Employee=Employee Employee=Employee
NewEmployee=New employee NewEmployee=New employee
ListOfEmployees=List of employees ListOfEmployees=List of employees
HrmSetup = Hrm setup HrmSetup=HRM module setup
HrmSetupPage = Hrm setup page
HRM_MAXRANK=Maximum rank for a skill HRM_MAXRANK=Maximum rank for a skill
HRM_DEFAULT_SKILL_DESCRIPTION=Default description of ranks when skill is created HRM_DEFAULT_SKILL_DESCRIPTION=Default description of ranks when skill is created
HrmAbout = About Hrm
traduction_note=Translate
deplacement=Shift deplacement=Shift
DateEval=Evaluation date DateEval=Evaluation date
JobCard=Job card JobCard=Job card
@ -82,11 +79,3 @@ NoEval=No evaluation done for this employee
HowManyUserWithThisMaxNote=Number of users with this rank HowManyUserWithThisMaxNote=Number of users with this rank
HighestRank=Highest rank HighestRank=Highest rank
SkillComparison=Skill comparison SkillComparison=Skill comparison
ReadSkillJobPosition=Read skills / jobs / positions
CreateUpdateSkillJobPosition=Create / update skills / jobs / positions
DeleteSkillJobPosition=Delete skills / jobs / positions
ReadEval=Read evaluations
CreateUpdateEval=Create / update evaluations
ValidateEval=Validate evaluations
DeleteEval=Delete evaluations
SeeComparisonMenu=Access skills comparison menu