profile.plugin.enabled.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. /*
  3. @name Profile
  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. @description affichage du profil et des infos
  9. */
  10. function dash_profil_plugin_menu(&$widgets){
  11. $widgets[] = array(
  12. 'uid' => 'dash_profil',
  13. 'icon' => 'fa fa-globe',
  14. 'label' => 'Connecté',
  15. 'background' => '#1BA1E2',
  16. 'color' => '#fffffff',
  17. 'onLoad' => 'action.php?action=dash_profil_plugin_load',
  18. 'onMove' => 'action.php?action=dash_profil_plugin_move',
  19. //'onSave' => 'action.php?action=dash_profil_plugin_save',
  20. 'onEdit' => 'action.php?action=dash_profi_plugin_edit',
  21. 'onDelete' => 'action.php?action=dash_profil_plugin_delete'
  22. );
  23. }
  24. function profil_plugin_actions(){
  25. global $myUser,$_,$conf;
  26. switch($_['action']){
  27. case 'dash_profi_plugin_edit':
  28. echo 'L\'edition de ce bloc est disponible depuis <a href="setting.php?section=profil">la page d\'edition du profil</a>';
  29. break;
  30. case 'dash_profil_plugin_load':
  31. header('content-type:application/json');
  32. $response['title'] = 'Connecté';
  33. $url_link = Functions::getBaseUrl('action.php').'/action.php';
  34. $response['content'] = '<div id="dash_application">'.$myUser->getGravatarImg().'
  35. <ul class="user-infos">
  36. <li><h1 onclick="window.location=\'setting.php?section=profil\';"><i class="fa fa-pencil"></i>'.$myUser->getFullName().'</h1></li>
  37. <li><a href="mailto:'.$myUser->getMail().'">'.$myUser->getMail().'</a></li>
  38. <li><div class="tokenbox" title="'.$myUser->getToken().'">Token : <br/><input type="text" onclick="$(this).select(); document.getElementById(\'Qrtoken\').style.display = \'block\'" value="'.$myUser->getToken().'"></div></li>
  39. <li><div class="tokenbox" id="Qrtoken" style="display:none;"><img src="https://api.qrserver.com/v1/create-qr-code/?size=100x100&data='.$myUser->getToken().'" alt="Qrcode for token"/></div></li>
  40. </ul>
  41. <a href="#yanaWindowsModal" role="button" data-toggle="modal" class="btn btn-primary"><i class="fa fa-download-alt fa fa-white"></i> Installer YANA Windows</a></div>
  42. <!-- Modal -->
  43. <div id="yanaWindowsModal" class="modal hide fade" style="width:750px;margin-left:-375px;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  44. <div class="modal-header">
  45. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  46. <h3 id="myModalLabel">Installer/Lier à yana windows</h3>
  47. </div>
  48. <div class="modal-body" >
  49. <p>Pour avoir accès à la partie vocale, vous devez installer yana-windows. Pour cela suivez les inscructions ci dessous.</p>
  50. <ul>
  51. <li>Si ce n\'est pas déja fait <a href="https://github.com/ldleman/yana-windows/archive/master.zip">téléchargez Yana Windows</a> et décompressez le.</li>
  52. <li>Exécutez le programme <b>"ScanSoft Virginie_Dri40_16kHz.exe"</b> pour installez la voix de yana</li>
  53. <li>Lancez le programme <b>"yana.exe"</b>, puis faites un clic droit sur l\'îcone de yana situé dans la barre de tâche et cliquez sur \'Configuration\'
  54. <li>Configurez \'Adresse du serveur\' avec la valeur suivante : <code>'.$url_link.'</code></li>
  55. <li>Dans le champs suivant, entrez le \'Token\' d\'identification suivant : <code>'.$myUser->getToken().'</code></li>
  56. <li>Cliquez sur enregistrer, le programme se relance et l\'installation est terminée !!</li>
  57. </ul>
  58. </div>
  59. <div class="modal-footer">
  60. <button class="btn" data-dismiss="modal" aria-hidden="true">Fermer</button>
  61. </div>
  62. </div>
  63. ';
  64. echo json_encode($response);
  65. break;
  66. case 'profile_set_profile':
  67. $myUser->setFirstName($_['firstname']);
  68. $myUser->setName($_['name']);
  69. $myUser->setLogin($_['login']);
  70. $myUser->setMail($_['mail']);
  71. $fields = array('mail'=>$myUser->getMail(),'login'=>$myUser->getLogin(),'firstname'=>$myUser->getFirstName(),'name'=>$myUser->getName());
  72. if(trim($_['password']) !=''){
  73. $fields['password'] = User::cryptPassword($_['password']);
  74. }
  75. $userManager = new User();
  76. $userManager->change($fields,array('id'=>$myUser->getId()));
  77. $_SESSION['currentUser'] = serialize($myUser);
  78. header('location: setting.php?section=profil');
  79. break;
  80. }
  81. }
  82. function profil_plugin_menu(){
  83. global $_;
  84. echo '<li '.((isset($_['section']) && $_['section']=='profil') ?'class="active"':'').'><a href="setting.php?section=profil"><i class="fa fa-angle-right"></i> Profil</a></li>';
  85. }
  86. function profil_plugin_page(){
  87. global $myUser,$_,$conf;
  88. if((isset($_['section']) && $_['section']=='profil') ){
  89. if($myUser!=false){
  90. ?>
  91. <div class="span9 userBloc">
  92. <h1>Mon profil</h1>
  93. <p>Page de profil de <?php echo $myUser->getFullName(); ?></p>
  94. <form class="left" action="action.php?action=profile_set_profile" style="margin-right:15px;" method="POST">
  95. <label for="name">Nom</label>
  96. <input type="text" class="input-large" id="name" name="name" value="<?php echo $myUser->getName(); ?>"><br/>
  97. <label for="firstname">Prénom</label>
  98. <input type="text" class="input-large" id="firstname" name="firstname" value="<?php echo $myUser->getFirstName(); ?>"><br/>
  99. <label for="login">Identifiant</label>
  100. <input type="text" class="input-large" id="login" name="login" value="<?php echo $myUser->getLogin(); ?>"><br/>
  101. <label for="mail">Email</label>
  102. <input type="text" class="input-large" id="mail" name="mail" value="<?php echo $myUser->getMail(); ?>"><br/>
  103. <label for="password">Mot de passe</label>
  104. <input type="password" class="input-large" id="password" name="password" value=""><br/>
  105. <button type="submit" class="btn">Modifier</button><br/>
  106. <br/>
  107. </form>
  108. </div>
  109. <?php }else{ ?>
  110. <div id="main" class="wrapper clearfix">
  111. <article>
  112. <h3>Vous devez être connecté</h3>
  113. </article>
  114. </div>
  115. <?php
  116. }
  117. }
  118. }
  119. Plugin::addCss('/css/style.css',true);
  120. Plugin::addHook("setting_menu", "profil_plugin_menu");
  121. Plugin::addHook("setting_bloc", "profil_plugin_page");
  122. Plugin::addHook("action_post_case", "profil_plugin_actions");
  123. Plugin::addHook("widgets", "dash_profil_plugin_menu");
  124. ?>