%{
}%
%TMPL:INCLUDE{"view"}%<!-- -->
%TMPL:DEF{"revinfo"}%%TMPL:END%
%TMPL:DEF{"topicactions"}%%TMPL:END%
%TMPL:DEF{"breadcrumbs::tail"}%%IF{"$'URLPARAM{group}'!=''" then="%TMPL:P{"sep"}%<a href='%SCRIPTURLPATH{"view"}%/%WEB%/%TOPIC%?group=%URLPARAM{"group"}%'>%URLPARAM{"group"}%</a>"}%%TMPL:END%
%{
}%

%{
}%
%TMPL:DEF{"title"}%<noautolink>%HTMLTITLE{
  separator=" %TMPL:P{"titlesep"}% "
  format="%URLPARAM{"group" default="%TOPIC%"}%$sep$webtitle$wikitoolname"
}%</noautolink>%TMPL:END%
%{
}%

%{
}%
%TMPL:DEF{"content"}%<noautolink>%IF{"$'URLPARAM{group}' != ''"
  then="$percntTMPL:P{\"displaygroup\" group=\"$percntURLPARAM{group}$percnt\"}$percnt"
  else="$percntTMPL:P{\"listgroups\"}$percnt"
}%</noautolink>%TMPL:END%
%{
}%

%{
}%
%TMPL:DEF{"listgroups"}%<!-- -->
<h1 > %TOPICTITLE% </h1>
%TMPL:P{context="authenticated" "creategroup"}%<!-- -->
%MAKEINDEX{"%GROUPINFO%"
  header="$anchors$n"
  sort="nocase"
  format="<a href='%SCRIPTURLPATH{"view"}%/%WEB%/$percntIF{\"istopic '%WEB%.$item'\" then=\"$item\" else=\"%TOPIC%?group=$item\"}$percnt'>$item</a>"
  footer="<p><span class='foswikiAlert'>$count</span> groups found</p>"
}%
<!-- -->%TMPL:END%
%{
}%

%{
}%
%TMPL:DEF{"creategroup"}%
%TWISTY{
  link="%BUTTON{"%MAKETEXT{"New group"}%" icon="group"}%"
  mode="div"
}%
<form class="createGroupForm" action="%SCRIPTURLPATH{"manage"}%/%WEB%/%TOPIC%" method="post">
<input type="hidden" name="action" value="addUserToGroup" />
<input type="hidden" name="create" value="1" />
<input type="hidden" name="username" value=" " />
<input type="hidden" name="redirectto" value="%WEB%.%TOPIC%" />
<div class="foswikiFormSteps">
  <div class="foswikiFormStep ">
    <h3>%MAKETEXT{"Group name"}%</h3>
    <input type="text" name="groupname" size="30" class="foswikiInputField" value="%URLPARAM{"groupname"}%" /> 
    <div class="foswikiFormDescription">
      %MAKETEXT{"*Note:* A group name must be a [[%SYSTEMWEB%.WikiWord][WikiWord]] and end in ...Group."}%
    </div>
  </div>
  <div class="foswikiFormStep">
    %BUTTON{"%MAKETEXT{"Submit"}%" icon="tick" type="submit"}%%CLEAR%
  </div>
