/** * @param SS_HTTPResponse $r * @return SS_HTTPResponse|void * @throws SS_HTTPResponse_Exception * @throws ValidationException * @throws null */ public function handleResolveCategoryChange(SS_HTTPResponse $r) { if (!Permission::check('ADMIN')) { return $this->httpError(403); } if (!is_numeric($r->param('ID'))) { return $this->httpError(500, "Invalid category change id"); } $vars = Convert::json2array($r->getBody()); if (!isset($vars['approved'])) { return $this->httpError(500, "Request body must contain 'approved' 1 or 0"); } $approved = (bool) $vars['approved']; $request = SummitCategoryChange::get()->byID($r->param('ID')); if (!$request) { return $this->httpError(500, "Request " . $r->param('ID') . " does not exist"); } $status = $approved ? SummitCategoryChange::STATUS_APPROVED : SummitCategoryChange::STATUS_REJECTED; if ($request->Presentation()->isSelectedByAnyone()) { return new SS_HTTPResponse("The presentation has already been selected by chairs.", 500); } if ($request->Presentation()->CategoryID == $request->NewCategoryID) { return new SS_HTTPResponse("The presentation is already in this category.", 200); } // Make the category change $summit = Summit::get_active(); $category = $summit->Categories()->filter('ID', $request->NewCategoryID)->first(); if (!$category->exists()) { return $this->httpError(500, "Category not found in current summit"); } $oldCat = $request->Presentation()->Category(); if ($approved) { $request->OldCategoryID = $request->Presentation()->CategoryID; $request->Presentation()->CategoryID = $request->NewCategoryID; $request->Presentation()->write(); $request->Presentation()->addNotification('{member} approved ' . $request->Reqester()->getName() . '\'s request to move this presentation from ' . $oldCat->Title . ' to ' . $category->Title); } else { $request->Presentation()->addNotification('{member} rejected ' . $request->Reqester()->getName() . '\'s request to move this presentation from ' . $oldCat->Title . ' to ' . $category->Title); } $request->AdminApproverID = Member::currentUserID(); $request->Status = $status; $request->ApprovalDate = SS_Datetime::now(); $request->write(); $peers = SummitCategoryChange::get()->filter(['PresentationID' => $request->PresentationID, 'NewCategoryID' => $request->NewCategoryID])->exclude(['ID' => $request->ID]); foreach ($peers as $p) { $p->AdminApproverID = Member::currentUserID(); $p->Status = SummitCategoryChange::STATUS_APPROVED; $p->ApprovalDate = SS_Datetime::now(); $p->write(); } return $this->ok('change request accepted.'); }
public function handleAcceptCategoryChange(SS_HTTPResponse $r) { if (!Permission::check('ADMIN')) { return $this->httpError(403); } if (!is_numeric($r->param('ID'))) { return $this->httpError(500, "Invalid category change id"); } $request = SummitCategoryChange::get()->byID($r->param('ID')); if ($request->exists()) { if ($request->Presentation()->isSelectedByAnyone()) { return new SS_HTTPResponse("The presentation has already been selected by chairs.", 500); } if ($request->Presentation()->CategoryID == $request->NewCategoryID) { $request->Done = TRUE; $request->write(); return new SS_HTTPResponse("The presentation is already in this category.", 200); } // Make the category change $summit = Summit::get_active(); $category = $summit->Categories()->filter('ID', $request->NewCategoryID)->first(); if (!$category->exists()) { return $this->httpError(500, "Category not found in current summit"); } $request->OldCategoryID = $request->Presentation()->CategoryID; $request->Presentation()->CategoryID = $request->NewCategoryID; $request->Presentation()->write(); $comment = new SummitPresentationComment(); $comment->Body = 'This presentaiton was moved into the category ' . $category->Title . '.' . ' The chage was approved by ' . Member::currentUser()->FirstName . ' ' . Member::currentUser()->Surname . '.'; $comment->PresentationID = $request->Presentation()->ID; $comment->write(); $request->AdminApproverID = Member::currentUserID(); $request->Approved = TRUE; $request->Done = TRUE; $request->ApprovalDate = SS_Datetime::now(); $request->write(); return new SS_HTTPResponse("change request accepted.", 200); } }
/** * Process request from the external gateway, this action is usually triggered if the payment was cancelled * and the user was redirected to the cancelURL. * * @param SS_HTTPResponse $request */ public function cancel($request) { // Reconstruct the payment object $this->payment = Payment::get()->byID($request->param('OtherID')); // Reconstruct the gateway object $methodName = $request->param('ID'); $this->gateway = PaymentFactory::get_gateway($methodName); // The payment result was a failure $this->payment->updateStatus(new PaymentGateway_Failure()); // Do redirection $this->doRedirect(); }