****************************************************************************/
$folder_query = $App->login->folder_query();
/** @var FOLDER $folder */
$folder = $folder_query->object_at_id(read_var('id'));
if (isset($folder) && $App->login->is_allowed(Privilege_set_folder, Privilege_secure, $folder)) {
    $App->set_referer();
    $security = $folder->security_definition();
    $security->load_all_permissions();
    $Page->title->add_object($folder);
    $Page->title->subject = 'Permissions';
    $Page->location->add_folder_link($folder);
    $Page->location->append("Permissions", '', '{icons}buttons/security');
    $Page->start_display();
    $defined = $folder->defines_security();
    $parent = $folder->parent_folder();
    $formatter = new PERMISSIONS_FORMATTER($App);
    $privilege_groups = $formatter->content_privilege_groups();
    include_once 'webcore/util/options.php';
    $tree_option = new STORED_OPTION($App, 'show_security_tree');
    $show_tree = $tree_option->value();
    $tree_opt_link = $tree_option->setter_url_as_html(!$show_tree);
    $details_option = new STORED_OPTION($App, 'show_full_permissions');
    $show_details = $details_option->value();
    $details_opt_link = $details_option->setter_url_as_html(!$show_details);
    $menu = $App->make_menu();
    if ($defined) {
        if ($App->login->is_allowed(Privilege_set_user, Privilege_view)) {
            $menu->append('Add user...', 'create_folder_user_permissions.php?id=' . $folder->id, '{icons}buttons/add');
        }
        if ($App->login->is_allowed(Privilege_set_group, Privilege_view)) {
            $menu->append('Add group...', 'create_folder_group_permissions.php?id=' . $folder->id, '{icons}buttons/add');
 /**
  * Draw the permission with icon and title.
  * Adds the icon to the title. This is done when drawn so that the icon
  * calculation is not done if the form is only being submitted.
  * @param PRIVILEGE_MAP $map Information about the privilege.
  * @param PERMISSIONS_FORMATTER $formatter Use this to get formatting information.
  * @param FORM_RENDERER $renderer
  * @access private
  */
 protected function _draw_permission($map, $formatter, $renderer)
 {
     $id = $map->id();
     $field = $this->field_at($id);
     $field->caption = $this->context->get_icon_with_text($formatter->icon_url_for($map), Sixteen_px, $formatter->title_for($map));
     echo $renderer->check_box_as_HTML($id);
 }
 /**
  * Draw the permission with icon and title.
  * Adds the icon to the title. This is done when drawn so that the icon
  * calculation is not done if the form is only being submitted.
  * @param PRIVILEGE_MAP $map Information about the privilege.
  * @param PERMISSIONS_FORMATTER $formatter Use this to get formatting information.
  * @param FORM_RENDERER $renderer
  * @param FORM_LIST_PROPERTIES $props
  * @access private
  */
 protected function _draw_tri_permission($map, $formatter, $renderer, $props)
 {
     $id = $map->id();
     $field = $this->field_at($id);
     $field->caption = $this->context->get_icon_with_text($formatter->icon_url_for($map), Sixteen_px, $formatter->title_for($map));
     $renderer->start_row();
     echo $renderer->drop_down_as_HTML($id, $props);
     echo $renderer->label_as_html($id);
     $renderer->finish_row();
 }