</div>
</form>
%ENDTWISTY%
%ADDTOZONE{"script" id="WIKIGROUPS::JS" requires="JQUERYPLUGIN" text="<script type='text/javascript'>
jQuery(function($) {
  $('.createGroupForm').submit(function() {
    var $this = $(this),
        groupName = $this.find('input[name=groupname]').val();
    if (groupName !== '') {
      $this.find('input[name=redirectto]').val('%WEB%.'+groupName);
    }
  });
});
</script>"}%%TMPL:END%
%{
}%

%{
}%
%TMPL:DEF{"displaygroup"}%<!-- -->
<h1 >
  %IF{"istopic '%USERSWEB%.%group%'" 
  then="[[%USERSWEB%.%group%][%group%]]" 
  else="<nop>%group%"
}%</h1>

%IF{"istopic '%USERSWEB%.%group%'"
  then="$percntINCLUDE{\"%WEB%.%group%\"}$percnt"
  else="<!-- -->"
}%

%IF{"'%USERSWEB%.%group%' allows 'change' and istopic '%USERSWEB%.%group%' and '%group%' != 'NobodyGroup'"
  then="$percntTMPL:P{\"editablegroup\" group=\"%group%\"}$percnt"
  else="$percntTMPL:P{\"noneditablegroup\"  group=\"%group%\"}$percnt"
}%
<!-- -->%TMPL:END%
%{
}%

%{
}%
%TMPL:DEF{"editablegroup"}%
%TWISTYBUTTON{id="add" mode="span" link="%BUTTON{"%MAKETEXT{"Add member"}%" icon="add" class="addButton"}%"}%
%BUTTON{"%MAKETEXT{"Edit group"}%" icon="pencil" href="%SCRIPTURLPATH{"edit"}%/%WEB%/%URLPARAM{"group" default="%TOPIC%"}%?t=%GMTIME{"$epoch"}%"}%
%BUTTON{"%MAKETEXT{"Rename group "}%" icon="page_white_go" href="%SCRIPTURLPATH{"rename"}%/%WEB%/%URLPARAM{"group" default="%TOPIC%"}%"}%
%BUTTON{"%MAKETEXT{"Remove members"}%" icon="delete" class="removeButton" style="display:none"}%
%CLEAR%
%TWISTYTOGGLE{id="add"}%

<form class='jqAjaxForm' action='%SCRIPTURLPATH{"manage"}%/%WEB%/%group%' method='post'> 
<input type='hidden' name='groupname' value='%group%'/> 
<input type='hidden' name='action' value='addUserToGroup'/>
<div class='foswikiFormSteps'>
  <div class='foswikiFormStep'>
     <h3>%MAKETEXT{"Add users or groups to this group"}%</h3>%JQREQUIRE{"textboxlist, form, blockui"}%

     <input type='text' name='username' value='' size='30' class='foswikiInputField jqTextboxList' autocomplete='%SCRIPTURL{"view"}%/%SYSTEMWEB%/JQueryAjaxHelper?section=user;skin=text;contenttype=application/json;baseweb=%USERSWEB%' />
  </div>
  <div class='foswikiFormStep'>
     %BUTTON{"%MAKETEXT{"Submit"}%" icon="add" type="submit"}%
     %CLEAR%
  </div>
</div>
</form>
%ENDTWISTY%

%FORMATLIST{"%GROUPINFO{"%group%" format="$wikiname" separator=", " expand="0"}%"
  header="<form class='editGroupForm jqAjaxForm' action='%SCRIPTURLPATH{"manage"}%/%WEB%/%group%' method='post'>
    <input type='hidden' name='groupname' value='%group%' />
    <input type='hidden' name='action' value='removeUserFromGroup' />
    <div class='foswikiPageForm'>
      <table class='foswikiLayoutTable'>
      <tr><th>#</th><th>%MAKETEXT{"Name"}%</th><th>%MAKETEXT{"Select"}%</th></tr>"
  format="<tr> 
      <td> $index. </td> 
      <td> 
        $percntIF{\"'$percntUSERINFO{\"$1\" format=\"$isgroup\"}$percnt'='true'\"
          then=\"<a href='%SCRIPTURLPATH{"view"}%/%USERSWEB%/WikiGroups?group=$1'>$1</a> (%MAKETEXT{"group"}%)\"
          else=\"[[$1]]\"
        }$percnt
      </td> 
      <td align='right'><input type='checkbox' name='username' value='$1' class='foswikiCheckbox' /></td>
    </tr>"
  separator="$n"
  footer="</table></div>"
  sort="on"
  casesensitive="off"
}%
</form>
%ADDTOZONE{"script"
  id="WIKIGROUPS::JAVASCRIPT"
  requires="JQUERYPLUGIN::FORM, JQUERYPLUGIN::BLOCKUI"
  text="<script class='$id'>
jQuery(function($) {
  $('.editGroupForm').each(function() {
    var $this = $(this);

    $this.find('input[type=\"checkbox\"]').change(function() {
      if ($this.find('input[type=\"checkbox\"]:checked').length) {
        $('.removeButton').fadeIn();
      } else {
        $('.removeButton').hide();
      }
    });
  });

  $('.jqAjaxForm').each(function() {
    var $this = $(this),
        action = $this.find('input[name=\"action\"]').val();

    $this.removeAttr('onsubmit');
    $this.ajaxForm({
      beforeSerialize: function() {
        if (typeof(StrikeOne) !== 'undefined') {
          StrikeOne.submit($this[0]);
        }
        $.blockUI({message:'<h1>' + (action == 'removeUserFromGroup'?'%MAKETEXT{"Removing"}%':'%MAKETEXT{"Adding"}%') + ' ...'});
      }, 
      error: function() {
        $.unblockUI();
        alert('%MAKETEXT{"Woops, there was an error adding/removing a user to this group"}%');
      },
      success: function() {
        $.unblockUI();
        window.location.reload();
      }
    });
  });

  $('.removeButton').click(function() {
    $('.editGroupForm').submit();
    return false;
  });
});
</script>"
}%%TMPL:END%
%{
}%

%{
}%
%TMPL:DEF{"noneditablegroup"}%<!-- -->
%FORMATLIST{"%GROUPINFO{"%group%" format="$wikiname" separator=", " expand="0"}%"
  header="<ol>"
  footer="</ol>"
  format="<li>$percntIF{\"istopic '%USERSWEB%.$1'\"
      then=\"[[%USERSWEB%.$1]]\"
      else=\"$percntIF{\"'$percntUSERINFO{\"$1\" format=\"$isgroup\"}$percnt'='true'\"
          then=\"<a href='%SCRIPTURLPATH{"view"}%/%USERSWEB%/WikiGroups?group=$1'>$1</a> (%MAKETEXT{"group"}%)\"
          else=\"[[$1]]\"
        }$percnt\"
    }$percnt</li>"
  separator="$n"
  expand="0"
  sort="on"
}%%TMPL:END%
%{
}%
Topic revision: r2 - 08 Oct 2017, AdminUser
This site is powered by FoswikiCopyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback