public function testCreate()
 {
     Database::delete('VolunteerApplications', ['uid' => -2]);
     self::$app = new VolunteerApplication();
     self::$app->grantAllPermissions();
     $this->assertTrue(self::$app->create(['uid' => -2, 'first_name' => 'Test', 'middle_name' => 'meh', 'last_name' => 'User', 'address' => 'abc st', 'city' => 'Tulsa', 'state' => 'OK', 'zip_code' => '74104', 'phone' => '1234567890', 'alternate_phone' => '1234567899', 'birth_date' => strtotime('21 years ago')]));
 }
Beispiel #2
0
 public static function setUpBeforeClass()
 {
     Database::delete('Users', ['user_email' => '*****@*****.**']);
     self::$twitterProfile = new TwitterProfile();
     self::$twitterProfile->create(['id' => 100, 'profile_image_url' => 'twitter_profile_picture']);
     self::$instagramProfile = new InstagramProfile();
     self::$instagramProfile->create(['id' => 100, 'profile_picture' => 'instagram_profile_picture']);
 }
 public static function setUpBeforeClass()
 {
     Database::delete('Users', ['user_email' => '*****@*****.**']);
     self::$user = new User();
     self::$user->grantAllPermissions();
     self::$user->create(['user_email' => '*****@*****.**', 'username' => 'testvolunteer1', 'user_password' => ['testpassword', 'testpassword'], 'ip' => '10.0.0.1', 'about' => 'bio']);
     Database::delete('Users', ['user_email' => '*****@*****.**']);
     self::$user2 = new User();
     self::$user2->grantAllPermissions();
     self::$user2->create(['user_email' => '*****@*****.**', 'username' => 'testvolunteer2', 'user_password' => ['testpassword', 'testpassword'], 'ip' => '10.0.0.1', 'about' => 'bio']);
     Database::delete('Users', ['user_email' => '*****@*****.**']);
     Database::delete('Users', ['user_email' => '*****@*****.**']);
 }
Beispiel #4
0
 public function markInactive($req, $res)
 {
     $org = $req->cliArgs(2);
     $file = $req->cliArgs(3);
     $emails = explode("\n", file_get_contents($file));
     if (!$org || !$file) {
         exit('Invalid arguments. Usage: php public/index.php /volunteers/markInactive org_id filename.txt');
     }
     $n = 0;
     foreach ($emails as $email) {
         $email = trim($email);
         if (!$email) {
             continue;
         }
         $query = "UPDATE Volunteers SET active=0 WHERE organization={$org} AND uid=(SELECT uid FROM Users WHERE user_email='{$email}')";
         if (Database::sql($query)) {
             ++$n;
         }
     }
     echo "Marked {$n} volunteer(s) as inactive\n";
 }
 /**
  * Gets the timestamp of the first volunteer hour.
  * If no hours have been created yet, will use the creation date.
  *
  * @return int
  */
 public function firstHourTimestamp()
 {
     $firstHourTs = (int) Database::select('VolunteerHours', 'MIN(timestamp)', ['where' => $this->hourWhereParams(), 'single' => true]);
     if ($firstHourTs <= 0) {
         $firstHourTs = $this->created_at;
     }
     // the first  hour timestamp cannot be older than InspireVive
     $firstHourTs = max(mktime(0, 0, 0, 4, 1, 2013), $firstHourTs);
     return $firstHourTs;
 }
Beispiel #6
0
 public function recordHoursStep2($req, $res)
 {
     $org = $this->getOrgForAdmin($req, $res);
     if (!is_object($org)) {
         return;
     }
     $place = $req->query('place');
     if ($place) {
         $place = new VolunteerPlace($place);
         if (!$place->exists()) {
             $place = false;
         }
     }
     if (!$place) {
         return $res->redirect($org->manageUrl() . '/hours/add');
     }
     // check for previous input
     $input = $req->request('json') ? json_decode($req->request('json'), true) : $req->request();
     $start = strtotime('-5 days');
     $end = strtotime('today');
     $days = $this->daysArray($start, $end);
     // recreate days from input
     if (isset($input['days'])) {
         $days = [];
         foreach ($input['days'] as $k => $day) {
             $date = \DateTime::createFromFormat('M j, Y', $day);
             if ($date) {
                 $days[] = $this->dayArrayFromTs($date->getTimestamp());
             }
         }
     }
     $volunteers = Volunteer::findAll(['where' => ['organization' => $org->id(), 'role >= ' . Volunteer::ROLE_VOLUNTEER], 'sort' => 'id ASC']);
     $availableTags = (array) Database::select('VolunteerHourTags', 'tag', ['where' => ['organization' => $org->id()], 'fetchStyle' => 'singleColumn', 'orderBy' => 'RAND()', 'groupBy' => 'tag', 'limit' => 10]);
     return new View('hours/add2', ['org' => $org, 'title' => 'Add Volunteer Hours', 'hoursPage' => true, 'days' => $days, 'input' => $input, 'volunteers' => $volunteers, 'place' => $place, 'tags' => U::array_value($input, 'tags'), 'availableTags' => $availableTags]);
 }
 /**
  * Gets the tags associated with this hour.
  *
  * @return array(string)
  */
 public function tags()
 {
     return (array) Database::select('VolunteerHourTags', 'tag', ['where' => ['hour' => $this->id()], 'fetchStyle' => 'singleColumn', 'orderBy' => 'tag ASC', 'groupBy' => 'tag']);
 }
Beispiel #8
0
 public function reportHoursStep2($req, $res)
 {
     $org = $this->getOrg($req, $res);
     if (!is_object($org)) {
         return $org;
     }
     $currentUser = $this->app['user'];
     // make sure the user is logged in
     if (!$currentUser->isLoggedIn()) {
         setcookie('redirect', $org->url() . '/hours/report', time() + 3600, '/');
         return $res->redirect('/login');
     }
     $place = $req->query('place');
     if ($place) {
         if ($place == -1) {
             return $res->redirect($org->url() . '/places/add');
         }
         $place = new VolunteerPlace($place);
     }
     if (!$place || !$place->exists()) {
         return $res->redirect($org->url() . '/hours/add');
     }
     $dayTs = $req->request('timestamp');
     $availableTags = (array) Database::select('VolunteerHourTags', 'tag', ['where' => ['organization' => $org->id()], 'fetchStyle' => 'singleColumn', 'orderBy' => 'RAND()', 'groupBy' => 'tag', 'limit' => 10]);
     return new View('reportHours2', ['org' => $org, 'title' => 'Report Volunteer Hours', 'place' => $place, 'tags' => $req->request('tags'), 'timestamp' => $dayTs, 'hours' => $req->request('hours'), 'availableTags' => $availableTags]);
 }