function submit($data, $form)
 {
     // if rewards added and get it button clicked then validate and save to order object
     if (isset($data['action_submit']) && isset($data['Quantity'])) {
         Session::clear($this->controller->RewardsSessionKey());
         foreach ($data['Quantity'] as $ProductID => $quantity) {
             $item = $this->controller->newReward($ProductID, $quantity);
             Session::set($this->controller->RewardsSessionKey($ProductID), serialize($item));
         }
         if ($this->controller->RewardsTotalPoints() > Page_Controller::MemberPointsBalance()) {
             $this->sessionMessage('You do not have enough points to purchase these rewards.', 'error');
             Director::redirectBack();
             return;
         }
         $new_items = $this->controller->RewardItems();
     }
     //delete all existing reward items for this order
     $order_items = $this->controller->Order()->RewardItems();
     foreach ($order_items as $o_item) {
         $o_item->delete();
     }
     // then flush rewards from session
     Session::clear($this->controller->RewardsSessionKey());
     //then link the reward items to the order
     if (isset($new_items)) {
         foreach ($new_items as $item) {
             $item->write();
         }
     }
     // then redirect to next step
     Director::redirect($this->controller->Link() . 'checkoutstep/orderconfirmationandpayment/');
 }
Ejemplo n.º 2
0
 function doRegister($data, $form)
 {
     // Check for existing member emial address
     if ($member = DataObject::get_one("Member", "'Email' = '" . Convert::raw2sql($data['Email']) . "'")) {
         // Set error message
         $form->AddErrorMessage('Email', "Sorry, that email address already exists. Please choose another.", 'bad');
         // Set form data from submitted values
         Session::set("FormInfo.Form_RegistrationForm.data", $data);
         // Return back to form
         return Director::redirectBack();
     }
     // Otherwise create new member and log them in
     $Member = new Member();
     $form->saveInto($Member);
     $Member->write();
     $Member->login();
     // Find or create the 'user' group
     if (!($userGroup = DataObject::get_one('Group', "Code = 'users'"))) {
         $userGroup = new Group();
         $userGroup->Code = "users";
         $userGroup->Title = "Users";
         $userGroup->Write();
         $userGroup->Members()->add($Member);
     }
     // Add member to user group
     $userGroup->Members()->add($Member);
     // Get Profile page
     if ($ProfilePage = DataObject::get_one('EditProfilePage')) {
         return Director::redirect($ProfilePage->Link('?success=1'));
     }
 }
Ejemplo n.º 3
0
 function doEditForm($data, $form)
 {
     $member = Member::currentUser();
     $form->saveInto($member);
     $member->write();
     Director::redirect('registration-edit-successful/');
 }
 /**
  * Form action handler for ContactInquiryForm.
  *
  * @param array $data The form request data submitted
  * @param Form $form The {@link Form} this was submitted on
  */
 function dosave(array $data, Form $form, SS_HTTPRequest $request)
 {
     $SQLData = Convert::raw2sql($data);
     $attrs = $form->getAttributes();
     if ($SQLData['Comment'] != '' || $SQLData['Url'] != '') {
         // most probably spam - terminate silently
         Director::redirect(Director::baseURL() . $this->URLSegment . "/success");
         return;
     }
     $item = new ContactInquiry();
     $form->saveInto($item);
     // $form->sessionMessage(_t("ContactPage.FORMMESSAGEGOOD", "Your inquiry has been submitted. Thanks!"), 'good');
     $item->write();
     $mailFrom = $this->currController->MailFrom ? $this->currController->MailFrom : $SQLData['Email'];
     $mailTo = $this->currController->MailTo ? $this->currController->MailTo : Email::getAdminEmail();
     $mailSubject = $this->currController->MailSubject ? $this->currController->MailSubject . ' - ' . $SQLData['Ref'] : _t('ContactPage.SUBJECT', '[web] New contact inquiry - ') . ' ' . $data['Ref'];
     $email = new Email($mailFrom, $mailTo, $mailSubject);
     $email->replyTo($SQLData['Email']);
     $email->setTemplate("ContactInquiry");
     $email->populateTemplate($SQLData);
     $email->send();
     // $this->controller->redirectBack();
     if ($email->send()) {
         $this->controller->redirect($this->controller->Link() . "success");
     } else {
         $this->controller->redirect($this->controller->Link() . "error");
     }
     return false;
 }
