[221420] Allow bookmarking file/string/translation
diff --git a/html/callback/getProjects.php b/html/callback/getProjects.php
index a17fcc8..90bfe8a 100644
--- a/html/callback/getProjects.php
+++ b/html/callback/getProjects.php
@@ -12,7 +12,10 @@
 *******************************************************************************/
 require_once("cb_global.php");
 
-$query = "select 
+$return = "";
+
+if(isset($_SESSION['language'])) {
+	$query = "select 
 			DISTINCT projects.*  
 		  from 
 		  	projects,
@@ -27,23 +30,23 @@
 		  ";
 
 
-$res = mysql_query($query,$dbh);
+	$res = mysql_query($query,$dbh);
 
-//$return = '<ul id="project-choices">';
+//	$return = '<ul id="project-choices">';
 
-while($line = mysql_fetch_array($res, MYSQL_ASSOC)){
-	$ret = Array();
-	$ret['project'] = $line['project_id'];
-//	$ret['version'] = $line['version'];
-	if(isset($_SESSION['project']) and $line['project_id'] == $_SESSION['project']){
-		$ret['current'] = true;
+	while($line = mysql_fetch_array($res, MYSQL_ASSOC)){
+		$ret = Array();
+		$ret['project'] = $line['project_id'];
+		//	$ret['version'] = $line['version'];
+		if(isset($_SESSION['project']) and $line['project_id'] == $_SESSION['project']){
+			$ret['current'] = true;
+		}
+		$return[] = $ret;
 	}
-	$return[] = $ret;
+	//	$return .= '<li><a href="project_id='.$line['project_id'].'">'.$line['project_id'].'</a>';
+
+	//$return .= "</ul>";
 }
-//	$return .= '<li><a href="project_id='.$line['project_id'].'">'.$line['project_id'].'</a>';
-
-//$return .= "</ul>";
-
 print json_encode($return);
 
 ?>
\ No newline at end of file
diff --git a/html/callback/getStringsforProject.php b/html/callback/getStringsforProject.php
index 0b0dee3..5c2a805 100644
--- a/html/callback/getStringsforProject.php
+++ b/html/callback/getStringsforProject.php
@@ -10,7 +10,7 @@
  *    Paul Colton (Aptana)- initial API and implementation
  *    Eclipse Foundation
 *******************************************************************************/
-
+error_reporting('E_NONE'); ini_set("display_errors", false);
 require_once("cb_global.php");
 
 $project_id = $App->getHTTPParameter("proj", "POST");
@@ -44,6 +44,7 @@
 	break;
 	$query = "select 
 				strings.value as string,
+				strings.name as stringName,
 				strings.non_translatable,
 				translations.value as translation
 			  from 
@@ -66,6 +67,7 @@
 	break;
 	$query = "select 
 				strings.value as string,
+				strings.name as stringName,
 				strings.non_translatable,
 				translations.value as translation,
 				users.username as translator
@@ -97,13 +99,12 @@
 					strings.non_translatable,
 					strings.value as text,
 					strings.created_on as createdOn,
-					translations.value as translationString,
-					users.first_name as first,
-					users.last_name as last
+					IF(ISNULL(translations.value), '', translations.value) as translationString,
+					IF(ISNULL(users.first_name), 'Unknown', users.first_name) as first,
+					IF(ISNULL(users.last_name), 'Unknown', users.last_name) as last
 					from 
 					files,
 				  	strings
-				  	
 				  	left join translations on (
 				  		translations.language_id = '".addslashes($language)."'
 				  	  and
diff --git a/html/callback/getVersionsforProject.php b/html/callback/getVersionsforProject.php
index 6e7885a..c32680b 100644
--- a/html/callback/getVersionsforProject.php
+++ b/html/callback/getVersionsforProject.php
@@ -14,17 +14,11 @@
 
 
 
-if(!isset($_SESSION['project'])){
-	return array();
-}
-
+$return = "";
 $language = "";
-if(isset($_SESSION['language'])) {
+if(isset($_SESSION['language']) && isset($_SESSION['project'])) {
 	$language =  $_SESSION['language'];
-}
-
-
-$query = "select DISTINCT
+	$query = "select DISTINCT
 		f.version,
 		f.project_id, 
 		IF(ISNULL(pct_complete),0,ROUND(pct_complete,1)) AS pct_complete
@@ -36,23 +30,22 @@
 		v.is_active = 1 
 		and v.project_id = '".addslashes($_SESSION['project'])."'";
 
-//print $query."\n";
+	$res = mysql_query($query,$dbh);
 
-$res = mysql_query($query,$dbh);
+	$return = array();
 
-$return = array();
-
-while($line = mysql_fetch_array($res, MYSQL_ASSOC)){
-	$ret = Array();
-	$ret['version'] = $line['version'];
-	$ret['pct'] = $line['pct_complete'];
+	while($line = mysql_fetch_array($res, MYSQL_ASSOC)){
+		$ret = Array();
+		$ret['version'] = $line['version'];
+		$ret['pct'] = $line['pct_complete'];
 	
-	if(isset($_SESSION['version']) and $line['version'] == $_SESSION['version']){
-		$ret['current'] = true;
+		if(isset($_SESSION['version']) and $line['version'] == $_SESSION['version']){
+			$ret['current'] = true;
+		}
+		$return[] = $ret;
 	}
-	$return[] = $ret;
 }
-
+//print $query."\n";
 print json_encode($return);
 
 ?>
\ No newline at end of file
diff --git a/html/global.php b/html/global.php
index ead3e53..57c9fb7 100644
--- a/html/global.php
+++ b/html/global.php
@@ -64,16 +64,16 @@
 
 
 function InitPage($login) {
-	$page = $login;
+  $page = $login;
   $lastPage = GetSessionVar('s_pageName');
   $User = GetSessionVar('User');
   
   if (empty($GLOBALS['page']))
 	  $GLOBALS['page'] = '';
-		
-  if (($lastPage != $_SERVER['PHP_SELF']) AND ($lastPage != "login"))
-		SetSessionVar('s_pageLast',$lastPage);
-		SetSessionVar('s_pageName',$GLOBALS['page']);
+	
+  if(strpos($_SERVER['REQUEST_URI'], "login.php") == FALSE) {
+	SetSessionVar('s_pageLast', $_SERVER['REQUEST_URI']);
+  }
   
   $dbc = new DBConnection();
   global $dbh;
@@ -88,7 +88,6 @@
   		$Session = new Session();
 
   		if(!$Session->validate()) {
-    		SetSessionVar('s_pageLast', $GLOBALS['page']);
     		exitTo("login.php");
   		}
   		else {
diff --git a/html/js/project.js b/html/js/project.js
index 5371d39..8d3c4d4 100644
--- a/html/js/project.js
+++ b/html/js/project.js
@@ -22,19 +22,23 @@
 				var domNode = document.getElementById('project-area');
 //				YAHOO.log(o.responseText);
 				domNode.innerHTML = "";
-				for(var i = 0; i < response.length; i++){
-					var proj = new project(response[i]['project']);
-					domNode.appendChild(proj.createHTML());
-					if(response[i]['current']){
-						YAHOO.projectManager.updateSelected(proj, domNode.scrollHeight);
-					}	
-				}
+				if(response){
+					for(var i = 0; i < response.length; i++){
+						var proj = new project(response[i]['project']);
+						domNode.appendChild(proj.createHTML());
+						if(response[i]['current']){
+							YAHOO.projectManager.updateSelected(proj, domNode.scrollHeight);
+						}	
+					}
 				
 	//			domNode.innerHTML = o.responseText;
 	//			YAHOO.util.Event.onAvailable("project-choices",setupSelectProjectCB);
 	
 				//start versions
-				YAHOO.versionManager.getAjaxVersions();
+					YAHOO.versionManager.getAjaxVersions();
+				} else{
+					domNode.innerHTML = "Please select a language to continue.";
+				}
 			},
 			failure: function(o) {
 				YAHOO.log('failed!');
diff --git a/html/js/version.js b/html/js/version.js
index 654aa81..cfaa1a1 100644
--- a/html/js/version.js
+++ b/html/js/version.js
@@ -32,14 +32,11 @@
 						if(response[i]['current']){
 							YAHOO.versionManager.updateSelected(proj, domNode.scrollHeight);
 						}
-						
-						
 					}
-				}else{
-					domNode.innerHTML = "";
+					YAHOO.filesManager.getAjax();
+				} else{
+					domNode.innerHTML = "Please select a project to continue.";
 				}
-				
-				YAHOO.filesManager.getAjax();
 			},
 			failure: function(o) {
 				YAHOO.log('failed!');
diff --git a/html/login.php b/html/login.php
index 18165dd..589e51a 100755
--- a/html/login.php
+++ b/html/login.php
@@ -49,7 +49,17 @@
 			$Session = new Session();
 			$Session->create($User->userid, $REMEMBER);
 			SetSessionVar('User', $User);
-			exitTo("translate.php");
+			if(isset($_SESSION['s_pageLast'])) {
+				if($_SESSION['s_pageLast'] != "") {
+					exitTo($_SESSION['s_pageLast']);
+				}
+				else {
+					exitTo("translate.php");
+				}
+			}
+			else {
+				exitTo("translate.php");
+			}
 		}
 	}
 	else {
diff --git a/html/translate.php b/html/translate.php
index fe66435..5c8a6c2 100644
--- a/html/translate.php
+++ b/html/translate.php
@@ -23,11 +23,6 @@
 //$_SESSION['project'] = "";
 //$_SESSION['version'] = "";
 
-if(!isset($_SESSION['language']) && (isset($_GET['project']) || isset($_GET['version']) || isset($_GET['file']))) {
-	# someone bookmarked a file, but hasn't selected a language.  Ajax will have a fit
-	$_SESSION['language'] = "fr";
-}
-
 # Bug 221420 Allow bookmarking file/string/translation
 if(isset($_GET['project'])) {
 	$_SESSION['project'] = stripslashes($_GET['project']);