当前位置: 首页>>代码示例>>PHP>>正文


PHP Director::redirectBack方法代码示例

本文整理汇总了PHP中Director::redirectBack方法的典型用法代码示例。如果您正苦于以下问题:PHP Director::redirectBack方法的具体用法?PHP Director::redirectBack怎么用?PHP Director::redirectBack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Director的用法示例。


在下文中一共展示了Director::redirectBack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doRegister

 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'));
     }
 }
开发者ID:dunatron,项目名称:onbaord-revamp,代码行数:31,代码来源:RegistrationPage.php

示例2: submit

 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/');
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-rewards,代码行数:32,代码来源:OrderRewardForm.php

示例3: saveComplexTableField

 /**
  * Very ugly copy of the same method in ComplexTableField, but need a way to inject the extra data into created
  * objects prior to writing them.
  */
 function saveComplexTableField($data, $form, $params)
 {
     $className = $this->sourceClass();
     $childData = new $className();
     $form->saveInto($childData);
     // Populate in the defaults as well.
     foreach ($this->defaultValues as $key => $value) {
         $childData->{$key} = $value;
     }
     $childData->write();
     // Save the many many relationship if it's available
     if (isset($data['ctf']['manyManyRelation'])) {
         $parentRecord = DataObject::get_by_id($data['ctf']['parentClass'], (int) $data['ctf']['sourceID']);
         $relationName = $data['ctf']['manyManyRelation'];
         $componentSet = $parentRecord->getManyManyComponents($relationName);
         $componentSet->add($childData);
     }
     if (isset($data['ctf']['hasManyRelation'])) {
         $parentRecord = DataObject::get_by_id($data['ctf']['parentClass'], (int) $data['ctf']['sourceID']);
         $relationName = $data['ctf']['hasManyRelation'];
         $componentSet = $parentRecord->getComponents($relationName);
         $componentSet->add($childData);
     }
     $referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;
     $closeLink = sprintf('<small><a href="%s" onclick="javascript:window.top.GB_hide(); return false;">(%s)</a></small>', $referrer, _t('ComplexTableField.CLOSEPOPUP', 'Close Popup'));
     $message = sprintf(_t('ComplexTableField.SUCCESSADD', 'Added %s %s %s'), $childData->singular_name(), '<a href="' . $this->Link() . '/item/' . $childData->ID . '/edit">' . $childData->Title . '</a>', $closeLink);
     $form->sessionMessage($message, 'good');
     Director::redirectBack();
 }
开发者ID:RyeDesigns,项目名称:silverstripe-forum,代码行数:33,代码来源:HasOneCTFWithDefaults.php

示例4: addMember

 function addMember($data, $form)
 {
     $member = new Member();
     $form->saveInto($member);
     $member->write();
     Director::redirectBack();
 }
开发者ID:normann,项目名称:silverstripe-frameworktest,代码行数:7,代码来源:TestFileUploadPage.php

示例5: Delete

 public function Delete($data, $item)
 {
     if (!$item->canDelete()) {
         $this->httpError(403);
     }
     $this->parent->{$this->name . 'ID'} = null;
     $this->parent->write();
     $item->delete();
     return Director::is_ajax() ? $this->FieldHolder() : Director::redirectBack();
 }
开发者ID:d00616,项目名称:silverstripe-itemsetfield,代码行数:10,代码来源:HasOnePickerField.php

示例6: removeFromWishList

 public function removeFromWishList($data, $form)
 {
     if (($member = Member::currentUser()) && ($wishListItems = $member->WishListItems("PageID = " . $data['PageID'])) && $wishListItems->exists()) {
         foreach ($wishListItems as $wishListItem) {
             $member->WishListItems()->remove($wishListItem);
         }
     }
     //$page = DataObject::get_by_id("Page", $data['PageID']);
     Director::redirectBack("?removed_wishlist=1");
 }
开发者ID:nimeso,项目名称:shop-wish-list,代码行数:10,代码来源:WishListPageController.php

