You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.2 KiB

  1. <?php
  2. /**
  3. * @package Widgets
  4. *
  5. * @file Statistics.php
  6. * This file is part of MOVIM.
  7. *
  8. * @brief The administration widget.
  9. *
  10. * @author Timothée Jaussoin <edhelas@gmail.com>
  11. * *
  12. * Copyright (C)2014 MOVIM project
  13. *
  14. * See COPYING for licensing information.
  15. */
  16. class Api extends WidgetBase {
  17. function load()
  18. {
  19. }
  20. function display()
  21. {
  22. $this->view->assign(
  23. 'infos',
  24. $this->__(
  25. 'api.info',
  26. '<a href="http://api.movim.eu/" target="_blank">',
  27. '</a>',
  28. '<a href="'.$this->route('pods').'">',
  29. '</a>'));
  30. $json = requestURL(MOVIM_API.'status', 1, array('uri' => BASE_URI));
  31. $json = json_decode($json);
  32. $conf = Conf::getServerConf();
  33. if(isset($json)) {
  34. $this->view->assign('json', $json);
  35. if($json->status == 200) {
  36. $this->view->assign('unregister', $this->genCallAjax('ajaxUnregister'));
  37. $this->view->assign('unregister_status', $conf['unregister']);
  38. } else {
  39. $conf['unregister'] = false;
  40. Conf::saveConfFile($conf);
  41. $this->view->assign('register', $this->genCallAjax('ajaxRegister'));
  42. }
  43. } else {
  44. $this->view->assign('json', null);
  45. }
  46. }
  47. function ajaxRegister()
  48. {
  49. $rewrite = false;
  50. if(isset($_SERVER['HTTP_MOD_REWRITE']) && $_SERVER['HTTP_MOD_REWRITE']) {
  51. $rewrite = true;
  52. }
  53. $json = requestURL(
  54. MOVIM_API.'register',
  55. 1,
  56. array(
  57. 'uri' => BASE_URI,
  58. 'rewrite' => $rewrite));
  59. $json = json_decode($json);
  60. if(isset($json) && $json->status == 200) {
  61. RPC::call('movim_reload_this');
  62. Notification::appendNotification(t('Configuration updated'));
  63. }
  64. }
  65. function ajaxUnregister()
  66. {
  67. $conf = Conf::getServerConf();
  68. $conf['unregister'] = !$conf['unregister'];
  69. Conf::saveConfFile($conf);
  70. sleep(2);
  71. RPC::call('movim_reload_this');
  72. RPC::commit();
  73. }
  74. }