groupsave.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * Elgg notifications groups subscription form
  4. *
  5. * @package ElggNotifications
  6. *
  7. * @uses $vars['user'] ElggUser
  8. */
  9. /* @var ElggUser $user */
  10. $user = $vars['user'];
  11. $NOTIFICATION_HANDLERS = _elgg_services()->notifications->getMethodsAsDeprecatedGlobal();
  12. foreach ($NOTIFICATION_HANDLERS as $method => $foo) {
  13. $subsbig[$method] = elgg_get_entities_from_relationship(array(
  14. 'relationship' => 'notify' . $method,
  15. 'relationship_guid' => $user->guid,
  16. 'type' => 'group',
  17. 'limit' => false,
  18. ));
  19. $tmparray = array();
  20. if ($subsbig[$method]) {
  21. foreach($subsbig[$method] as $tmpent) {
  22. $tmparray[] = $tmpent->guid;
  23. }
  24. }
  25. $subsbig[$method] = $tmparray;
  26. }
  27. ?>
  28. <div class="elgg-module elgg-module-info">
  29. <div class="elgg-body">
  30. <?php
  31. echo elgg_view('notifications/subscriptions/jsfuncs',$vars);
  32. ?>
  33. <div>
  34. <?php
  35. echo elgg_echo('notifications:subscriptions:groups:description');
  36. ?>
  37. </div>
  38. <?php
  39. if (isset($vars['groups']) && !empty($vars['groups'])) {
  40. ?>
  41. <table id="notificationstable" cellspacing="0" cellpadding="4" width="100%">
  42. <tr>
  43. <td>&nbsp;</td>
  44. <?php
  45. $i = 0;
  46. foreach($NOTIFICATION_HANDLERS as $method => $foo) {
  47. if ($i > 0) {
  48. echo "<td class='spacercolumn'>&nbsp;</td>";
  49. }
  50. ?>
  51. <td class="<?php echo $method; ?>togglefield"><?php echo elgg_echo('notification:method:'.$method); ?></td>
  52. <?php
  53. $i++;
  54. }
  55. ?>
  56. <td>&nbsp;</td>
  57. </tr>
  58. <?php
  59. foreach($vars['groups'] as $group) {
  60. $fields = '';
  61. $i = 0;
  62. foreach($NOTIFICATION_HANDLERS as $method => $foo) {
  63. if (in_array($group->guid,$subsbig[$method])) {
  64. $checked[$method] = 'checked="checked"';
  65. } else {
  66. $checked[$method] = '';
  67. }
  68. if ($i > 0) {
  69. $fields .= "<td class=\"spacercolumn\">&nbsp;</td>";
  70. }
  71. $fields .= <<< END
  72. <td class="{$method}togglefield">
  73. <a border="0" id="{$method}{$group->guid}" class="{$method}toggleOff" onclick="adjust{$method}_alt('{$method}{$group->guid}');">
  74. <input type="checkbox" name="{$method}subscriptions[]" id="{$method}checkbox" onclick="adjust{$method}('{$method}{$group->guid}');" value="{$group->guid}" {$checked[$method]} /></a></td>
  75. END;
  76. $i++;
  77. }
  78. ?>
  79. <tr>
  80. <td class="namefield">
  81. <div>
  82. <?php echo $group->name; ?>
  83. </div>
  84. </td>
  85. <?php echo $fields; ?>
  86. <td>&nbsp;</td>
  87. </tr>
  88. <?php
  89. }
  90. ?>
  91. </table>
  92. <?php
  93. }
  94. echo '<div class="elgg-foot mtm">';
  95. echo elgg_view('input/hidden', array('name' => 'guid', 'value' => $user->guid));
  96. echo elgg_view('input/submit', array('value' => elgg_echo('save')));
  97. echo '</div>';
  98. ?>
  99. </div>
  100. </div>