Skip to content

Commit

Permalink
Some cleanup in progress of the manage files
Browse files Browse the repository at this point in the history
* config_defaults_inc.php:
  (g_delete_project_threshold): new option to control who can delete projects
  (g_create_project_threshold): new option to control who can creates projecs

* manage_proj_add.php:
  + use new threshold (create_project_threshold)
  + user print instead of ECHO

* manage_proj_cat_copy.php:
  + use new function category_get_all_rows()

* manage_proj_cat_edit_page.php:
  + add a comment to come back to later

* manage_proj_delete.php:
  + use bew threshold (delete_project_threshold)

* manage_proj_edit_page.php:
  + remove unused GPC parameter f_action
  + use file_is_uploading_enabled() instead of checking one variable ourselves
  + use bew threshold (delete_project_threshold)
  + split categories and versions into two tables
  + use new function category_get_all_rows()
  + use new function version_get_all_rows()

* manage_proj_page.php:
  + use new threshold (create_project_threshold)

* core/category_api.php:
  (category_get_all): renamed to category_get_all_rows
  (category_get_all_rows): return an array of rows instead of a result

* core/file_api.php:
  (file_is_uploading_enabled): new function that determines whether uploading
    is enabled in general
  (file_allow_project_upload): use files_is_uploading_enabled()
  (file_allow_bug_upload): use files_is_uploading_enabled()

* core/project_api.php:
  (project_get_row): new function
  (project_get_field): use project_get_row()


git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@1791 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
Julian Fitzell committed Jan 30, 2003
1 parent 7462eec commit fa10a0c
Show file tree
Hide file tree
Showing 13 changed files with 210 additions and 119 deletions.
8 changes: 7 additions & 1 deletion config_defaults_inc.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: config_defaults_inc.php,v 1.65 2003-01-25 21:13:16 jlatour Exp $
# $Id: config_defaults_inc.php,v 1.66 2003-01-30 09:41:11 jfitzell Exp $
# --------------------------------------------------------


Expand Down Expand Up @@ -568,6 +568,12 @@
# details (not to add/delete projects), upload documentation, news, ...etc.
$g_manage_project_threshold = MANAGER;

# Threshold required to delete a project
$g_delete_project_threshold = ADMINISTRATOR;

# Threshold needed to create a new project
$g_create_project_threshold = ADMINISTRATOR;

# --- login method ----------------
# CRYPT or CRYPT_FULL_SALT or PLAIN or MD5 or LDAP or BASIC_AUTH
# If you were using CRYPT and it now fails, try CRYPT_FULL_SALT
Expand Down
24 changes: 19 additions & 5 deletions core/category_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: category_api.php,v 1.4 2003-01-03 03:24:24 jfitzell Exp $
# $Id: category_api.php,v 1.5 2003-01-30 09:41:31 jfitzell Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -84,16 +84,30 @@ function category_delete( $p_project_id, $p_category ) {
}
# --------------------
# return all categories for the specified project id
function category_get_all( $p_project_id ) {
function category_get_all_rows( $p_project_id ) {
global $g_mantis_project_category_table;

$c_project_id = (integer)$p_project_id;
$c_project_id = db_prepare_int( $p_project_id );

$t_project_category_table = config_get( 'mantis_project_category_table' );

$query = "SELECT category, user_id
FROM $g_mantis_project_category_table
FROM $t_project_category_table
WHERE project_id='$c_project_id'
ORDER BY category";
return db_query( $query );
$result = db_query( $query );

$count = db_num_rows( $result );

$rows = array();

for ( $i = 0 ; $i < $count ; $i++ ) {
$row = db_fetch_array( $result );

$rows[] = $row;
}

return $rows;
}
# --------------------
# delete all categories associated with a project
Expand Down
21 changes: 16 additions & 5 deletions core/file_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: file_api.php,v 1.21 2003-01-29 00:53:04 vboctor Exp $
# $Id: file_api.php,v 1.22 2003-01-30 09:41:32 jfitzell Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -300,6 +300,19 @@ function file_add( $p_bug_id, $p_tmp_file, $p_file_name, $p_file_type='' ) {
}

}

# --------------------
# Return true if file uploading is enabled (in our config and PHP's),
# false otherwise
function file_is_uploading_enabled() {
if ( ini_get_bool( 'file_uploads' ) &&
ON == config_get( 'allow_file_upload' ) ) {
return true;
} else {
return false;
}
}

