예제 #1
0
function update_log_row($athlete_id, $details, $post_data)
{
    $columns = array();
    $columns = validate_form_data($details, $post_data);
    $session_id = $columns['session_id'];
    // Find out who owns this session and check that this user
    // has permission to edit the owner's log
    $session_owner = get_session_owner($session_id);
    if ($athlete_id == $session_owner) {
    } elseif ($athlete_id != $session_owner && check_share_permission($session_owner, "edit log {$athlete_id}")) {
        $athlete_id = $session_owner;
    } else {
        echo "You do not have permission to edit this athlete's log<br>";
        return false;
    }
    # Build insert query
    $query = "UPDATE log SET ";
    #foreach ($details as $column){
    foreach (array_keys($columns) as $column) {
        $entry = $columns[$column];
        $query = "{$query} {$column} = '{$entry}' ,";
    }
    # remove final comma from query
    $query = substr($query, 0, strlen($query) - 1);
    $query = "{$query} WHERE athlete_id = {$athlete_id} AND session_id = {$session_id} ";
    #echo "DEBUG Entry update query:<br>$query";
    # Update session using build UPDATE query
    $result = do_sql($query) or die('Query failed: ' . pg_last_error());
    ## END OF FUNCTION
}
예제 #2
0
<HEAD>
<LINK REL="stylesheet"    HREF="styles/login.css" type="text/css">
<SCRIPT src="pop-up-resize.js" type="text/javascript" ></SCRIPT>

<STYLE TYPE='text/css'>
        .hiddentext {display:none} ;
        .outline {cursor:hand } ;
        </STYLE>
</HEAD>

<BODY onLoad="javascript:autoResize('mainlogentry');" >

<H2>Editing session</H2>

ENDHTML;
// Find out who owns this session and check that this user
// has permission to edit the owner's log
$session_owner = get_session_owner($session_id);
if ($athlete_id == $session_owner) {
    // Is owner so Permission granted
    $extra = array("EDIT", "{$session_id}");
    display_edit_log_entry($athlete_id, $session_id, "");
} elseif (check_share_permission($session_owner, "edit log {$athlete_id}")) {
    // Is not owner but Permission has been granted
    $athlete_id = $session_owner;
    $extra = array("EDIT", "{$session_id}");
    display_edit_log_entry($athlete_id, $session_id, "");
} else {
    echo "You do not have permission to edit this athlete's log<br>";
}
echo "</BODY></HTML>\n";