organizational.plugin.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. //Déclaration d'un item de menu dans le menu principal
  3. function organizational_menu(&$menuItems){
  4. global $myUser;
  5. if(!$myUser->can('organizational','read')) return;
  6. $item = array(
  7. 'sort'=>4,
  8. 'url'=>'index.php?module=organizational',
  9. 'label'=>'Organigramme',
  10. 'icon'=> 'fas fa-sitemap',
  11. 'color'=> '#4c5d9e',
  12. 'parent'=> 'organization'
  13. );
  14. $menuItems[] = $item;
  15. }
  16. //Cette fonction va generer une page quand on clique sur organizational dans menu
  17. function organizational_page(){
  18. global $_;
  19. if(!isset($_['module']) || $_['module'] !='organizational') return;
  20. $page = !isset($_['page']) ? 'sheet' : $_['page'];
  21. $file = __DIR__.SLASH.'page.'.$page.'.php';
  22. if(!file_exists($file)) throw new Exception("Page ".$page." inexistante");
  23. require_once($file);
  24. }
  25. //Fonction executée lors de l'activation du plugin
  26. function organizational_install($id){
  27. if($id != 'organizational') return;
  28. Entity::install(__DIR__);
  29. }
  30. //Fonction executée lors de la désactivation du plugin
  31. function organizational_uninstall($id){
  32. if($id != 'organizational') return;
  33. Entity::uninstall(__DIR__);
  34. }
  35. //Comprends toutes les actions du plugin qui ne nécessitent pas de vue html
  36. require_once(__DIR__.SLASH.'action.php');
  37. function organizational_setting_menu(&$settingMenu){
  38. global $myUser;
  39. if(!$myUser->can('organizational','read')) return;
  40. $settingMenu[]= array(
  41. 'sort' =>0,
  42. 'url' => 'setting.php?section=organizational',
  43. 'icon' => 'fas fa-angle-right',
  44. 'label' => 'Organigramme'
  45. );
  46. }
  47. //Déclaration des pages de réglages
  48. function organizational_content_setting(){
  49. global $_;
  50. if(file_exists(__DIR__.SLASH.'setting.'.$_['section'].'.php'))
  51. require_once(__DIR__.SLASH.'setting.'.$_['section'].'.php');
  52. }
  53. Configuration::setting('organizational',array(
  54. "Paramètre généraux",
  55. 'organizational_root' => array("label"=>"PDG de l'organigramme","legend"=>"L'utilisateur de niveau 0 de l'entreprise","type"=>"user","placeholder"=>"eg. Jean Bernard"),
  56. 'organizational_hidden_users_ranks' => array("label"=>"Liste d'utilisateurs et de rangs à masquer","type"=>"user", "attributes"=> array("data-multiple"=>true)),
  57. 'organizational_origin' => array("label"=>"Origine", "legend" => "Origine des utilisateurs à afficher dans l'organigramme","type"=>"text","placeholder"=>"eg. active_directory"),
  58. ));
  59. //Déclation des assets
  60. Plugin::addCss("/css/main.css");
  61. Plugin::addJs("/js/main.js");
  62. Plugin::addCss("/css/jquery.orgchart.min.css");
  63. Plugin::addJs("/js/jquery.orgchart.min.js");
  64. //Mapping hook / fonctions
  65. function organizational_scope(&$sections){
  66. $sections['organizational'] = "Lecture de l'organigramme";
  67. }
  68. Plugin::addHook("install", "organizational_install");
  69. Plugin::addHook("uninstall", "organizational_uninstall");
  70. Plugin::addHook("menu_main", "organizational_menu");
  71. Plugin::addHook("page", "organizational_page");
  72. Plugin::addHook("content_setting", "organizational_content_setting");
  73. Plugin::addHook("menu_setting", "organizational_setting_menu");
  74. ?>