Ejemplo n.º 5
0
 static function redirect_to_login_prompt($redirect_url)
 {
     $redirect_url = "http://{$_SERVER['HTTP_HOST']}{$redirect_url}";
     $_SESSION['state'] = md5(uniqid(rand(), TRUE));
     //CSRF protection
     $dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" . FACEBOOK_APP_ID . "&redirect_uri=" . urlencode($redirect_url) . "&state=" . $_SESSION['state'] . "&scope=email";
     return Director::redirect($dialog_url);
 }
 function redirect($status = "success", $message = "")
 {
     if (Director::is_ajax()) {
         return $status;
         //TODO: allow for custom return types, eg json - similar to ShoppingCart::return_data()
     }
     Director::redirect(CheckoutPage::find_link());
 }
 public function saveComplexTableField($data, $form, $params)
 {
     $child = new $data['ClassName']();
     $child->ParentID = $this->controller->ID;
     $child->write();
     $link = SecurityToken::inst()->addToUrl(Controller::join_links($this->Link(), 'item', $child->ID, 'edit'));
     Session::set('FormInfo.ComplexTableField_Popup_DetailForm.formError', array('message' => _t('MemberProfiles.SECTIONADDED', 'Profile section added, please edit it below.'), 'type' => 'good'));
     return Director::redirect($link);
 }
Ejemplo n.º 8
0
 /**
  * Form handler.  Saves all changed fields to the database, and returns back to the
  * index action of the given object
  */
 function save($params)
 {
     $record = $this->controller->data();
     foreach ($this->fields as $field) {
         $fieldName = $field->Name();
         if (isset($params[$fieldName])) {
             $record->{$fieldName} = $params[$fieldName];
         }
     }
     $record->write();
     Director::redirect($this->controller->Link());
 }
 function activate($data, $form, $request)
 {
     //Check if there's a temp member with a Verification Code equal to this
     //if there is, register the new member and log him in
     //if not, tell him the code is wrong
     //Check if this member already exists
     $tempMember = TempMember::codeExists($data);
     if (!$tempMember) {
         $form->sessionMessage(_t("Register.REGISTRATION ERROR", "There's no account waiting for activation with this code.\n\t\t\t\t\t\t\t\t\t If you already have an account log in here <a href=\"my-events/\">here</a>"), 'bad');
         Director::redirectBack();
         return;
     }
     // Create a new Member object
     $member = new Member();
     $member->FirstName = $tempMember->FirstName;
     $member->Surname = $tempMember->Surname;
     $member->Phone = $tempMember->Phone;
     $member->Email = $tempMember->Email;
     $member->Password = $tempMember->Password;
     $member->ReceiveMail = $tempMember->ReceiveMail;
     $member->ReceiveMail = $tempMember->ReceiveMail;
     $member->RequestListedAsPresenter = $tempMember->RequestListedAsPresenter;
     $member->LocationAddress = $tempMember->LocationAddress;
     $member->LocationLatitude = $tempMember->LocationLatitude;
     $member->LocationLongitude = $tempMember->LocationLongitude;
     $member->Description = $tempMember->Description;
     // Write to db.
     // This needs to happen before we add it to a group
     $member->write();
     if ($tempMember->RequestListedAsPresenter) {
         $presentorApproval = new PresentorApproval();
         $presentorApproval->MemberID = $member->ID;
         $presentorApproval->MemberName = $tempMember->FirstName . ' ' . $tempMember->Surname;
         $presentorApproval->Message = $tempMember->Description;
         $presentorApproval->Email = $tempMember->Email;
         $presentorApproval->Confirmation = 'Pending';
         $presentorApproval->IsDone = false;
         $presentorApproval->write();
     }
     $tempMember->delete();
     $member->logIn();
     // Add the member to User Group
     // Check if it exists first
     if ($group = DataObject::get_one('Group', 'ID = 3')) {
         $member->Groups()->add($group);
         // Redirect based on URL
         // TO EDIT
         Director::redirect('SuccessVerification');
     } else {
         $form->sessionMessage(_t("Register.REGISTRATION ERROR", "Your registration wasn't successful please try again"), 'bad');
         Director::redirectBack();
     }
 }
 /**
  * Save the changes to the form, and redirect to the checkout page
  */
 function proceed($data, $form, $request)
 {
     $member = Member::currentUser();
     if (!$member) {
         return false;
     }
     $form->saveInto($member);
     $member->write();
     $form->sessionMessage(_t("MemberForm.DETAILSSAVED", 'Your details have been saved'), 'good');
     Director::redirect(CheckoutPage::find_link());
     return true;
 }
