Kentico CMS 6.0 Developer's Guide

Setting document level permissions

Setting document level permissions

Previous topic Next topic Mail us feedback on this topic!  

Setting document level permissions

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Arrow


API examples for newer versions


Please visit the latest API Examples documentation to view API examples for newer versions of Kentico.



The following example is not directly related to document permissions. It only prepares a sample document structure used by the API examples on the following pages.

 

private bool CreateDocumentStructure()

{

  // Create new instance of the Tree provider

  TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

 

  // Get default culture code

  string culture = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultCultureCode");

 

  // Get parent node

  TreeNode parentNode = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/", culture);

 

  if (parentNode != null)

   {

      // Create the API Example document

      TreeNode newNode = TreeNode.New("CMS.MenuItem", tree);

 

       newNode.DocumentName = "API Example";

       newNode.DocumentCulture = culture;

 

       newNode.Insert(parentNode);

 

       parentNode = newNode;

 

      // Create the API Example subpage

       newNode = TreeNode.New("CMS.MenuItem", tree);

 

       newNode.DocumentName = "API Example subpage";

       newNode.DocumentCulture = culture;

 

       newNode.Insert(parentNode);

 

      return true;

   }

 

  return false;

}

 

The following example deletes the sample document structure created by the API example above.

 

private bool DeleteDocumentStructure()

{

  // Create an instance of the Tree provider

  TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

 

  // Get default culture code

  string culture = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultCultureCode");

 

 

  // Get the API Example document

  TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example", culture);

 

  if (node != null)

   {

      // Delete the document and all child documents

       node.DeleteAllCultures();

   }

 

  return true;

}