Skip to content

Commit

Permalink
Add support for paging in insights.php
Browse files Browse the repository at this point in the history
  • Loading branch information
ginatrapani committed Jul 30, 2012
1 parent e56d119 commit ab18816
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions webapp/_lib/controller/class.InsightStreamController.php
Expand Up @@ -37,20 +37,20 @@ public function control() {

if ($this->shouldRefreshCache() ) {
$insight_dao = DAOFactory::getDAO('InsightDAO');
$page = (isset($_GET['page']) && is_numeric($_GET['page']))?$_GET['page']:1;
if (Session::isLoggedIn()) {
if ($this->isAdmin()) {
///show all insights for all service users
$insights = $insight_dao->getAllInstanceInsights($page_count=10, $page_number=1);
$insights = $insight_dao->getAllInstanceInsights($page_count=10, $page);
$this->addToView('insights', $insights);
$page = (isset($_GET['page']) && is_numeric($_GET['page']))?$_GET['page']:1;
$this->addToView('next_page', $page+1);
$this->addToView('last_page', $page-1);
} else {
//show only service users owner owns
}
} else {
//show just public service users in stream
$insights = $insight_dao->getPublicInsights($page_count=10, $page_number=1);
$insights = $insight_dao->getPublicInsights($page_count=10, $page);
$this->addToView('insights', $insights);
}
}
Expand Down
4 changes: 2 additions & 2 deletions webapp/_lib/model/class.InsightMySQLDAO.php
Expand Up @@ -152,11 +152,11 @@ public function deleteInsightsBySlug($slug, $instance_id) {
}

public function getPublicInsights($page_count=10, $page_number=1) {
return self::getInsightsForInstances($page_count=10, $page_number=1, $public_only = true);
return self::getInsightsForInstances($page_count, $page_number, $public_only = true);
}

public function getAllInstanceInsights($page_count=10, $page_number=1) {
return self::getInsightsForInstances($page_count=10, $page_number=1, $public_only = false);
return self::getInsightsForInstances($page_count, $page_number, $public_only = false);
}

private function getInsightsForInstances($page_count=10, $page_number=1, $public_only = true) {
Expand Down

0 comments on commit ab18816

Please sign in to comment.