Ejemplo n.º 11
0
 /**
  * Prepare to run a sake more command.
  */
 public function init()
 {
     // Ensure it's being run via the command line.
     if (!$this->isCli()) {
         // If it's not, redirect to the homepage.
         Director::redirect('/');
         parent::init();
         return;
     }
     // What're the command and arguments?
     if (!array_key_exists('args', $_GET)) {
         $cmdargs = array();
     } else {
         $cmdargs = $_GET['args'];
     }
     // Validate them.
     if (empty($cmdargs)) {
         return $this->showError('Expected parameter. Type "sake more help" for a list of commands');
     }
     // Get all the potential commands.
     $allcommands = $this->availableCommands();
     // Which command is being called?
     $cmd = array_shift($cmdargs);
     if (!array_key_exists($cmd, $allcommands)) {
         return $this->showError("Unable to find command '{$cmd}'. Run 'sake more help' for list of commands");
     }
     // Run the given command.
     if (count($allcommands[$cmd]) == 2) {
         list($class, $function) = $allcommands[$cmd];
         $argarray = false;
     } else {
         list($class, $function, $argarray) = $allcommands[$cmd];
     }
     // Passing the arguments as one array or individual arguments?
     if ($argarray) {
         // One single array? Useful for when using unlimited arguments.
         $cmdargs = array($cmdargs);
     }
     $object = null;
     if (is_object($class)) {
         // Passed an object instead of a static class? Ok.
         $object = $class;
         $class = get_class($object);
     }
     $method = new ReflectionMethod($class, $function);
     $response = $method->invokeArgs($object, $cmdargs);
     // Print the response.
     if (!is_null($response)) {
         printf("%s\n", $response);
     }
     // Done.
     die;
 }
 public function doProcess($data, $form, $request)
 {
     $order = new Order();
     $items = $order->Items();
     $member = Member::currentUserID() ? Member::currentUser() : new Member();
     $paymentClass = isset($data['PaymentMethod']) ? $data['PaymentMethod'] : null;
     $payment = class_exists($paymentClass) ? new $paymentClass() : null;
     $requirePayment = $order->Subtotal() > 0 ? true : false;
     if (!($items && $items->Count() > 0)) {
         $form->sessionMessage(_t('OrderForm.NOITEMS', 'Error placing order: You have no items in your cart.'), 'bad');
         return Director::redirectBack();
     }
     if ($requirePayment) {
         if (!($payment && $payment instanceof Payment)) {
             user_error("OrderForm::doProcess(): '{$paymentClass}' is not a valid payment class!", E_USER_ERROR);
         }
     }
     // Ensure existing members don't get their record hijacked (IMPORTANT!)
     if (!$member->checkUniqueFieldValue($data)) {
         $uniqueField = Member::get_unique_identifier_field();
         $uniqueValue = $data[$uniqueField];
         $uniqueError = "Error placing order: The %s \"%d\" is\n\t\t\t\talready taken by another member. If this belongs to you, please\n\t\t\t\tlog in first before placing your order.";
         $form->sessionMessage(_t('EcommerceMemberExtension.ALREADYEXISTS', printf($uniqueError, strtolower($uniqueField), $uniqueValue), PR_MEDIUM, 'Let the user know that member already exists (e.g. %s could be "Email", %d could be "joe@somewhere.com)'), 'bad');
         return Director::redirectBack();
     }
     $form->saveInto($member);
     if (!$member->Password) {
         $member->setField('Password', Member::create_new_password());
     }
     $member->write();
     $form->saveInto($order);
     try {
         $result = $order->process($member->ID);
     } catch (Exception $e) {
         $form->sessionMessage(_t('OrderForm.PROCESSERROR', "An error occurred while placing your order: {$e->getMessage()}.<br>\n\t\t\t\t\tPlease contact the website administrator."), 'bad');
         // Send an email to site admin with $e->getMessage() error
         return Director::redirectBack();
     }
     if ($requirePayment) {
         $form->saveInto($payment);
         $payment->write();
         $result = $payment->processPayment($data, $form);
         if ($result->isSuccess()) {
             $order->sendReceipt();
         }
         // Long payment process. e.g. user goes to external site to pay (PayPal, WorldPay)
         if ($result->isProcessing()) {
             return $result->getValue();
         }
     }
     Director::redirect($order->Link());
 }
 function setStepConfig()
 {
     $whichStep = Director::URLParam("ID");
     $validSteps = array('twostep', 'threestep');
     if (!in_array($whichStep, $validSteps)) {
         return false;
     }
     CMSWorkflowSiteConfigDecorator::set_step_config($whichStep);
     echo "<p>CMS Workflow has been set to <strong>{$whichStep}</strong></p>";
     // rebuild the database schema
     Director::redirect("dev/build?flush=1");
     return true;
 }
 /**
  * SubmitFilter Form
  * 
  */
 function SubmitFilter($data, $form, $request)
 {
     // Get the current timestamp
     $iCurrentTimestamp = self::GetCurrentTimeStamp();
     /* selected Country */
     $oSelectedCountry = $data['Country'];
     $sFromDate = isset($data['FromDate']) && !empty($data['FromDate']) ? $data['FromDate'] : date('d/m/Y', $iCurrentTimestamp);
     $sToDate = isset($data['ToDate']) && !empty($data['ToDate']) ? $data['ToDate'] : date('d/m/Y', $iCurrentTimestamp);
     //set session variables to use on the showevents function
     Session::set('FilterCountry', $oSelectedCountry);
     Session::set('FilterFromDate', $sFromDate);
     Session::set('FilterToDate', $sToDate);
     Director::redirect('Events/showevents');
 }
 function setShippingMethod($data, $form)
 {
     $cart = $this->owner->Cart();
     $option = null;
     if (isset($data['ShippingMethodID'])) {
         $option = DataObject::get_by_id("ShippingMethod", (int) $data['ShippingMethodID']);
     }
     //assign option to order / modifier
     if ($option) {
         $checkout = new Checkout($cart);
         $checkout->setShippingMethod($option);
     }
     Director::redirect($this->NextStepLink('paymentmethod'));
 }
 function spamCheck($field)
 {
     //filter_var() sanitizes the e-mail
     //address using FILTER_SANITIZE_EMAIL
     $field = filter_var($field, FILTER_SANITIZE_EMAIL);
     //filter_var() validates the e-mail
     //address using FILTER_VALIDATE_EMAIL
     if (filter_var($field, FILTER_VALIDATE_EMAIL)) {
         return true;
     } else {
         Director::redirect(Director::absoluteBaseURL());
         return false;
     }
 }
 protected function processMessage($data, $form, $request)
 {
     $from = !empty($_REQUEST['Email']) ? $_REQUEST['Email'] : 'loveyourcoast2010';
     $to = '*****@*****.**';
     $subject = !empty($_REQUEST['Subject']) ? $_REQUEST['Subject'] : 'Enquiry from Love Your Coast Site';
     //$body = 'BODY';
     $Name = !empty($_REQUEST['Name']) ? $_REQUEST['Name'] : 'No name given';
     $Phone = !empty($_REQUEST['Phone']) ? $_REQUEST['Phone'] : 'No phone given';
     $Email = !empty($_REQUEST['Email']) ? $_REQUEST['Email'] : 'No email given';
     $Message = !empty($_REQUEST['Message']) ? $_REQUEST['Message'] : 'No message given';
     $body = 'Name: ' . $Name . '<br /><br /> Phone: ' . $Phone . '<br /><br />  Email: ' . $Email . '<br /><br />  Message: <br />' . $Message;
     $email = new Email($from, $to, $subject, $body);
     $email->send();
     Director::redirect('Success');
 }
 /**
  *
  * Action called by the form to actually create a new page object. 
  *
  * @param SS_HttpRequest $request
  * @param Form $form
  */
 public function createpage($request, Form $form)
 {
     // create a new object and bind the form data
     $pid = $this->CreateLocation()->ID;
     if (!$pid) {
         $pid = 0;
     }
     $type = $this->CreateType;
     $obj = new $type();
     $form->saveInto($obj);
     $obj->ParentID = $pid;
     Versioned::reading_stage('Stage');
     $obj->write('Stage');
     // redirect to the created object
     Director::redirect($obj->Link() . '?stage=Stage');
 }
 function finish($data, $form)
 {
     parent::finish($data, $form);
     $savedSteps = $this->getSavedSteps();
     $savedData = array();
     foreach ($savedSteps as $step) {
         $savedData = array_merge($savedData, $step->loadData());
     }
     $fields = new FieldSet();
     $fields->push(new LiteralField("Heading", "<h3>You have submitted the following information:</h3>"));
     foreach ($savedData as $key => $value) {
         $fields->push(new LiteralField($key . '_copy', "<p><strong>{$key}</strong> {$value}</p>"));
     }
     Session::set("MultiFormMessage", "Your information has been submitted.");
     Director::redirect(Director::BaseURL() . $this->Controller()->URLSegment);
 }
