preference.plugin.enabled.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /*
  3. @name Preference
  4. @author Valentin CARRUESCO <idleman@idleman.fr>
  5. @link http://blog.idleman.fr
  6. @licence CC by nc sa
  7. @version 1.0.0
  8. @type component
  9. @description Module de gestion des préférences du programme
  10. */
  11. function preference_plugin_menu(){
  12. global $_;
  13. echo '<li '.(isset($_['section']) && $_['section']=='preference' || !isset($_['section']) ?'class="active"':'').'><a href="setting.php?section=preference"><i class="fa fa-angle-right"></i> Préférences</a></li>';
  14. }
  15. function preference_plugin_page(){
  16. global $myUser,$_;
  17. if((isset($_['section']) && $_['section']=='preference') || !isset($_['section']) ){
  18. if($myUser!=false){
  19. ?>
  20. <div class="span9 userBloc">
  21. <h1>Préférence</h1>
  22. <p>Gestion des préférences du programme</p>
  23. <ul class="nav nav-tabs">
  24. <li <?php echo (isset($_['block']) && $_['block']=='global'?'class="active"':'')?> ><a href="setting.php?section=preference&amp;block=global"><i class="fa fa-angle-right"></i> Général</a></li>
  25. <?php Plugin::callHook("preference_menu", array()); ?>
  26. </ul>
  27. <?php
  28. if((isset($_['section']) && $_['section']=='preference' && @$_['block']=='global' ) || !isset($_['section'])){
  29. if($myUser!=false){
  30. ?>
  31. <div class="span9 userBloc">
  32. <table class="table table-striped table-bordered" id="setting_table">
  33. <tr><th>Clé</th><th>Valeur</th><tr>
  34. <?php
  35. $conf = new Configuration();
  36. $confs = $conf->populate();
  37. foreach($confs as $value){
  38. $ns = 'conf';
  39. $key = $value->getKey();
  40. $infos = explode(':',$key);
  41. if(count($infos) ==2){
  42. list($ns,$key) = $infos;
  43. }
  44. if($ns != 'conf') continue;
  45. echo '<tr><td>'.$key.'</td><td><input class="input-xxlarge" type="text" value="'.$value->getValue().'" id="'.$value->getId().'"></td></tr>';
  46. }
  47. ?>
  48. <tr><td colspan="2"><button type="submit" onclick="save_settings();" class="btn">Modifier</button></td></tr>
  49. </table>
  50. </div>
  51. <?php }else{ ?>
  52. <div id="main" class="wrapper clearfix">
  53. <article>
  54. <h3>Vous devez être connecté</h3>
  55. </article>
  56. </div>
  57. <?php
  58. }
  59. }
  60. Plugin::callHook("preference_content", array());
  61. ?>
  62. </div>
  63. <?php }else{ ?>
  64. <div id="main" class="wrapper clearfix">
  65. <article>
  66. <h3>Vous devez être connecté</h3>
  67. </article>
  68. </div>
  69. <?php
  70. }
  71. }
  72. }
  73. function preference_plugin_action(){
  74. global $_,$myUser,$conf;
  75. switch($_['action']){
  76. case 'SAVE_SETTINGS':
  77. $configuration = new Configuration();
  78. $configuration->getAll();
  79. foreach($_['data'] as $key=>$value){
  80. $configuration->put($key,$value);
  81. }
  82. echo 'Réglages sauvegardés';
  83. break;
  84. }
  85. }
  86. Plugin::addJs('/js/main.js',true);
  87. Plugin::addHook("setting_menu", "preference_plugin_menu");
  88. Plugin::addHook("setting_bloc", "preference_plugin_page");
  89. Plugin::addHook("action_post_case", "preference_plugin_action");
  90. ?>