<h1 tal:replace="structure here/manage_page_header">Header</h1>
<h2 tal:define="manage_tabs_message options/manage_tabs_message | nothing"
    tal:replace="structure here/manage_tabs">Tabs</h2>

  <ol>
    <p class="form-help">
      You are currently running <strong>GRUF v.<span tal:replace="here/getGRUFVersion">version</span></strong><br />
      Information, latest version, documentation... see 
      <a target="_blank" href="http://ingeniweb.sourceforge.net/Products/GroupUserFolder">The GRUF Webpage</a>.
    </p>
  </ol>

  <!-- Show problems if it happens -->
  <div tal:condition="request/GRUF_PROBLEM|nothing">
    <font color="red"><strong><span tal:content="request/GRUF_PROBLEM">gruf message</span></strong></font>
  </div>


  <h4>Users folders management</h4>
  <ol>
    <p class="form-help">Use this form to check/manage the underlying user folders.</p>
    <p class="form-help">BE CAREFUL THAT MISUSE OF THIS FORM CAN LEAD YOU TO UNRECOVERABLE LOSS OF USER DATA.</p>
    <p class="form-help">For this reason, all destructive actions (ie. replacing or deleting) with existing UserFolders must be confirmed
    by clicking the rightmost checkbox.</p>

    <form action="" tal:attributes="action string:${here/absolute_url}" method="POST">
      <!-- Users selection -->
      <table bgcolor="#EEEEEE" tal:on-error="nothing">
        <tr>
          <td rowspan="2" valign="middle"></td>
          <th class="list-header" rowspan="2" valign="middle">Type</th>
          <th class="list-header" colspan="4">Actions</th>
        </tr>
        <tr class="list-header">
          <th>Move</th>
          <th>Replace</th>
          <th>Delete</th>
          <th>Confirm</th>
        </tr>

        <!-- Groups source row -->
        <tr>
          <th class="list-header">Groups source</th>
          <td bgcolor="#EEEEEE">
              <img src="" tal:attributes="src here/Groups/acl_users/icon">&nbsp;
              <a href="Groups/acl_users/manage_workspace" tal:content="here/Groups/acl_users/meta_type">Type</a>
          </td>
          <td></td>
          <td bgcolor="#EEEEEE">
            <table border="0">
              <tr>
                <td align="left">
                  <input type="hidden" name="source_rec.id:records" value="Groups" />
                  <select name="source_rec.new_factory:records">
                    <option value="">-- Select your source type --</option>
                    <tal:block tal:repeat="source here/listAvailableUserSources">
                      <option value="" 
                              tal:condition="python:source[0] != path('here/Groups/acl_users/meta_type')"
                        tal:attributes="value python:source[1]">
                        <span tal:replace="python:source[0]">name</span>
                      </option>
                    </tal:block>
                  </select>
                </td>
                <td align="right">
                  <input type="submit" name="replaceUserSource:action" value="Ok" />
                </td>
              </tr>
            </table>
          </td>
          <td class="list-item">(forbidden)</td>
          <td bgcolor="#EEEEEE" class="list-item">
            <input type="checkbox" name="id" value="Groups" />I'm sure
          </td>
        </tr>


        <!-- Users sources row -->
        <tr tal:repeat="source here/listUserSourceFolders">
          <th class="list-header">Users source #<span tal:replace="repeat/source/number">1</span></th>
          <td bgcolor="#EEEEEE" tal:condition="source/isValid">
            <img src="" tal:attributes="src source/acl_users/icon">&nbsp;
              <a href="" tal:attributes="href string:${source/acl_users/absolute_url}/manage_workspace" tal:content="source/acl_users/meta_type">Type</a>
          </td>
          <td bgcolor="#EEEEEE" tal:condition="not:source/isValid">
            <font color="red"><strong><i>(invalid or broken)</i></strong></font>
          </td>
          <td bgcolor="#EEEEEE" align="center">
            <a tal:condition="not:repeat/source/start" 
              tal:attributes="href string:${here/absolute_url}/moveUserSourceUp?id=${source/getUserSourceId}"
              href=""><img src="img_up_arrow" border="0" alt="Move up"></a>
            <span tal:condition="repeat/source/start"><img src="img_up_arrow_grey" border="0" alt="Move up"></span>
            &nbsp;
            <a tal:condition="not:repeat/source/end" 
              tal:attributes="href string:${here/absolute_url}/moveUserSourceDown?id=${source/getUserSourceId}"
              href=""><img src="img_down_arrow" border="0" alt="Move down"></a>
            <span tal:condition="repeat/source/end"><img src="img_down_arrow_grey" border="0" alt="Move down"></span>
          </td>
          <td bgcolor="#EEEEEE">
            <table border="0">
              <tr>
                <td align="left">
                  <input type="hidden" name="source_rec.id:records" value="" tal:attributes="value source/getUserSourceId" />
                  <select name="source_rec.new_factory:records">
                    <option value="">-- Select your source type --</option>
                    <tal:block tal:repeat="new_source here/listAvailableUserSources">
                      <option value="" 
                              tal:condition="python:new_source[0] != path('source/acl_users/meta_type')"
                        tal:attributes="value python:new_source[1]">
                        <span tal:replace="python:new_source[0]">name</span>
                      </option>
                    </tal:block>
                  </select>
                </td>
                <td align="right">
                  <input type="submit" name="replaceUserSource:action" value="Ok" />
                </td>
              </tr>
            </table>
          </td>
          <td bgcolor="#EEEEEE" tal:condition="python:repeat['source'].length > 1" class="list-item">
            <input 
                   type="submit" 
                   name="deleteUserSource:action" 
                   value="Delete" />
          </td>
          <td tal:condition="python:not repeat['source'].length > 1" class="list-item">
            (forbidden)
          </td>
          <td bgcolor="#EEEEEE" class="list-item">
            <input type="checkbox" name="id" value="" tal:attributes="value source/getUserSourceId" />I'm sure
          </td>
        </tr>


        <!-- Blank row -->
        <tr>
          <td class="list-item" colspan="5">&nbsp;</td>
        </tr>

        <!-- New sources row -->
        <tr>
          <th class="list-header">Add...</th>
          <td colspan="5" class="list-item">
            <select name="factory_uri">
              <option value="">-- Select your source type --</option>
              <option value="" tal:repeat="source here/listAvailableUserSources" tal:attributes="value python:source[1]">
                <span tal:replace="python:source[0]">name</span>
              </option>
            </select>
            <input type="submit" name="addUserSource:method" value="Add" />
          </td>
        </tr>
      </table>
    </form>
    
  </ol>
<h1 tal:replace="structure here/manage_page_footer">Footer</h1>
