/**
  * 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 selector for all branches.
     * @param FORM_RENDERER $renderer
     * @access private
     */
    protected function _draw_branch_controls($renderer)
    {
        if (sizeof($this->branches)) {
            $renderer->start_block('Branches');
            ?>
      <p class="description">
        Assign this job to one or more of the following branches.
      </p>
<?php 
            $check_props = $renderer->make_check_properties();
            foreach ($this->branches as $branch) {
                $style = '';
                $visible = $this->value_for("branch_{$branch->id}_enabled");
                if ($visible || !$branch->locked()) {
                    if (!$visible) {
                        $style = 'display: none';
                    }
                    $locked = $branch->locked();
                    $release_id = $this->value_for("branch_{$branch->id}_release_id");
                    if ($release_id) {
                        /** @var $release_query BRANCH_RELEASE_QUERY */
                        $release_query = $branch->release_query();
                        /** @var $release RELEASE */
                        $release = $release_query->object_at_id($release_id);
                        $locked = $locked || $this->_branch_is_locked($branch, $release);
                    } else {
                        $release = null;
                    }
                    if ($locked) {
                        $renderer->draw_hidden("branch_{$branch->id}_enabled");
                        $title = $branch->title_as_html();
                        if ($branch->locked()) {
                            $title = $this->context->get_icon_with_text('{icons}indicators/locked', Sixteen_px, $title);
                        }
                        echo $title;
                    } else {
                        $check_props->on_click_script = "on_click_branch (this, '{$branch->id}')";
                        echo $renderer->check_box_as_HTML("branch_{$branch->id}_enabled", $check_props);
                    }
                    ?>
        <div id="branch_<?php 
                    echo $branch->id;
                    ?>
_panel" <?php 
                    if ($style) {
                        echo 'style="' . $style . '"';
                    }
                    ?>
>
          <?php 
                    $renderer->start_block('');
                    $this->_draw_branch_info_controls($branch, $renderer, $visible, $release);
                    $renderer->finish_block();
                    ?>
        </div>
        <?php 
                }
            }
            $renderer->draw_error_row('main_branch_id');
            $renderer->finish_block();
        }
    }