Ejemplo n.º 20
0
 /**
  * Updates the database schema, creating tables & fields as necessary.
  */
 function build()
 {
     // The default time limit of 30 seconds is normally not enough
     increase_time_limit_to(600);
     // Get all our classes
     ManifestBuilder::create_manifest_file();
     require MANIFEST_FILE;
     if (isset($_GET['returnURL'])) {
         echo "<p>Setting up the database; you will be returned to your site shortly....</p>";
         $this->doBuild(true);
         echo "<p>Done!</p>";
         Director::redirect($_GET['returnURL']);
     } else {
         $this->doBuild(isset($_REQUEST['quiet']) || isset($_REQUEST['from_installer']), !isset($_REQUEST['dont_populate']));
     }
 }
 protected function processMessage($data, $form, $request)
 {
     //Decide who to send this message to
     $cleanupid = $_REQUEST['CleanupID'];
     if (!$cleanupid) {
         Director::redirect('my-events/Error/');
     }
     $cleanup = DataObject::get_one('CleanUpGroup', "CleanUpGroup.ID = '{$cleanupid}'");
     $creatorid = $cleanup->CreatorID;
     $curr_member = Member::currentUser();
     $memberid = Member::currentUserID();
     if ($creatorid == $memberid) {
         //CASE1: CLEANUP ADMIN EMAIL! sends to group
         $members = $cleanup->getManyManyComponents("Members");
         if (!$members) {
             //this better work
             Director::redirect('Nomembers');
         }
         foreach ($members as $member) {
             $emailmsg = EventEmail::save_current_msg();
             $form->saveInto($emailmsg);
             $emailmsg->MemberID = $memberid;
             $emailmsg->SenderEmail = $_REQUEST['Email'];
             $emailmsg->Recipient = $member->Email;
             $emailmsg->CleanUpGroupID = $cleanupid;
             $emailmsg->write();
             $emailmsg->goMessage();
         }
         Director::redirectBack();
     } else {
         //CASE2: SEND CLEANUP ADMIN AN EMAIL!
         $creator = DataObject::get_by_id('Member', $creatorid);
         $emailmsg = EventEmail::save_current_msg();
         $form->saveInto($emailmsg);
         $emailmsg->MemberID = $memberid;
         $emailmsg->FirstName = $_REQUEST['FirstName'];
         $emailmsg->Phone = $_REQUEST['Phone'];
         $emailmsg->SenderEmail = $_REQUEST['Email'];
         $emailmsg->Message = $_REQUEST['Message'];
         $emailmsg->Recipient = $creator->Email;
         $emailmsg->CleanUpGroupID = $cleanupid;
         $emailmsg->write();
         $emailmsg->goMessage();
         Director::redirectBack();
     }
     //PROCESS ENDS
 }
 function init()
 {
     parent::init();
     $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
     $page = null;
     //NOTE: this function (Director::urlParam) is depreciated, but should actuall be kept
     $URLSegment = Director::urlParam("URLSegment");
     $Action = Director::urlParam("Action");
     foreach (self::$old_to_new_array as $oldURL => $newURL) {
         if ($URLSegment == $oldURL) {
             $page = DataObject::get_one("SiteTree", "URLSegment = '{$newURL}'");
             Director::redirect($page->Link(), 301);
         } elseif ($URLSegment . "/" . $Action == $oldURL) {
             $page = DataObject::get_one("SiteTree", "URLSegment = '{$newURL}'");
             Director::redirect($page->Link(), 301);
         }
     }
 }
