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.

121 lines
3.4 KiB

  1. <?php
  2. /**
  3. * @package Widgets
  4. *
  5. * @file GroupConfig.php
  6. * This file is part of MOVIM.
  7. *
  8. * @brief The Group configuration widget
  9. *
  10. * @author Ho Christine <nodpounod@gmail.com>
  11. *
  12. * @version 1.0
  13. * @date 12 March 2013
  14. *
  15. * Copyright (C)2010 MOVIM project
  16. *
  17. * See COPYING for licensing information.
  18. */
  19. use Moxl\Xec\Action\Pubsub\GetConfig;
  20. use Moxl\Xec\Action\Pubsub\SetConfig;
  21. class NodeConfig extends WidgetBase
  22. {
  23. function load()
  24. {
  25. $this->registerEvent('pubsubconfig', 'onConfigForm');
  26. $this->registerEvent('pubsubconfigsubmited', 'onGroupConfig');
  27. $this->registerEvent('deletionsuccess', 'onGroupDeleted');
  28. }
  29. function display()
  30. {
  31. if(isset($_GET['s']) && isset($_GET['n'])) {
  32. $nd = new modl\ItemDAO();
  33. $node = $nd->getItem($_GET['s'], $_GET['n']);
  34. if($node != null)
  35. $title = $node->getName();
  36. else
  37. $title = $groupid;
  38. $this->view->assign('server', $_GET['s']);
  39. $this->view->assign('node', $_GET['n']);
  40. $this->view->assign('name', $title);
  41. $this->view->assign('group_config', $this->genCallAjax('ajaxGroupConfig', "'".$_GET['s']."'", "'".$_GET['n']."'"));
  42. $this->view->assign('group_delete', $this->genCallAjax('ajaxGroupDelete', "'".$_GET['s']."'", "'".$_GET['n']."'"));
  43. }
  44. }
  45. function onGroupDeleted($server) {
  46. $html = '
  47. <a href="'.Route::urlize('server', $server).'">
  48. '.t("Return to %s's list of groups", $server).'
  49. </a><br /><br />';
  50. Notification::appendNotification(t('Group deleted'), 'success');
  51. RPC::call('movim_fill', 'handlingmessages', $html);
  52. RPC::commit();
  53. }
  54. function onGroupConfig($stanza) {
  55. Notification::appendNotification(t('Group configuration saved'), 'success');
  56. RPC::commit();
  57. }
  58. function onConfigForm($form) {
  59. $submit = $this->genCallAjax('ajaxSubmitConfig', "movim_parse_form('config')", "'".$form[1]."'", "'".$form[2]."'");
  60. $html = '
  61. <form name="config">'.
  62. $form[0].
  63. '
  64. <hr /><br />
  65. <a
  66. class="button color green icon yes"
  67. style="float: right;"
  68. onclick="
  69. '.$submit.'
  70. this.onclick=null;
  71. this.style.display = \'none\'
  72. "
  73. >
  74. '.t('Validate').'
  75. </a>
  76. <br />
  77. <br />
  78. </form>';
  79. RPC::call('movim_fill', 'groupconfiguration', $html);
  80. RPC::commit();
  81. }
  82. function ajaxGroupConfig($server, $node){
  83. $r = new GetConfig;
  84. $r->setTo($server)
  85. ->setNode($node)
  86. ->request();
  87. }
  88. function ajaxGroupDelete($server, $node){
  89. $nd = new \Modl\ItemDAO();
  90. $nd->deleteItem($server, $node);
  91. $r = new \Moxl\GroupDelete();
  92. $r->setTo($server)
  93. ->setNode($node)
  94. ->request();
  95. }
  96. function ajaxSubmitConfig($data, $server, $node){
  97. $r = new SetConfig;
  98. $r->setTo($server)
  99. ->setNode($node)
  100. ->setData($data)
  101. ->request();
  102. }
  103. }
  104. ?>