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


PHP Form::sessionMessage方法代码示例

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


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

示例1: validate_payment

 /**
  * @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 - true if the data is valid
  */
 public static function validate_payment(Order $order, Form $form, array $data)
 {
     if (!$order) {
         $form->sessionMessage(_t('EcommercePayment.NOORDER', 'Order not found.'), 'bad');
         return false;
     }
     //nothing to pay, always valid
     if ($order->TotalOutstanding() == 0) {
         return true;
     }
     $hasValidPaymentClass = false;
     $paymentClass = !empty($data['PaymentMethod']) ? $data['PaymentMethod'] : null;
     if ($paymentClass) {
         if (class_exists($paymentClass)) {
             $paymentClass = new $paymentClass();
             if ($paymentClass instanceof EcommercePayment) {
                 $hasValidPaymentClass = true;
             }
         }
     }
     if (!$hasValidPaymentClass) {
         $form->sessionMessage(_t('EcommercePayment.NOPAYMENTOPTION', 'No Payment option selected.'), 'bad');
         return false;
     }
     // Check payment, get the result back
     return $paymentClass->validatePayment($data, $form);
 }
开发者ID:TouchtechLtd,项目名称:silverstripe-ecommerce,代码行数:33,代码来源:EcommercePayment.php

示例2: dopayment

 /**
  * Make payment for a place order, where payment had previously failed.
  *
  * @param array $data
  * @param Form  $form
  *
  * @return boolean
  */
 public function dopayment($data, $form)
 {
     if (self::config()->allow_paying && $this->order && $this->order->canPay()) {
         // Save payment data from form and process payment
         $data = $form->getData();
         $gateway = !empty($data['PaymentMethod']) ? $data['PaymentMethod'] : null;
         if (!GatewayInfo::is_manual($gateway)) {
             $processor = OrderProcessor::create($this->order);
             $data['cancelUrl'] = $processor->getReturnUrl();
             $response = $processor->makePayment($gateway, $data);
             if ($response) {
                 if ($response->isRedirect() || $response->isSuccessful()) {
                     return $response->redirect();
                 }
                 $form->sessionMessage($response->getMessage(), 'bad');
             } else {
                 $form->sessionMessage($processor->getError(), 'bad');
             }
         } else {
             $form->sessionMessage(_t('OrderActionsForm.MANUAL_NOT_ALLOWED', "Manual payment not allowed"), 'bad');
         }
         return $this->controller->redirectBack();
     }
     $form->sessionMessage(_t('OrderForm.COULDNOTPROCESSPAYMENT', 'Payment could not be processed.'), 'bad');
     $this->controller->redirectBack();
 }
开发者ID:NobrainerWeb,项目名称:silverstripe-shop,代码行数:34,代码来源:OrderActionsForm.php

示例3: authenticate

 /**
  * Performs the login, but will also create and sync the Member record on-the-fly, if not found.
  *
  * @param array $data
  * @param Form $form
  * @return bool|Member|void
  * @throws SS_HTTPResponse_Exception
  */
 public static function authenticate($data, Form $form = null)
 {
     $service = Injector::inst()->get('LDAPService');
     $result = $service->authenticate($data['Username'], $data['Password']);
     $success = $result['success'] === true;
     if (!$success) {
         if ($form) {
             $form->sessionMessage($result['message'], 'bad');
         }
         return;
     }
     $data = $service->getUserByUsername($result['identity']);
     if (!$data) {
         if ($form) {
             $form->sessionMessage(_t('LDAPAuthenticator.PROBLEMFINDINGDATA', 'There was a problem retrieving your user data'), 'bad');
         }
         return;
     }
     // LDAPMemberExtension::memberLoggedIn() will update any other AD attributes mapped to Member fields
     $member = Member::get()->filter('GUID', $data['objectguid'])->limit(1)->first();
     if (!($member && $member->exists())) {
         $member = new Member();
         $member->GUID = $data['objectguid'];
         $member->write();
     }
     Session::clear('BackURL');
     return $member;
 }
开发者ID:andrewandante,项目名称:silverstripe-activedirectory,代码行数:36,代码来源:LDAPAuthenticator.php

示例4: save

 /**
  * Updates an existing Member's profile.
  */
 public function save(array $data, Form $form)
 {
     $form->saveInto($this->member);
     try {
         $this->member->write();
     } catch (ValidationException $e) {
         $form->sessionMessage($e->getResult()->message(), 'bad');
         return $this->redirectBack();
     }
     $form->sessionMessage(_t('MemberProfiles.PROFILEUPDATED', 'Your profile has been updated.'), 'good');
     return $this->redirectBack();
 }