Ejemplo n.º 23
0
 function init()
 {
     if ($this->RedirectionType == 'External') {
         if ($this->ExternalURL) {
             Director::redirect($this->ExternalURL);
         } else {
             echo "<p>" . _t('RedirectorPage.HASBEENSETUP', 'A redirector page has been set up without anywhere to redirect to.') . "</p>";
         }
     } else {
         $linkTo = DataObject::get_by_id("SiteTree", $this->LinkToID);
         if ($linkTo) {
             Director::redirect($linkTo->Link());
         } else {
             echo "<p>" . _t('RedirectorPage.HASBEENSETUP') . "</p>";
         }
     }
     parent::init();
 }
Ejemplo n.º 24
0
 /**
  * Updates the database schema, creating tables & fields as necessary.
  */
 function build()
 {
     // The default time limit of 30 seconds is normally not enough
     increase_time_limit_to(600);
     // Get all our classes
     SS_ClassLoader::instance()->getManifest()->regenerate();
     if (isset($_GET['returnURL'])) {
         echo "<p>Setting up the database; you will be returned to your site shortly....</p>";
         $this->doBuild(true);
         echo "<p>Done!</p>";
         Director::redirect($_GET['returnURL']);
     } else {
         if (!Director::is_cli() && Director::urlParam('Controller') == __CLASS__) {
             echo '<p style="color: red;"><i>db/build</i> has been deprecated. Please use <b>dev/build</b> instead.</p>';
         }
         $this->doBuild(isset($_REQUEST['quiet']) || isset($_REQUEST['from_installer']), !isset($_REQUEST['dont_populate']));
     }
 }
