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


PHP Director::redirect方法代码示例

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


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

示例1: 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

示例2: 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

示例3: doEditForm

 function doEditForm($data, $form)
 {
     $member = Member::currentUser();
     $form->saveInto($member);
     $member->write();
     Director::redirect('registration-edit-successful/');
 }
开发者ID:joshkosmala,项目名称:rsamembership,代码行数:7,代码来源:RegistrationForm.php

示例4: dosave

 /**
  * 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;
 }
开发者ID:helpfulrobot,项目名称:jelicanin-silverstripe-contact-page,代码行数:35,代码来源:ContactInquiryForm.php

示例5: redirect_to_login_prompt

 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);
 }
开发者ID:nickfrandsen,项目名称:social_integration,代码行数:8,代码来源:Facebook.php

示例6: redirect

 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());
 }
开发者ID:riddler7,项目名称:silverstripe-ecommerce,代码行数:8,代码来源:OrderModifierForm.php

示例7: saveComplexTableField

 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);
 }
开发者ID:newsplash,项目名称:silverstripe-memberprofiles,代码行数:9,代码来源:MemberProfileSectionField.php

示例8: save

 /**
  * 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());
 }
开发者ID:ramziammar,项目名称:websites,代码行数:16,代码来源:EditForm.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: proceed

 /**
  * 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;
 }
开发者ID:riddler7,项目名称:silverstripe-ecommerce,代码行数:15,代码来源:ShopAccountForm.php

示例11: init

 /**
  * 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;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-sakemore,代码行数:56,代码来源:More.php

示例12: 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

示例13: setStepConfig

 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;
 }
开发者ID:normann,项目名称:silverstripe-frameworktest,代码行数:13,代码来源:CMSWorkflowSiteConfigController.php

示例14: SubmitFilter

 /**
  * 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');
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:18,代码来源:EventFilterForm.php

示例15: setShippingMethod

 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'));
 }
开发者ID:tylerkidd,项目名称:silverstripe-shop-shippingframework,代码行数:14,代码来源:CheckoutStep_ShippingMethod.php


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