View Issue Details

IDProjectCategoryView StatusLast Update
0006039mantisbtfeaturepublic2008-07-24 16:50
Reporterjonozzz Assigned Togiallu  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionduplicate 
Product Version1.0.0rc1 
Summary0006039: global categories
Description

When you have many projects, and you want to add/delete some categories from all of them things gets nasty ;)

This patch adds a "Global" checkbox near the "Category" field, when this is checked that category will appear in all projects.

Maybe some1 needs this.

TagsNo tags attached.
Attached Files
03-mantis-1.0.0rc1-global_categories.patch (9,758 bytes)   
diff -Nru mantis_b4cat/core/category_api.php mantis/core/category_api.php
--- mantis_b4cat/core/category_api.php	2005-07-28 15:46:05.000000000 +0300
+++ mantis/core/category_api.php	2005-07-28 15:50:06.000000000 +0300
@@ -70,10 +70,12 @@
 
 	# --------------------
 	# Add a new category to the project
-	function category_add( $p_project_id, $p_category ) {
+	function category_add( $p_project_id, $p_category, $p_global ) {
 		$c_project_id	= db_prepare_int( $p_project_id );
-		$c_category		= db_prepare_string( $p_category );
+		$c_category	= db_prepare_string( $p_category );
+		$c_global	= db_prepare_string( $p_global );
 
+		$c_project_id = ($c_global) ? 0 : $c_project_id;
 		category_ensure_unique( $p_project_id, $p_category );
 
 		$t_project_category_table = config_get( 'mantis_project_category_table' );
@@ -90,20 +92,23 @@
 
 	# --------------------
 	# Update the name and user associated with the category
-	function category_update( $p_project_id, $p_category, $p_new_category, $p_assigned_to ) {
+	function category_update( $p_project_id, $p_category, $p_new_category, $p_assigned_to, $p_global ) {
 		$c_project_id	= db_prepare_int( $p_project_id );
-		$c_category		= db_prepare_string( $p_category );
+		$c_category	= db_prepare_string( $p_category );
 		$c_new_category	= db_prepare_string( $p_new_category );
 		$c_assigned_to	= db_prepare_int( $p_assigned_to );
+		$c_global	= db_prepare_int( $p_global );
 
 		category_ensure_exists( $p_project_id, $p_category );
 
 		$t_project_category_table	= config_get( 'mantis_project_category_table' );
 		$t_bug_table				= config_get( 'mantis_bug_table' );
 
+		$t_project_id = ($c_global == 1) ? 0 : helper_get_current_project();
 		$query = "UPDATE $t_project_category_table
 				  SET category='$c_new_category',
-				  	  user_id=$c_assigned_to
+				  	  user_id=$c_assigned_to,
+				  	  project_id=$t_project_id
 				  WHERE category='$c_category' AND
 						project_id='$c_project_id'";
 		db_query( $query );
@@ -186,7 +191,7 @@
 
 		$t_project_category_table = config_get( 'mantis_project_category_table' );
 
-		$query = "SELECT category, user_id
+		$query = "SELECT category, user_id, project_id
 				FROM $t_project_category_table
 				WHERE project_id='$c_project_id' AND
 					category='$c_category'";
@@ -206,9 +211,9 @@
 
 		$t_project_category_table = config_get( 'mantis_project_category_table' );
 
-		$query = "SELECT category, user_id
+		$query = "SELECT category, user_id, project_id
 				FROM $t_project_category_table
-				WHERE project_id='$c_project_id'
+				WHERE project_id='$c_project_id' OR project_id='0'
 				ORDER BY category";
 		$result = db_query( $query );
 		$count = db_num_rows( $result );
diff -Nru mantis_b4cat/core/print_api.php mantis/core/print_api.php
--- mantis_b4cat/core/print_api.php	2005-07-28 15:46:05.000000000 +0300
+++ mantis/core/print_api.php	2005-07-28 15:50:06.000000000 +0300
@@ -489,7 +489,7 @@
 		$cat_arr = array();
 		$query = "SELECT DISTINCT category
 				FROM $t_mantis_project_category_table
-				WHERE $t_project_where
+				WHERE $t_project_where OR project_id='0'
 				ORDER BY category";
 		$result = db_query( $query );
 		$category_count = db_num_rows( $result );
diff -Nru mantis_b4cat/lang/strings_romanian.txt mantis/lang/strings_romanian.txt
--- mantis_b4cat/lang/strings_romanian.txt	2005-07-28 15:46:05.000000000 +0300
+++ mantis/lang/strings_romanian.txt	2005-07-28 15:50:33.000000000 +0300
@@ -281,7 +281,7 @@
 $s_project_view_state_enum_string = '10:public,50:privat';
 $s_view_state_enum_string         = '10:public,50:private';
 
-$s_priority_enum_string           = '10:fara,20:scazuta,30:normala,40:mare,50:urgenta,60:imediata';
+$s_priority_enum_string           = '20:scazut�,30:normal�,40:mare,50:critic�';
 $s_severity_enum_string           = '10:noutate,20:trivial,30:text,40:optimizare,50:minor,60:major,70:fatal,80:blocant';
 $s_reproducibility_enum_string    = '10:totdeauna,30:uneori,50:aleator,70:nu am incercat,90:nu am reusit sa duplic,100:N/A';
 $s_status_enum_string             = '10:nou,20:feedback,30:vazut,40:confirmat,50:asignat,80:rezolvat,90:inchis';
@@ -565,6 +565,7 @@
 $s_description = 'Descriere';
 $s_steps_to_reproduce = 'Pasi de reprodus';
 $s_update_information_button = 'Modifica informatia';
+$s_global = 'Global';
 $s_sticky_issue = 'Sticky Issue';
 $s_profile = 'Profile';
 
--- mantis_b4cat/lang/strings_english.txt	2005-07-20 17:17:42.000000000 +0300
+++ mantis/lang/strings_english.txt	2005-07-28 16:06:20.000000000 +0300
@@ -566,6 +566,7 @@
 $s_description = 'Description';
 $s_steps_to_reproduce = 'Steps To Reproduce';
 $s_update_information_button = 'Update Information';
+$s_global = 'Global';
 $s_sticky_issue = 'Sticky Issue';
 $s_profile = 'Profile';
 
diff -Nru mantis_b4cat/manage_proj_cat_add.php mantis/manage_proj_cat_add.php
--- mantis_b4cat/manage_proj_cat_add.php	2005-07-28 15:46:05.000000000 +0300
+++ mantis/manage_proj_cat_add.php	2005-07-28 15:50:06.000000000 +0300
@@ -18,7 +18,8 @@
 ?>
 <?php
 	$f_project_id	= gpc_get_int( 'project_id' );
-	$f_category		= gpc_get_string( 'category' );
+	$f_category	= gpc_get_string( 'category' );
+	$f_global	= gpc_get_string( 'global', 0 );
 
 	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
 
@@ -36,7 +37,7 @@
 
 		$t_category = trim( $t_category );
 		if ( category_is_unique( $f_project_id, $t_category ) ) {
-			category_add( $f_project_id, $t_category );
+			category_add( $f_project_id, $t_category, $f_global );
 		} else if ( 1 == $t_category_count ) {
 			# We only error out on duplicates when a single value was
 			#  given.  If multiple values were given, we just add the
diff -Nru mantis_b4cat/manage_proj_cat_edit_page.php mantis/manage_proj_cat_edit_page.php
--- mantis_b4cat/manage_proj_cat_edit_page.php	2005-07-28 15:46:05.000000000 +0300
+++ mantis/manage_proj_cat_edit_page.php	2005-07-28 15:50:06.000000000 +0300
@@ -24,6 +24,7 @@
 
 	$t_row = category_get_row( $f_project_id, $f_category );
 	$t_assigned_to = $t_row['user_id'];
+	$t_project_id = $t_row['project_id'];
 ?>
 <?php html_page_top1() ?>
 <?php html_page_top2() ?>
@@ -62,6 +63,14 @@
 		</select>
 	</td>
 </tr>
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'global' ) ?>
+	</td>
+	<td>
+		<input type="checkbox" name="global" value="1" <?php check_checked( $t_project_id, 0 ); ?> />
+	</td>
+</tr>
 <tr>
 	<td>
 		&nbsp;
diff -Nru mantis_b4cat/manage_proj_cat_update.php mantis/manage_proj_cat_update.php
--- mantis_b4cat/manage_proj_cat_update.php	2005-07-28 15:46:05.000000000 +0300
+++ mantis/manage_proj_cat_update.php	2005-07-28 15:50:06.000000000 +0300
@@ -18,9 +18,10 @@
 ?>
 <?php
 	$f_project_id		= gpc_get_int( 'project_id' );
-	$f_category			= gpc_get_string( 'category' );
+	$f_category		= gpc_get_string( 'category' );
 	$f_new_category		= gpc_get_string( 'new_category' );
 	$f_assigned_to		= gpc_get_int( 'assigned_to', 0 );
+	$f_global		= gpc_get_int( 'global', 0 );
 
 	access_ensure_project_level( config_get( 'manage_project_threshold' ), $f_project_id );
 
@@ -28,18 +29,19 @@
 		trigger_error( ERROR_EMPTY_FIELD, ERROR );
 	}
 
-	$f_category		= trim( $f_category );
+	$f_category	= trim( $f_category );
 	$f_new_category	= trim( $f_new_category );
 
 	# check for duplicate
 	if ( strtolower( $f_category ) == strtolower( $f_new_category ) ||
 		 category_is_unique( $f_project_id, $f_new_category ) ) {
-		category_update( $f_project_id, $f_category, $f_new_category, $f_assigned_to );
+		category_update( $f_project_id, $f_category, $f_new_category, $f_assigned_to, $f_global );
 	} else {
 		trigger_error( ERROR_CATEGORY_DUPLICATE, ERROR );
 	}
 
-	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;
+	$t_project_id = helper_get_current_project();
+	$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $t_project_id;
 ?>
 <?php
 	html_page_top1();
diff -Nru mantis_b4cat/manage_proj_edit_page.php mantis/manage_proj_edit_page.php
--- mantis_b4cat/manage_proj_edit_page.php	2005-07-28 15:46:05.000000000 +0300
+++ mantis/manage_proj_edit_page.php	2005-07-28 15:51:22.000000000 +0300
@@ -290,6 +290,7 @@
 
 	foreach ( $t_categories as $t_category ) {
 		$t_name = $t_category['category'];
+		$t_project_id = $t_category['project_id'];
 
 		if ( NO_USER != $t_category['user_id'] && user_exists( $t_category['user_id'] )) {
 			$t_user_name = user_get_name( $t_category['user_id'] );
@@ -301,6 +302,8 @@
 		<tr <?php echo helper_alternate_class() ?>>
 			<td>
 				<?php echo string_display( $t_name ) ?>
+				<?php if($t_project_id == 0)
+					echo '*' ?>
 			</td>
 			<td>
 				<?php echo $t_user_name ?>
@@ -309,9 +312,9 @@
 				<?php
 					$t_name = urlencode( $t_name );
 
-					print_button( 'manage_proj_cat_edit_page.php?project_id=' . $f_project_id . '&amp;category=' . $t_name, lang_get( 'edit_link' ) );
+					print_button( 'manage_proj_cat_edit_page.php?project_id=' . $t_project_id . '&amp;category=' . $t_name, lang_get( 'edit_link' ) );
 					echo '&nbsp;';
-					print_button( 'manage_proj_cat_delete.php?project_id=' . $f_project_id . '&amp;category=' . $t_name, lang_get( 'delete_link' ) );
+					print_button( 'manage_proj_cat_delete.php?project_id=' . $t_project_id . '&amp;category=' . $t_name, lang_get( 'delete_link' ) );
 				?>
 			</td>
 		</tr>
@@ -325,6 +328,7 @@
 		<form method="post" action="manage_proj_cat_add.php">
 			<input type="hidden" name="project_id" value="<?php echo $f_project_id ?>" />
 			<input type="text" name="category" size="32" maxlength="64" />
+			Global: <input type="checkbox" name="global" value="1" />
 			<input type="submit" class="button" value="<?php echo lang_get( 'add_category_button' ) ?>" />
 		</form>
 	</td>

Relationships

duplicate of 0008435 closedjreese Implement Global and Inheriting Categories Structure 

Activities

djidave

djidave

2006-03-03 09:15

reporter   ~0012277

I have Applied changes to mantis 1.0.1 and it works apart from deleting a global category. So have made the following changes to: manage_proj_cat_delete.php

if ($f_project_id == 0)
$t_redirect_url = 'manage_proj_page.php';
else
$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;

Instead of

$t_redirect_url = 'manage_proj_edit_page.php?project_id=' . $f_project_id;

This returns to the main project admin screen as no project information is known

djiDave

giallu

giallu

2008-04-22 06:13

reporter   ~0017656

I think this request is covered by 0008435