/** * Renders the portion of a form that contains the elements for editing * a template's access settings. This is especially useful for tabbed forms. * * @param TemplateModel $template A Template entity * @param bool|ValidationResult $errors FALSE (if nothing was submitted) or * a ValidationResult object. This is needed to render any inline erorrs * on the form. * @return string HTML */ private function renderAccessPartial(TemplateModel $template, $errors) { $existing_templates = array(); foreach (ee('Model')->get('TemplateGroup')->all() as $template_group) { $templates = array(); foreach ($template_group->getTemplates() as $t) { $templates[$t->template_id] = $t->template_name; } $existing_templates[$template_group->group_name] = $templates; } $member_groups = ee('Model')->get('MemberGroup')->fields('group_id', 'group_title')->filter('site_id', ee()->config->item('site_id'))->filter('group_id', '!=', 1)->all(); $allowed_member_groups = array_diff($member_groups->pluck('group_id'), $template->getNoAccess()->pluck('group_id')); $sections = array(array(array('title' => 'allowed_member_groups', 'desc' => 'allowed_member_groups_desc', 'desc_cont' => 'allowed_member_groups_super_admin', 'fields' => array('allowed_member_groups' => array('type' => 'checkbox', 'wrap' => TRUE, 'choices' => $member_groups->getDictionary('group_id', 'group_title'), 'value' => $allowed_member_groups))), array('title' => 'no_access_redirect', 'desc' => 'no_access_redirect_desc', 'fields' => array('no_auth_bounce' => array('type' => 'select', 'choices' => $existing_templates, 'value' => $template->no_auth_bounce))), array('title' => 'enable_http_authentication', 'desc' => 'enable_http_authentication_desc', 'fields' => array('enable_http_auth' => array('type' => 'inline_radio', 'choices' => array('y' => 'enable', 'n' => 'disable'), 'value' => $template->enable_http_auth))))); if (!IS_CORE) { $route = $template->getTemplateRoute(); if (!$route) { $route = ee('Model')->make('TemplateRoute'); } $sections[0][] = array('title' => 'template_route_override', 'desc' => 'template_route_override_desc', 'fields' => array('route' => array('type' => 'text', 'value' => $route->route))); $sections[0][] = array('title' => 'require_all_segments', 'desc' => 'require_all_segments_desc', 'fields' => array('route_required' => array('type' => 'yes_no', 'value' => $route->route_required))); } $html = ''; foreach ($sections as $name => $settings) { $html .= ee('View')->make('_shared/form/section')->render(array('name' => $name, 'settings' => $settings, 'errors' => $errors)); } return $html; }