Ejemplo n.º 25
0
 /**
  * Change the password
  *
  * @param array $data The user submitted data
  */
 function doChangePassword(array $data)
 {
     if ($member = Member::currentUser()) {
         // The user was logged in, check the current password
         if (isset($data['OldPassword']) && $member->checkPassword($data['OldPassword']) == false) {
             $this->clearMessage();
             $this->sessionMessage(_t('Member.ERRORPASSWORDNOTMATCH', "Your current password does not match, please try again"), "bad");
             Director::redirectBack();
             return;
         }
     }
     if (!$member) {
         if (Session::get('AutoLoginHash')) {
             $member = Member::member_from_autologinhash(Session::get('AutoLoginHash'));
         }
         // The user is not logged in and no valid auto login hash is available
         if (!$member) {
             Session::clear('AutoLoginHash');
             Director::redirect('loginpage');
             return;
         }
     }
     // Check the new password
     if ($data['NewPassword1'] == $data['NewPassword2']) {
         $isValid = $member->changePassword($data['NewPassword1']);
         if ($isValid->valid()) {
             $this->clearMessage();
             $this->sessionMessage(_t('Member.PASSWORDCHANGED', "Your password has been changed, and a copy emailed to you."), "good");
             Session::clear('AutoLoginHash');
             $redirectURL = HTTP::setGetVar('BackURL', urlencode(Director::absoluteBaseURL()), Security::Link('login'));
             Director::redirect($redirectURL);
         } else {
             $this->clearMessage();
             $this->sessionMessage(nl2br("We couldn't accept that password:\n" . $isValid->starredList()), "bad");
             Director::redirectBack();
         }
     } else {
         $this->clearMessage();
         $this->sessionMessage(_t('Member.ERRORNEWPASSWORD', "Your have entered your new password differently, try again"), "bad");
         Director::redirectBack();
     }
 }
 /**
  * Save the cleanup and redirect
  */
 function uploadimages($data, $form)
 {
     //Check there is a member! IF not return false
     $member = Member::currentUser();
     if (!$member) {
         $form->sessionMessage(_t("Create.CLEANUPCREATTIONERROR", "You Need to be logged in to Edit An Event"), 'bad');
         Director::redirectBack();
     } else {
         //$fri = (!empty($_REQUEST['Friday'])) ? $_REQUEST['Friday'] : null;
         //CLEANUP EVENT WE ARE ADDING IMAGES FO
         $cleanupID = !empty($_REQUEST['CleanUpID']) ? $_REQUEST['CleanUpID'] : null;
         $cleanupgroup = DataObject::get_one('CleanUpGroup', "CleanUpGroup.ID = '{$cleanupID}'");
         if (!$cleanupgroup) {
             $form->sessionMessage(_t("Create.CLEANUPIMAGEUPLOADERROR", "You Need to have a Clean Up Event to add images "), 'bad');
             Director::redirectBack();
         } else {
             $form->saveInto($cleanupgroup);
             $cleanupgroup->write();
             Director::redirect($cleanupgroup->Link());
         }
     }
 }
 protected function processInvites($data, $form, $request)
 {
     //Decide who to send this message to
     $cleanupid = $_REQUEST['CleanupID'];
     if (!$cleanupid) {
         Director::redirect('my-events/Error/');
     }
     $cleanup = DataObject::get_one('CleanUpGroup', "CleanUpGroup.ID = '{$cleanupid}'");
     $creator = Member::currentUser();
     $creatorid = Member::currentUserID();
     //CASE: Send Email to Recipients list!
     $emailmsg = EventEmail::save_current_msg();
     $form->saveInto($emailmsg);
     $emailmsg->MemberID = $creatorid;
     $emailmsg->SenderEmail = $_REQUEST['Email'];
     $emailmsg->Recipients = $_REQUEST['Recipients'];
     $emailmsg->CleanUpGroupID = $cleanupid;
     $emailmsg->write();
     $emailmsg->invitePeeps();
     Director::redirectBack();
     //PROCESS ENDS
 }
