/** * Print header for the specified project version. * @param int $p_version_id a valid version id * @return null */ function print_version_header( $p_version_id ) { $t_project_id = version_get_field( $p_version_id, 'project_id' ); $t_version_name = version_get_field( $p_version_id, 'version' ); $t_project_name = project_get_field( $t_project_id, 'name' ); $t_release_title = '<a href="changelog_page.php?project_id=' . $t_project_id . '">' . string_display_line( $t_project_name ) . '</a> - <a href="changelog_page.php?version_id=' . $p_version_id . '">' . string_display_line( $t_version_name ) . '</a>'; if ( config_get( 'show_changelog_dates' ) ) { $t_version_released = version_get_field( $p_version_id, 'released' ); $t_release_timestamp = version_get_field( $p_version_id, 'date_order' ); if ( (bool) $t_version_released ) { $t_release_date = ' (' . lang_get('released') . ' ' . string_display_line( date( config_get( 'short_date_format' ), $t_release_timestamp ) ) . ')'; } else { $t_release_date = ' (' . lang_get( 'not_released' ) . ')'; } } else { $t_release_date = ''; } echo '<br />', $t_release_title, $t_release_date, lang_get( 'word_separator' ), print_bracket_link( 'view_all_set.php?type=1&temporary=y&' . FILTER_PROPERTY_PROJECT_ID . '=' . $t_project_id . '&' . filter_encode_field_and_value( FILTER_PROPERTY_FIXED_IN_VERSION, $t_version_name ), lang_get( 'view_bugs_link' ) ), '<br />'; $t_release_title_without_hyperlinks = $t_project_name . ' - ' . $t_version_name . $t_release_date; echo utf8_str_pad( '', utf8_strlen( $t_release_title_without_hyperlinks ), '=' ), '<br />'; }
function print_version_header($p_version_id) { $t_project_id = version_get_field($p_version_id, 'project_id'); $t_version_name = version_get_field($p_version_id, 'version'); $t_project_name = project_get_field($t_project_id, 'name'); $t_release_title = string_display($t_project_name) . ' - ' . string_display($t_version_name); echo '<tt>'; echo '<br />', $t_release_title, '<br />'; echo str_pad('', strlen($t_release_title), '='), '<br />'; }
/** * if all projects selected, default to <username>.csv, otherwise default to * <projectname>.csv. * @return string filename * @access public */ function csv_get_default_filename() { $t_current_project_id = helper_get_current_project(); if (ALL_PROJECTS == $t_current_project_id) { $t_filename = user_get_name(auth_get_current_user_id()); } else { $t_filename = project_get_field($t_current_project_id, 'name'); } return $t_filename . '.csv'; }
function print_version_header($p_version_id) { $t_project_id = version_get_field($p_version_id, 'project_id'); $t_version_name = version_get_field($p_version_id, 'version'); $t_project_name = project_get_field($t_project_id, 'name'); $t_release_title = string_display($t_project_name) . ' - ' . string_display($t_version_name); echo $t_release_title, '<br />'; echo str_pad('', strlen($t_release_title), '='), '<br />'; $t_description = version_get_field($p_version_id, 'description'); if ($t_description !== false && !is_blank($t_description)) { echo string_display("<br />{$t_description}<br /><br />"); } }
function print_version_header($p_version_row) { $t_project_id = $p_version_row['project_id']; $t_version_id = $p_version_row['id']; $t_version_name = $p_version_row['version']; $t_project_name = project_get_field($t_project_id, 'name'); $t_release_title = '<a href="roadmap_page.php?project_id=' . $t_project_id . '">' . string_display_line($t_project_name) . '</a> - <a href="roadmap_page.php?version_id=' . $t_version_id . '">' . string_display_line($t_version_name) . '</a>'; if (config_get('show_roadmap_dates')) { $t_version_timestamp = $p_version_row['date_order']; $t_scheduled_release_date = ' (' . lang_get('scheduled_release') . ' ' . string_display_line(date(config_get('short_date_format'), $t_version_timestamp)) . ')'; } else { $t_scheduled_release_date = ''; } echo '<tt>'; echo '<br />', $t_release_title, $t_scheduled_release_date, lang_get('word_separator'), print_bracket_link('view_all_set.php?type=1&temporary=y&' . FILTER_PROPERTY_PROJECT_ID . '=' . $t_project_id . '&' . filter_encode_field_and_value(FILTER_PROPERTY_TARGET_VERSION, $t_version_name), lang_get('view_bugs_link')), '<br />'; $t_release_title_without_hyperlinks = $t_project_name . ' - ' . $t_version_name . $t_scheduled_release_date; echo utf8_str_pad('', utf8_strlen($t_release_title_without_hyperlinks), '='), '<br />'; }
function twitter_news($p_news_id) { if (!twitter_enabled()) { return true; } $t_news_view_state = news_get_field($p_news_id, 'view_state'); if (VS_PUBLIC != $t_news_view_state) { return true; } $t_news_project_id = news_get_field($p_news_id, 'project_id'); if ($t_news_project_id != ALL_PROJECTS) { $t_project_view_state = project_get_field($t_news_project_id, 'view_state'); if (VS_PUBLIC != $t_project_view_state) { return true; } } $t_news_headline = news_get_field($p_news_id, 'headline'); return twitter_update($t_news_headline); }
function project_get_all_user_rows($p_project_id = ALL_PROJECTS, $p_access_level = ANYBODY, $p_include_global_users = true) { $c_project_id = db_prepare_int($p_project_id); # Optimization when access_level is NOBODY if (NOBODY == $p_access_level) { return array(); } $t_user_table = db_get_table('mantis_user_table'); $t_project_user_list_table = db_get_table('mantis_project_user_list_table'); $t_project_table = db_get_table('mantis_project_table'); $t_on = ON; $t_users = array(); $t_global_access_level = $p_access_level; if ($c_project_id != ALL_PROJECTS && $p_include_global_users) { # looking for specific project if (VS_PRIVATE == project_get_field($p_project_id, 'view_state')) { /** @todo (thraxisp) this is probably more complex than it needs to be * When a new project is created, those who meet 'private_project_threshold' are added * automatically, but don't have an entry in project_user_list_table. * if they did, you would not have to add global levels. */ $t_private_project_threshold = config_get('private_project_threshold'); if (is_array($t_private_project_threshold)) { if (is_array($p_access_level)) { # both private threshold and request are arrays, use intersection $t_global_access_level = array_intersect($p_access_level, $t_private_project_threshold); } else { # private threshold is an array, but request is a number, use values in threshold higher than request $t_global_access_level = array(); foreach ($t_private_project_threshold as $t_threshold) { if ($p_access_level <= $t_threshold) { $t_global_access_level[] = $t_threshold; } } } } else { if (is_array($p_access_level)) { // private threshold is a number, but request is an array, use values in request higher than threshold $t_global_access_level = array(); foreach ($p_access_level as $t_threshold) { if ($t_threshold >= $t_private_project_threshold) { $t_global_access_level[] = $t_threshold; } } } else { // both private threshold and request are numbers, use maximum $t_global_access_level = max($p_access_level, $t_private_project_threshold); } } } } if (is_array($t_global_access_level)) { if (0 == count($t_global_access_level)) { $t_global_access_clause = '>= ' . NOBODY . ' '; } else { if (1 == count($t_global_access_level)) { $t_global_access_clause = '= ' . array_shift($t_global_access_level) . ' '; } else { $t_global_access_clause = 'IN (' . implode(',', $t_global_access_level) . ')'; } } } else { $t_global_access_clause = ">= {$t_global_access_level} "; } if ($p_include_global_users) { $query = "SELECT id, username, realname, access_level\n\t\t\t\tFROM {$t_user_table}\n\t\t\t\tWHERE enabled = " . db_param() . "\n\t\t\t\t\tAND access_level {$t_global_access_clause}"; $result = db_query_bound($query, array($t_on)); $t_row_count = db_num_rows($result); for ($i = 0; $i < $t_row_count; $i++) { $row = db_fetch_array($result); $t_users[$row['id']] = $row; } } if ($c_project_id != ALL_PROJECTS) { // Get the project overrides $query = "SELECT u.id, u.username, u.realname, l.access_level\n\t\t\t\tFROM {$t_project_user_list_table} l, {$t_user_table} u\n\t\t\t\tWHERE l.user_id = u.id\n\t\t\t\tAND u.enabled = " . db_param() . "\n\t\t\t\tAND l.project_id = " . db_param(); $result = db_query_bound($query, array($t_on, $c_project_id)); $t_row_count = db_num_rows($result); for ($i = 0; $i < $t_row_count; $i++) { $row = db_fetch_array($result); if (is_array($p_access_level)) { $t_keep = in_array($row['access_level'], $p_access_level); } else { $t_keep = $row['access_level'] >= $p_access_level; } if ($t_keep) { $t_users[$row['id']] = $row; } else { # If user's overridden level is lower than required, so remove # them from the list if they were previously there unset($t_users[$row['id']]); } } } user_cache_array_rows(array_keys($t_users)); return array_values($t_users); }
<tr <?php echo helper_alternate_class(); ?> > <!-- Bug ID --> <td> <?php echo bug_format_id($f_bug_id); ?> </td> <!-- Category --> <td> <?php $t_project_name = string_display(project_get_field($t_bug->project_id, 'name')); echo "[{$t_project_name}] {$t_bug->category}"; ?> </td> <!-- Severity --> <td> <?php echo get_enum_element('severity', $t_bug->severity); ?> </td> <!-- Reproducibility --> <td> <?php echo get_enum_element('reproducibility', $t_bug->reproducibility);
/** * Update a project * * @param string $p_username The name of the user * @param string $p_password The password of the user * @param integer $p_project_id A project's id * @param Array $p_project A new ProjectData structure * @return bool returns true or false depending on the success of the update action */ function mc_project_update($p_username, $p_password, $p_project_id, $p_project) { $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return new soap_fault('Client', '', 'Access Denied', 'Username/password combination was incorrect'); } if (!mci_has_administrator_access($t_user_id, $p_project_id)) { return new soap_fault('Client', '', 'Access Denied', 'User does not have administrator access'); } if (!project_exists($p_project_id)) { return new soap_fault('Client', '', "Project '{$p_project_id}' does not exist."); } if (!isset($p_project['name'])) { return new soap_fault('Client', '', 'Missing Field', 'Required Field Missing'); } else { $t_name = $p_project['name']; } // check to make sure project doesn't already exist if ($t_name != project_get_name($p_project_id)) { if (!project_is_name_unique($t_name)) { return new soap_fault('Client', '', 'Project name exists', 'The project name you attempted to add exists already'); } } if (!isset($p_project['description'])) { $t_description = project_get_field($p_project_id, 'description'); } else { $t_description = $p_project['description']; } if (!isset($p_project['status'])) { $t_status = project_get_field($p_project_id, 'status'); } else { $t_status = $p_project['status']; } if (!isset($p_project['view_state'])) { $t_view_state = project_get_field($p_project_id, 'view_state'); } else { $t_view_state = $p_project['view_state']; } if (!isset($p_project['file_path'])) { $t_file_path = project_get_field($p_project_id, 'file_path'); } else { $t_file_path = $p_project['file_path']; } if (!isset($p_project['enabled'])) { $t_enabled = project_get_field($p_project_id, 'enabled'); } else { $t_enabled = $p_project['enabled']; } if (!isset($p_project['inherit_global'])) { $t_inherit_global = project_get_field($p_project_id, 'inherit_global'); } else { $t_inherit_global = $p_project['inherit_global']; } $t_project_status = mci_get_project_status_id($t_status); $t_project_view_state = mci_get_project_view_state_id($t_view_state); return project_update($p_project_id, $t_name, $t_description, $t_project_status, $t_project_view_state, $t_file_path, $t_enabled, $t_inherit_global); }
/** * Update a project * * @param string $p_username The name of the user. * @param string $p_password The password of the user. * @param integer $p_project_id A project's identifier. * @param stdClass $p_project A new ProjectData structure. * @return boolean returns true or false depending on the success of the update action */ function mc_project_update($p_username, $p_password, $p_project_id, stdClass $p_project) { global $g_project_override; $t_user_id = mci_check_login($p_username, $p_password); if ($t_user_id === false) { return mci_soap_fault_access_denied(); } if (!mci_has_administrator_access($t_user_id, $p_project_id)) { return mci_soap_fault_access_denied($t_user_id); } if (!project_exists($p_project_id)) { return SoapObjectsFactory::newSoapFault('Client', 'Project \'' . $p_project_id . '\' does not exist.'); } $g_project_override = $p_project_id; $p_project = SoapObjectsFactory::unwrapObject($p_project); if (!isset($p_project['name'])) { return SoapObjectsFactory::newSoapFault('Client', 'Missing required field \'name\'.'); } else { $t_name = $p_project['name']; } # check to make sure project doesn't already exist if ($t_name != project_get_name($p_project_id)) { if (!project_is_name_unique($t_name)) { return SoapObjectsFactory::newSoapFault('Client', 'Project name exists'); } } if (!isset($p_project['description'])) { $t_description = project_get_field($p_project_id, 'description'); } else { $t_description = $p_project['description']; } if (!isset($p_project['status'])) { $t_status = project_get_field($p_project_id, 'status'); } else { $t_status = $p_project['status']; } if (!isset($p_project['view_state'])) { $t_view_state = project_get_field($p_project_id, 'view_state'); } else { $t_view_state = $p_project['view_state']; } if (!isset($p_project['file_path'])) { $t_file_path = project_get_field($p_project_id, 'file_path'); } else { $t_file_path = $p_project['file_path']; } if (!isset($p_project['enabled'])) { $t_enabled = project_get_field($p_project_id, 'enabled'); } else { $t_enabled = $p_project['enabled']; } if (!isset($p_project['inherit_global'])) { $t_inherit_global = project_get_field($p_project_id, 'inherit_global'); } else { $t_inherit_global = $p_project['inherit_global']; } $t_project_status = mci_get_project_status_id($t_status); $t_project_view_state = mci_get_project_view_state_id($t_view_state); project_update($p_project_id, $t_name, $t_description, $t_project_status, $t_project_view_state, $t_file_path, $t_enabled, $t_inherit_global); return true; }
# Select the faq posts $query = "SELECT *, UNIX_TIMESTAMP(date_posted) as date_posted\n\t\t\tFROM {$g_mantis_worklog_table}\n\t\t\tWHERE id='{$f_id}'"; $result = db_query_bound($query); $worklog_count = db_num_rows($result); # Loop through results for ($i = 0; $i < $worklog_count; $i++) { $row = db_fetch_array($result); extract($row, EXTR_PREFIX_ALL, "v"); $v_headline = string_display($v_headline); $v_content = string_display_links($v_content); $v_date_posted = date($g_normal_date_format, $v_date_posted); $t_poster_name = user_get_name($v_poster_id); $t_poster_email = user_get_email($v_poster_id); $t_project_name = " "; if ($v_project_id != 0) { $t_project_name = project_get_field($v_project_id, "name"); } ?> <p> <div align="center"> <table class="width75" cellspacing="0"> <tr> <td class="worklog-heading"> <span class="worklog-subject"><?php echo '[' . worklog_type_display($v_log_type) . ']' . $v_subject; ?> </span> - <span class="worklog-date"><?php echo $v_date_posted; ?> </span> -
event_signal('EVENT_REPORT_BUG_FORM_TOP', array($t_project_id)); if ($t_show_category) { ?> <tr> <th class="category" width="30%"> <?php echo config_get('allow_no_category') ? '' : '<span class="required">*</span>'; echo '<label for="category_id">'; print_documentation_link('category'); echo '</label>'; ?> </th> <td width="70%"> <?php if ($t_changed_project) { echo '[' . project_get_field($t_bug->project_id, 'name') . '] '; } ?> <select <?php echo helper_get_tab_index(); ?> id="category_id" name="category_id" class="autofocus"> <?php print_category_option_list($f_category_id); ?> </select> </td> </tr> <?php } if ($t_show_reproducibility) {
function print_custom_field_projects_list($p_field_id) { $c_field_id = (int) $p_field_id; $t_project_ids = custom_field_get_project_ids($p_field_id); $t_security_token = form_security_param('manage_proj_custom_field_remove'); foreach ($t_project_ids as $t_project_id) { $t_project_name = project_get_field($t_project_id, 'name'); $t_sequence = custom_field_get_sequence($p_field_id, $t_project_id); echo '<strong>', string_display_line($t_project_name), '</strong>: '; print_bracket_link("manage_proj_custom_field_remove.php?field_id={$c_field_id}&project_id={$t_project_id}&return=custom_field{$t_security_token}", lang_get('remove_link')); echo '<br />- '; $t_linked_field_ids = custom_field_get_linked_ids($t_project_id); $t_current_project_fields = array(); $t_first = true; foreach ($t_linked_field_ids as $t_current_field_id) { if ($t_first) { $t_first = false; } else { echo ', '; } if ($t_current_field_id == $p_field_id) { echo '<em>'; } echo string_display_line(custom_field_get_field($t_current_field_id, 'name')); echo ' (', custom_field_get_sequence($t_current_field_id, $t_project_id), ')'; if ($t_current_field_id == $p_field_id) { echo '</em>'; } } echo '<br /><br />'; } }
function print_column_category($p_row, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE) { global $t_sort, $t_dir; # grab the project name $t_project_name = project_get_field($p_row['project_id'], 'name'); echo '<td class="center">'; # type project name if viewing 'all projects' or if issue is in a subproject if (ON == config_get('show_bug_project_links') && helper_get_current_project() != $p_row['project_id']) { echo '<small>['; print_view_bug_sort_link($t_project_name, 'project_id', $t_sort, $t_dir, $p_columns_target); echo ']</small><br />'; } echo string_display($p_row['category']); echo '</td>'; }
function helper_get_default_export_filename($p_extension_with_dot, $p_prefix = '', $p_suffix = '') { $t_filename = $p_prefix; $t_current_project_id = helper_get_current_project(); if (ALL_PROJECTS == $t_current_project_id) { $t_filename .= user_get_name(auth_get_current_user_id()); } else { $t_filename .= project_get_field($t_current_project_id, 'name'); } return $t_filename . $p_suffix . $p_extension_with_dot; }
</tr> </table> </div> <?php } event_signal('EVENT_MANAGE_PROJECT_PAGE', array($f_project_id)); ?> <!-- PROJECT VIEW STATUS --> <br /> <div align="center"> <table class="width75" cellspacing="1"> <tr> <td class="center"> <?php if (VS_PUBLIC == project_get_field($f_project_id, 'view_state')) { echo lang_get('public_project_msg'); } else { echo lang_get('private_project_msg'); } ?> </td> </tr> </table> </div> <!-- USER MANAGEMENT (ADD) --> <?php # We want to allow people with global permissions and people with high enough # permissions on the project we are editing
# $Id: news_rss.php,v 1.9 2005/08/21 21:07:29 ryandesign Exp $ # -------------------------------------------------------- require_once 'core.php'; $t_core_path = config_get('core_path'); require_once $t_core_path . 'class.RSSBuilder.inc.php'; require_once $t_core_path . 'news_api.php'; require_once $t_core_path . 'project_api.php'; require_once $t_core_path . 'print_api.php'; # only allow RSS generation of anonymous login is enabled. # @@@ consider adding an explicit option to enable/disable RSS syndication. if (OFF == config_get('allow_anonymous_login')) { access_denied(); } # Make sure that the user selected either all projects or a public one. $f_project_id = gpc_get_int('project_id', 0); if ($f_project_id != 0 && VS_PRIVATE == project_get_field($f_project_id, 'view_state')) { access_denied(); } # construct rss file $encoding = lang_get('charset'); $about = config_get('path'); $title = string_rss_links(config_get('window_title') . ' - ' . lang_get('news')); $description = $title; $image_link = config_get('path') . 'images/mantis_logo_button.gif'; # only rss 2.0 $category = string_rss_links(project_get_name($f_project_id)); # in minutes (only rss 2.0) $cache = '60'; $rssfile = new RSSBuilder($encoding, $about, $title, $description, $image_link, $category, $cache); # person, an organization, or a service $publisher = '';
/** * Print the menu bar with a list of projects to which the user has access * @return null */ function print_subproject_menu_bar($p_project_id, $p_parents = '') { $t_subprojects = current_user_get_accessible_subprojects($p_project_id); $t_char = ':'; foreach ($t_subprojects as $t_subproject) { echo $t_char . ' <a href="' . helper_mantis_url('set_project.php?project_id=' . $p_parents . $t_subproject) . '">' . string_html_specialchars(project_get_field($t_subproject, 'name')) . '</a>'; print_subproject_menu_bar($t_subproject, $p_parents . $t_subproject . ';'); $t_char = ','; } }
function getProjectDescription($p_project_id) { return project_get_field($p_project_id, 'description'); }
?> "> <?php echo form_security_field('plugin_xml_import_action'); ?> <input type="hidden" name="project_id" value="<?php echo $t_project_id; ?> " /> <table class="width100"> <tr> <td class="form-title" colspan="2"> <?php echo plugin_lang_get('importing_in_project') . ' ' . string_display(project_get_field($t_project_id, 'name')); ?> </td> </tr> <tr class="row-1"> <td class="category" width="25%"> <?php echo lang_get('select_file'); ?> <br /> <?php echo '<span class="small">(' . lang_get('max_file_size') . ': ' . number_format($t_max_file_size / 1000) . 'k)</span>'; ?> </td> <td width="85%"> <input type="hidden" name="max_file_size" value="<?php
function mci_file_add($p_id, $p_name, $p_content, $p_file_type, $p_table, $p_title = '', $p_desc = '', $p_user_id = null) { if (!file_type_check($p_name)) { return new soap_fault('Client', '', 'File type not allowed.'); } if (!file_is_name_unique($p_name, $p_id)) { return new soap_fault('Client', '', 'Duplicate filename.'); } $t_file_size = strlen($p_content); $t_max_file_size = (int) min(ini_get_number('upload_max_filesize'), ini_get_number('post_max_size'), config_get('max_file_size')); if ($t_file_size > $t_max_file_size) { return new soap_fault('Client', '', 'File is too big.'); } if ('bug' == $p_table) { $t_project_id = bug_get_field($p_id, 'project_id'); $t_issue_id = bug_format_id($p_id); } else { $t_project_id = $p_id; $t_issue_id = 0; } # prepare variables for insertion $c_issue_id = db_prepare_int($t_issue_id); $c_project_id = db_prepare_int($t_project_id); $c_file_type = db_prepare_string($p_file_type); $c_title = db_prepare_string($p_title); $c_desc = db_prepare_string($p_desc); if ($p_user_id === null) { $c_user_id = auth_get_current_user_id(); } else { $c_user_id = (int) $p_user_id; } if ($t_project_id == ALL_PROJECTS) { $t_file_path = config_get('absolute_path_default_upload_folder'); } else { $t_file_path = project_get_field($t_project_id, 'file_path'); if ($t_file_path == '') { $t_file_path = config_get('absolute_path_default_upload_folder'); } } $c_file_path = db_prepare_string($t_file_path); $c_new_file_name = db_prepare_string($p_name); $t_file_hash = $t_issue_id; $t_disk_file_name = $t_file_path . file_generate_unique_name($t_file_hash . '-' . $p_name, $t_file_path); $c_disk_file_name = db_prepare_string($t_disk_file_name); $t_file_size = strlen($p_content); $c_file_size = db_prepare_int($t_file_size); $t_method = config_get('file_upload_method'); switch ($t_method) { case FTP: case DISK: if (!file_exists($t_file_path) || !is_dir($t_file_path) || !is_writable($t_file_path) || !is_readable($t_file_path)) { return new soap_fault('Server', '', "Upload folder '{$t_file_path}' doesn't exist."); } file_ensure_valid_upload_path($t_file_path); if (!file_exists($t_disk_file_name)) { mci_file_write_local($t_disk_file_name, $p_content); if (FTP == $t_method) { $conn_id = file_ftp_connect(); file_ftp_put($conn_id, $t_disk_file_name, $t_disk_file_name); file_ftp_disconnect($conn_id); file_delete_local($t_disk_file_name); } else { chmod($t_disk_file_name, config_get('attachments_file_permissions')); } $c_content = "''"; } break; case DATABASE: $c_content = db_prepare_binary_string($p_content); break; } $t_file_table = db_get_table($p_table . '_file'); $c_id = 'bug' == $p_table ? $c_issue_id : $c_project_id; $query = "INSERT INTO {$t_file_table}\n\t\t\t(" . $p_table . "_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content, user_id)\n\t\tVALUES\n\t\t\t({$c_id}, '{$c_title}', '{$c_desc}', '{$c_disk_file_name}', '{$c_new_file_name}', '{$c_file_path}', {$c_file_size}, '{$c_file_type}', '" . db_now() . "', {$c_content}, {$c_user_id})"; db_query($query); # get attachment id $t_attachment_id = db_insert_id($t_file_table); if ('bug' == $p_table) { # updated the last_updated date $result = bug_update_date($c_issue_id); # log new bug history_log_event_special($c_issue_id, FILE_ADDED, $c_new_file_name); } return $t_attachment_id; }
/** * Move any attachments as needed when a bug is moved from project to project. * * @param integer $p_bug_id ID of bug containing attachments to be moved. * @param integer $p_project_id_to Destination project ID for the bug. * @return void * * @todo: this function can't cope with source or target storing attachments in DB */ function file_move_bug_attachments($p_bug_id, $p_project_id_to) { $t_project_id_from = bug_get_field($p_bug_id, 'project_id'); if ($t_project_id_from == $p_project_id_to) { return; } $t_method = config_get('file_upload_method'); if ($t_method != DISK) { return; } if (!file_bug_has_attachments($p_bug_id)) { return; } $t_path_from = project_get_field($t_project_id_from, 'file_path'); if (is_blank($t_path_from)) { $t_path_from = config_get('absolute_path_default_upload_folder', null, null, $t_project_id_from); } file_ensure_valid_upload_path($t_path_from); $t_path_to = project_get_field($p_project_id_to, 'file_path'); if (is_blank($t_path_to)) { $t_path_to = config_get('absolute_path_default_upload_folder', null, null, $p_project_id_to); } file_ensure_valid_upload_path($t_path_to); if ($t_path_from == $t_path_to) { return; } # Initialize the update query to update a single row $c_bug_id = (int) $p_bug_id; $t_query_disk_attachment_update = 'UPDATE {bug_file} SET folder=' . db_param() . ' WHERE bug_id=' . db_param() . ' AND id =' . db_param(); $t_attachment_rows = bug_get_attachments($p_bug_id); $t_attachments_count = count($t_attachment_rows); for ($i = 0; $i < $t_attachments_count; $i++) { $t_row = $t_attachment_rows[$i]; $t_basename = basename($t_row['diskfile']); $t_disk_file_name_from = file_path_combine($t_path_from, $t_basename); $t_disk_file_name_to = file_path_combine($t_path_to, $t_basename); if (!file_exists($t_disk_file_name_to)) { chmod($t_disk_file_name_from, 0775); if (!rename($t_disk_file_name_from, $t_disk_file_name_to)) { if (!copy($t_disk_file_name_from, $t_disk_file_name_to)) { trigger_error(ERROR_FILE_MOVE_FAILED, ERROR); } file_delete_local($t_disk_file_name_from); } chmod($t_disk_file_name_to, config_get('attachments_file_permissions')); db_query($t_query_disk_attachment_update, array(db_prepare_string($t_path_to), $c_bug_id, (int) $t_row['id'])); } else { trigger_error(ERROR_FILE_DUPLICATE, ERROR); } } }
<tr <?php echo helper_alternate_class(); ?> > <td class="category" width="30%"> <?php echo '<span class="required">*</span>', lang_get('category'); ?> <?php print_documentation_link('category'); ?> </td> <td width="70%"> <?php if ($t_changed_project) { echo "[" . project_get_field($t_bug->project_id, 'name') . "] "; } ?> <select <?php echo helper_get_tab_index(); ?> name="category"> <?php if (is_blank($f_category)) { echo '<option value="" selected="selected">', string_attribute(lang_get('select_option')), '</option>'; } print_category_option_list($f_category); ?> </select> </td> </tr>
?> </tr> <?php $field_name_count = $field_name_count; $f_bug_arr = explode_enum_string($f_export); # @@debug var_dump($t_field_name_arr); for ($i = 0; $i < $row_count; $i++) { # prefix bug data with v_ extract($result[$i], EXTR_PREFIX_ALL, 'v'); if (in_array($v_id, $f_bug_arr) || $f_show_flag == 0) { $t_last_updated = date($g_short_date_format, $v_last_updated); # grab the bugnote count $bugnote_count = bug_get_bugnote_count($v_id); # grab the project name $project_name = project_get_field($v_project_id, 'name'); $t_bug_text_table = config_get('mantis_bug_text_table'); $query4 = "SELECT *\r\n FROM {$t_bug_text_table}\r\n WHERE id='{$v_bug_text_id}'"; $result4 = db_query($query4); $row = db_fetch_array($result4); extract($row, EXTR_PREFIX_ALL, 'v2'); $v_os = string_display($v_os); $v_os_build = string_display($v_os_build); $v_platform = string_display($v_platform); $v_version = string_display($v_version); $v_summary = string_display_links($v_summary); # line feeds are desactivated in case of excel export, to avoid multiple lines if ($f_type_page != 'html') { $v2_description = stripslashes(htmlspecialchars(str_replace('\\n', ' ', $v2_description))); $v2_steps_to_reproduce = stripslashes(htmlspecialchars(str_replace('\\n', ' ', $v2_steps_to_reproduce))); $v2_additional_information = stripslashes(htmlspecialchars(str_replace('\\n', ' ', $v2_additional_information)));
$t_sponsor = sponsorship_get($t_sponsor_row['sponsor']); $t_buglist[] = $t_sponsor_row['bug'] . ':' . $t_sponsor_row['sponsor']; # describe bug $t_status = string_attribute(get_enum_element('status', $t_bug->status, auth_get_current_user_id(), $t_bug->project_id)); $t_resolution = string_attribute(get_enum_element('resolution', $t_bug->resolution, auth_get_current_user_id(), $t_bug->project_id)); $t_version_id = version_get_id($t_bug->fixed_in_version, $t_bug->project_id); if (false !== $t_version_id && VERSION_RELEASED == version_get_field($t_version_id, 'released')) { $t_released_label = '<a title="' . lang_get('released') . '">' . $t_bug->fixed_in_version . '</a>'; } else { $t_released_label = $t_bug->fixed_in_version; } # choose color based on status $t_status_label = html_get_status_css_class($t_bug->status, auth_get_current_user_id(), $t_bug->project_id); echo '<tr class="' . $t_status_label . '">'; echo '<td><a href="' . string_get_bug_view_url($t_sponsor_row['bug']) . '">' . bug_format_id($t_sponsor_row['bug']) . '</a></td>'; echo '<td>' . string_display_line(project_get_field($t_bug->project_id, 'name')) . ' </td>'; echo '<td class="right">' . $t_released_label . ' </td>'; echo '<td><a title="' . $t_resolution . '"><span class="underline">' . $t_status . '</span> </a></td>'; # summary echo '<td>' . string_display_line($t_bug->summary); if (VS_PRIVATE == $t_bug->view_state) { printf(' <img src="%s" alt="(%s)" title="%s" />', $t_icon_path . 'protected.gif', lang_get('private'), lang_get('private')); } echo '</td>'; # describe sponsorship amount echo '<td>'; print_user($t_sponsor->user_id); echo '</td>'; echo '<td class="right">' . sponsorship_format_amount($t_sponsor->amount) . '</td>'; echo '<td><select name="sponsor_' . $t_row['bug'] . '_' . $t_sponsor->id . '">'; print_enum_string_option_list('sponsorship', $t_sponsor->paid);
/** * Localizes one raw history item specified by set the next parameters: $p_field_name, $p_type, $p_old_value, $p_new_value * Returns array with two elements indexed as 'note' and 'change' * @param string $p_field_name The field name of the field being localized. * @param integer $p_type The type of the history entry. * @param string $p_old_value The old value of the field. * @param string $p_new_value The new value of the field. * @param boolean $p_linkify Whether to return a string containing hyperlinks. * @return array */ function history_localize_item($p_field_name, $p_type, $p_old_value, $p_new_value, $p_linkify = true) { $t_note = ''; $t_change = ''; $t_field_localized = $p_field_name; $t_raw = true; if (PLUGIN_HISTORY == $p_type) { $t_note = lang_get_defaulted('plugin_' . $p_field_name, $p_field_name); $t_change = isset($p_new_value) ? $p_old_value . ' => ' . $p_new_value : $p_old_value; return array('note' => $t_note, 'change' => $t_change, 'raw' => true); } switch ($p_field_name) { case 'category': $t_field_localized = lang_get('category'); break; case 'status': $p_old_value = get_enum_element('status', $p_old_value); $p_new_value = get_enum_element('status', $p_new_value); $t_field_localized = lang_get('status'); break; case 'severity': $p_old_value = get_enum_element('severity', $p_old_value); $p_new_value = get_enum_element('severity', $p_new_value); $t_field_localized = lang_get('severity'); break; case 'reproducibility': $p_old_value = get_enum_element('reproducibility', $p_old_value); $p_new_value = get_enum_element('reproducibility', $p_new_value); $t_field_localized = lang_get('reproducibility'); break; case 'resolution': $p_old_value = get_enum_element('resolution', $p_old_value); $p_new_value = get_enum_element('resolution', $p_new_value); $t_field_localized = lang_get('resolution'); break; case 'priority': $p_old_value = get_enum_element('priority', $p_old_value); $p_new_value = get_enum_element('priority', $p_new_value); $t_field_localized = lang_get('priority'); break; case 'eta': $p_old_value = get_enum_element('eta', $p_old_value); $p_new_value = get_enum_element('eta', $p_new_value); $t_field_localized = lang_get('eta'); break; case 'view_state': $p_old_value = get_enum_element('view_state', $p_old_value); $p_new_value = get_enum_element('view_state', $p_new_value); $t_field_localized = lang_get('view_status'); break; case 'projection': $p_old_value = get_enum_element('projection', $p_old_value); $p_new_value = get_enum_element('projection', $p_new_value); $t_field_localized = lang_get('projection'); break; case 'sticky': $p_old_value = gpc_string_to_bool($p_old_value) ? lang_get('yes') : lang_get('no'); $p_new_value = gpc_string_to_bool($p_new_value) ? lang_get('yes') : lang_get('no'); $t_field_localized = lang_get('sticky_issue'); break; case 'project_id': if (project_exists($p_old_value)) { $p_old_value = project_get_field($p_old_value, 'name'); } else { $p_old_value = '@' . $p_old_value . '@'; } # Note that the new value maybe an intermediately project and not the # current one. if (project_exists($p_new_value)) { $p_new_value = project_get_field($p_new_value, 'name'); } else { $p_new_value = '@' . $p_new_value . '@'; } $t_field_localized = lang_get('email_project'); break; case 'handler_id': $t_field_localized = lang_get('assigned_to'); case 'reporter_id': if ('reporter_id' == $p_field_name) { $t_field_localized = lang_get('reporter'); } if (0 == $p_old_value) { $p_old_value = ''; } else { $p_old_value = user_get_name($p_old_value); } if (0 == $p_new_value) { $p_new_value = ''; } else { $p_new_value = user_get_name($p_new_value); } break; case 'version': $t_field_localized = lang_get('product_version'); break; case 'fixed_in_version': $t_field_localized = lang_get('fixed_in_version'); break; case 'target_version': $t_field_localized = lang_get('target_version'); break; case 'date_submitted': $p_old_value = date(config_get('normal_date_format'), $p_old_value); $p_new_value = date(config_get('normal_date_format'), $p_new_value); $t_field_localized = lang_get('date_submitted'); break; case 'last_updated': $p_old_value = date(config_get('normal_date_format'), $p_old_value); $p_new_value = date(config_get('normal_date_format'), $p_new_value); $t_field_localized = lang_get('last_update'); break; case 'os': $t_field_localized = lang_get('os'); break; case 'os_build': $t_field_localized = lang_get('os_version'); break; case 'build': $t_field_localized = lang_get('build'); break; case 'platform': $t_field_localized = lang_get('platform'); break; case 'summary': $t_field_localized = lang_get('summary'); break; case 'duplicate_id': $t_field_localized = lang_get('duplicate_id'); break; case 'sponsorship_total': $t_field_localized = lang_get('sponsorship_total'); break; case 'due_date': if ($p_old_value !== '') { $p_old_value = date(config_get('normal_date_format'), (int) $p_old_value); } if ($p_new_value !== '') { $p_new_value = date(config_get('normal_date_format'), (int) $p_new_value); } $t_field_localized = lang_get('due_date'); break; default: # assume it's a custom field name $t_field_id = custom_field_get_id_from_name($p_field_name); if (false !== $t_field_id) { $t_cf_type = custom_field_type($t_field_id); if ('' != $p_old_value) { $p_old_value = string_custom_field_value_for_email($p_old_value, $t_cf_type); } $p_new_value = string_custom_field_value_for_email($p_new_value, $t_cf_type); $t_field_localized = lang_get_defaulted($p_field_name); } } if (NORMAL_TYPE != $p_type) { switch ($p_type) { case NEW_BUG: $t_note = lang_get('new_bug'); break; case BUGNOTE_ADDED: $t_note = lang_get('bugnote_added') . ': ' . $p_old_value; break; case BUGNOTE_UPDATED: $t_note = lang_get('bugnote_edited') . ': ' . $p_old_value; $t_old_value = (int) $p_old_value; $t_new_value = (int) $p_new_value; if ($p_linkify && bug_revision_exists($t_new_value)) { if (bugnote_exists($t_old_value)) { $t_bug_revision_view_page_argument = 'bugnote_id=' . $t_old_value . '#r' . $t_new_value; } else { $t_bug_revision_view_page_argument = 'rev_id=' . $t_new_value; } $t_change = '<a href="bug_revision_view_page.php?' . $t_bug_revision_view_page_argument . '">' . lang_get('view_revisions') . '</a>'; $t_raw = false; } break; case BUGNOTE_DELETED: $t_note = lang_get('bugnote_deleted') . ': ' . $p_old_value; break; case DESCRIPTION_UPDATED: $t_note = lang_get('description_updated'); $t_old_value = (int) $p_old_value; if ($p_linkify && bug_revision_exists($t_old_value)) { $t_change = '<a href="bug_revision_view_page.php?rev_id=' . $t_old_value . '#r' . $t_old_value . '">' . lang_get('view_revisions') . '</a>'; $t_raw = false; } break; case ADDITIONAL_INFO_UPDATED: $t_note = lang_get('additional_information_updated'); $t_old_value = (int) $p_old_value; if ($p_linkify && bug_revision_exists($t_old_value)) { $t_change = '<a href="bug_revision_view_page.php?rev_id=' . $t_old_value . '#r' . $t_old_value . '">' . lang_get('view_revisions') . '</a>'; $t_raw = false; } break; case STEP_TO_REPRODUCE_UPDATED: $t_note = lang_get('steps_to_reproduce_updated'); $t_old_value = (int) $p_old_value; if ($p_linkify && bug_revision_exists($t_old_value)) { $t_change = '<a href="bug_revision_view_page.php?rev_id=' . $t_old_value . '#r' . $t_old_value . '">' . lang_get('view_revisions') . '</a>'; $t_raw = false; } break; case FILE_ADDED: $t_note = lang_get('file_added') . ': ' . $p_old_value; break; case FILE_DELETED: $t_note = lang_get('file_deleted') . ': ' . $p_old_value; break; case BUGNOTE_STATE_CHANGED: $p_old_value = get_enum_element('view_state', $p_old_value); $t_note = lang_get('bugnote_view_state') . ': ' . $p_new_value . ': ' . $p_old_value; break; case BUG_MONITOR: $p_old_value = user_get_name($p_old_value); $t_note = lang_get('bug_monitor') . ': ' . $p_old_value; break; case BUG_UNMONITOR: if ($p_old_value !== '') { $p_old_value = user_get_name($p_old_value); } $t_note = lang_get('bug_end_monitor') . ': ' . $p_old_value; break; case BUG_DELETED: $t_note = lang_get('bug_deleted') . ': ' . $p_old_value; break; case BUG_ADD_SPONSORSHIP: $t_note = lang_get('sponsorship_added'); $t_change = user_get_name($p_old_value) . ': ' . sponsorship_format_amount($p_new_value); break; case BUG_UPDATE_SPONSORSHIP: $t_note = lang_get('sponsorship_updated'); $t_change = user_get_name($p_old_value) . ': ' . sponsorship_format_amount($p_new_value); break; case BUG_DELETE_SPONSORSHIP: $t_note = lang_get('sponsorship_deleted'); $t_change = user_get_name($p_old_value) . ': ' . sponsorship_format_amount($p_new_value); break; case BUG_PAID_SPONSORSHIP: $t_note = lang_get('sponsorship_paid'); $t_change = user_get_name($p_old_value) . ': ' . get_enum_element('sponsorship', $p_new_value); break; case BUG_ADD_RELATIONSHIP: $t_note = lang_get('relationship_added'); $t_change = relationship_get_description_for_history($p_old_value) . ' ' . bug_format_id($p_new_value); break; case BUG_REPLACE_RELATIONSHIP: $t_note = lang_get('relationship_replaced'); $t_change = relationship_get_description_for_history($p_old_value) . ' ' . bug_format_id($p_new_value); break; case BUG_DEL_RELATIONSHIP: $t_note = lang_get('relationship_deleted'); # Fix for #7846: There are some cases where old value is empty, this may be due to an old bug. if (!is_blank($p_old_value) && $p_old_value > 0) { $t_change = relationship_get_description_for_history($p_old_value) . ' ' . bug_format_id($p_new_value); } else { $t_change = bug_format_id($p_new_value); } break; case BUG_CLONED_TO: $t_note = lang_get('bug_cloned_to') . ': ' . bug_format_id($p_new_value); break; case BUG_CREATED_FROM: $t_note = lang_get('bug_created_from') . ': ' . bug_format_id($p_new_value); break; case TAG_ATTACHED: $t_note = lang_get('tag_history_attached') . ': ' . $p_old_value; break; case TAG_DETACHED: $t_note = lang_get('tag_history_detached') . ': ' . $p_old_value; break; case TAG_RENAMED: $t_note = lang_get('tag_history_renamed'); $t_change = $p_old_value . ' => ' . $p_new_value; break; case BUG_REVISION_DROPPED: $t_note = lang_get('bug_revision_dropped_history') . ': ' . bug_revision_get_type_name($p_new_value) . ': ' . $p_old_value; break; case BUGNOTE_REVISION_DROPPED: $t_note = lang_get('bugnote_revision_dropped_history') . ': ' . $p_new_value . ': ' . $p_old_value; break; } } # output special cases if (NORMAL_TYPE == $p_type) { $t_note = $t_field_localized; $t_change = $p_old_value . ' => ' . $p_new_value; } # end if DEFAULT return array('note' => $t_note, 'change' => $t_change, 'raw' => $t_raw); }
/** * This function checks the project access level first (for the current project * if none is specified) and if the user is not listed, it falls back on the * user's global access level. * @param int $p_project_id integer representing project id to check access against * @param int|null $p_user_id integer representing user id, defaults to null to use current user * @return int access level user has to given project * @access public */ function access_get_project_level($p_project_id = null, $p_user_id = null) { if (null === $p_user_id) { $p_user_id = auth_get_current_user_id(); } # Deal with not logged in silently in this case /** @todo we may be able to remove this and just error and once we default to anon login, we can remove it for sure */ if (empty($p_user_id) && !auth_is_user_authenticated()) { return ANYBODY; } if (null === $p_project_id) { $p_project_id = helper_get_current_project(); } $t_global_access_level = access_get_global_level($p_user_id); if (ALL_PROJECTS == $p_project_id || user_is_administrator($p_user_id)) { return $t_global_access_level; } else { $t_project_access_level = access_get_local_level($p_user_id, $p_project_id); $t_project_view_state = project_get_field($p_project_id, 'view_state'); # Try to use the project access level. # If the user is not listed in the project, then try to fall back # to the global access level if (false === $t_project_access_level) { # If the project is private and the user isn't listed, then they # must have the private_project_threshold access level to get in. if (VS_PRIVATE == $t_project_view_state) { if (access_compare_level($t_global_access_level, config_get('private_project_threshold', null, null, ALL_PROJECTS))) { return $t_global_access_level; } else { return ANYBODY; } } else { # project access not set, but the project is public return $t_global_access_level; } } else { # project specific access was set return $t_project_access_level; } } }
/** * Returns the upload path for the specified project, empty string if * file_upload_method is DATABASE * @param int $p_project_id * @return string upload path */ function project_get_upload_path($p_project_id) { if (DATABASE == config_get('file_upload_method', null, ALL_USERS, $p_project_id)) { return ''; } if ($p_project_id == ALL_PROJECTS) { $t_path = config_get('absolute_path_default_upload_folder', '', ALL_USERS, ALL_PROJECTS); } else { $t_path = project_get_field($p_project_id, 'file_path'); if (is_blank($t_path)) { $t_path = config_get('absolute_path_default_upload_folder', '', ALL_USERS, $p_project_id); } } return $t_path; }
/** * Print column content for column category id * * @param BugData $p_bug bug object * @param int $p_columns_target see COLUMNS_TARGET_* in constant_inc.php * @return null * @access public */ function print_column_category_id($p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE) { global $t_sort, $t_dir; # grab the project name $t_project_name = project_get_field($p_bug->project_id, 'name'); echo '<td class="column-category">'; # type project name if viewing 'all projects' or if issue is in a subproject if (ON == config_get('show_bug_project_links') && helper_get_current_project() != $p_bug->project_id) { echo '<small class="project">['; print_view_bug_sort_link(string_display_line($t_project_name), 'project_id', $t_sort, $t_dir, $p_columns_target); echo ']</small><br />'; } echo string_display_line(category_full_name($p_bug->category_id, false)); echo '</td>'; }
function print_subproject_menu_bar($p_project_id, $p_parents = '') { $t_subprojects = current_user_get_accessible_subprojects($p_project_id); $t_char = ':'; foreach ($t_subprojects as $t_subproject) { print "{$t_char} <a href=\"set_project.php?project_id={$p_parents}{$t_subproject}\">" . string_display(project_get_field($t_subproject, 'name')) . '</a>'; print_subproject_menu_bar($t_subproject, $p_parents . $t_subproject . ';'); $t_char = ','; } }