Changeset 2921


Ignore:
Timestamp:
Nov 15, 2006, 2:22:44 PM (16 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #348: Take ownership of items

Location:
trunk/www/admin
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/admin/annotationtypecategories/index.jsp

    r2811 r2921  
    4242  import="net.sf.basedb.util.RemovableUtil"
    4343  import="net.sf.basedb.util.ShareableUtil"
     44  import="net.sf.basedb.util.OwnableUtil"
    4445  import="net.sf.basedb.clients.web.Base"
    4546  import="net.sf.basedb.clients.web.WebException"
     
    232233    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    233234  }
     235  else if ("TakeOwnershipOfItem".equals(cmd))
     236  {
     237    // Take ownership a single item and then return to the view page
     238    dc = sc.newDbControl();
     239    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     240    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     241    dc.commit();
     242    redirect = viewPage;
     243  }
     244  else if ("TakeOwnershipOfItems".equals(cmd))
     245  {
     246    // Take ownership all selected items on the list page
     247    dc = sc.newDbControl();
     248    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     249    int numTotal = cc.getSelected().size();
     250    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     251    dc.commit();
     252    if (numTotal != numOwned)
     253    {
     254      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     255    }
     256    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     257  }
    234258  else if ("ExportItems".equals(cmd))
    235259  {
  • trunk/www/admin/annotationtypecategories/list_categories.jsp

    r2753 r2921  
    144144      frm.submit();
    145145    }
     146    function takeOwnership()
     147    {
     148      var frm = document.forms[formId];
     149      if (Forms.numChecked(frm) == 0)
     150      {
     151        alert('Please select at least one item in the list');
     152        return;
     153      }
     154      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     155      {
     156        frm.action = submitPage;
     157        frm.cmd.value = 'TakeOwnershipOfItems';
     158        frm.submit();
     159      }
     160    }
    146161    function shareItems()
    147162    {
     
    262277          title="Share…"
    263278          tooltip="Share the selected items"
     279        />
     280        <tbl:button
     281          image="take_ownership.png"
     282          onclick="takeOwnership()"
     283          title="Take ownership&hellip;"
     284          tooltip="Take ownership of the selected items"
    264285        />
    265286        <tbl:button
  • trunk/www/admin/annotationtypecategories/view_category.jsp

    r2753 r2921  
    7373  final boolean deletePermission = annotationTypeCategory.hasPermission(Permission.DELETE);
    7474  final boolean sharePermission = annotationTypeCategory.hasPermission(Permission.SET_PERMISSION);
     75  final boolean setOwnerPermission = annotationTypeCategory.hasPermission(Permission.SET_OWNER);
     76  final boolean isOwner = annotationTypeCategory.isOwner();
    7577  %>
    76 
    7778  <base:page title="<%=title%>">
    7879  <base:head scripts="tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
     
    9394    {
    9495      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     96    }
     97    function takeOwnership()
     98    {
     99      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     100      {
     101        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     102      }
    95103    }
    96104    function runPlugin(cmd)
     
    141149        title="Share&hellip;"
    142150        tooltip="<%=sharePermission ? "Share this annotation type category to other user, groups and projects" : "You do not have permission to share this annotation type"%>"
     151      />
     152      <tbl:button
     153        disabled="<%=setOwnerPermission ? false : true%>"
     154        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     155        onclick="takeOwnership()"
     156        title="Take ownership&hellip;"
     157        visible="<%=!isOwner%>"
     158        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    143159      />
    144160      <tbl:button
  • trunk/www/admin/annotationtypes/index.jsp

    r2875 r2921  
    4242  import="net.sf.basedb.util.RemovableUtil"
    4343  import="net.sf.basedb.util.ShareableUtil"
     44  import="net.sf.basedb.util.OwnableUtil"
    4445  import="net.sf.basedb.clients.web.Base"
    4546  import="net.sf.basedb.clients.web.WebException"
     
    325326    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    326327  }
     328  else if ("TakeOwnershipOfItem".equals(cmd))
     329  {
     330    // Take ownership a single item and then return to the view page
     331    dc = sc.newDbControl();
     332    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     333    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     334    dc.commit();
     335    redirect = viewPage;
     336  }
     337  else if ("TakeOwnershipOfItems".equals(cmd))
     338  {
     339    // Take ownership all selected items on the list page
     340    dc = sc.newDbControl();
     341    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     342    int numTotal = cc.getSelected().size();
     343    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     344    dc.commit();
     345    if (numTotal != numOwned)
     346    {
     347      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     348    }
     349    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     350  }
    327351  else if ("ExportItems".equals(cmd))
    328352  {
  • trunk/www/admin/annotationtypes/list_annotationtypes.jsp

    r2875 r2921  
    170170      frm.submit();
    171171    }
     172    function takeOwnership()
     173    {
     174      var frm = document.forms[formId];
     175      if (Forms.numChecked(frm) == 0)
     176      {
     177        alert('Please select at least one item in the list');
     178        return;
     179      }
     180      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     181      {
     182        frm.action = submitPage;
     183        frm.cmd.value = 'TakeOwnershipOfItems';
     184        frm.submit();
     185      }
     186    }
    172187    function shareItem(itemId)
    173188    {
     
    356371          title="Share&hellip;"
    357372          tooltip="Share the selected items"
     373        />
     374        <tbl:button
     375          image="take_ownership.png"
     376          onclick="takeOwnership()"
     377          title="Take ownership&hellip;"
     378          tooltip="Take ownership of the selected items"
    358379        />
    359380        <tbl:button
  • trunk/www/admin/annotationtypes/view_annotationtype.jsp

    r2875 r2921  
    7575  final boolean deletePermission = annotationType.hasPermission(Permission.DELETE);
    7676  final boolean sharePermission = annotationType.hasPermission(Permission.SET_PERMISSION);
     77  final boolean setOwnerPermission = annotationType.hasPermission(Permission.SET_OWNER);
     78  final boolean isOwner = annotationType.isOwner();
    7779  %>
    78 
    7980  <base:page title="<%=title%>">
    8081  <base:head scripts="tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
     
    9596    {
    9697      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     98    }
     99    function takeOwnership()
     100    {
     101      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     102      {
     103        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     104      }
    97105    }
    98106    function runPlugin(cmd)
     
    143151        title="Share&hellip;"
    144152        tooltip="<%=sharePermission ? "Share this annotation type to other user, groups and projects" : "You do not have permission to share this annotation type"%>"
     153      />
     154      <tbl:button
     155        disabled="<%=setOwnerPermission ? false : true%>"
     156        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     157        onclick="takeOwnership()"
     158        title="Take ownership&hellip;"
     159        visible="<%=!isOwner%>"
     160        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    145161      />
    146162      <tbl:button
  • trunk/www/admin/clients/index.jsp

    r2811 r2921  
    3939  import="net.sf.basedb.util.RemovableUtil"
    4040  import="net.sf.basedb.util.ShareableUtil"
     41  import="net.sf.basedb.util.OwnableUtil"
    4142  import="net.sf.basedb.clients.web.Base"
    4243  import="net.sf.basedb.clients.web.WebException"
     
    210211    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    211212  }
     213  else if ("TakeOwnershipOfItem".equals(cmd))
     214  {
     215    // Take ownership a single item and then return to the view page
     216    dc = sc.newDbControl();
     217    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     218    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     219    dc.commit();
     220    redirect = viewPage;
     221  }
     222  else if ("TakeOwnershipOfItems".equals(cmd))
     223  {
     224    // Take ownership all selected items on the list page
     225    dc = sc.newDbControl();
     226    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     227    int numTotal = cc.getSelected().size();
     228    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     229    dc.commit();
     230    if (numTotal != numOwned)
     231    {
     232      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     233    }
     234    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     235  }
    212236  else if ("ExportItems".equals(cmd))
    213237  {
  • trunk/www/admin/clients/list_clients.jsp

    r2753 r2921  
    127127      frm.submit();
    128128    }
     129    function takeOwnership()
     130    {
     131      var frm = document.forms[formId];
     132      if (Forms.numChecked(frm) == 0)
     133      {
     134        alert('Please select at least one item in the list');
     135        return;
     136      }
     137      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     138      {
     139        frm.action = submitPage;
     140        frm.cmd.value = 'TakeOwnershipOfItems';
     141        frm.submit();
     142      }
     143    }
    129144    function shareItem(itemId)
    130145    {
     
    253268          title="Share&hellip;"
    254269          tooltip="Share the selected items"
     270        />
     271        <tbl:button
     272          image="take_ownership.png"
     273          onclick="takeOwnership()"
     274          title="Take ownership&hellip;"
     275          tooltip="Take ownership of the selected items"
    255276        />
    256277        <tbl:button
  • trunk/www/admin/clients/view_client.jsp

    r2753 r2921  
    6969  final boolean deletePermission = client.hasPermission(Permission.DELETE);
    7070  final boolean sharePermission = client.hasPermission(Permission.SET_PERMISSION);
     71  final boolean setOwnerPermission = client.hasPermission(Permission.SET_OWNER);
     72  final boolean isOwner = client.isOwner();
    7173  %>
    72 
    7374  <base:page title="<%=title%>">
    7475  <base:head scripts="tabcontrol.js" styles="toolbar.css,headertabcontrol.css,path.css">
     
    8990    {
    9091      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     92    }
     93    function takeOwnership()
     94    {
     95      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     96      {
     97        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     98      }
    9199    }
    92100    function runPlugin(cmd)
     
    154162      />
    155163      <tbl:button
     164        disabled="<%=setOwnerPermission ? false : true%>"
     165        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     166        onclick="takeOwnership()"
     167        title="Take ownership&hellip;"
     168        visible="<%=!isOwner%>"
     169        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
     170      />
     171      <tbl:button
    156172        image="import.gif"
    157173        onclick="runPlugin('ImportItem')"
  • trunk/www/admin/hardware/index.jsp

    r2811 r2921  
    4040  import="net.sf.basedb.util.RemovableUtil"
    4141  import="net.sf.basedb.util.ShareableUtil"
     42  import="net.sf.basedb.util.OwnableUtil"
    4243  import="net.sf.basedb.clients.web.Base"
    4344  import="net.sf.basedb.clients.web.WebException"
     
    219220    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    220221  }
     222  else if ("TakeOwnershipOfItem".equals(cmd))
     223  {
     224    // Take ownership a single item and then return to the view page
     225    dc = sc.newDbControl();
     226    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     227    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     228    dc.commit();
     229    redirect = viewPage;
     230  }
     231  else if ("TakeOwnershipOfItems".equals(cmd))
     232  {
     233    // Take ownership all selected items on the list page
     234    dc = sc.newDbControl();
     235    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     236    int numTotal = cc.getSelected().size();
     237    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     238    dc.commit();
     239    if (numTotal != numOwned)
     240    {
     241      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     242    }
     243    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     244  }
    221245  else if ("ExportItems".equals(cmd))
    222246  {
  • trunk/www/admin/hardware/list_hardware.jsp

    r2753 r2921  
    132132      frm.submit();
    133133    }
     134    function takeOwnership()
     135    {
     136      var frm = document.forms[formId];
     137      if (Forms.numChecked(frm) == 0)
     138      {
     139        alert('Please select at least one item in the list');
     140        return;
     141      }
     142      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     143      {
     144        frm.action = submitPage;
     145        frm.cmd.value = 'TakeOwnershipOfItems';
     146        frm.submit();
     147      }
     148    }
    134149    function shareItem(itemId)
    135150    {
     
    277292          title="Share&hellip;"
    278293          tooltip="Share the selected items"
     294        />
     295        <tbl:button
     296          image="take_ownership.png"
     297          onclick="takeOwnership()"
     298          title="Take ownership&hellip;"
     299          tooltip="Take ownership of the selected items"
    279300        />
    280301        <tbl:button
  • trunk/www/admin/hardware/view_hardware.jsp

    r2753 r2921  
    7070  final boolean deletePermission = hardware.hasPermission(Permission.DELETE);
    7171  final boolean sharePermission = hardware.hasPermission(Permission.SET_PERMISSION);
     72  final boolean setOwnerPermission = hardware.hasPermission(Permission.SET_OWNER);
     73  final boolean isOwner = hardware.isOwner();
    7274  %>
    73 
    7475  <base:page title="<%=title%>">
    7576  <base:head scripts="tabcontrol.js" styles="toolbar.css,headertabcontrol.css,path.css">
     
    9091    {
    9192      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     93    }
     94    function takeOwnership()
     95    {
     96      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     97      {
     98        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     99      }
    92100    }
    93101    function runPlugin(cmd)
     
    138146        title="Share&hellip;"
    139147        tooltip="<%=sharePermission ? "Share this hardware to other user, groups and projects" : "You do not have permission to share this hardware"%>"
     148      />
     149      <tbl:button
     150        disabled="<%=setOwnerPermission ? false : true%>"
     151        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     152        onclick="takeOwnership()"
     153        title="Take ownership&hellip;"
     154        visible="<%=!isOwner%>"
     155        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    140156      />
    141157      <tbl:button
  • trunk/www/admin/jobagents/index.jsp

    r2811 r2921  
    4141  import="net.sf.basedb.util.RemovableUtil"
    4242  import="net.sf.basedb.util.ShareableUtil"
     43  import="net.sf.basedb.util.OwnableUtil"
    4344  import="net.sf.basedb.util.jobagent.JobAgentConnection"
    4445  import="net.sf.basedb.clients.web.Base"
     
    249250    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    250251  }
     252  else if ("TakeOwnershipOfItem".equals(cmd))
     253  {
     254    // Take ownership a single item and then return to the view page
     255    dc = sc.newDbControl();
     256    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     257    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     258    dc.commit();
     259    redirect = viewPage;
     260  }
     261  else if ("TakeOwnershipOfItems".equals(cmd))
     262  {
     263    // Take ownership all selected items on the list page
     264    dc = sc.newDbControl();
     265    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     266    int numTotal = cc.getSelected().size();
     267    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     268    dc.commit();
     269    if (numTotal != numOwned)
     270    {
     271      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     272    }
     273    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     274  }
    251275  else if ("ExportItems".equals(cmd))
    252276  {
  • trunk/www/admin/jobagents/list_agents.jsp

    r2753 r2921  
    137137      frm.submit();
    138138    }
     139    function takeOwnership()
     140    {
     141      var frm = document.forms[formId];
     142      if (Forms.numChecked(frm) == 0)
     143      {
     144        alert('Please select at least one item in the list');
     145        return;
     146      }
     147      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     148      {
     149        frm.action = submitPage;
     150        frm.cmd.value = 'TakeOwnershipOfItems';
     151        frm.submit();
     152      }
     153    }
    139154    function shareItem(itemId)
    140155    {
     
    309324          title="Share&hellip;"
    310325          tooltip="Share the selected items"
     326        />
     327        <tbl:button
     328          image="take_ownership.png"
     329          onclick="takeOwnership()"
     330          title="Take ownership&hellip;"
     331          tooltip="Take ownership of the selected items"
    311332        />
    312333        <tbl:button
  • trunk/www/admin/jobagents/view_agent.jsp

    r2753 r2921  
    8181  final boolean deletePermission = agent.hasPermission(Permission.DELETE);
    8282  final boolean sharePermission = agent.hasPermission(Permission.SET_PERMISSION);
     83  final boolean setOwnerPermission = agent.hasPermission(Permission.SET_OWNER);
     84  final boolean isOwner = agent.isOwner();
    8385  %>
    84 
    8586  <base:page title="<%=title%>">
    8687  <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css,progressbar.css">
     
    101102    {
    102103      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     104    }
     105    function takeOwnership()
     106    {
     107      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     108      {
     109        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     110      }
    103111    }
    104112    function configurePlugin(pluginId)
     
    153161        title="Share&hellip;"
    154162        tooltip="<%=sharePermission ? "Share this job agent to other user, groups and projects" : "You do not have permission to share this job agent"%>"
     163      />
     164      <tbl:button
     165        disabled="<%=setOwnerPermission ? false : true%>"
     166        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     167        onclick="takeOwnership()"
     168        title="Take ownership&hellip;"
     169        visible="<%=!isOwner%>"
     170        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    155171      />
    156172      <tbl:button
  • trunk/www/admin/pluginconfigurations/index.jsp

    r2811 r2921  
    4040  import="net.sf.basedb.util.RemovableUtil"
    4141  import="net.sf.basedb.util.ShareableUtil"
     42  import="net.sf.basedb.util.OwnableUtil"
    4243  import="net.sf.basedb.util.JarClassLoader"
    4344  import="net.sf.basedb.clients.web.Base"
     
    241242    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    242243  }
     244  else if ("TakeOwnershipOfItem".equals(cmd))
     245  {
     246    // Take ownership a single item and then return to the view page
     247    dc = sc.newDbControl();
     248    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     249    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     250    dc.commit();
     251    redirect = viewPage;
     252  }
     253  else if ("TakeOwnershipOfItems".equals(cmd))
     254  {
     255    // Take ownership all selected items on the list page
     256    dc = sc.newDbControl();
     257    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     258    int numTotal = cc.getSelected().size();
     259    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     260    dc.commit();
     261    if (numTotal != numOwned)
     262    {
     263      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     264    }
     265    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     266  }
    243267  else if ("ExportItems".equals(cmd))
    244268  {
  • trunk/www/admin/pluginconfigurations/list_configurations.jsp

    r2753 r2921  
    167167      frm.submit();
    168168    }
     169    function takeOwnership()
     170    {
     171      var frm = document.forms[formId];
     172      if (Forms.numChecked(frm) == 0)
     173      {
     174        alert('Please select at least one item in the list');
     175        return;
     176      }
     177      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     178      {
     179        frm.action = submitPage;
     180        frm.cmd.value = 'TakeOwnershipOfItems';
     181        frm.submit();
     182      }
     183    }
    169184    function shareItem(itemId)
    170185    {
     
    321336          title="Share&hellip;"
    322337          tooltip="Share the selected items"
     338        />
     339        <tbl:button
     340          image="take_ownership.png"
     341          onclick="takeOwnership()"
     342          title="Take ownership&hellip;"
     343          tooltip="Take ownership of the selected items"
    323344        />
    324345        <tbl:button
  • trunk/www/admin/pluginconfigurations/view_configuration.jsp

    r2753 r2921  
    8484  final boolean deletePermission = configuration.hasPermission(Permission.DELETE);
    8585  final boolean sharePermission = configuration.hasPermission(Permission.SET_PERMISSION);
     86  final boolean setOwnerPermission = configuration.hasPermission(Permission.SET_OWNER);
     87  final boolean isOwner = configuration.isOwner();
    8688
    8789  final Set<GuiContext> contexts = new TreeSet<GuiContext>(new ToStringComparator<GuiContext>(false));
     
    124126      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
    125127    }
     128    function takeOwnership()
     129    {
     130      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     131      {
     132        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     133      }
     134    }
    126135    function runPlugin(cmd)
    127136    {
     
    181190        title="Share&hellip;"
    182191        tooltip="<%=sharePermission ? "Share this plugin configuration to other user, groups and projects" : "You do not have permission to share this plugin configuration"%>"
     192      />
     193      <tbl:button
     194        disabled="<%=setOwnerPermission ? false : true%>"
     195        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     196        onclick="takeOwnership()"
     197        title="Take ownership&hellip;"
     198        visible="<%=!isOwner%>"
     199        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    183200      />
    184201      <tbl:button
  • trunk/www/admin/plugindefinitions/index.jsp

    r2854 r2921  
    4444  import="net.sf.basedb.util.RemovableUtil"
    4545  import="net.sf.basedb.util.ShareableUtil"
     46  import="net.sf.basedb.util.OwnableUtil"
    4647  import="net.sf.basedb.util.JarClassLoader"
    4748  import="net.sf.basedb.clients.web.Base"
     
    273274    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    274275  }
     276  else if ("TakeOwnershipOfItem".equals(cmd))
     277  {
     278    // Take ownership a single item and then return to the view page
     279    dc = sc.newDbControl();
     280    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     281    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     282    dc.commit();
     283    redirect = viewPage;
     284  }
     285  else if ("TakeOwnershipOfItems".equals(cmd))
     286  {
     287    // Take ownership all selected items on the list page
     288    dc = sc.newDbControl();
     289    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     290    int numTotal = cc.getSelected().size();
     291    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     292    dc.commit();
     293    if (numTotal != numOwned)
     294    {
     295      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     296    }
     297    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     298  }
    275299  else if ("ExportItems".equals(cmd))
    276300  {
  • trunk/www/admin/plugindefinitions/list_plugins.jsp

    r2854 r2921  
    158158      frm.submit();
    159159    }
     160    function takeOwnership()
     161    {
     162      var frm = document.forms[formId];
     163      if (Forms.numChecked(frm) == 0)
     164      {
     165        alert('Please select at least one item in the list');
     166        return;
     167      }
     168      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     169      {
     170        frm.action = submitPage;
     171        frm.cmd.value = 'TakeOwnershipOfItems';
     172        frm.submit();
     173      }
     174    }
    160175    function unloadItems()
    161176    {
     
    445460          title="Share&hellip;"
    446461          tooltip="Share the selected items"
     462        />
     463        <tbl:button
     464          image="take_ownership.png"
     465          onclick="takeOwnership()"
     466          title="Take ownership&hellip;"
     467          tooltip="Take ownership of the selected items"
    447468        />
    448469        <tbl:button
  • trunk/www/admin/plugindefinitions/view_plugin.jsp

    r2916 r2921  
    103103  final boolean deletePermission = plugin.hasPermission(Permission.DELETE);
    104104  final boolean sharePermission = plugin.hasPermission(Permission.SET_PERMISSION);
     105  final boolean setOwnerPermission = plugin.hasPermission(Permission.SET_OWNER);
     106  final boolean isOwner = plugin.isOwner();
    105107  %>
    106 
    107108  <base:page title="<%=title%>">
    108109  <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css">
     
    123124    {
    124125      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     126    }
     127    function takeOwnership()
     128    {
     129      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     130      {
     131        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     132      }
    125133    }
    126134    function runPlugin(cmd)
     
    186194        title="Share&hellip;"
    187195        tooltip="<%=sharePermission ? "Share this plugin to other user, groups and projects" : "You do not have permission to share this plugin"%>"
     196      />
     197      <tbl:button
     198        disabled="<%=setOwnerPermission ? false : true%>"
     199        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     200        onclick="takeOwnership()"
     201        title="Take ownership&hellip;"
     202        visible="<%=!isOwner%>"
     203        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    188204      />
    189205      <tbl:button
  • trunk/www/admin/protocols/index.jsp

    r2875 r2921  
    4242  import="net.sf.basedb.util.RemovableUtil"
    4343  import="net.sf.basedb.util.ShareableUtil"
     44  import="net.sf.basedb.util.OwnableUtil"
    4445  import="net.sf.basedb.clients.web.Base"
    4546  import="net.sf.basedb.clients.web.WebException"
     
    241242    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    242243  }
     244  else if ("TakeOwnershipOfItem".equals(cmd))
     245  {
     246    // Take ownership a single item and then return to the view page
     247    dc = sc.newDbControl();
     248    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     249    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     250    dc.commit();
     251    redirect = viewPage;
     252  }
     253  else if ("TakeOwnershipOfItems".equals(cmd))
     254  {
     255    // Take ownership all selected items on the list page
     256    dc = sc.newDbControl();
     257    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     258    int numTotal = cc.getSelected().size();
     259    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     260    dc.commit();
     261    if (numTotal != numOwned)
     262    {
     263      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     264    }
     265    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     266  }
    243267  else if ("ExportItems".equals(cmd))
    244268  {
  • trunk/www/admin/protocols/list_protocol.jsp

    r2753 r2921  
    132132      frm.submit();
    133133    }
     134    function takeOwnership()
     135    {
     136      var frm = document.forms[formId];
     137      if (Forms.numChecked(frm) == 0)
     138      {
     139        alert('Please select at least one item in the list');
     140        return;
     141      }
     142      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     143      {
     144        frm.action = submitPage;
     145        frm.cmd.value = 'TakeOwnershipOfItems';
     146        frm.submit();
     147      }
     148    }
    134149    function shareItem(itemId)
    135150    {
     
    277292          title="Share&hellip;"
    278293          tooltip="Share the selected items"
     294        />
     295        <tbl:button
     296          image="take_ownership.png"
     297          onclick="takeOwnership()"
     298          title="Take ownership&hellip;"
     299          tooltip="Take ownership of the selected items"
    279300        />
    280301        <tbl:button
  • trunk/www/admin/protocols/view_protocol.jsp

    r2875 r2921  
    7777  final boolean deletePermission = protocol.hasPermission(Permission.DELETE);
    7878  final boolean sharePermission = protocol.hasPermission(Permission.SET_PERMISSION);
     79  final boolean setOwnerPermission = protocol.hasPermission(Permission.SET_OWNER);
     80  final boolean isOwner = protocol.isOwner();
    7981  %>
    80 
    8182  <base:page title="<%=title%>">
    8283  <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css">
     
    9798    {
    9899      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     100    }
     101    function takeOwnership()
     102    {
     103      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     104      {
     105        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     106      }
    99107    }
    100108    function runPlugin(cmd)
     
    145153        title="Share&hellip;"
    146154        tooltip="<%=sharePermission ? "Share this protocol to other user, groups and projects" : "You do not have permission to share this protocol"%>"
     155      />
     156      <tbl:button
     157        disabled="<%=setOwnerPermission ? false : true%>"
     158        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     159        onclick="takeOwnership()"
     160        title="Take ownership&hellip;"
     161        visible="<%=!isOwner%>"
     162        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    147163      />
    148164      <tbl:button
  • trunk/www/admin/software/index.jsp

    r2811 r2921  
    4040  import="net.sf.basedb.util.RemovableUtil"
    4141  import="net.sf.basedb.util.ShareableUtil"
     42  import="net.sf.basedb.util.OwnableUtil"
    4243  import="net.sf.basedb.clients.web.Base"
    4344  import="net.sf.basedb.clients.web.WebException"
     
    219220    redirect = "../../common/share/share.jsp?ID="+ID+"&item_type="+itemType.name();
    220221  }
     222  else if ("TakeOwnershipOfItem".equals(cmd))
     223  {
     224    // Take ownership a single item and then return to the view page
     225    dc = sc.newDbControl();
     226    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     227    OwnableUtil.setOwner(dc, itemType, Collections.singleton(cc.getId()), null);
     228    dc.commit();
     229    redirect = viewPage;
     230  }
     231  else if ("TakeOwnershipOfItems".equals(cmd))
     232  {
     233    // Take ownership all selected items on the list page
     234    dc = sc.newDbControl();
     235    ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext);
     236    int numTotal = cc.getSelected().size();
     237    int numOwned = OwnableUtil.setOwner(dc, itemType, cc.getSelected(), null);
     238    dc.commit();
     239    if (numTotal != numOwned)
     240    {
     241      message = (numOwned == 0 ? "No" : "Only "+numOwned+" of "+numTotal) + " items could be taken, because you have no SET_OWNER permission";
     242    }
     243    redirect = listPage+(message != null ? "&popmessage="+HTML.urlEncode(message) : "");
     244  }
    221245  else if ("ExportItems".equals(cmd))
    222246  {
  • trunk/www/admin/software/list_software.jsp

    r2776 r2921  
    132132      frm.submit();
    133133    }
     134    function takeOwnership()
     135    {
     136      var frm = document.forms[formId];
     137      if (Forms.numChecked(frm) == 0)
     138      {
     139        alert('Please select at least one item in the list');
     140        return;
     141      }
     142      if (confirm('Are you sure that you want to take ownership of the selected items? It can\'t be undone.'))
     143      {
     144        frm.action = submitPage;
     145        frm.cmd.value = 'TakeOwnershipOfItems';
     146        frm.submit();
     147      }
     148    }
    134149    function shareItem(itemId)
    135150    {
     
    277292          title="Share&hellip;"
    278293          tooltip="Share the selected items"
     294        />
     295        <tbl:button
     296          image="take_ownership.png"
     297          onclick="takeOwnership()"
     298          title="Take ownership&hellip;"
     299          tooltip="Take ownership of the selected items"
    279300        />
    280301        <tbl:button
  • trunk/www/admin/software/view_software.jsp

    r2753 r2921  
    7070  final boolean deletePermission = software.hasPermission(Permission.DELETE);
    7171  final boolean sharePermission = software.hasPermission(Permission.SET_PERMISSION);
     72  final boolean setOwnerPermission = software.hasPermission(Permission.SET_OWNER);
     73  final boolean isOwner = software.isOwner();
    7274  %>
    73 
    7475  <base:page title="<%=title%>">
    7576  <base:head scripts="tabcontrol.js" styles="toolbar.css,headertabcontrol.css,path.css">
     
    9091    {
    9192      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
     93    }
     94    function takeOwnership()
     95    {
     96      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
     97      {
     98        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
     99      }
    92100    }
    93101    function runPlugin(cmd)
     
    137145        title="Share&hellip;"
    138146        tooltip="<%=sharePermission ? "Share this software to other user, groups and projects" : "You do not have permission to share this software"%>"
     147      />
     148      <tbl:button
     149        disabled="<%=setOwnerPermission ? false : true%>"
     150        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
     151        onclick="takeOwnership()"
     152        title="Take ownership&hellip;"
     153        visible="<%=!isOwner%>"
     154        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
    139155      />
    140156      <tbl:button
Note: See TracChangeset for help on using the changeset viewer.