/** * @param FORM_RENDERER $renderer * @param $ctrl_id * @return mixed */ protected function _make_user_list_properties_for($renderer, $ctrl_id) { $Result = $renderer->make_list_properties(); $Result->on_click_script = 'on_group_type_changed (this, this.form.' . $ctrl_id . ')'; $Result->add_item('Allow all users', Project_user_all); $Result->add_item('Allow only registered users', Project_user_registered_only); if ($this->login->is_allowed(Privilege_set_group, Privilege_view)) { $group_query = $this->app->group_query(); /** @var GROUP[] $groups */ $groups = $group_query->objects(); if (sizeof($groups)) { $group_props = $renderer->make_list_properties(); $group_props->css_class = 'small'; foreach ($groups as $group) { $group_props->add_item($group->title_as_plain_text(), $group->id); } $Result->add_item('Allow only ' . $renderer->drop_down_as_HTML($ctrl_id, $group_props), Project_user_group); } else { $this->_user_list_error_message = 'Cannot limit by group (no groups available)'; } } else { $this->_user_list_error_message = 'Cannot limit by group (cannot see groups)'; } return $Result; }
/** * 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(); }