Changeset 374 for trunk


Ignore:
Timestamp:
08/03/12 17:54:42 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Checkpoint adding location/view UI bits. See #10.

  • add location add/edit template
  • stub out location add/edit, start filling in add section
  • straighten out use of some of the new location-related permission flags
Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns.cgi

    r371 r374  
    13441344} elsif ($webvar{page} eq 'loclist') {
    13451345
    1346 #  changepage(page => "domlist", errmsg => "You are not allowed access to this function")
    1347 #       unless $permissions{admin} || $permissions{ foo? };
     1346  changepage(page => "domlist", errmsg => "You are not allowed access to this function")
     1347        unless $permissions{admin} || $permissions{location_view};
    13481348
    13491349  # security check - does the user have permission to access this entity?
     
    13541354
    13551355# Permissions!
    1356   $page->param(addloc => $permissions{admin} || $permissions{loc_create});
    1357   $page->param(delloc => $permissions{admin} || $permissions{loc_delete});
     1356  $page->param(addloc => $permissions{admin} || $permissions{location_create});
     1357  $page->param(delloc => $permissions{admin} || $permissions{location_delete});
    13581358
    13591359} elsif ($webvar{page} eq 'location') {
    13601360
     1361  changepage(page => "domlist", errmsg => "You are not allowed access to this function")
     1362        unless $permissions{admin} || $permissions{location_view};
     1363
     1364  # security check - does the user have permission to access this entity?
     1365#  if (!check_scope(id => $webvar{id}, type => 'loc')) {
     1366#    changepage(page => "loclist", errmsg => "You are not permitted to <foo> the requested location/view");
     1367#  }
     1368
     1369  if ($webvar{locact} eq 'new') {
     1370
     1371  } elsif ($webvar{locact} eq 'add') {
     1372    changepage(page => "loclist", errmsg => "You are not permitted to add locations/views", id => $webvar{parentid})
     1373        unless ($permissions{admin} || $permissions{location_create});
     1374
     1375##work
     1376    my ($code,$msg) = addLocation($dbh, $webvar{parentid}, $webvar{locname}, $webvar{iplist});
     1377
     1378    if ($code eq 'OK' || $code eq 'WARN') {
     1379      my %pageparams = (page => "loclist", id => $webvar{parentid},
     1380        defrec => $webvar{defrec}, revrec => $webvar{revrec});
     1381      $pageparams{warnmsg} = $msg."<br><br>\n".$DNSDB::resultstr if $code eq 'WARN';
     1382      $pageparams{resultmsg} = $DNSDB::resultstr if $code eq 'OK';
     1383      changepage(%pageparams);
     1384    } else {
     1385      $page->param(failed       => 1);
     1386      $page->param(errmsg       => $msg);
     1387      $page->param(wastrying    => "adding");
     1388      $page->param(todo         => "Add location/view");
     1389      $page->param(locact       => "add");
     1390      $page->param(parentid     => $webvar{parentid});
     1391      $page->param(id           => $webvar{id});
     1392      fill_recdata();   # populate the form... er, mostly.
     1393    }
     1394
     1395  } elsif ($webvar{locact} eq 'edit') {
     1396    changepage(page => "loclist", errmsg => "You are not permitted to edit locations/views", id => $webvar{parentid})
     1397        unless ($permissions{admin} || $permissions{location_edit});
     1398  } elsif ($webvar{locact} eq 'update') {
     1399    changepage(page => "loclist", errmsg => "You are not permitted to edit locations/views", id => $webvar{parentid})
     1400        unless ($permissions{admin} || $permissions{location_edit});
     1401  } else {
     1402    changepage(page => "loclist", errmsg => "You are not permitted to add locations/views", id => $webvar{parentid})
     1403        unless ($permissions{admin} || $permissions{location_create});
     1404
     1405    $page->param(todo => "Add location/view");
     1406    $page->param(locact => "add");
     1407    $page->param(parentid => $webvar{parentid});
     1408
     1409    $page->param(locname => ($webvar{locname} ? $webvar{locname} : ''));
     1410    $page->param(iplist => ($webvar{iplist} ? $webvar{iplist} : ''));
     1411  }
    13611412
    13621413} elsif ($webvar{page} eq 'dnsq') {
     
    15941645
    15951646##common bits
     1647# mostly things in the menu
    15961648if ($webvar{page} ne 'login' && $webvar{page} ne 'badpage') {
    15971649  $page->param(username => $session->param("username"));
     
    16041656##fixme
    16051657  $page->param(mayrdns => 1);
    1606   $page->param(mayloc => 1);
     1658
     1659  $page->param(mayloc => ($permissions{admin} || $permissions{loc_view}));
    16071660
    16081661  $page->param(maydefrec => $permissions{admin});
  • trunk/templates/loclist.tmpl

    r372 r374  
    2323</tr>
    2424<TMPL_IF addloc>
    25 <tr><td colspan="3" align="right"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&amp;page=loc">New Location/View</a></td></tr>
     25<tr><td colspan="3" align="right"><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&amp;page=location">New Location/View</a></td></tr>
    2626</TMPL_IF>
    2727</table>
     
    3636<TMPL_LOOP name=loctable>
    3737<tr class="row<TMPL_IF __odd__>0<TMPL_ELSE>1</TMPL_IF>">
    38         <td align="left"><TMPL_IF edloc><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&amp;page=location&amp;loc_action=edit&amp;loc=<TMPL_VAR NAME=location>"><TMPL_VAR NAME=description></a><TMPL_ELSE><TMPL_VAR NAME=description></TMPL_IF></td>
     38        <td align="left"><TMPL_IF edloc><a href="dns.cgi?sid=<TMPL_VAR NAME=sid>&amp;page=location&amp;locact=edit&amp;loc=<TMPL_VAR NAME=location>"><TMPL_VAR NAME=description></a><TMPL_ELSE><TMPL_VAR NAME=description></TMPL_IF></td>
    3939        <td><TMPL_VAR name=iplist></td>
    4040        <td><TMPL_VAR name=group_name></td>
Note: See TracChangeset for help on using the changeset viewer.