开发者ID:helpfulrobot,项目名称:zucchi-membermanagement,代码行数:15,代码来源:MembersAccountPage_Controller.php

示例5: doSubmit

 /**
  * @param array $data
  * @param Form $form
  *
  * @return mixed
  */
 public function doSubmit($data, $form)
 {
     $controller = Controller::curr();
     $redirect = Director::baseURL() . $this->owner->URLSegment;
     if ((bool) Config::inst()->get('QuickFeedbackExtension', 'redirect_field') && isset($data['Redirect']) && Director::is_site_url($data['Redirect'])) {
         $redirect = Director::absoluteURL($data['Redirect'], true);
     }
     if (!$controller) {
         goto error;
     }
     $request = $controller->getRequest();
     if (!$request) {
         goto error;
     }
     $limit = (int) Config::inst()->get('QuickFeedbackExtension', 'rate_limit');
     $existing = Feedback::get()->filter('IP', $request->getIP())->sort('Created desc')->first();
     if ($existing) {
         $created = $existing->dbObject('Created');
         if (!$created) {
             goto error;
         }
         $seconds = abs(time() - strtotime($created->getValue()));
         $minutes = round($seconds / 60);
         if ($minutes <= $limit) {
             goto rate;
         }
     }
     $feedback = Feedback::create();
     $feedback->Rating = $data['Rating'];
     $feedback->Comment = $data['Comment'];
     $feedback->IP = $request->getIP();
     if (!empty($this->owner->ID)) {
         $feedback->PageID = $this->owner->ID;
     }
     if (!empty($this->owner->URLSegment)) {
         $feedback->URL = $this->owner->RelativeLink();
     }
     if ((bool) Config::inst()->get('QuickFeedbackExtension', 'redirect_field') && isset($data['Redirect'])) {
         $feedback->URL = $data['Redirect'];
     }
     $feedback->write();
     $form->sessionMessage(_t('QuickFeedback.ThanksMessage', 'Thanks for your comment!'), 'good');
     return $this->owner->redirect($redirect . '?success=1');
     error:
     $form->sessionMessage(_t('QuickFeedback.ErrorMessage', 'An error occurred!'), 'error');
     return $this->owner->redirect($redirect . '?error=1');
     rate:
     $form->sessionMessage(_t('QuickFeedback.RateMessage', 'Please wait a while before submitting!'), 'error');
     return $this->owner->redirect($redirect . '?rate=1');
 }
开发者ID:assertchris,项目名称:silverstripe-quickfeedback,代码行数:56,代码来源:QuickFeedbackExtension.php

示例6: doRegisterPersonal

 public function doRegisterPersonal(array $data, Form $form)
 {
     $exist = Member::get()->filter(array('Email' => $this->Email))->first();
     if ($exist) {
         $form->sessionMessage('该电子邮件已被注册', 'bad');
         return $this->redirectBack();
     }
     $member = new UnapprovedMember();
     $form->saveInto($member);
     $member->setField('MemberType', 'Personal');
     $member->write();
     $form->sessionMessage('注册成功,请等待您所属的企业审核账号,审核通过之后可以正常登陆', 'good');
     return $this->redirectBack();
 }
开发者ID:jallen0927,项目名称:lytech,代码行数:14,代码来源:RegisterPage_Controller.php

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

示例8: regenerate

 public function regenerate($data, Form $form)
 {
     $form->sessionMessage('Regenerated script files', 'good');
     $class = $this->modelClass();
     $this->scriptService->generateScriptFilesFor($class);
     $this->owner->redirectBack();
 }
开发者ID:Marketo,项目名称:SilverStripe-Script-Genie,代码行数:7,代码来源:ScriptGenieAdminExtension.php

示例9: doRegister

 function doRegister($data, Form $form)
 {
     //Check for existing member email address
     if ($member = DataObject::get_one("Member", "`Email` = '" . Convert::raw2sql($data['Email']) . "'")) {
         //Set error message
         $form->sessionMessage($data['Email'] . ". Sorry, that email address already exists. Please choose another.", 'bad');
         //Return back to form
         return $this->redirectBack();
         //return Director::redirectBack();
     } else {
         //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')) {
             //echo "profile page exists";
             //Redirect to profile page with success message
             return $this->redirect($ProfilePage->Link());
         }
     }
 }
开发者ID:helpfulrobot,项目名称:phuongle-silverstripe-member-registration,代码行数:33,代码来源:RegistrationPage.php

