Ejemplo n.º 1
0
 public function volunteersBrowse($req, $res)
 {
     $org = $this->getOrgForAdmin($req, $res);
     if (!is_object($org)) {
         return $org;
     }
     $limit = 100;
     $page = max(0, $req->query('page'));
     $showInactive = !!$req->query('inactive');
     $showApproved = $req->query('approved');
     if ($showApproved === null) {
         $showApproved = true;
     }
     $roleSql = $showApproved ? 'role >= ' . Volunteer::ROLE_VOLUNTEER : 'role = ' . Volunteer::ROLE_AWAITING_APPROVAL;
     $query = ['where' => ['organization' => $org->id(), $roleSql, 'active' => !$showInactive, 'uid IS NOT NULL'], 'sort' => 'id ASC', 'limit' => $limit, 'start' => $page * $limit];
     $result = Volunteer::find($query);
     $volunteers = $result['models'];
     $count = $result['count'];
     if ($req->query('error') == 'cannot_delete_self') {
         $this->app['errors']->push(['error' => 'As a volunteer coordinator, you cannot remove yourself.']);
     }
     return new View('volunteers/browse', ['org' => $org, 'title' => 'Volunteers', 'volunteersPage' => true, 'volunteers' => $volunteers, 'showApproved' => $showApproved, 'showInactive' => $showInactive, 'hasLess' => $page > 0, 'hasMore' => $count > $limit * ($page + 1), 'page' => $page, 'count' => $count, 'numAdded' => $req->params('numAdded'), 'usernameNotFound' => $req->params('usernameNotFound'), 'username' => $req->query('username')]);
 }
Ejemplo n.º 2
0
 /**
  * @depends testCreate
  */
 public function testFind()
 {
     // try with the organization supplied
     $volunteers = Volunteer::find(['where' => ['organization' => self::$org->id()], 'sort' => 'id ASC'])['models'];
     $this->assertCount(2, $volunteers);
     // look for our 3 known customers
     $find = [self::$volunteer->id(), self::$volunteer2->id()];
     foreach ($volunteers as $m) {
         if (($key = array_search($m->uid, $find)) !== false) {
             unset($find[$key]);
         }
     }
     $this->assertCount(0, $find);
 }
Ejemplo n.º 3
0
 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()]);
 }