share.dropdown.php 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. if(array_key_exists('calid', $_)){
  3. $id = $_['calid'];
  4. $sharedelements = OC_Calendar_Share::allUsersSharedwith($_['calid'], OC_Calendar_Share::CALENDAR);
  5. }else{
  6. $sharedelements = OC_Calendar_Share::allUsersSharedwith($_['eventid'], OC_Calendar_Share::EVENT);
  7. $id = $_['eventid'];
  8. }
  9. $users = array();$groups = array();$public = array();
  10. foreach($sharedelements as $sharedelement){
  11. if($sharedelement['sharetype'] == 'user'){
  12. $users[] = $sharedelement;
  13. }elseif($sharedelement['sharetype'] == 'group'){
  14. $groups[] = $sharedelement;
  15. }elseif($sharedelement['sharetype'] == 'public'){
  16. $public = $sharedelement;
  17. }
  18. }
  19. ?>
  20. <strong><?php echo $l->t('Users');?>:</strong><br>
  21. <select id="share_user" title="<?php echo $l->t('select users');?>" data-placeholder="<?php echo $l->t('select users'); ?>">
  22. <option value=""></option>
  23. <?php
  24. $allocusers = OCP\USER::getUsers();
  25. $allusers = array();
  26. foreach($allocusers as $ocuser){
  27. $allusers[$ocuser] = $ocuser;
  28. }
  29. unset($allusers[OCP\USER::getUser()]);
  30. $allusers = array_flip($allusers);
  31. echo OCP\html_select_options($allusers, array());
  32. ?>
  33. </select><br>
  34. <ul id="sharewithuser_list">
  35. <?php foreach($users as $user): ?>
  36. <li id="sharewithuser_<?php echo $user['share']; ?>"><input type="checkbox" width="12px" <?php echo ($user['permissions']?'checked="checked"':'')?> style="visibility:hidden;" title="<?php echo $l->t('Editable'); ?>"><?php echo $user['share']; ?><img src="<?php echo OC::$WEBROOT; ?>/core/img/actions/delete.svg" class="svg action" style="display:none;float:right;"></li>
  37. <script>
  38. $('#sharewithuser_<?php echo $user['share']; ?> > img').click(function(){
  39. $('#share_user option[value="<?php echo $user['share']; ?>"]').removeAttr('disabled');
  40. Calendar.UI.Share.unshare(<?php echo $id; ?>, '<?php echo (array_key_exists('calid', $_)?'calendar':'event');?>', '<?php echo $user['share']; ?>', 'user');
  41. $('#sharewithuser_<?php echo $user['share']; ?>').remove();
  42. $("#share_user").trigger("liszt:updated");
  43. });
  44. $('#share_user option[value="<?php echo $user['share']; ?>"]').attr('disabled', 'disabled');
  45. </script>
  46. <?php endforeach; ?>
  47. </ul>
  48. <strong><?php echo $l->t('Groups');?>:</strong><br>
  49. <select id="share_group" title="<?php echo $l->t('select groups');?>" data-placeholder="<?php echo $l->t('select groups'); ?>">
  50. <option value=""></option>
  51. <?php
  52. $allocgroups = OC_Group::getGroups();
  53. $allgroups = array();
  54. foreach($allocgroups as $ocgroup){
  55. $allgroups[$ocgroup] = $ocgroup;
  56. }
  57. echo OCP\html_select_options($allgroups, array());
  58. ?>
  59. </select><br>
  60. <ul id="sharewithgroup_list">
  61. <?php foreach($groups as $group): ?>
  62. <li id="sharewithgroup_<?php echo $group['share']; ?>"><input type="checkbox" width="12px" <?php echo ($group['permissions']?'checked="checked"':'')?> style="visibility:hidden;" title="<?php echo $l->t('Editable'); ?>"><?php echo $group['share']; ?><img src="<?php echo OC::$WEBROOT; ?>/core/img/actions/delete.svg" class="svg action" style="display:none;float:right;"></li>
  63. <script>
  64. $('#sharewithgroup_<?php echo $group['share']; ?> > img').click(function(){
  65. $('#share_group option[value="<?php echo $group['share']; ?>"]').removeAttr('disabled');
  66. Calendar.UI.Share.unshare(<?php echo $id; ?>, '<?php echo (array_key_exists('calid', $_)?'calendar':'event');?>', '<?php echo $group['share']; ?>', 'group');
  67. $('#sharewithgroup_<?php echo $group['share']; ?>').remove();
  68. $("#share_group").trigger("liszt:updated");
  69. });
  70. $('#share_group option[value="<?php echo $group['share']; ?>"]').attr('disabled', 'disabled');
  71. </script>
  72. <?php endforeach; ?>
  73. </ul>
  74. <div id="public">
  75. <input type="checkbox" id="publish" <?php echo (array_key_exists('share', $public))?'checked="checked"':'' ?>><label for="publish"><?php echo $l->t('make public'); ?></label><br>
  76. <input type="text" id="public_token" value="<?php if(array_key_exists('share', $public)){echo OCP\Util::linkToAbsolute('', 'public.php').'?service=calendar&t=' . $public['share']; } ?>" onmouseover="$('#public_token').select();" style="<?php echo (!array_key_exists('share', $public))?'display:none':'' ?>">
  77. </div>