Ejemplo n.º 28
0
 /**
  * Get all content as a javascript-compatible string (only if there is an Ajax-Request present).
  * Falls back to {non_ajax_content}, {redirect_url} or Director::redirectBack() (in this order).
  * 
  * @return string
  */
 static function respond()
 {
     // we don't want non-ajax calls to receive javascript
     if (isset($_REQUEST['forcehtml'])) {
         return self::$non_ajax_content;
     } else {
         if (isset($_REQUEST['forceajax']) || Director::is_ajax()) {
             ContentNegotiator::disable();
             // TODO figure out a way to stay backwards-compatible with Ajax.Evaluator and still use the automatic evaluating of Prototype
             //header("Content-type: text/javascript");
             return self::get_javascript();
         } elseif (!empty(self::$non_ajax_content)) {
             return self::$non_ajax_content;
         } elseif (!empty(self::$redirect_url)) {
             Director::redirect(self::$redirect_url);
             return null;
         } else {
             Director::redirectBack();
             return null;
         }
     }
 }
Ejemplo n.º 29
0
 static function redirect_to_login_prompt($redirect_url)
 {
     $redirect_url = "http://{$_SERVER['HTTP_HOST']}{$redirect_url}";
     /* Build TwitterOAuth object with client credentials. */
     $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
     /* Get temporary credentials. */
     $request_token = $connection->getRequestToken($redirect_url);
     /* Save temporary credentials to session. */
     $_SESSION['oauth_token'] = $token = $request_token['oauth_token'];
     $_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
     /* If last connection failed don't display authorization link. */
     switch ($connection->http_code) {
         case 200:
             /* Build authorize URL and redirect user to Twitter. */
             $url = $connection->getAuthorizeURL($token);
             return Director::redirect($url);
             break;
         default:
             /* Show notification if something went wrong. */
             throw new Exception('Could not connect to Twitter. Refresh the page or try again later.');
     }
 }
 function doCreate($data, $form, $request)
 {
     if (isset($data['TemplateID']) && $data['TemplateID']) {
         $template = DataObject::get_by_id('Subsite_Template', $data['TemplateID']);
     } else {
         $template = null;
     }
     // Create subsite from existing template
     switch ($data['Type']) {
         case 'template':
             if ($template) {
                 $subsite = $template->duplicate();
             } else {
                 $subsite = new Subsite_Template();
                 $subsite->write();
             }
             break;
         case 'subsite':
         default:
             if ($template) {
                 $subsite = $template->createInstance($data['Title']);
             } else {
                 $subsite = new Subsite();
                 $subsite->Title = $data['Title'];
                 $subsite->write();
             }
             break;
     }
     $form->dataFieldByName('Domains')->setExtraData(array("SubsiteID" => $subsite->ID));
     $form->saveInto($subsite);
     $subsite->write();
     if (Director::is_ajax()) {
         $recordController = new ModelAdmin_RecordController($this, $request, $subsite->ID);
         return new SS_HTTPResponse($recordController->EditForm()->forAjaxTemplate(), 200, sprintf(_t('ModelAdmin.LOADEDFOREDITING', "Loaded '%s' for editing."), $subsite->Title));
     } else {
         Director::redirect(Controller::join_links($this->Link(), $subsitess->ID, 'edit'));
     }
 }