/** * Load an existing TimecardProject object from the database, or generate * a new object when one doesn't exist. * @param int Project ID * @param boolean Load TimecardBug objects * @return object TimecardProject object */ static function load($p_project_id, $p_load_bugs = false) { $t_project_table = plugin_table('project', 'Timecard'); $t_query = "SELECT * FROM {$t_project_table} WHERE project_id=" . db_param(); $t_result = db_query_bound($t_query, array($p_project_id)); if (db_num_rows($t_result) < 1) { return new TimecardProject($p_project_id); } $t_row = db_fetch_array($t_result); $t_project = new TimecardProject($t_row['project_id'], $t_row['timecard']); $t_project->new = false; if ($p_load_bugs) { $t_project->load_bugs($p_load_bugs); } return $t_project; }
/** * When creating or updating a project, save the given default timecard * string to the database. */ function project_update($p_event, $p_project_id) { if (plugin_config_get('use_timecard')) { $f_timecard = trim(gpc_get_string('plugin_timecard', '')); $t_project = TimecardProject::load($p_project_id); if ($t_project->timecard != $f_timecard) { $t_project->timecard = $f_timecard; $t_project->save(); } } }