private function renderSection($sec, $open) { global $_MAINCFG, $CORE; render_section_start($sec, $open); echo '<table class="mytable">'; foreach ($_MAINCFG->getValidObjectType($sec) as $key => $spec) { // Skip deprecated options if (isset($spec['deprecated']) && $spec['deprecated'] == 1) { continue; } $field_type = val($spec, 'field_type', 'text'); if ($field_type == 'hidden') { continue; } $ident = $sec . '_' . $key; // value configured by the user. might be null when nothing is configured $cur_val = $this->getCurVal($sec, $key); // Get either the option configured in non gui editable config files or the // hardcoded default value $def_val = $_MAINCFG->getValue($sec, $key, false, true); if (is_array($def_val)) { $def_val = implode(',', $def_val); } // Check if depends_on and depends_value are defined and if the value // is equal. If not equal hide the field $row_class = ''; $row_style = ''; if (isset($spec['depends_on']) && isset($spec['depends_value']) && $this->getCurVal($sec, $spec['depends_on'], false) != $spec['depends_value']) { $row_class = ' class="child-row"'; $row_style = ' style="display:none;"'; } elseif (isset($spec['depends_on']) && isset($spec['depends_value']) && $this->getCurVal($sec, $spec['depends_on'], false) == $spec['depends_value']) { $row_class = ' class="child-row"'; } if ($cur_val !== null) { $checked = ' checked="checked"'; $show_default = ' style="display:none"'; $show_input = ''; } else { $checked = ''; $show_default = ''; $show_input = ' style="display:none"'; } echo '<tr' . $row_class . $row_style . '>'; echo '<td class="tdlabel">' . $key . '</td>'; echo '<td class="tdbox"><input type="checkbox" name="toggle_' . $ident . '" value="1" ' . 'onclick="toggle_option(\'box_' . $ident . '\')"' . $checked . '/></td>'; echo '<td class="tdfield">'; echo '<div id="_txt_box_' . $ident . '"' . $show_default . ' class="default">'; switch ($field_type) { case 'boolean': if ($def_val == '1') { echo l('Yes'); } else { echo l('No'); } break; default: echo escape_html($def_val); } echo '</div>'; echo '<div id="box_' . $ident . '"' . $show_input . '>'; $this->renderInput($sec, $key, $spec, $def_val, $cur_val); if ($this->error && $this->error->field == $ident) { echo '<div class="err">' . escape_html($this->error->msg) . '</div>'; } echo '</div>'; echo '</td>'; echo '</tr>'; } echo '</table>'; render_section_end(); }
private function drawForm() { js_form_start('addmodify'); $obj_spec = $this->getProperties(); $props_by_section = array(); foreach ($obj_spec as $propname => $prop) { $sec = $prop['section']; if (!isset($props_by_section[$sec])) { $props_by_section[$sec] = array(); } $props_by_section[$sec][$propname] = $prop; } $sections = array(); foreach (array_keys($props_by_section) as $sec) { if ($sec != 'hidden') { $sections[$sec] = $this->MAPCFG->getSectionTitle($sec); } } $open = get_open_section('general'); render_section_navigation($open, $sections); foreach ($props_by_section as $sec => $sec_props) { if ($sec != 'hidden') { render_section_start($sec, $open); echo '<table class="mytable">'; $this->drawFields($sec_props); echo '</table>'; render_section_end(); } } if ($this->mode == 'view_params') { echo '<table class=mytable>'; echo '<tr><td class=tdlabel style="width:70px">' . l('Make permanent') . '</td>'; echo '<td class=tdfield>'; checkbox('perm'); echo l('for all users') . '<br>'; checkbox('perm_user'); echo l('for you'); echo '</td></tr>'; echo '</table>'; } submit(l('Save')); form_end(); }
private function renderPermissions($role_id) { global $AUTHORISATION; if (!$role_id) { return; } $sections = array('general' => l('General'), 'maps' => l('Maps'), 'rotations' => l('Rotations')); echo '<h3>' . l('Permissions') . '</h3>'; $open = get_open_section('general'); render_section_navigation($open, $sections); $permissions_by_section = array('general' => array(), 'maps' => array(), 'rotations' => array()); foreach ($AUTHORISATION->getAllVisiblePerms() as $perm) { if ($perm['mod'] == 'Map' && $perm['act'] != 'add' && $perm['act'] != 'manage') { $map_name = $perm['obj']; if (!isset($permissions_by_section['maps'][$map_name])) { $permissions_by_section['maps'][$map_name] = array(); } $permissions_by_section['maps'][$map_name][$perm['act']] = $perm; } elseif ($perm['mod'] == 'Rotation') { $permissions_by_section['rotations'][] = $perm; } else { $permissions_by_section['general'][] = $perm; } } $permitted = $AUTHORISATION->getRolePerms($role_id); foreach ($permissions_by_section as $sec => $permissions) { render_section_start($sec, $open); if ($sec == 'maps') { $this->renderMapsSection($permissions, $permitted); } else { $this->renderOtherSection($permissions, $permitted); } render_section_end(); } }