Browse Source

register/login fixes

Nathaniel van Diepen 11 years ago
parent
commit
43907daf84

+ 5 - 1
api.php

@@ -37,6 +37,7 @@
 						$ret['template'] = file_get_contents(PATH_DATA.'pages/project.template');
 					}
 					$context = projectObj($id);
+					$context['user'] = userObj($context['user']);
 					if($LOGGEDIN){
 						$context['key'] = true;
 						$context['user'] = userObj($_SESSION['username']);
@@ -67,8 +68,11 @@
 										}
 									break;
 									case 'projects':
-										if($res = query("SELECT title,description,id FROM `projects`;")){
+										if($res = query("SELECT p.title,p.id,p.description,u.name as user FROM `projects` p JOIN `users` u ON u.id = p.u_id")){
 											$context['projects'] = fetch_all($res,MYSQLI_ASSOC);
+											foreach($context['projects'] as $key => $project){
+												$context['projects'][$key]['user'] = userObj($project['user']);
+											}
 										}
 									break;
 								}

+ 2 - 5
css/style.css

@@ -67,7 +67,7 @@ div#topbar .menuitem{
 	min-width: 35px;
 	height: 35px;
 }
-div#topbar .menuitem:not(.topbar-home):not(.topbar-back):not(.topbar-history){
+div#topbar .menuitem:not(.topbar-home):not(.topbar-back){
 	background: url(../img/headers/ui/separator.png) no-repeat scroll left center transparent;
 }
 div#topbar .menuitem:hover{
@@ -204,9 +204,6 @@ span.icon-bugs-invert{
 	}
 	a.topbar-back{
 	}
-	a.topbar-history{
-		left: 37px;
-	}
 	div#topbar{
 		min-height: 35px;
 	}
@@ -215,7 +212,7 @@ span.icon-bugs-invert{
 		width: 100%;
 		padding-top: 35px;
 	}
-	.topbar-home,.topbar-back,.topbar-history{
+	.topbar-back,.topbar-history{
 		background: url(../img/headers/ui/separator.png) no-repeat scroll right center transparent;
 	}
 	.screen-small{

+ 2 - 2
data/pages/login.template

@@ -21,10 +21,10 @@
 	</div>
 	<div class="row">
 		<div class="cell align-right">
-			<input type="submit" value="login"/>
+			<input type="button" value="cancel" class="cancel"/>
 		</div>
 		<div class="cell">
-			<input type="button" value="cancel" class="cancel"/>
+			<input type="submit" value="login"/>
 		</div>
 	</div>
 </form>

+ 1 - 1
data/pages/project.template

@@ -1,5 +1,5 @@
 <h3>
-	{{title}}
+	{{title}} - <a style="font-size:small;color:gray;text-decoration:none;" href="#~{{user.name}}">{{user.name}}</a>
 </h3>
 <div>
 	{{description}}

+ 1 - 1
data/pages/projects.template

@@ -12,7 +12,7 @@
 	</span>
 	{{#each projects}}
 		<h3>
-			{{title}}
+			{{title}} - <small>{{user.name}}</small>
 			<a href="#project-{{id}}" class="button">
 				Open
 			</a>

+ 2 - 2
data/pages/register.template

@@ -44,10 +44,10 @@
 	</div>
 	<div class="row">
 		<div class="cell align-right">
-			<input type="submit" value="register"/>
+			<input type="button" value="cancel" class="cancel"/>
 		</div>
 		<div class="cell">
-			<input type="button" value="cancel" class="cancel"/>
+			<input type="submit" value="login"/>
 		</div>
 	</div>
 </form>

+ 3 - 3
data/pages/topbar.template

@@ -37,6 +37,9 @@
 			</ul>
 		</span>
 	{{/if}}
+	<a class="topbar-history menuitem" href="#page-index" >
+		<div style="background-image:url(img/headers/icons/back.png);background-repeat:no-repeat;background-position:center;width:35px;height:35px;"></div>
+	</a>
 	<a class="topbar-current menuitem" href="#{{url}}">
 		{{title}}
 	</a>
@@ -45,9 +48,6 @@
 	<a class="topbar-back menuitem" href="#{{url}}">
 		<div style="background-image:url(img/headers/icons/menu.png);height:35px;background-position:center;"></div>
 	</a>
-	<a class="topbar-history menuitem" href="#page-index" >
-		<div style="background-image:url(img/headers/icons/back.png);background-repeat:no-repeat;background-position:center;width:35px;height:35px;"></div>
-	</a>
 	<a class="topbar-current menuitem" href="#{{url}}">
 		{{title}}
 	</a>

+ 1 - 0
js/index.js

@@ -217,6 +217,7 @@
 				$(window).resize();
 			},
 			content: function(t,c){
+				console.log(c);
 				$('#content').html(
 					Handlebars.compile(t)(c)
 				);

+ 4 - 2
php/project.php

@@ -3,9 +3,11 @@
 	require_once(PATH_PHP.'database.php');
 	global $mysqli;
 	function projectObj($id){
-		if($res = query("SELECT * FROM `projects` WHERE id='%d'",Array($id))){
+		if($res = query("SELECT p.title,p.id,p.description,u.name as user FROM `projects` p JOIN `users` u ON u.id = p.u_id  WHERE p.id='%d'",Array($id))){
 			if($res->num_rows == 1){
-				return $res->fetch_assoc();
+				$project = $res->fetch_assoc();
+				$project['user'] = userObj($project['user']);
+				return $project;
 			}
 		}
 		return false;

+ 6 - 1
php/user.php

@@ -34,7 +34,12 @@
 		}
 		if($res = query("SELECT * FROM `users` WHERE id='%d'",Array($id))){
 			if($res->num_rows == 1){
-				return $res->fetch_assoc();
+				if($user = $res->fetch_assoc()){
+					unset($user['password']);
+					unset($user['salt']);
+					unset($user['key']);
+					return $user;
+				}
 			}
 		}
 		return false;