function do_cron() { // jobs to run during cron /* 1. check the deadlines of all active pleas - if the deadline is past, and status is still active, deactivate and process pledges - if the deadline is soon, send warning notification 2. other jobs??? */ $today = date('Y-m-d', time() - 24 * 60 * 60); $tomorrow = date('Y-m-d', time() + 24 * 60 * 60); $expired = Plea::with('pledges.author', 'author')->where('deadline', '>=', $tomorrow)->where('status', '<>', 'expired')->get(); $expiring = Plea::with('pledges.author', 'author')->where('deadline', '=', $today)->where('status', '<>', 'expiring')->get(); // process expired pleas foreach ($expired as $plea) { // label as expired $plea->expire(); // notify all interested parties foreach ($plea->pledges as $pledge) { $notification = array('object' => $pledge, 'type' => 'pledge', 'reason' => 'expired'); $pledge->author->notify($notification); } // notify the original author $notification = array('object' => $plea, 'type' => 'plea', 'reason' => 'expired'); $plea->author->notify($notification); } // process expiring pleas foreach ($expiring as $plea) { // label as expiring $plea->expiring(); // notify all interested parties foreach ($plea->pledges as $pledge) { $notification = array('object' => $pledge, 'type' => 'pledge', 'reason' => 'expiring'); $pledge->author->notify($notification); } // notify the original author $notification = array('object' => $plea, 'type' => 'plea', 'reason' => 'expiring'); $plea->author->notify($notification); } return Response::json(TRUE); }
public function reject($id) { $plea = Plea::find($id); // check privileges if (!me()->hasPermissionTo('reject', $plea)) { err('You do not have permission to reject requests for help.'); return Redirect::to(URL::previous()); } $reason = Input::get('reason', 'NO REASON GIVEN.'); if ($reason == '') { $reason = 'NO REASON GIVEN.'; } $default_message = <<<EOF <p>lafayettehelps.com depends on the integrity and honesty of its users and the validity of the requests that are posted. We intend for it to be a supportive community of people who truly care for each other and are eager to have healthy relationships with each other. However, a request connected to you doesn't fit within our standards of a healthy community, and so one of our administrators has removed it.</p> <h3>The Request:</h3> <p>%s</p> <p>This wasn't done by an automatic computer process. An actual human being decided to remove your request, and the reasons for doing so are here:</p> <p>%s</p> <p>If you think this was done in error, simply reply to this email message and we will reconsider this action. <hr /> <h4>request_id: %s</h4> EOF; $message = sprintf($default_message, $plea->summary, $reason, $plea->id); // softDelete this Plea and email the author. $plea->delete(); msg('Request has been sent to the trash'); // send email message to author and everyone who made a pledge toward that request email($plea->author, me(), "Your request was removed.", $message); foreach ($plea->pledges as $pledge) { email($pledge->author, me(), "A request you pledged to help was removed.", $message); } return Redirect::route('pleas'); }
public function showWelcome() { $urgent = Plea::where('status', '=', 'expiring')->get(); $newest = Plea::take(4)->orderBy('created_at', 'DESC')->where('status', '=', 'active')->get(); return View::make('hello', array('urgent' => $urgent, 'newest' => $newest)); }
foreach ($user->organizations as $organization) { $relationship_details[] = array('user' => $user, 'organization' => $organization, 'relationship_type' => $organization->pivot->relationship_type); } } return View::make('organization.relationships', array('relationships' => $relationship_details)); } } err('You are not allowed to do that.'); return Redirect::route('home'); })); // ORGANIZATION ADMIN Route::get('organization/{id}/approve', array('uses' => 'OrganizationController@approve')); Route::get('organization/{id}/disapprove', array('uses' => 'OrganizationController@disapprove')); // PLEA ROUTES Route::get('pleas', array('as' => 'pleas', function () { return View::make('plea.list', array('pleas' => Plea::paginate(20))); })); Route::get('plea/add', array('as' => 'pleaadd', 'uses' => 'PleaController@add')); Route::post('plea/add', array('before' => 'csrf', 'uses' => 'PleaController@add')); Route::get('plea/{id}', array('as' => 'pleadetail', 'uses' => 'PleaController@showDetail')); Route::get('plea/{id}/edit', array('as' => 'pleaedit', 'uses' => 'PleaController@edit')); Route::post('plea/{id}/reject', array('as' => 'pleareject', 'uses' => 'PleaController@reject')); Route::post('plea/{id}/edit', array('before' => 'csrf', 'uses' => 'PleaController@edit')); Route::get('pleas/by/user/{user_id}', array('as' => 'pleasbyuser', 'uses' => 'PleaController@showPleasByUser')); // PLEDGES ROUTES //Route::get('pledge/add', array('as'=>'pledgeadd', 'uses'=>'PledgeController@add')); Route::post('pledge/add', array('before' => 'csrf', 'uses' => 'PledgeController@add')); Route::get('pledges/by/user/{user_id}', array('as' => 'pledgesbyuser', 'uses' => 'PledgeController@showPledgesByUser')); Route::get('pledges/by/plea/{plea_id}', array('as' => 'pledgesbyplea', 'uses' => 'PledgeController@showPledgesByPlea')); // OFFER ROUTES Route::get('offers', function () {