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
}
Exemple #2
0
}
$startdate = $_SESSION['startdate'];
if (isset($_POST['enddate'])) {
    $_SESSION['enddate'] = $_POST['enddate'];
} elseif (!isset($_SESSION['enddate'])) {
    $_SESSION['enddate'] = "+7 days";
}
$enddate = $_SESSION['enddate'];
##########################
$athlete_id = $_SESSION['athlete_id'];
// Check whether the user is requesting to view a different athlete's log
// and check whether he has permission.  Some functions request this
// via GET, others by POST so check both. POST gets priority.
if (isset($_POST['athlete_id']) && check_share_permission($_POST['athlete_id'], "view log {$athlete_id}")) {
    $athlete_id = $_POST['athlete_id'];
} elseif (isset($_GET['shareid']) && check_share_permission($_GET['shareid'], "view log {$athlete_id}")) {
    $athlete_id = $_GET['shareid'];
}
$athlete_details = get_user_details($athlete_id);
########################
# Display HTML headers
########################
include_once "log_display_functions.php";
include_once "validation/validate_date.php";
include_once "menubar.php";
// Only send the IE Quirks mode header if this is ie, else hidden stuff will not reveal in FFox
$browser = $_SERVER['HTTP_USER_AGENT'];
if (preg_match("/MSIE/", $browser)) {
    echo <<<ENDHTML
    <!-- Internet Explorer has to be in quirks mode, this comment just does that -->
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Exemple #3
0
function print_row($subyn, $level, $row, $details_to_view, $athlete_id, $split)
{
    # print the session details
    $parent_id = $row['parent_session'];
    $session_id = $row['session_id'];
    $previous_date = $GLOBALS['previous_date'];
    $start_date = $row['start_date'];
    $numcols = count($details_to_view);
    # Start the table row
    # echo "<TR>\n\n";
    print_split_expander_column($subyn, $session_id);
    #  foreach ( array_keys($row) as $key ) {
    #   if ( in_array( $key , $details_to_view ) ){
    unset($fullentry);
    $fullentry = array();
    //Find out what sort of entry type it is and use the appropriate
    //datacell class so the row gets the right background colour
    $row['session_type'] = trim($row['session_type']);
    $row['entry_type'] = trim($row['entry_type']);
    if ($row['session_type'] == "competition" && "X" . $row['entry_type'] == "X") {
        $datacell_class = get_datacell_class($row['session_type']);
    } else {
        $datacell_class = get_datacell_class($row['entry_type']);
    }
    foreach ($details_to_view as $key) {
        $entry = $row["{$key}"];
        $width = "";
        $expander = "";
        if (strlen($entry) > 20) {
            $width = "width=120";
            //put the full notes into fullentry
            $fullentry[$key] = $entry;
            // trim down displayed notes
            $entry = substr($entry, 0, 16);
            $expander = "<a onClick='reveal({$key}Note{$session_id}); return false' class=expander > +</a>\n";
        }
        if ($entry == "") {
            $entry = "&nbsp";
        }
        ##echo "\t\t<td class=datacell nowrap $width >$entry $expander </td>\n";
        echo "\t\t<td class={$datacell_class} >{$entry} {$expander} </td>\n";
    }
    // Check that the current user has permission to use these edit commands
    // on the athlete being viewed
    $viewer = $_SESSION['athlete_id'];
    if (check_share_permission($athlete_id, "edit log {$viewer}")) {
        # add a link to the end of each line to allow addition of sub-session
        # this will call the add_log_entry sending it the
        # session_id in _GET[parent_session]
        $session_id = $row['session_id'];
        echo "<td nowrap >";
        display_options_menu($session_id, $start_date);
        echo "\n</TD>\t</tr>\n";
    } else {
        echo "\n<TD>&nbsp;</TD>\n";
    }
    $num = $numcols + 1;
    foreach (array_keys($fullentry) as $key) {
        $notes = $fullentry[$key];
        echo <<<ENDHTML

\t<TR><TD border=0 cellpadding=0 cellspacing=0 class=firstcolumn ></TD><TD></TD><TD colspan={$num} >
\t<DIV ID='{$key}Note{$session_id}' class='hiddentext'> 
\t <TABLE cellpadding=0 cellspacing=0 > <TR><TD class=datacell ><b>{$key}:</b> {$notes} &nbsp;</TD></TR></TABLE> 
\t</DIV>
\t</TD></TR>


ENDHTML;
    }
    if ($split > 0) {
        # This function has been called by the add-user split function
        # and it is this session that is being split
        # so dislplay the add-user session form here
        $span = $num + 2;
        // Get the parent's start date
        $start_date = $row['start_date'];
        #echo "<TR><TD></TD><TD></TD><TD colspan=$span ><font size=2 >\n";
        echo "<TR><TD colspan={$span} ><font size=2 >\n";
        echo "<b>Insert Session Split Info</b>\n";
        session_form($session_id, $athlete_id, "", $start_date);
        echo "\t</TD></TR>\n\n";
    }
    #echo "</table>\n";
    # Set the global to the last start date so it can be compared on the next
    # time this is run so we know whether this is a new day or not.
    $GLOBALS['previous_date'] = $start_date;
}
Exemple #4
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";