Graham Quince Posted September 3, 2021 Share Posted September 3, 2021 Here's an interesting snippet should anyone need it. A school deleted a collection, but kept the ePortfolios as sites, not realising that this meant the sharing would be transferred to each site. They were faced with manually altering 1000 sites, so I helped them with this: <div class="btn btn-danger shareChange">Change Teacher Comments share</div> <div class="shareStatus"></div> <script> var SEARCH_TERM = "old sites"; function getSites() { Frog.Model.api('sites.search', { exclude_sources: ["temporary"], filter: {is_eportfolio: "0"}, include_associations: "true", limit: "1000", offset: "0", order: {updated: "desc"}, query: SEARCH_TERM, requires: {columns: "false"}, scope: "global" }).done(function(response) { var sites = response.data.sites; $('.shareStatus').text("Found: "+sites.length); onebyone(sites,0); }).fail(function(e) { console.log("FAILED"); }); } function onebyone(allSites,i) { console.log(i); if (i < allSites.length) { if (i == 100 || i == 200 || i == 300 || i == 400 || i == 500 || i == 600 || i == 700 || i == 800 || i == 900 || i == 1000) { $('.shareStatus').html('Pausing for 1 minute to prevent maxing out API requests'); setTimeout(function(){ changeshare(allSites,i); }, 60000); } else { $('.shareStatus').html('Running '+i+' of '+ allSites.length); changeshare(allSites,i); } } } function changeshare(allSites,i) { Frog.Model.api('sites.sharing.set', { associations: {template: "0"}, external_url: allSites[i].external_url, is_external: "false", site: allSites[i].uuid },{ type: 'POST' }).done(function(response) { }).fail(function(e) { console.log("FAILED to share :"+i+" - "+allSites[i].uuid); }); Frog.Model.api('share.set', { permissions: 'none', target: allSites[i].uuid },{ type: 'POST' }).done(function(response) { }).fail(function(e) { console.log("FAILED to share :"+i+" - "+allSites[i].uuid); }); i = i+1; onebyone(allSites,i); } $('.shareChange').click(function(){ getSites(); }); </script> This removed the individual shares, although I had to go back over it and remove the profile shares. To do that, I removed the shares from one site and observed the API call. The permissions for share.set were stored as an object. The search term is what was a searched for in FrogDrive > Sites to identify the sites to change. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now