示例#1
0
 public function parse()
 {
     global $_MAINCFG;
     ob_start();
     js_form_start('edit_config');
     if (is_action()) {
         try {
             $this->handleAction();
         } catch (FieldInputError $e) {
             $this->error = $e;
         }
     }
     $sections = array();
     foreach ($_MAINCFG->getValidConfig() as $sec => $arr) {
         if (!preg_match($this->exclude_pattern, $sec)) {
             $sections[$sec] = $_MAINCFG->getSectionTitle($sec);
         }
     }
     $open = get_open_section('global');
     render_section_navigation($open, $sections);
     foreach ($sections as $sec => $title) {
         $this->renderSection($sec, $open);
     }
     submit(l('save'));
     form_end();
     return ob_get_clean();
 }
示例#2
0
 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();
 }
示例#3
0
 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();
     }
 }