示例7: fontAction

 protected function fontAction($change)
 {
     $currentSize = $this->currentFontSize();
     $currentSize = floatval($currentSize) + $change;
     Session::set("fontsize", $currentSize);
     if (Director::is_ajax()) {
         return $this->CurrentFontSizeInPercentages($currentSize);
     } else {
         Director::redirectBack();
     }
     return array();
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-fontresizer,代码行数:12,代码来源:FontResizer.php

示例8: submit

 /**
  * Save the changes to the form
  */
 function submit($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::redirectBack();
     return true;
 }
开发者ID:riddler7,项目名称:silverstripe-ecommerce,代码行数:15,代码来源:ShopAccountForm.php

示例9: activate

 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();
     }
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:53,代码来源:VerificationForm.php

示例10: doProcess

 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());
 }
开发者ID:halkyon,项目名称:silverstripe-ecommerce_experiment,代码行数:52,代码来源:OrderForm.php

示例11: finish

 /**
  * Handles validating the final step and writing the tickets data to the
  * registration object.
  */
 public function finish($data, $form)
 {
     parent::finish($data, $form);
     $step = $this->getCurrentStep();
     $datetime = $this->getController()->getDateTime();
     $registration = $this->session->getRegistration();
     $ticketsStep = $this->getSavedStepByClass('EventRegisterTicketsStep');
     $tickets = $ticketsStep->loadData();
     // Check that the requested tickets are still available.
     if (!$this->validateTickets($tickets['Tickets'], $form)) {
         Session::set("FormInfo.{$form->FormName()}.data", $form->getData());
         Director::redirectBack();
         return false;
     }
     // Validate the final step.
     if (!$step->validateStep($data, $form)) {
         Session::set("FormInfo.{$form->FormName()}.data", $form->getData());
         Director::redirectBack();
         return false;
     }
     // Reload the first step fields into a form, then save it into the
     // registration object.
     $ticketsStep->setForm($form);
     $fields = $ticketsStep->getFields();
     $form = new Form($this, '', $fields, new FieldSet());
     $form->loadDataFrom($tickets);
     $form->saveInto($registration);
     if ($member = Member::currentUser()) {
         $registration->Name = $member->getName();
         $registration->Email = $member->Email;
     }
     $registration->TimeID = $datetime->ID;
     $registration->MemberID = Member::currentUserID();
     $total = $ticketsStep->getTotal();
     $registration->Total->setCurrency($total->getCurrency());
     $registration->Total->setAmount($total->getAmount());
     foreach ($tickets['Tickets'] as $id => $quantity) {
         if ($quantity) {
             $registration->Tickets()->add($id, array('Quantity' => $quantity));
         }
     }
     $registration->write();
     $this->session->delete();
     // If the registrations is already valid, then send a details email.
     if ($registration->Status == 'Valid') {
         EventRegistrationDetailsEmail::factory($registration)->send();
     }
     $this->extend('onRegistrationComplete', $registration);
     return Director::redirect(Controller::join_links($datetime->Event()->Link(), 'registration', $registration->ID, '?token=' . $registration->Token));
 }
开发者ID:nyeholt,项目名称:silverstripe-eventmanagement,代码行数:54,代码来源:EventRegisterForm.php

示例12: process_payment_form_and_return_next_step

 /**
  * Process payment form and return next step in the payment process.
  * Steps taken are:
  * 1. create new payment
  * 2. save form into payment
  * 3. return payment result
  *
  * @param Order $order - the order that is being paid
  * @param Form $form - the form that is being submitted
  * @param Array $data - Array of data that is submittted
  * @return Boolean - if successful, this method will return TRUE
  */
 public static function process_payment_form_and_return_next_step($order, $form, $data)
 {
     if (!$order) {
         $form->sessionMessage(_t('EcommercePayment.NOORDER', 'Order not found.'), 'bad');
         Director::redirectBack();
         return false;
     }
     $paidBy = $order->Member();
     if (!$paidBy) {
         $paidBy = Member::currentUser();
     }
     $paymentClass = !empty($data['PaymentMethod']) ? $data['PaymentMethod'] : null;
     $payment = class_exists($paymentClass) ? new $paymentClass() : null;
     if (!($payment && $payment instanceof Payment)) {
         $form->sessionMessage(_t('EcommercePayment.NOPAYMENTOPTION', 'No Payment option selected.'), 'bad');
         Director::redirectBack();
         return false;
     }
     // Save payment data from form and process payment
     $form->saveInto($payment);
     $payment->OrderID = $order->ID;
     if (is_object($paidBy)) {
         $payment->PaidByID = $paidBy->ID;
     }
     $payment->Amount = $order->TotalOutstandingAsMoneyObject();
     $payment->write();
     // Process payment, get the result back
     $result = $payment->processPayment($data, $form);
     if (!$result instanceof Payment_Result) {
         return false;
     } else {
         if ($result->isProcessing()) {
             //IMPORTANT!!!
             // isProcessing(): Long payment process redirected to another website (PayPal, Worldpay)
             //redirection is taken care of by payment processor
             return $result->getValue();
         } else {
             //payment is done, redirect to either returntolink
             //OR to the link of the order ....
             if (isset($data["returntolink"])) {
                 Director::redirect($data["returntolink"]);
             } else {
                 Director::redirect($order->Link());
             }
         }
         return true;
     }
 }
