public function hoursBrowse($req, $res) { $org = $this->getOrgForAdmin($req, $res); if (!is_object($org)) { return; } $limit = 100; $page = max(0, $req->query('page')); $showApproved = $req->query('approved'); if ($showApproved === null) { $showApproved = true; } $query = ['where' => ['organization' => $org->id(), 'approved' => $showApproved], 'sort' => 'timestamp DESC', 'limit' => $limit, 'start' => $page * $limit]; $result = VolunteerHour::find($query); $hours = $result['models']; $count = $result['count']; return new View('hours/browse', ['org' => $org, 'title' => 'Volunteer Hours', 'hoursPage' => true, 'showApproved' => $showApproved, 'hours' => $hours, 'hasLess' => $page > 0, 'hasMore' => $count > $limit * ($page + 1), 'page' => $page, 'count' => $count, 'numAdded' => $req->params('numAdded'), 'numVolunteers' => $req->params('numVolunteers')]); }
/** * @depends testCreateWithTags */ public function testFindApprovalLink() { // should be able to look up hours with an approval link $hours = VolunteerHour::find(['where' => ['organization' => self::$org2->id(), 'approval_link' => self::$hour4->approval_link]])['models']; $this->assertCount(1, $hours); $this->assertEquals(self::$hour4->id(), $hours[0]->id()); }
public function myProfile($req, $res) { $currentUser = $this->app['user']; if (!$currentUser->isLoggedIn()) { return $res->redirect('/login'); } // organizations user is volunteer at $volunteersAt = Volunteer::find(['where' => ['organization IN ( SELECT id FROM Organizations )', 'role >= ' . Volunteer::ROLE_VOLUNTEER, 'uid' => $currentUser->id()]])['models']; // recent volunteer hours $recentVolunteerHours = VolunteerHour::find(['where' => ['uid' => $currentUser->id(), 'timestamp >= ' . strtotime('-1800 days')], 'sort' => 'timestamp DESC', 'limit' => 1000])['models']; return new View('myProfile', ['title' => 'My Profile', 'profileTab' => true, 'tabClass' => 'profile', 'recentVolunteerHours' => $recentVolunteerHours, 'volunteersAt' => $volunteersAt, 'completedApplication' => $currentUser->hasCompletedVolunteerApplication()]); }