# --------------------
# Check if the user can upload files for this project
# return true if they can, false otherwise
Expand All @@ -314,8 +327,7 @@ function file_allow_project_upload( $p_project_id = null, $p_user_id = null ) {

$t_access = user_get_access_level( $p_user_id, $p_project_id );

if ( ! ini_get_bool( 'file_uploads' ) ||
OFF == config_get( 'allow_file_upload' ) ||
if ( ! file_is_uploading_enabled() ||
$t_access < config_get( 'upload_project_file_threshold' ) ) {
return false;
}
Expand All @@ -336,8 +348,7 @@ function file_allow_bug_upload( $p_bug_id = null, $p_user_id = null ) {
}

# If uploads are disbled just return false
if ( ! ini_get_bool( 'file_uploads' ) ||
OFF == config_get( 'allow_file_upload' ) ) {
if ( ! file_is_uploading_enabled() ) {
return false;
}

Expand Down
10 changes: 8 additions & 2 deletions core/project_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: project_api.php,v 1.25 2003-01-25 18:21:09 jlatour Exp $
# $Id: project_api.php,v 1.26 2003-01-30 09:41:35 jfitzell Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -278,10 +278,16 @@ function project_update( $p_project_id, $p_name, $p_description, $p_status, $p_v
# Data Access
#===================================

# --------------------
# Return the row describing the given project
function project_get_row( $p_project_id ) {
return project_cache_row( $p_project_id );
}

# --------------------
# Return the specified field of the specified project
function project_get_field( $p_project_id, $p_field_name ) {
$row = project_cache_row( $p_project_id );
$row = project_get_row( $p_project_id );

if ( isset( $row[$p_field_name] ) ) {
return $row[$p_field_name];
Expand Down
22 changes: 17 additions & 5 deletions core/version_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: version_api.php,v 1.5 2003-01-03 03:24:25 jfitzell Exp $
# $Id: version_api.php,v 1.6 2003-01-30 09:41:39 jfitzell Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -88,16 +88,28 @@ function version_delete( $p_project_id, $p_version ) {
}
# --------------------
# return all categories for the specified project id
function version_get_all( $p_project_id ) {
$c_project_id = db_prepare_int($p_project_id);
function version_get_all_rows( $p_project_id ) {
$c_project_id = db_prepare_int( $p_project_id );

$t_project_version_table = config_get('mantis_project_version_table');
$t_project_version_table = config_get( 'mantis_project_version_table' );

$query = "SELECT version, date_order
FROM $t_project_version_table
WHERE project_id='$c_project_id'
ORDER BY date_order DESC";
return db_query( $query );
$result = db_query( $query );

$count = db_num_rows( $result );

$rows = array();

for ( $i = 0 ; $i < $count ; $i++ ) {
$row = db_fetch_array( $result );

$rows[] = $row;
}

return $rows;
}
# --------------------
# delete all versions associated with a project
Expand Down
3 changes: 3 additions & 0 deletions doc/ChangeLog
Expand Up @@ -148,6 +148,9 @@ Mantis ChangeLog
* New config option (custom_field_edit_after_create): new option to control whether a user is directed to edit a custom field after creating it
* Enhancement: User names are now auto-generated for accounts that no longer exists. The user names are prefixed by the string (prefix_for_deleted_users).
* Fix: when viewing all bugs for all projects you no longer see bugs from disabled projects
* New config option (create_project_threshold): provide a threshold for users who can create projects
* New config option (delete_project_threshold): provide a threshold for users who can delete projects


2002.08.23 - 0.17.5
* Corrected bug_delete.php and bug_delete_page.php, which ignored the $g_allow_bug_delete_access_level setting.
Expand Down
8 changes: 6 additions & 2 deletions manage_proj_add.php
Expand Up @@ -4,11 +4,15 @@
# Copyright (C) 2002 - 2003 Mantis Team - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: manage_proj_add.php,v 1.25 2003-01-30 09:41:16 jfitzell Exp $
# --------------------------------------------------------
?>
<?php require_once( 'core.php' ) ?>
<?php login_cookie_check() ?>
<?php
check_access( ADMINISTRATOR );
check_access( config_get( 'create_project_threshold' ) );

$f_name = gpc_get_string( 'name' );
$f_description = gpc_get_string( 'description' );
Expand All @@ -30,7 +34,7 @@
<br />
<div align="center">
<?php
PRINT lang_get( 'operation_successful' ).'<br />';
echo lang_get( 'operation_successful' ) . '<br />';

print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) );
?>
Expand Down
7 changes: 3 additions & 4 deletions manage_proj_cat_copy.php
Expand Up @@ -31,10 +31,9 @@
trigger_error( ERROR_GENERIC, ERROR );
}

$result = category_get_all( $t_src_project_id );
$category_count = db_num_rows( $result );
for ($i=0;$i<$category_count;$i++) {
$row = db_fetch_array( $result );
$rows = category_get_all_rows( $t_src_project_id );

foreach ( $rows as $row ) {
$t_category = $row['category'];
$t_category = addslashes( $t_category );

Expand Down
2 changes: 2 additions & 0 deletions manage_proj_cat_edit_page.php
Expand Up @@ -12,6 +12,8 @@

$f_project_id = gpc_get_int( 'project_id' );
$f_category = gpc_get_string( 'category' );

# @@@ we should optain this by looking it up
$f_assigned_to = gpc_get_int( 'assigned_to', 0 );
?>
<?php print_page_top1() ?>
Expand Down
6 changes: 5 additions & 1 deletion manage_proj_delete.php
Expand Up @@ -4,11 +4,15 @@
# Copyright (C) 2002 - 2003 Mantis Team - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: manage_proj_delete.php,v 1.23 2003-01-30 09:41:20 jfitzell Exp $
# --------------------------------------------------------
?>
<?php require_once( 'core.php' ) ?>
<?php login_cookie_check() ?>
<?php
check_access( ADMINISTRATOR );
check_access( config_get( 'delete_project_threshold' ) );

$f_project_id = gpc_get_int( 'project_id' );

Expand Down

0 comments on commit fa10a0c

Please sign in to comment.