Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed categries

  • Loading branch information...
commit baabc7dc8d09708d1bcf21cbbbb3bc07a2b234fd 1 parent 00fcac1
@rwarasaurus rwarasaurus authored
View
26 roar/models/discussion.php
@@ -9,20 +9,24 @@ public static function slug($str) {
}
public static function by_category($id, $offset = 0, $perpage = 10) {
- $params = array($id);
+ $params[':category'] = $id;
if($user = Auth::user()) {
- $params[] = $user->id;
+ $params[':user'] = $user->id;
}
- else $params[] = 0;
-
- $sql = '
- select discussions.*, user_discussions.viewed
- from discussions
- left join user_discussions on (user_discussions.discussion = discussions.id)
- where discussions.category = ?
- and (user_discussions.user = ? or user_discussions.user is null)
- order by votes desc, lastpost desc
+ else $params[':user'] = 0;
+
+ $sql = 'select d.*, ud.viewed
+
+ from discussions as d
+
+ left join (select * from user_discussions where user_discussions.user = :user) as ud
+ on (ud.discussion = d.id)
+
+ where d.category = :category
+
+ order by d.votes desc, d.lastpost desc
+
limit ' . $perpage . ' offset ' . $offset;
list($result, $statement) = DB::ask($sql, $params);
View
4 roar/routes/discussion.php
@@ -64,9 +64,7 @@
/*
View discussion
*/
-$patterns = array('discussion/(:any)', 'discussion/(:any)/(:num)');
-
-Route::get($patterns, function($slug, $page = 1) {
+Route::get(array('discussion/(:any)', 'discussion/(:any)/(:num)'), function($slug, $page = 1) {
if(is_numeric($slug)) {
if( ! $discussion = Discussion::find($slug)) {
return Response::error(404);
View
5 roar/routes/site.php
@@ -31,8 +31,6 @@
View Index
*/
Route::get(array('/', 'discussions', 'discussions/(:num)'), function($page = 1) {
- Registry::set('categories', new Items(Category::all()));
-
$user = Auth::user();
$perpage = 10;
@@ -55,6 +53,7 @@
Registry::set('discussions', new Items($paginator->results));
Registry::set('paginator', $paginator->links());
+ Registry::set('categories', new Items(Category::all()));
return new Template('index');
});
@@ -162,7 +161,7 @@
'name' => $input['name'],
'email' => $input['email'],
'username' => $input['username'],
- 'password' => Hash::make($input['password'])
+ 'password' => Hash::password($input['password'])
));
$user = User::search(array('username' => $input['username']));
View
4 system/route.php
@@ -72,7 +72,7 @@ public static function action($name, $callback) {
}
/**
- * Start a collection of routes
+ * Start a collection of routes with common actions
*
* @param string
* @param string|closure
@@ -114,7 +114,7 @@ public function before() {
* @param string
*/
public function after($response) {
- if( ! isset($this->actions['after'])) return;
+ if( ! isset($this->callbacks['after'])) return;
foreach(explode(',', $this->callbacks['after']) as $action) {
call_user_func(Router::$actions[$action], $response);

0 comments on commit baabc7d

Please sign in to comment.
Something went wrong with that request. Please try again.