/** * Gets the billing information for the specified project during the specified date range. * * @param integer $p_project_id A project identifier or ALL_PROJECTS. * @param string $p_from Starting date (yyyy-mm-dd) inclusive, if blank, then ignored. * @param string $p_to Ending date (yyyy-mm-dd) inclusive, if blank, then ignored. * @param integer $p_cost_per_hour Cost per hour. * @return array array of bugnotes * @access public */ function billing_get_for_project($p_project_id, $p_from, $p_to, $p_cost_per_hour) { $t_params = array(); $c_to = strtotime($p_to) + SECONDS_PER_DAY - 1; $c_from = strtotime($p_from); if ($c_to === false || $c_from === false) { error_parameters(array($p_from, $p_to)); trigger_error(ERROR_GENERIC, ERROR); } db_param_push(); if (ALL_PROJECTS != $p_project_id) { access_ensure_project_level(config_get('view_bug_threshold'), $p_project_id); $t_project_where = ' AND b.project_id = ' . db_param() . ' AND bn.bug_id = b.id '; $t_params[] = $p_project_id; } else { $t_project_ids = user_get_all_accessible_projects(); $t_project_where = ' AND b.project_id in (' . implode(', ', $t_project_ids) . ')'; } if (!is_blank($c_from)) { $t_from_where = ' AND bn.date_submitted >= ' . db_param(); $t_params[] = $c_from; } else { $t_from_where = ''; } if (!is_blank($c_to)) { $t_to_where = ' AND bn.date_submitted <= ' . db_param(); $t_params[] = $c_to; } else { $t_to_where = ''; } $t_results = array(); $t_query = 'SELECT bn.id id, bn.time_tracking minutes, bn.date_submitted as date_submitted, bnt.note note, u.realname realname, b.project_id project_id, c.name bug_category, b.summary bug_summary, bn.bug_id bug_id, bn.reporter_id reporter_id FROM {user} u, {bugnote} bn, {bug} b, {bugnote_text} bnt, {category} c WHERE u.id = bn.reporter_id AND bn.time_tracking != 0 AND bn.bug_id = b.id AND bnt.id = bn.bugnote_text_id AND c.id=b.category_id ' . $t_project_where . $t_from_where . $t_to_where . ' ORDER BY bn.id'; $t_result = db_query($t_query, $t_params); $t_cost_per_min = $p_cost_per_hour / 60.0; $t_access_level_required = config_get('time_tracking_view_threshold'); while ($t_row = db_fetch_array($t_result)) { if (!access_has_bugnote_level($t_access_level_required, $t_row['id'])) { continue; } $t_total_cost = $t_cost_per_min * $t_row['minutes']; $t_row['cost'] = $t_total_cost; $t_results[] = $t_row; } $t_billing_rows = billing_rows_to_array($t_results); return $t_billing_rows; }
/** * return string to use in db queries containing projects of given user * @param int $p_project_id * @param int $p_user_id * @return string */ function helper_project_specific_where($p_project_id, $p_user_id = null) { if (null === $p_user_id) { $p_user_id = auth_get_current_user_id(); } $t_project_ids = user_get_all_accessible_projects($p_user_id, $p_project_id); if (0 == count($t_project_ids)) { $t_project_filter = ' 1<>1'; } else { if (1 == count($t_project_ids)) { $t_project_filter = ' project_id=' . $t_project_ids[0]; } else { $t_project_filter = ' project_id IN (' . join(',', $t_project_ids) . ')'; } } return $t_project_filter; }
* @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net * @link http://www.mantisbt.org */ /** * MantisBT Core API's */ require_once 'core.php'; require_api('version_api.php'); require_api('history_api.php'); $f_project_id = gpc_get_int('project_id', helper_get_current_project()); # Override the current page to make sure we get the appropriate project-specific configuration $g_project_override = $f_project_id; access_ensure_project_level(config_get('view_summary_threshold')); $t_user_id = auth_get_current_user_id(); $t_project_ids = user_get_all_accessible_projects($t_user_id, $f_project_id); html_page_top(plugin_lang_get('menu', 'GanttChart')); ?> <br /> <table class="width100" cellspacing="1"> <tr valign="top"> <td class="form-title" colspan="1"> <?php echo lang_get('email_project'); ?> </td> <td class="form-title" colspan="3"> <?php echo lang_get('versions'); ?>
*/ $a_userMiteRsrces = $a_userMiteBindings = $s_quickLinksList = $a_userProject_ids = array(); /* * @local int */ $i_userId = 0; /* * @local strings */ $s_query = $s_type = $s_DBTable_mpsmp = $s_output = $s_projectsBindingOptions = $s_projectName = ''; ############ # ACTION ####### $o_pluginController = $g_plugin_cache['Mantis2mite']; $i_userId = $o_pluginController->getCurrentUserId(); $a_userProject_ids = user_get_all_accessible_projects($i_userId, ALL_PROJECTS); # !!! POSSIBLE SCRIPT EXIT !!! # only proceed if the user has access to any of the projects ############################################### if (empty($a_userProject_ids)) { echo lang_get('plugin_mite_no_projets_assigned'); exit; } $o_userMiteData = $o_pluginController->getMiteUserData(); $a_userMiteRsrces[Mantis2mitePlugin::API_RSRC_P] = $o_userMiteData->getProjects(); $a_userMiteRsrces[Mantis2mitePlugin::API_RSRC_S] = $o_userMiteData->getServices(); $a_userMiteBindings = $o_userMiteData->getBindings(); # build form with configured values ################################### $s_output .= "\n\t\t<hr size='1' />\n\t\t<form id='frm_mite_mantis_bindings'>\n\t\t<h2>" . lang_get('plugin_mite_header_preferences') . "</h2>"; $s_quickLinksList = "<ul>";
$t_project_id = version_get_field($f_version_id, 'project_id'); } } else { if ($f_project_id == -1) { $t_project_id = helper_get_current_project(); } else { $t_project_id = $f_project_id; } $f_version_id = version_get_id($f_version, $t_project_id); if ($f_version_id === false) { error_parameters($f_version); trigger_error(ERROR_VERSION_NOT_FOUND, ERROR); } } if (ALL_PROJECTS == $t_project_id) { $t_project_ids_to_check = user_get_all_accessible_projects($t_user_id, ALL_PROJECTS); $t_project_ids = array(); foreach ($t_project_ids_to_check as $t_project_id) { $t_roadmap_view_access_level = config_get('roadmap_view_threshold', null, null, $t_project_id); if (access_has_project_level($t_roadmap_view_access_level, $t_project_id)) { $t_project_ids[] = $t_project_id; } } } else { access_ensure_project_level(config_get('roadmap_view_threshold'), $t_project_id); $t_project_ids = user_get_all_accessible_subprojects($t_user_id, $t_project_id); array_unshift($t_project_ids, $t_project_id); } $t_project_id_for_access_check = $t_project_id; html_page_top(lang_get('roadmap')); version_cache_array_rows($t_project_ids);