开发者ID:nieku,项目名称:silverstripe-ecommerce,代码行数:60,代码来源:EcommercePayment.php

示例13: submit

 function submit($data, $form)
 {
     if ($order = ShoppingCart::singleton()->current()) {
         $package = $order->createShippingPackage();
         $address = new Address();
         $form->saveInto($address);
         $estimator = new ShippingEstimator($package, $address);
         $estimates = $estimator->getEstimates();
         Session::set("ShippingEstimates", $estimates);
         if (Director::is_ajax()) {
             return json_encode($estimates->toArray());
             //TODO: replace with an AJAXResponse class that can output to different formats
         }
     }
     Director::redirectBack();
 }
开发者ID:nimeso,项目名称:silverstripe-shop-shippingframework,代码行数:16,代码来源:ShippingEstimateForm.php

示例14: handleAction

 function handleAction($request)
 {
     // This method can't be called without ajax.
     if (!Director::is_ajax()) {
         Director::redirectBack();
         return;
     }
     // Protect against CSRF on destructive action
     if (!SecurityToken::inst()->checkRequest($request)) {
         return $this->httpError(400);
     }
     $actions = Object::get_static($this->class, 'batch_actions');
     $actionClass = $actions[$request->param('BatchAction')];
     $actionHandler = new $actionClass();
     // Sanitise ID list and query the database for apges
     $ids = split(' *, *', trim($request->requestVar('csvIDs')));
     foreach ($ids as $k => $v) {
         if (!is_numeric($v)) {
             unset($ids[$k]);
         }
     }
     if ($ids) {
         $pages = DataObject::get('SiteTree', "\"SiteTree\".\"ID\" IN (" . implode(", ", $ids) . ")");
         // If we didn't query all the pages, then find the rest on the live site
         if (!$pages || $pages->Count() < sizeof($ids)) {
             foreach ($ids as $id) {
                 $idsFromLive[$id] = true;
             }
             if ($pages) {
                 foreach ($pages as $page) {
                     unset($idsFromLive[$page->ID]);
                 }
             }
             $idsFromLive = array_keys($idsFromLive);
             // Debug::message("\"SiteTree\".\"ID\" IN (" . implode(", ", $idsFromLive) . ")");
             $livePages = Versioned::get_by_stage('SiteTree', 'Live', "\"SiteTree\".\"ID\" IN (" . implode(", ", $idsFromLive) . ")");
             if ($pages) {
                 $pages->merge($livePages);
             } else {
                 $pages = $livePages;
             }
         }
     } else {
         $pages = new DataObjectSet();
     }
     return $actionHandler->run($pages);
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:47,代码来源:CMSBatchActionHandler.php

示例15: SaveProfile

 /**
  * @param $data
  * @param $form
  * @return SS_HTTPResponse
  */
 function SaveProfile($data, $form)
 {
     // Check for a logged in member
     if ($CurrentMember = Member::currentUser()) {
         // Check for another member with the same email address
         if ($member = DataObject::get_one("Member", "Email = '" . Convert::raw2sql($data['Email']) . "' AND ID != " . $CurrentMember->ID)) {
             $form->addErrorMessage("Name", 'Sorry, that name already exists.', "bad");
             Session::set("FormInfo.Form_EditProfileForm.data", $data);
             return Director::redirectBack();
         } else {
             $form->saveInto($CurrentMember);
             $CurrentMember->write();
             return $this->redirect($this->Link('?saved=1'));
         }
     } else {
         return Security::PermissionFailure($this->controller, 'you must be logged in to edit your profile');
     }
 }
开发者ID:dunatron,项目名称:onbaord-revamp,代码行数:23,代码来源:EditProfilePage.php


注:本文中的Director::redirectBack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。