Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 227151
Collapse All | Expand All

(-)server/html/callback/setStringTranslation.php (-7 / +32 lines)
Lines 16-36 Link Here
16
16
17
//print_r($_REQUEST);
17
//print_r($_REQUEST);
18
18
19
//print_r($_POST);
19
// print_r($_POST);
20
20
21
$string_id = $App->getHTTPParameter("string_id", "POST");
21
$string_id = $App->getHTTPParameter("string_id", "POST");
22
$translation = $App->getHTTPParameter("translation", "POST");
22
$translation = $App->getHTTPParameter("translation", "POST");
23
23
24
$language_id = $_SESSION["language"];
24
$language_id = $_SESSION["language"];
25
$project_id = $_SESSION['project'];
25
$project_id = $_SESSION['project'];
26
$language_id = $_SESSION["language"];
27
$version = $_SESSION["version"];
26
$version = $_SESSION["version"];
28
27
29
$user_id =	$User->userid;
28
$user_id =	$User->userid;
30
29
30
# TODO: refactor these ifs
31
$do_nothing = false;
32
31
if (empty($translation) || (trim($translation) == '')) {
33
if (empty($translation) || (trim($translation) == '')) {
32
34
33
	// do nothing
35
	$do_nothing = true;
34
	
36
	
35
} else if($_POST['translate_action'] != "all"){
37
} else if($_POST['translate_action'] != "all"){
36
	$query = "update 
38
	$query = "update 
Lines 155-164 Link Here
155
				   		created_on  = NOW()
157
				   		created_on  = NOW()
156
					";
158
					";
157
			$res2 = mysql_query($query,$dbh);
159
			$res2 = mysql_query($query,$dbh);
158
		}
160
		}	
159
		
161
	}	
160
	}
162
}
163
164
if(!$do_nothing) {
165
	# Find all string_id's that have the same binary value as the one we're translating
166
	# *and* have no translation yet, and update those too.
167
	$sql = "SELECT s.string_id, COUNT(t.string_id) AS tr_count
168
	FROM strings AS s 
169
	LEFT JOIN translations AS t ON t.string_id = s.string_id AND t.language_id = '".addslashes($language_id)."'
170
	WHERE BINARY s.value = (select value from strings where string_id = '".addslashes($string_id)."')  
171
		AND s.is_active = 1 AND t.value IS NULL GROUP BY s.string_id HAVING tr_count = 0";
172
173
	$res 		= mysql_query($sql, $dbh);
174
	$str_count 	= mysql_affected_rows();
161
	
175
	
176
	while($myrow = mysql_fetch_assoc($res)) {
177
		$sql = "insert into 
178
					translations
179
				  set
180
				  	string_id = " . $myrow['string_id'] . ",
181
				  	language_id = '".addslashes($language_id)."',
182
				  	value = '".addslashes($translation)."',
183
				  	userid = '".addslashes($user_id)."',
184
				  	created_on = NOW()";
185
		mysql_query($sql, $dbh);
186
	}
162
}
187
}
163
	 
188
164
?>
189
?>

Return to bug 227151