$project_owner = Sql::get_user_from_name($project_ownername); if ($project_owner) { $project = Sql::get_project_from_url($project_owner->get_id(), $project_urlname); } $tasks = NULL; $project_name = "<Unknown project>"; $project_owner_name = "<Unknown owner>"; $project_description = "This project does not exist yet."; $project_id = 0; $worked_per_week = -1; $owner_logged_in = FALSE; if ($project) { $project_name = $project->get_name(); $project_description = $project->get_description(); $project_id = $project->get_id(); $tasks = Sql::get_tasks_from_project_id($project_id); $project_owner = Sql::get_user_from_id($project->get_owner_user_id()); $owner_logged_in = Authentication::authenticate_user_by_cookie($project->get_owner_user_id()); $worked_per_week = $project->get_worked_per_week(); if ($project_owner) { $project_owner_name = $project_owner->get_name(); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo $project_owner_name; ?> /<?php
/** * Update todays date with the given work change. If todays date * is 2011-01-23 and the remaining work size left that day is * 10.0, and this function is called with $work_change set to 2.0, * then after this function call the stored remaining work would * be changed to 12.0. * * The user must be authenticated. */ public static function update_todays_remaining_work_authed($project_id, $work_change) { // Our dates are always UTC $todays_date = date('Y-m-d'); $query = new SqlQuery("SELECT remaining_size FROM Remaining WHERE remaining_projectid='%s' AND remaining_date='%s' LIMIT 1", $project_id, $todays_date); if ($query->select_was_successful()) { // We've updated todays date before $update_mode = 'update'; $last_size = $query->get_next_row_column('remaining_size'); } else { // First time we update the time for this day, use size // from yesterday (or rather, last day we made an update) $update_mode = 'insert'; $query = new SqlQuery("SELECT remaining_size FROM Remaining WHERE remaining_projectid='%s' LIMIT 1", $project_id); if ($query->select_was_successful()) { $last_size = $query->get_next_row_column('remaining_size'); } else { // First update ever for the project, start at zero $last_size = 0.0; } } $new_size = 0; $tasks = Sql::get_tasks_from_project_id($project_id); foreach ((array) $tasks as $task) { $new_size += $task->get_size(); } if ($update_mode == 'update') { $query = new SqlQuery("UPDATE Remaining SET remaining_size='%s' WHERE remaining_projectid='%s' AND remaining_date='%s' LIMIT 1", $new_size, $project_id, $todays_date); } else { $query = new SqlQuery("INSERT INTO Remaining (remaining_projectid, remaining_size, remaining_date) VALUES ('%s', '%s', '%s')", $project_id, $new_size, $todays_date); } }