Guest User

Untitled

a guest
Dec 12th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. var ctx = new SP.ClientContext.get_current();
  2. var web = context.get_web();
  3.  
  4. var ob = new SP.BasePermissions();
  5. ob.set(SP.PermissionKind.addAndCustomizePages)
  6.  
  7. var per = web.doesUserHavePermissions(ob)
  8. ctx.executeQueryAsync(
  9. function(){
  10. alert(per.get_value()); // true if user has permission
  11. },
  12. function(a,b){
  13. alert ("Something wrong");
  14. }
  15. );
  16.  
  17. this.context.pageContext.listItem.permissions
  18.  
  19. this.context.pageContext.web.permissions
  20.  
  21. tsd install microsoft.ajax
  22.  
  23. tsd install sharepoint
  24.  
  25. {
  26. "sp-init": {
  27. "path": "https://tenantname.sharepoint.com/_layouts/15/init.js",
  28. "globalName": "$_global_init"
  29. },
  30. "microsoft-ajax": {
  31. "path": "https://tenantname.sharepoint.com/_layouts/15/MicrosoftAjax.js",
  32. "globalName": "Sys",
  33. "globalDependencies": [ "sp-init" ]
  34. },
  35. "sp-runtime": {
  36. "path": "https://tenantname.sharepoint.com/_layouts/15/SP.Runtime.js",
  37. "globalName": "SP",
  38. "globalDependencies": [ "microsoft-ajax" ]
  39. },
  40. "sharepoint": {
  41. "path": "https://tenantname.sharepoint.com/_layouts/15/SP.js",
  42. "globalName": "SP",
  43. "globalDependencies": [ "sp-runtime" ]
  44. }
  45. }
  46.  
  47. require('sp-init');
  48. require('microsoft-ajax');
  49. require('sp-runtime');
  50. require('sharepoint');
  51.  
  52. https://<site url>/_api/web/doesuserhavepermissions(@v)?@v={'High':'0', 'Low':'262144'}
  53.  
  54. requirejs.config({ enforceDefine: false });
  55.  
  56. var requireQueue = function (modules, callback) {
  57. function load(queue, results) {
  58. if (queue.length) {
  59. require([queue.shift()], function (result) {
  60. results.push(result);
  61. load(queue, results);
  62. });
  63. } else {
  64. callback.apply(null, results);
  65. }
  66. }
  67. load(modules, []);
  68. };
  69.  
  70. requireQueue([
  71. '/_layouts/15/init.js',
  72. '/_layouts/15/MicrosoftAjax.js',
  73. '/_layouts/15/SP.Runtime.js',
  74. '/_layouts/15/SP.js'
  75. ], function () {
  76. // JSOM is loaded
  77. });
Add Comment
Please, Sign In to add comment