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


PHP Group::Write方法代码示例

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


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

示例1: StartSurvey

 function StartSurvey($data, $form)
 {
     //Check for existing member email address
     if ($member = Member::get()->filter('Email', Convert::raw2sql($data['Email']))->first()) {
         //Set error message
         $form->AddErrorMessage('Email', "Sorry, that email address already exists. Please choose another or login with that email.", 'bad');
         //Set form data from submitted values
         Session::set("FormInfo.Form_DeploymentSurveyRegistrationForm.data", $data);
         //Return back to form
         return Controller::curr()->redirectBack();
     }
     //Otherwise create new member and log them in
     $Member = new Member();
     $form->saveInto($Member);
     $Member->write();
     //Find or create the 'user' group
     if (!($userGroup = Group::get()->filter('Code', 'users')->first())) {
         $userGroup = new Group();
         $userGroup->Code = "users";
         $userGroup->Title = "Users";
         $userGroup->Write();
         $Member->Groups()->add($userGroup);
     }
     //Add member to user group
     $Member->Groups()->add($userGroup);
     $BackURL = Controller::curr()->Link('AboutYou');
     return OpenStackIdCommon::loginMember($Member, $BackURL);
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:28,代码来源:DeploymentSurveyRegistrationForm.php

示例2: Register

 /**
  * @param $data
  * @param $form
  * @return bool|SS_HTTPResponse
  */
 function Register($data, $form)
 {
     // Set session array individually as setting the password breaks the form.
     $sessionArray = array('Email' => $data['Email']);
     // Check for existing member email address
     if ($existingUser = DataObject::get_one('Member', "Email = '" . Convert::raw2sql($data['Email']) . "'")) {
         $form->AddErrorMessage('Email', _t('RegistrationPage.EmailValidationText', 'Sorry, that email address already exists. Please choose another.'), 'validation');
         Session::set('FormInfo.Form_RegistrationForm.data', $sessionArray);
         return $this->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 otherwise display warning.
     if ($ProfilePage = DataObject::get_one('EditProfilePage')) {
         $name = $data['FirstName'] ?: ($name = $data['Email']);
         $this->setFlash(_t('RegistrationPage.RegisteredSuccessText', 'Welcome ' . $name . ', your account has been created!'), 'success');
         return $this->redirect($ProfilePage->Link());
     } else {
         $this->setFlash(_t('RegistrationPage.RegisteredWarningText', 'Please add a "Edit Profile Page" in your SiteTree to enable profile editing'), 'warning');
         return $this->redirect(Director::absoluteBaseURL());
     }
 }
开发者ID:ormandroid,项目名称:ss_boilerplate,代码行数:40,代码来源:RegistrationPage.php

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

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

示例5: addChair

 /**
  * @param $member
  * @param $category_id
  * @throws ValidationException
  * @throws null
  */
 public static function addChair($member, $category_id)
 {
     $priorChair = SummitTrackChair::get()->filter('MemberID', $member->ID)->first();
     $category = PresentationCategory::get()->byID($category_id);
     if (!$priorChair) {
         $chair = new self();
         $chair->MemberID = $member->ID;
         $chair->write();
         $chair->Categories()->add($category);
         //Find or create the 'track-chairs' group
         if (!($Group = Group::get()->filter('Code', 'track-chairs')->first())) {
             $Group = new Group();
             $Group->Code = "track-chairs";
             $Group->Title = "Track Chairs";
             $Group->Write();
             $member->Groups()->add($Group);
         }
         //Add member to the group
         $member->Groups()->add($Group);
         return $chair->ID;
     } else {
         $priorChair->Categories()->add($category);
         $priorChair->Member()->addToGroupByCode('track-chairs');
         return $priorChair->ID;
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:32,代码来源:SummitTrackChair.php

示例6: doRegister

 function doRegister($data, $form)
 {
     //Check for existing member email address
     if ($member = Member::get()->filter('Email', Convert::raw2sql($data['Email']))->first()) {
         //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.SafeXSSForm_Form.data", $data);
         //Return back to form
         return $this->redirectBack();
     }
     //Otherwise create new member and log them in
     $Member = new Member();
     $form->saveInto($Member);
     $Member->write();
     //Find or create the 'user' group
     if (!($userGroup = Group::get()->filter('Code', 'presentation-voters')->first())) {
         $userGroup = new Group();
         $userGroup->Code = "presentation-voters";
         $userGroup->Title = "Presentation Voters";
         $userGroup->Write();
         $Member->Groups()->add($userGroup);
     }
     //Add member to user group
     $Member->Groups()->add($userGroup);
     //Get current voting page and redirect there
     if ($VotingPage = PresentationVotingPage::get()->first()) {
         $BackURL = Session::get('BackURL');
         if ($BackURL) {
             $BackURL = $VotingPage->Link() . 'Presentation/' . $BackURL;
         } else {
             $BackURL = $VotingPage->Link();
         }
     }
     return OpenStackIdCommon::loginMember($Member, $BackURL);
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:36,代码来源:SpeakerVotingRegistrationPage.php

示例7: doRegister

 function doRegister($data, $form)
 {
     if (!isset($data["Affiliations"]) || empty($data["Affiliations"])) {
         //Set error message
         $form->AddErrorMessage('Affiliations', "Sorry, You must at least enter one valid Affiliation.", 'bad');
         //Set form data from submitted values
         Session::set("FormInfo.Form_RegistrationForm.data", $data);
         //Return back to form
         return $this->redirectBack();
     }
     $new_affiliations = json_decode($data["Affiliations"]);
     //Check for existing member email address
     if ($member = Member::get()->filter('Email', Convert::raw2sql($data['Email']))->first()) {
         //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 $this->redirectBack();
     }
     //Otherwise create new member and log them in
     $Member = new Member();
     $form->saveInto($Member);
     if (isset($data['Gender'])) {
         $Gender = $data['Gender'];
         if ($Gender != 'Male' && $Gender != 'Female' && $Gender != 'Prefer not to say') {
             $Member->Gender = Convert::raw2sql($data['GenderSpecify']);
         }
     }
     $Member->write();
     if ($data['MembershipType'] == 'foundation') {
         $Member->upgradeToFoundationMember();
     } else {
         $Member->convert2SiteUser();
     }
     //Find or create the 'user' group
     if (!($userGroup = Group::get()->filter('Code', 'users')->first())) {
         $userGroup = new Group();
         $userGroup->Code = "users";
         $userGroup->Title = "Users";
         $userGroup->Write();
         $Member->Groups()->add($userGroup);
     }
     //Add member to user group
     $Member->Groups()->add($userGroup);
     foreach ($new_affiliations as $key => $newAffiliation) {
         $dbAffiliation = new Affiliation();
         $org_name = Convert::raw2sql($newAffiliation->OrgName);
         $org_name = trim($org_name);
         AffiliationController::Save($dbAffiliation, $newAffiliation, $org_name, $Member);
     }
     PublisherSubscriberManager::getInstance()->publish('new_user_registered', array($Member->ID));
     //Get profile page
     if ($ProfilePage = EditProfilePage::get()->first()) {
         //send Thank you email
         $config = SiteConfig::current_site_config();
         if ($config->RegistrationSendMail && !empty($config->RegistrationFromMessage) && !empty($config->RegistrationSubjectMessage) && !empty($config->RegistrationHTMLMessage) && !empty($config->RegistrationPlainTextMessage)) {
             $registration_email = new CustomEmail($config->RegistrationFromMessage, $Member->Email, $data['MembershipType'] == 'foundation' ? 'Thank you for becoming an OpenStack Foundation Member' : 'Thank you for becoming an OpenStack Community Member', $config->RegistrationHTMLMessage, $config->RegistrationPlainTextMessage);
             $registration_email->send();
         }
         //Redirect to profile page with success message
         return OpenStackIdCommon::loginMember($member, $ProfilePage->Link('?success=1'));
     }
 }
开发者ID:rbowen,项目名称:openstack-org,代码行数:64,代码来源:RegistrationPage.php

示例8: doPrepaidSignup

 function doPrepaidSignup()
 {
     $data = $_POST;
     //Check for existing member email address
     if ($member = DataObject::get_one("Member", "`Email` = '" . Convert::raw2sql($data['Email']) . "'")) {
         return "inlineMsg1";
     }
     $currentYear = date('Y');
     $currentMonth = date('n');
     //Stop sign-up when the credit card is expired
     if ($data['ExpirationYear'] < $currentYear) {
         return "inlineMsg6";
     }
     if ($data['ExpirationYear'] == $currentYear) {
         if ($data['ExpirationMonth'] < $currentMonth) {
             return "inlineMsg6";
         }
     }
     //Get InfusionSoft Api
     $app = $this->getInfusionSoftApi();
     // Get country text from code
     $country = Geoip::countryCode2name($data['Country']);
     // Create IndusionSoft contact
     $returnFields = array('Id');
     $conInfo = $app->findByEmail($data['Email'], $returnFields);
     if (count($conInfo)) {
         $isConID = $conInfo[0]['Id'];
     } else {
         $conDat = array('FirstName' => $data['FirstName'], 'LastName' => $data['LastName'], 'Company' => $data['Company'], 'StreetAddress1' => $data['StreetAddress1'], 'StreetAddress2' => $data['StreetAddress2'], 'City' => $data['City'], 'State' => $data['State'], 'PostalCode' => $data['PostalCode'], 'Country' => $country, 'Email' => $data['Email']);
         $isConID = $app->addCon($conDat);
     }
     // Locate existing credit card
     $ccID = $app->locateCard($isConID, substr($data['CreditCardNumber'], -4, 4));
     $creditCardType = $this->getISCreditCardType($data['CreditCardType']);
     if (!$ccID) {
         //Validate the credit card
         $card = array('CardType' => $creditCardType, 'ContactId' => $isConID, 'CardNumber' => $data['CreditCardNumber'], 'ExpirationMonth' => sprintf("%02s", $data['ExpirationMonth']), 'ExpirationYear' => $data['ExpirationYear'], 'CVV2' => $data['CVVCode']);
         $result = $app->validateCard($card);
         if ($result['Valid'] == 'false') {
             return "inlineMsg5";
         }
         $ccData = array('ContactId' => $isConID, 'FirstName' => $data['FirstName'], 'LastName' => $data['LastName'], 'BillAddress1' => $data['StreetAddress1'], 'BillAddress2' => $data['StreetAddress2'], 'BillCity' => $data['City'], 'BillState' => $data['State'], 'BillZip' => $data['PostalCode'], 'BillCountry' => $country, 'CardType' => $creditCardType, 'NameOnCard' => $data['NameOnCard'], 'CardNumber' => $data['CreditCardNumber'], 'CVV2' => $data['CVVCode'], 'ExpirationMonth' => sprintf("%02s", $data['ExpirationMonth']), 'ExpirationYear' => $data['ExpirationYear']);
         $ccID = $app->dsAdd("CreditCard", $ccData);
     }
     // Create AttentionWizard member
     $member = new Member();
     $member->FirstName = $data['FirstName'];
     $member->Surname = $data['LastName'];
     $member->Email = $data['Email'];
     $member->Password = $data['Password']['_Password'];
     $member->ISContactID = $isConID;
     $memberID = $member->write();
     //Find or create the 'user' group
     if (!($userGroup = DataObject::get_one('Group', "Code = 'customers'"))) {
         $userGroup = new Group();
         $userGroup->Code = "customers";
         $userGroup->Title = "Customers";
         $userGroup->Write();
     }
     //Add member to user group
     $userGroup->Members()->add($member);
     //Get the current date
     $curdate = $app->infuDate(date('j-n-Y'));
     $product = Product::get()->byID(7);
     // Store credit card info
     $creditCard = new CreditCard();
     $creditCard->CreditCardType = $data['CreditCardType'];
     $creditCard->CreditCardNumber = $data['CreditCardNumber'];
     $creditCard->NameOnCard = $data['NameOnCard'];
     $creditCard->CreditCardCVV = $data['CVVCode'];
     $creditCard->ExpiryMonth = $data['ExpirationMonth'];
     $creditCard->ExpiryYear = $data['ExpirationYear'];
     $creditCard->Company = $data['Company'];
     $creditCard->StreetAddress1 = $data['StreetAddress1'];
     $creditCard->StreetAddress2 = $data['StreetAddress2'];
     $creditCard->City = $data['City'];
     $creditCard->State = $data['State'];
     $creditCard->PostalCode = $data['PostalCode'];
     $creditCard->Country = $data['Country'];
     $creditCard->Current = 1;
     $creditCard->ISCCID = $ccID;
     $creditCard->MemberID = $memberID;
     $creditCardID = $creditCard->write();
     // Create an Infusionsoft order
     $config = SiteConfig::current_site_config();
     $invoiceId = $app->blankOrder($isConID, $product->Name, $curdate, 0, 0);
     $orderItem = $app->addOrderItem($invoiceId, $this->getNonExpiringIsProductId(7), 3, floatval($data['Price']), intval($data['Quantity']), $product->Name, $product->Name);
     $result = $app->chargeInvoice($invoiceId, $product->Name, $ccID, $config->MerchantAccount, false);
     // Create an order
     $order = new Order();
     $order->OrderStatus = 'P';
     $order->Amount = $data['Price'] * $data['Quantity'];
     $order->MemberID = $memberID;
     $order->ProductID = 7;
     $order->CreditCardID = $creditCardID;
     $orderID = $order->write();
     $returnFields = array('_AttentionWizard', 'Leadsource');
     $conDat1 = $app->loadCon($isConID, $returnFields);
     if ($result['Successful']) {
         // Add tag Paid member - prepaid
//.........这里部分代码省略.........
开发者ID:hemant-chakka,项目名称:awss,代码行数:101,代码来源:PrepaidSignup.php

示例9: addAction

 function addAction($data, $form)
 {
     //Check for a logged in member
     if ($CurrentMember = Member::currentUser()) {
         // Find a site member (in any group) based on the MemberID field
         $id = Convert::raw2sql($data['MemberID']);
         $member = DataObject::get_by_id("Member", $id);
         if ($data['SpeakerID'] && is_numeric($data['SpeakerID'])) {
             $speaker = PresentationSpeaker::get()->byID(intval($data['SpeakerID']));
         } elseif ($member) {
             $speaker = PresentationSpeaker::get()->filter('MemberID', $member->ID)->first();
         }
         if (!$speaker) {
             $speaker = new PresentationSpeaker();
         }
         //Find or create the 'speaker' group
         if (!($userGroup = DataObject::get_one('Group', "Code = 'speakers'"))) {
             $userGroup = new Group();
             $userGroup->Code = "speakers";
             $userGroup->Title = "Speakers";
             $userGroup->Write();
             $member->Groups()->add($userGroup);
         }
         //Add member to the group
         $member->Groups()->add($userGroup);
         if ($data['Country'] != '' && $data['Country'] != $member->Country) {
             $member->Country = convert::raw2sql($data['Country']);
         }
         if ($data['ReplaceName'] == 1) {
             $member->FirstName = $data['FirstName'];
         }
         if ($data['ReplaceSurname'] == 1) {
             $member->Surname = $data['LastName'];
         }
         if ($data['ReplaceBio'] == 1) {
             $member->Bio = $data['Bio'];
         }
         $member->write();
         $form->saveInto($speaker);
         $speaker->MemberID = $member->ID;
         $speaker->AdminID = Member::currentUser()->ID;
         // Attach Photo
         if ($member->PhotoID && $speaker->PhotoID == 0) {
             $speaker->PhotoID = $member->PhotoID;
         }
         $speaker->AskedAboutBureau = TRUE;
         // Languages
         foreach ($speaker->Languages() as $currentlang) {
             $currentlang->delete();
         }
         foreach ($data['Language'] as $lang) {
             if (trim($lang) != '') {
                 $spoken_lang = SpeakerLanguage::create(array('Language' => $lang));
                 $speaker->Languages()->add($spoken_lang);
             }
         }
         // Expertise
         $speaker->AreasOfExpertise()->removeAll();
         foreach ($data['Expertise'] as $exp) {
             if (trim($exp) != '') {
                 $expertise = SpeakerExpertise::create(array('Expertise' => $exp));
                 $speaker->AreasOfExpertise()->add($expertise);
             }
         }
         // Presentation Link
         $speaker->OtherPresentationLinks()->removeAll();
         foreach ($data['PresentationLink'] as $key => $link) {
             if (trim($link) != '') {
                 $presentation_title = trim($data['PresentationTitle'][$key]);
                 $presentation_link = SpeakerPresentationLink::create(array('LinkUrl' => $link, 'Title' => $presentation_title));
                 $speaker->OtherPresentationLinks()->add($presentation_link);
             }
         }
         // Travel Preferences
         $speaker->TravelPreferences()->removeAll();
         foreach ($data['CountriesToTravel'] as $travel_country) {
             $travel_pref = SpeakerTravelPreference::create(array('Country' => $travel_country));
             $speaker->TravelPreferences()->add($travel_pref);
         }
         $speaker->write();
         $form->sessionMessage('Your profile has been updated', 'good');
         Session::clear("FormInfo.{$form->FormName()}.data", $data);
         return $this->controller()->redirectBack();
     } else {
         return Security::PermissionFailure($this->controller, 'You must be <a href="/join">registered</a> and logged in to edit your profile:');
     }
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:87,代码来源:EditSpeakerProfileForm.php

示例10: addAction

 function addAction($data, $form)
 {
     //Check for a logged in member
     if ($CurrentMember = Member::currentUser()) {
         // Find a site member (in any group) based on the MemberID field
         $id = Convert::raw2sql($data['MemberID']);
         $member = DataObject::get_by_id("Member", $id);
         if ($data['SpeakerID'] && is_numeric($data['SpeakerID'])) {
             $speaker = PresentationSpeaker::get()->byID(intval($data['SpeakerID']));
         } elseif ($member) {
             $speaker = PresentationSpeaker::get()->filter('MemberID', $member->ID)->first();
         }
         if (!$speaker) {
             $speaker = new PresentationSpeaker();
         }
         //Find or create the 'speaker' group
         if (!($userGroup = DataObject::get_one('Group', "Code = 'speakers'"))) {
             $userGroup = new Group();
             $userGroup->Code = "speakers";
             $userGroup->Title = "Speakers";
             $userGroup->Write();
             $member->Groups()->add($userGroup);
         }
         //Add member to the group
         $member->Groups()->add($userGroup);
         if ($data['Country'] != '' && $data['Country'] != $member->Country) {
             $member->Country = convert::raw2sql($data['Country']);
         }
         if ($data['ReplaceName'] == 1) {
             $member->FirstName = $data['FirstName'];
         }
         if ($data['ReplaceSurname'] == 1) {
             $member->Surname = $data['LastName'];
         }
         if ($data['ReplaceBio'] == 1) {
             $member->Bio = $data['Bio'];
         }
         $member->write();
         $form->saveInto($speaker);
         $speaker->MemberID = $member->ID;
         $speaker->AdminID = Member::currentUser()->ID;
         // Attach Photo
         if ($member->PhotoID && $speaker->PhotoID == 0) {
             $speaker->PhotoID = $member->PhotoID;
         }
         $speaker->AskedAboutBureau = TRUE;
         $speaker->write();
         $this->controller->redirect($this->controller()->Link() . 'speaker?saved=1');
     } else {
         return Security::PermissionFailure($this->controller, 'You must be <a href="/join">registered</a> and logged in to edit your profile:');
     }
 }
开发者ID:rbowen,项目名称:openstack-org,代码行数:52,代码来源:EditSpeakerProfileForm.php

示例11: createSubscription

 public function createSubscription($data, $form)
 {
     //Get member id
     $memberId = $data['MemberID'];
     //Get product id
     $productId = $data['ProductID'];
     // Get the Page controller
     $Page_Ctrl = new Page_Controller();
     //Get InfusionSoft Api
     $app = $Page_Ctrl->getInfusionSoftApi();
     // Get curent date
     $curdate = $app->infuDate(date('j-n-Y'));
     $member = Member::get()->byID($memberId);
     //Find or create the 'user' group and add the member to the group
     if (!($userGroup = DataObject::get_one('Group', "Code = 'customers'"))) {
         $userGroup = new Group();
         $userGroup->Code = "customers";
         $userGroup->Title = "Customers";
         $userGroup->Write();
         $userGroup->Members()->add($member);
     } else {
         $userGroup->Members()->add($member);
     }
     $isConID = $member->ISContactID;
     $product = Product::get()->byID($productId);
     // Get existing credit card ID
     $creditCard = $Page_Ctrl->getCurrentCreditCard($memberId);
     // Get the current InfusionSoft credit card ID
     $ccID = $creditCard->ISCCID;
     //Get siteconfig object
     $config = SiteConfig::current_site_config();
     //Process non-expiring heatmaps purchase
     if ($productId == 4 || $productId == 5 || $productId == 6 || $productId == 7) {
         if (!$data['Quantity']) {
             $form->addErrorMessage('Quantity', "Quantity is required for non-expiring products.", 'bad');
             return $this->edit(Controller::curr()->getRequest());
         }
         // Create an Infusionsoft order
         $invoiceId = $app->blankOrder($isConID, $product->Name, $curdate, 0, 0);
         $orderItem = $app->addOrderItem($invoiceId, intval($Page_Ctrl->getNonExpiringIsProductId($data['ProductID'])), 3, floatval($product->Price), intval($data['Quantity']), $product->Name, $product->Name);
         $result = $app->chargeInvoice($invoiceId, $product->Name, $ccID, $config->MerchantAccount, false);
         // Create an order
         $order = new Order();
         $order->OrderStatus = 'P';
         $order->Amount = $product->Price * $data['Quantity'];
         $order->MemberID = $member->ID;
         $order->ProductID = $data['ProductID'];
         $order->CreditCardID = $creditCard->ID;
         $orderID = $order->write();
         if ($result['Successful']) {
             // Add tag Paid member - prepaid
             $app->grpAssign($isConID, 2290);
             $conDat = array('ContactType' => 'AW Customer');
             $returnFields = array('_AttentionWizard');
             $conDat1 = $app->loadCon($isConID, $returnFields);
             if (isset($conDat1['_AttentionWizard']) && $conDat1['_AttentionWizard'] != 'Paid and Current' && $conDat1['_AttentionWizard'] != 'Free') {
                 $conDat['_AttentionWizard'] = 'Prepaid only - no subscription';
             }
             if (!isset($conDat1['_AttentionWizard'])) {
                 $conDat['_AttentionWizard'] = 'Prepaid only - no subscription';
             }
             $conID = $app->updateCon($isConID, $conDat);
             // Note is added
             $conActionDat = array('ContactId' => $isConID, 'ActionType' => 'UPDATE', 'ActionDescription' => "Purchased AW Prepaid Credits", 'CreationDate' => $curdate, 'ActionDate' => $curdate, 'CompletionDate' => $curdate, 'UserID' => 1);
             $conActionID = $app->dsAdd("ContactAction", $conActionDat);
             // Update order
             $order->OrderStatus = 'c';
             $order->write();
             // Create a Subscription record
             $subscription = new Subscription();
             $subscription->StartDate = date("Y-m-d H:i:s");
             $subscription->MemberID = $member->ID;
             $subscription->ProductID = $data['ProductID'];
             $subscription->OrderID = $orderID;
             $subscription->write();
             // Create a MemberCredits record
             $memberCredits = new MemberCredits();
             $memberCredits->Credits = $product->Credits * $data['Quantity'];
             $memberCredits->MemberID = $member->ID;
             $memberCredits->ProductID = $product->ID;
             $memberCredits->SubscriptionID = $subscription->ID;
             $memberCredits->write();
             $form->sessionMessage("Purchased non-expiring heatmaps successfully.", 'good');
             return Controller::curr()->redirect("admin/manage-data/Subscription/EditForm/field/Subscription/item/{$subscription->ID}/edit");
         } else {
             // Add an AW prospect tag
             $app->grpAssign($isConID, $Page_Ctrl->getISTagIdByPaymentCode(strtoupper($result['Code'])));
             // Add a note
             $conActionDat = array('ContactId' => $isConID, 'ActionType' => 'UPDATE', 'ActionDescription' => "Unsuccessful attempt to purchase prepaid plan", 'CreationDate' => $curdate, 'ActionDate' => $curdate, 'CompletionDate' => $curdate, 'UserID' => 1);
             $conActionID = $app->dsAdd("ContactAction", $conActionDat);
             $form->sessionMessage("Sorry,the payment failed,please update the user credit card.", 'bad');
             return $this->edit(Controller::curr()->getRequest());
         }
     }
     //Process subscriptions
     if ($productId == 1 || $productId == 2 || $productId == 3) {
         $credits = $product->Credits;
         $subscriptionID = $Page_Ctrl->createISSubscription($isConID, $product->ISProductID, $product->RecurringPrice, $ccID, 30);
         if ($subscriptionID && is_int($subscriptionID)) {
             if ($productId == 1 && !$Page_Ctrl->isCCUsedForTrial($creditCard->CreditCardNumber)) {
//.........这里部分代码省略.........
开发者ID:hemant-chakka,项目名称:awss,代码行数:101,代码来源:DataAdmin.php

示例12: doSignup

 function doSignup()
 {
     $data = $_POST;
     //Stop sign-up if the user does not check the chebox
     if (!isset($data['Agreement'])) {
         return "inlineMsg5";
     }
     if ($this->isCCUsedForTrial("{$data['CreditCardNumber']}") && $data['SubscriptionType'] == 1) {
         return "inlineMsg1";
     }
     $currentYear = date('Y');
     $currentMonth = date('n');
     //Stop sign-up when the credit card is expired
     if ($data['ExpirationYear'] < $currentYear) {
         return "inlineMsg4";
     }
     if ($data['ExpirationYear'] == $currentYear) {
         if ($data['ExpirationMonth'] < $currentMonth) {
             return "inlineMsg4";
         }
     }
     //Get InfusionSoft Api
     $app = $this->getInfusionSoftApi();
     //Get current date
     $curdate = $app->infuDate(date('j-n-Y'));
     //Get the registration form from session
     $regFormData = Session::get('RegistrationFormData');
     // Get country text from code
     $country = Geoip::countryCode2name($data['Country']);
     // Get InfusionSoft Contact ID
     $returnFields = array('Id', 'Leadsource');
     $conInfo = $app->findByEmail($regFormData['Email'], $returnFields);
     if (empty($conInfo)) {
         // If IS contact doesn't exist create one
         $conDat = array('FirstName' => $data['FirstName'], 'LastName' => $data['LastName'], 'Company' => $data['Company'], 'StreetAddress1' => $data['StreetAddress1'], 'StreetAddress2' => $data['StreetAddress2'], 'City' => $data['City'], 'State' => $data['State'], 'PostalCode' => $data['PostalCode'], 'Country' => $country, 'Email' => $regFormData['Email']);
         if (empty($conInfo)) {
             $conDat['Leadsource'] = 'AttentionWizard';
         }
         $isConID = $app->addCon($conDat);
     } else {
         $isConID = $conInfo[0]['Id'];
     }
     // Locate existing credit card
     $ccID = $app->locateCard($isConID, substr($data['CreditCardNumber'], -4, 4));
     $creditCardType = $this->getISCreditCardType($data['CreditCardType']);
     if (!$ccID) {
         //Validate the credit card
         $card = array('CardType' => $creditCardType, 'ContactId' => $isConID, 'CardNumber' => $data['CreditCardNumber'], 'ExpirationMonth' => sprintf("%02s", $data['ExpirationMonth']), 'ExpirationYear' => $data['ExpirationYear'], 'CVV2' => $data['CVVCode']);
         $result = $app->validateCard($card);
         if ($result['Valid'] == 'false') {
             return "inlineMsg3";
         }
         $ccData = array('ContactId' => $isConID, 'FirstName' => $data['FirstName'], 'LastName' => $data['LastName'], 'BillAddress1' => $data['StreetAddress1'], 'BillAddress2' => $data['StreetAddress2'], 'BillCity' => $data['City'], 'BillState' => $data['State'], 'BillZip' => $data['PostalCode'], 'BillCountry' => $country, 'CardType' => $creditCardType, 'NameOnCard' => $data['NameOnCard'], 'CardNumber' => $data['CreditCardNumber'], 'CVV2' => $data['CVVCode'], 'ExpirationMonth' => sprintf("%02s", $data['ExpirationMonth']), 'ExpirationYear' => $data['ExpirationYear']);
         $ccID = $app->dsAdd("CreditCard", $ccData);
     }
     // Create AttentionWizard member
     $member = new Member();
     $member->FirstName = $data['FirstName'];
     $member->Surname = $data['LastName'];
     $member->Email = $regFormData['Email'];
     $member->Password = $regFormData['Password']['_Password'];
     $member->ISContactID = $isConID;
     $memberID = $member->write();
     //Find or create the 'user' group and add the member to the group
     if (!($userGroup = DataObject::get_one('Group', "Code = 'customers'"))) {
         $userGroup = new Group();
         $userGroup->Code = "customers";
         $userGroup->Title = "Customers";
         $userGroup->Write();
         $userGroup->Members()->add($member);
     } else {
         $userGroup->Members()->add($member);
     }
     //Get product details
     $product = Product::get()->byID($data['SubscriptionType']);
     $credits = $product->Credits;
     if ($data['SubscriptionType'] == 1) {
         $orderAmount = $product->TrialPrice;
         $productName = "30 days 1-dollar Trial";
         $isProductID = 38;
     } else {
         $productName = $product->Name;
         $orderAmount = $product->RecurringPrice;
         $isProductID = $product->ISInitialProductID;
     }
     // Store credit card info
     $creditCard = new CreditCard();
     $creditCard->CreditCardType = $data['CreditCardType'];
     $creditCard->CreditCardNumber = $data['CreditCardNumber'];
     $creditCard->NameOnCard = $data['NameOnCard'];
     $creditCard->CreditCardCVV = $data['CVVCode'];
     $creditCard->ExpiryMonth = $data['ExpirationMonth'];
     $creditCard->ExpiryYear = $data['ExpirationYear'];
     $creditCard->Company = $data['Company'];
     $creditCard->StreetAddress1 = $data['StreetAddress1'];
     $creditCard->StreetAddress2 = $data['StreetAddress2'];
     $creditCard->City = $data['City'];
     $creditCard->State = $data['State'];
     $creditCard->PostalCode = $data['PostalCode'];
     $creditCard->Country = $data['Country'];
//.........这里部分代码省略.........
开发者ID:hemant-chakka,项目名称:awss,代码行数:101,代码来源:TrialSignup.php


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