示例10: respondToFormAppropriately

 /**
  * Respond to a form view ajax or redirect
  * @param array $params
  * @param \Form $form
  * @param string $redirect
  * @return \SS_HTTPResponse|null
  */
 public function respondToFormAppropriately(array $params, $form = null, $redirect = '')
 {
     if ($redirect && !isset($params['redirect'])) {
         $params['redirect'] = $redirect;
     }
     if ($this->owner->Request->isAjax()) {
         if (!isset($params['code'])) {
             $params['code'] = 200;
         }
         if (!isset($params['code'])) {
             $params['status'] = 'success';
         }
         return singleton('director')->ajax_response($params, $params['code'], $params['status']);
     } else {
         if (isset($params['redirect'])) {
             $this->owner->redirect($params['redirect']);
         }
         if ($form && isset($params['message'])) {
             $form->sessionMessage($params['message'], 'good');
         }
         if (!$this->owner->redirectedTo()) {
             $this->owner->redirectBack();
         }
     }
 }
开发者ID:milkyway-multimedia,项目名称:ss-mwm-core,代码行数:32,代码来源:Controller.php

示例11: doSetPassword

 /**
  * Handles the SetPassword form
  * @param  array $data 
  * @param  Form $form 	 
  */
 public function doSetPassword($data, $form)
 {
     if (!Member::currentUser()) {
         return false;
     }
     if ($data['Password'] && $data['Password'] == $data['Password_confirm']) {
         Member::currentUser()->Password = $data['Password'];
         Member::currentUser()->write();
         if ($data['BackURL']) {
             return $this->owner->redirect($data['BackURL']);
         }
         $form->sessionMessage('Password updated', 'good');
     }
     $form->sessionMessage('Passwords do not match', 'bad');
     return $this->owner->redirectBack();
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:21,代码来源:MemberTokenAuthenticator.php

示例12: createreport

 /**
  * Create a new report
  *
  * @param array  $data
  * @param Form $form
  */
 public function createreport($data, $form)
 {
     // assume a user's okay if they can edit the reportholder
     // @TODO have a new create permission here?
     if ($this->data()->canEdit()) {
         $type = $data['ReportType'];
         $classes = ClassInfo::subclassesFor('AdvancedReport');
         if (!in_array($type, $classes)) {
             throw new Exception("Invalid report type");
         }
         $report = new ReportPage();
         $report->Title = $data['ReportName'];
         $report->MetaDescription = isset($data['ReportDescription']) ? $data['ReportDescription'] : '';
         $report->ReportType = $type;
         $report->ParentID = $this->data()->ID;
         $oldMode = Versioned::get_reading_mode();
         Versioned::reading_stage('Stage');
         $report->write();
         $report->doPublish();
         Versioned::reading_stage('Live');
         $this->redirect($report->Link());
     } else {
         $form->sessionMessage(_t('ReporHolder.NO_PERMISSION', 'You do not have permission to do that'), 'warning');
         $this->redirect($this->data()->Link());
     }
 }
开发者ID:rodneyway,项目名称:silverstripe-advancedreports,代码行数:32,代码来源:ReportHolder.php

示例13: authenticate_member

 /**
  * Attempt to find and authenticate member if possible from the given data.
  *
  * @param array $data
  * @param Form $form
  * @param bool &$success Success flag
  * @return Member Found member, regardless of successful login
  * @see MemberAuthenticator::authenticate_member()
  */
 protected static function authenticate_member($data, $form, &$success)
 {
     // Default success to false
     $success = false;
     // Attempt to identify by temporary ID
     $member = null;
     $email = null;
     if (!empty($data['tempid'])) {
         // Find user by tempid, in case they are re-validating an existing session
         $member = Member::member_from_tempid($data['tempid']);
         if ($member) {
             $email = $member->Email;
         }
     }
     // Otherwise, get email from posted value instead
     if (!$member && !empty($data['Email'])) {
         $email = $data['Email'];
     }
     // Check default login (see Security::setDefaultAdmin()) the standard way and the "extension"-way :-)
     $asDefaultAdmin = $email === Security::default_admin_username();
     if ($asDefaultAdmin || isset($GLOBALS['_DEFAULT_ADMINS']) && array_key_exists($email, $GLOBALS['_DEFAULT_ADMINS'])) {
         // If logging is as default admin, ensure record is setup correctly
         $member = Member::default_admin();
         $success = Security::check_default_admin($email, $data['Password']);
         // If not already true check if one of the extra admins match
         if (!$success) {
             $success = $GLOBALS['_DEFAULT_ADMINS'][$email] == $data['Password'];
         }
         if ($success) {
             return $member;
         }
     }
     // Attempt to identify user by email
     if (!$member && $email) {
         // Find user by email
         $member = Member::get()->filter(Member::config()->unique_identifier_field, $email)->first();
     }
     // Validate against member if possible
     if ($member && !$asDefaultAdmin) {
         $result = $member->checkPassword($data['Password']);
         $success = $result->valid();
     } else {
         $result = new ValidationResult(false, _t('Member.ERRORWRONGCRED'));
     }
     // Emit failure to member and form (if available)
     if (!$success) {
         if ($member) {
             $member->registerFailedLogin();
         }
         if ($form) {
             $form->sessionMessage($result->message(), 'bad');
         }
     } else {
         if ($member) {
             $member->registerSuccessfulLogin();
         }
     }
     return $member;
 }
开发者ID:helpfulrobot,项目名称:level51-more-admins,代码行数:68,代码来源:MoreAdminsAuthenticator.php

示例14: doConvertObject

 /**
  * Handles conversion of the current record
  * @param {array} $data Submitted Data
  * @param {Form} $form Submitting Form
  * @return {mixed} Returns an SS_HTTPResponse or an HTML string
  */
 public function doConvertObject($data, Form $form)
 {
     //Make sure the record still exists
     if (empty($this->record) || $this->record === false || !$this->record->exists()) {
         return $this->httpError(404);
     }
     if ($data['ConvertMode'] == 'ReplacePage') {
         if (empty($data['ReplacePageID']) || $data['ReplacePageID'] == 0) {
             $form->sessionMessage(_t('KapostAdmin.NO_REPLACE_PAGE_TARGET', '_You must select a page to replace'), 'error');
             return $this->popupController->redirectBack();
         }
         if (($redirectURL = $this->replacePage($data, $form)) === false) {
             $form->sessionMessage(_t('KapostAdmin.ERROR_COULD_NOT_REPLACE', '_Sorry an error occured and the target page could not be replaced.'), 'error');
             return $this->popupController->redirectBack();
         } else {
             Requirements::clear();
             Requirements::customScript('window.parent.jQuery(\'.cms-edit-form.KapostAdmin\').entwine(\'ss\').panelRedirect(' . json_encode($redirectURL) . ')');
             //Clean up the expired previews
             $this->cleanUpExpiredPreviews();
             return $this->customise(array('Title' => null, 'Content' => null, 'Form' => null))->renderWith('CMSDialog');
         }
     } else {
         if ($data['ConvertMode'] == 'NewPage') {
             if (($redirectURL = $this->newPage($data, $form)) === false) {
                 $form->sessionMessage(_t('KapostAdmin.ERROR_COULD_NOT_CREATE', '_Sorry an error occured and the page could not be created.'), 'error');
                 return $this->popupController->redirectBack();
             } else {
                 Requirements::clear();
                 Requirements::customScript('window.parent.jQuery(\'.cms-edit-form.KapostAdmin\').entwine(\'ss\').panelRedirect(' . json_encode($redirectURL) . ')');
                 //Clean up the expired previews
                 $this->cleanUpExpiredPreviews();
                 return $this->customise(array('Title' => null, 'Content' => null, 'Form' => null))->renderWith('CMSDialog');
             }
         }
     }
     //Allow extensions to convert the object
     if (in_array($data['ConvertMode'], KapostAdmin::config()->extra_conversion_modes)) {
         $results = $this->extend('doConvert' . $data['ConvertMode'], $this->record, $data, $form);
         if (count($results) > 0) {
             foreach ($results as $result) {
                 if ($result !== false) {
                     Requirements::clear();
                     Requirements::customScript('window.parent.jQuery(\'.cms-edit-form.KapostAdmin\').entwine(\'ss\').panelRedirect(' . json_encode($result) . ')');
                     //Clean up the expired previews
                     $this->cleanUpExpiredPreviews();
                     return $this->customise(array('Title' => null, 'Content' => null, 'Form' => null))->renderWith('CMSDialog');
                 }
             }
             $message = $form->Message();
             if (empty($message)) {
                 $form->sessionMessage(_t('KapostAdmin.GENERIC_CONVERSION_ERROR', '_Conversion method returns an error and no specific message'), 'error');
             }
             //All failed redirect back
             return $this->popupController->redirectBack();
         }
     }
     $form->sessionMessage(_t('KapostAdmin.UNKNOWN_CONVERSION_MODE', '_Unknown conversion mode: {mode}', array('mode' => $data['ConvertMode'])), 'error');
     return $this->popupController->redirectBack();
 }
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-kapost-bridge,代码行数:65,代码来源:KapostGridFieldDetailForm_ItemRequest.php

示例15: processApplication

 public function processApplication($data, Form $form)
 {
     $application = JobApplication::create();
     $form->saveinto($application);
     $application->write();
     $form->sessionMessage('Thanks for applying.', 'good');
     $this->redirectBack();
 }
开发者ID:Fr3dj,项目名称:training,代码行数:8,代码来源:JobPage.php


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