/**
  * If the REMOTE_USER is set and is in the Member table, log that member in. If
  * not, and Config::inst()->get('AuthRemoteUserExtension', 'auto_create_user') is set, add that
  * Member to the configured group, and log the new user in. Otherwise, do nothing.
  */
 public function onAfterInit()
 {
     if (isset($_SERVER['REMOTE_USER'])) {
         $unique_identifier = $_SERVER['REMOTE_USER'];
     } elseif (isset($_SERVER['REDIRECT_REMOTE_USER'])) {
         $unique_identifier = $_SERVER['REDIRECT_REMOTE_USER'];
     }
     if (isset($unique_identifier)) {
         $unique_identifier_field = Member::config()->unique_identifier_field;
         $member = Member::get()->filter($unique_identifier_field, $unique_identifier)->first();
         if ($member) {
             $member->logIn();
             $this->owner->redirectBack();
         } elseif (Config::inst()->get('AuthRemoteUserExtension', 'auto_create_user') && strlen(Config::inst()->get('AuthRemoteUserExtension', 'auto_user_group'))) {
             $group = Group::get()->filter('Title', Config::inst()->get('AuthRemoteUserExtension', 'auto_user_group'))->first();
             if ($group) {
                 $member = new Member();
                 $member->{$unique_identifier_field} = $unique_identifier;
                 $member->write();
                 $member->Groups()->add($group);
                 $member->logIn();
             }
         }
     }
 }
 /**
  * creates and logs in a temporary user.
  *
  */
 private function createAndLoginUser()
 {
     $this->username = "******";
     $this->password = rand(1000000000, 9999999999);
     //Make temporary admin member
     $adminMember = Member::get()->filter(array("Email" => $this->username))->first();
     if ($adminMember != NULL) {
         $adminMember->delete();
     }
     $this->member = new Member();
     $this->member->Email = $this->username;
     $this->member->Password = $this->password;
     $this->member->write();
     $adminGroup = Group::get()->filter(array("code" => "administrators"))->first();
     if (!$adminGroup) {
         user_error("No admin group exists");
     }
     $this->member->Groups()->add($adminGroup);
     curl_setopt($this->ch, CURLOPT_USERPWD, $this->username . ":" . $this->password);
     $loginUrl = Director::absoluteURL('/Security/LoginForm');
     curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, "POST");
     curl_setopt($this->ch, CURLOPT_URL, $loginUrl);
     curl_setopt($this->ch, CURLOPT_POST, 1);
     curl_setopt($this->ch, CURLOPT_POSTFIELDS, 'Email=' . $this->username . '&Password='******'color:red'>There was an error logging in!</span><br />";
     }
 }
 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();
     }
 }
 /**
  * Test that orphaned pages are handled correctly
  */
 public function testOrphanedPages()
 {
     $origStage = Versioned::get_reading_mode();
     // Setup user who can view draft content, but lacks cms permission.
     // To users such as this, orphaned pages should be inaccessible. canView for these pages is only
     // necessary for admin / cms users, who require this permission to edit / rearrange these pages.
     $permission = new Permission();
     $permission->Code = 'VIEW_DRAFT_CONTENT';
     $group = new Group(array('Title' => 'Staging Users'));
     $group->write();
     $group->Permissions()->add($permission);
     $member = new Member();
     $member->Email = '*****@*****.**';
     $member->write();
     $member->Groups()->add($group);
     // both pages are viewable in stage
     Versioned::reading_stage('Stage');
     $about = $this->objFromFixture('Page', 'about');
     $staff = $this->objFromFixture('Page', 'staff');
     $this->assertFalse($about->isOrphaned());
     $this->assertFalse($staff->isOrphaned());
     $this->assertTrue($about->canView($member));
     $this->assertTrue($staff->canView($member));
     // Publishing only the child page to live should orphan the live record, but not the staging one
     $staff->publish('Stage', 'Live');
     $this->assertFalse($staff->isOrphaned());
     $this->assertTrue($staff->canView($member));
     Versioned::reading_stage('Live');
     $staff = $this->objFromFixture('Page', 'staff');
     // Live copy of page
     $this->assertTrue($staff->isOrphaned());
     // because parent isn't published
     $this->assertFalse($staff->canView($member));
     // Publishing the parent page should restore visibility
     Versioned::reading_stage('Stage');
     $about = $this->objFromFixture('Page', 'about');
     $about->publish('Stage', 'Live');
     Versioned::reading_stage('Live');
     $staff = $this->objFromFixture('Page', 'staff');
     $this->assertFalse($staff->isOrphaned());
     $this->assertTrue($staff->canView($member));
     // Removing staging page should not prevent live page being visible
     $about->deleteFromStage('Stage');
     $staff->deleteFromStage('Stage');
     $staff = $this->objFromFixture('Page', 'staff');
     $this->assertFalse($staff->isOrphaned());
     $this->assertTrue($staff->canView($member));
     // Cleanup
     Versioned::set_reading_mode($origStage);
 }
 /**
  * Gets the list of groups that can be set after the submission of a particular form
  *
  * This works around the problem with the checkboxsetfield which doesn't validate that the
  * groups that the user has selected are not validated against the list of groups the user is
  * allowed to choose from.
  *
  * @param Form   $form
  * @param Member $member
  */
 protected function getSettableGroupIdsFrom(Form $form, Member $member = null)
 {
     // first off check to see if groups were selected by the user. If so, we want
     // to remove that control from the form list (just in case someone's sent through an
     // ID for a group like, say, the admin's group...). It means we have to handle the setting
     // ourselves, but that's okay
     $groupField = $form->Fields()->dataFieldByName('Groups');
     // The list of selectable groups
     $groupIds = $allowedIds = $this->SelectableGroups()->map('ID', 'ID')->toArray();
     // we need to track the selected groups against the existing user's groups - this is
     // so that we don't accidentally remove them from the list of groups
     // a user might have been placed in via other means
     $existingIds = array();
     if ($member) {
         $existing = $member->Groups();
         if ($existing && $existing->Count() > 0) {
             $existingIds = $existing->map('ID', 'ID')->toArray();
             // remove any that are in the selectable groups map - we only want to
             // worry about those that aren't managed by this form
             foreach ($groupIds as $gid) {
                 unset($existingIds[$gid]);
             }
         }
     }
     if ($groupField) {
         $givenIds = $groupField->Value();
         $groupIds = array();
         if ($givenIds) {
             foreach ($givenIds as $givenId) {
                 if (isset($allowedIds[$givenId])) {
                     $groupIds[] = $givenId;
                 }
             }
         }
         $form->Fields()->removeByName('Groups');
     }
     foreach ($this->Groups()->column('ID') as $mustId) {
         $groupIds[] = $mustId;
     }
     foreach ($existingIds as $existingId) {
         if (!in_array($existingId, $groupIds)) {
             $groupIds[] = $existingId;
         }
     }
     return $groupIds;
 }
 /**
  * No validation errors occured, so we register the customer and send
  * mails with further instructions for the double opt-in procedure.
  *
  * @param SS_HTTPRequest $data       SS session data
  * @param Form           $form       the form object
  * @param array          $formData   CustomHTMLForms session data
  * @param bool           $doRedirect Set to true to redirect after submitSuccess
  *
  * @return void
  * 
  * @author Sebastian Diel <*****@*****.**>,
  *         Roland Lehmann <*****@*****.**>,
  *         Sascha Koehler <*****@*****.**>
  * @since 28.01.2015
  */
 protected function submitSuccess($data, $form, $formData, $doRedirect = true)
 {
     $anonymousCustomer = false;
     /*
      * Logout anonymous users and save their shoppingcart temporarily.
      */
     if (SilvercartCustomer::currentUser()) {
         $anonymousCustomer = SilvercartCustomer::currentUser();
         SilvercartCustomer::currentUser()->logOut();
     }
     // Aggregate Data and set defaults
     $formData['MemberID'] = Member::currentUserID();
     $formData['Locale'] = Translatable::get_current_locale();
     if ($this->demandBirthdayDate()) {
         $formData['Birthday'] = $formData['BirthdayYear'] . '-' . $formData['BirthdayMonth'] . '-' . $formData['BirthdayDay'];
         if ($this->UseMinimumAgeToOrder()) {
             if (!SilvercartConfig::CheckMinimumAgeToOrder($formData['Birthday'])) {
                 $this->errorMessages['BirthdayDay'] = array('message' => SilvercartConfig::MinimumAgeToOrderError(), 'fieldname' => _t('SilvercartPage.BIRTHDAY'), 'BirthdayDay' => array('message' => SilvercartConfig::MinimumAgeToOrderError()));
                 $this->errorMessages['BirthdayMonth'] = array('message' => SilvercartConfig::MinimumAgeToOrderError(), 'fieldname' => _t('SilvercartPage.BIRTHDAY'), 'BirthdayMonth' => array('message' => SilvercartConfig::MinimumAgeToOrderError()));
                 $this->errorMessages['BirthdayYear'] = array('message' => SilvercartConfig::MinimumAgeToOrderError(), 'fieldname' => _t('SilvercartPage.BIRTHDAY'), 'BirthdayYear' => array('message' => SilvercartConfig::MinimumAgeToOrderError()));
                 $this->setSubmitSuccess(false);
                 return $this->submitFailure($data, $form);
             }
         }
     }
     // Create new regular customer and perform a log in
     $customer = new Member();
     // Pass shoppingcart to registered customer and delete the anonymous
     // customer.
     if ($anonymousCustomer) {
         $newShoppingCart = $anonymousCustomer->getCart()->duplicate(true);
         foreach ($anonymousCustomer->getCart()->SilvercartShoppingCartPositions() as $shoppingCartPosition) {
             $newShoppingCartPosition = $shoppingCartPosition->duplicate(false);
             $newShoppingCartPosition->SilvercartShoppingCartID = $newShoppingCart->ID;
             $newShoppingCartPosition->write();
             $shoppingCartPosition->transferToNewPosition($newShoppingCartPosition);
         }
         $customer->SilvercartShoppingCartID = $newShoppingCart->ID;
         $anonymousCustomer->delete();
     }
     $customer->castedUpdate($formData);
     $customer->write();
     $customer->logIn();
     $customer->changePassword($formData['Password']);
     $customerGroup = $this->getTargetCustomerGroup($formData);
     if ($customerGroup) {
         $customer->Groups()->add($customerGroup);
     }
     // Create ShippingAddress for customer and populate it with registration data
     $address = new SilvercartAddress();
     $address->castedUpdate($formData);
     $country = DataObject::get_by_id('SilvercartCountry', (int) $formData['Country']);
     if ($country) {
         $address->SilvercartCountryID = $country->ID;
     }
     $address->write();
     $this->extend('updateRegisteredAddress', $address, $data, $form, $formData);
     //connect the ShippingAddress and the InvoiceAddress to the customer
     $customer->SilvercartShippingAddressID = $address->ID;
     $customer->SilvercartInvoiceAddressID = $address->ID;
     $customer->SilvercartAddresses()->add($address);
     $customer->write();
     // Remove from the anonymous newsletter recipients list
     if (SilvercartAnonymousNewsletterRecipient::doesExist($customer->Email)) {
         $recipient = SilvercartAnonymousNewsletterRecipient::getByEmailAddress($customer->Email);
         if ($recipient->NewsletterOptInStatus) {
             $customer->NewsletterOptInStatus = 1;
             $customer->NewsletterConfirmationHash = $recipient->NewsletterOptInConfirmationHash;
             $customer->write();
         }
         SilvercartAnonymousNewsletterRecipient::removeByEmailAddress($customer->Email);
     }
     if ($customer->SubscribedToNewsletter && !$customer->NewsletterOptInStatus) {
         SilvercartNewsletter::subscribeRegisteredCustomer($customer);
     }
     $this->extend('updateRegisteredCustomer', $customer, $data, $form, $formData);
     if ($doRedirect) {
         // Redirect to welcome page
         if (array_key_exists('backlink', $formData) && !empty($formData['backlink'])) {
             $this->controller->redirect($formData['backlink']);
         } else {
             $this->controller->redirect($this->controller->PageByIdentifierCode('SilvercartRegisterConfirmationPage')->Link());
         }
     }
 }
 /**
  * Create permissions, groups and member records if they don't exist.
  */
 public function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     $groups = array();
     // create or update groups, cache id by title
     foreach (self::$groups as $title => $description) {
         if (!($group = DataObject::get_one('Group', " Title = '{$title}'"))) {
             $group = new Group(array('Title' => $title));
         }
         // update description if exists, otherwise set
         $group->Description = $description;
         $group->write();
         $groups[$title] = $group->ID;
     }
     // create or update permissions and assign to associated group
     foreach (self::$permissions as $code => $groupTitle) {
         if (!($perm = DataObject::get_one('Permission', " Code = '{$code}' "))) {
             $perm = new Permission(array('Code' => $code));
         }
         $perm->GroupID = $groups[$groupTitle];
         $perm->write();
     }
     // if config option is true create or update members, then add Member to group
     if ($this->config()->get('create_members_and_assign_to_groups') === true) {
         foreach (self::$members as $memberInfo) {
             $email = $memberInfo['Email'];
             if (!($member = DataObject::get_one('Member', " Email = '{$email}' "))) {
                 $member = new Member();
             }
             // set or update data
             $member->update($memberInfo);
             $member->write();
             foreach (self::$member_groups[$email] as $groupTitle) {
                 // if not in the group already add it
                 $groupID = $groups[$groupTitle];
                 if (!$member->Groups()->filter('ID', $groupID)->first()) {
                     $member->Groups()->add($groupID);
                 }
                 $member->write();
             }
         }
     }
 }
 /**
  * Get all the workflows that this user is responsible for
  *
  * @param Member $user
  *				The user to get workflows for
  *
  * @return ArrayList
  *				The list of workflow instances this user owns
  */
 public function usersWorkflows(Member $user)
 {
     $groupIds = $user->Groups()->column('ID');
     $groupInstances = null;
     $filter = array('');
     if (is_array($groupIds)) {
         $groupInstances = DataList::create('WorkflowInstance')->filter(array('Group.ID:ExactMatchMulti' => $groupIds))->where('"WorkflowStatus" != \'Complete\'');
     }
     $userInstances = DataList::create('WorkflowInstance')->filter(array('Users.ID:ExactMatch' => $user->ID))->where('"WorkflowStatus" != \'Complete\'');
     if ($userInstances) {
         $userInstances = $userInstances->toArray();
     } else {
         $userInstances = array();
     }
     if ($groupInstances) {
         $groupInstances = $groupInstances->toArray();
     } else {
         $groupInstances = array();
     }
     $all = array_merge($groupInstances, $userInstances);
     return ArrayList::create($all);
 }
 private function createshopadmin()
 {
     $member = new Member();
     $member->FirstName = 'Shop';
     $member->Surname = 'Admin';
     $member->Email = '*****@*****.**';
     $member->SetPassword = '******';
     $member->Password = '******';
     $member->write();
     $group = EcommerceRole::get_admin_group();
     $member->Groups()->add($group);
 }
 /**
  * Returns allowed payment methods.
  * 
  * @param string                 $shippingCountry                  The SilvercartCountry to check the payment methods for.
  * @param SilvercartShoppingCart $shoppingCart                     The shopping cart object
  * @param Boolean                $forceAnonymousCustomerIfNotExist When true, an anonymous customer will be created when no customer exists
  * 
  * @return ArrayList
  * 
  * @author Sebastian Diel <*****@*****.**>,
  *         Sascha Koehler <*****@*****.**>
  * @since 15.11.2014
  */
 public static function getAllowedPaymentMethodsFor($shippingCountry, $shoppingCart, $forceAnonymousCustomerIfNotExist = false)
 {
     $allowedPaymentMethods = array();
     if (!$shippingCountry) {
         return $allowedPaymentMethods;
     }
     $paymentMethods = $shippingCountry->SilvercartPaymentMethods('isActive = 1');
     $member = SilvercartCustomer::currentUser();
     if (!$member && $forceAnonymousCustomerIfNotExist) {
         $member = new Member();
         $anonymousGroup = Group::get()->filter('Code', 'anonymous')->first();
         $memberGroups = new ArrayList();
         $memberGroups->push($anonymousGroup);
     } else {
         $memberGroups = $member->Groups();
     }
     $shippingMethodID = null;
     if (Controller::curr() instanceof SilvercartCheckoutStep_Controller) {
         $checkoutData = Controller::curr()->getCombinedStepData();
         if (array_key_exists('ShippingMethod', $checkoutData)) {
             $shippingMethodID = $checkoutData['ShippingMethod'];
         }
     }
     if ($paymentMethods) {
         foreach ($paymentMethods as $paymentMethod) {
             $assumePaymentMethod = true;
             $containedInGroup = false;
             $containedInUsers = false;
             $doAccessChecks = true;
             // ------------------------------------------------------------
             // Basic checks
             // ------------------------------------------------------------
             if ($paymentMethod->enableActivationByOrderRestrictions) {
                 $assumePaymentMethod = $paymentMethod->isActivationByOrderRestrictionsPossible($member);
                 $doAccessChecks = false;
             }
             $checkAmount = $shoppingCart->getAmountTotalWithoutFees()->getAmount();
             if (!$paymentMethod->isAvailableForAmount($checkAmount)) {
                 $assumePaymentMethod = false;
                 $doAccessChecks = false;
             }
             // ------------------------------------------------------------
             // Shipping method check
             // ------------------------------------------------------------
             if (!is_null($shippingMethodID) && $paymentMethod->SilvercartShippingMethods()->exists() && !$paymentMethod->SilvercartShippingMethods()->find('ID', $shippingMethodID)) {
                 $assumePaymentMethod = false;
                 $doAccessChecks = false;
             }
             // ------------------------------------------------------------
             // Access checks
             // ------------------------------------------------------------
             if ($doAccessChecks) {
                 // Check if access for groups or is set positively
                 if ($paymentMethod->ShowOnlyForGroups()->exists()) {
                     foreach ($paymentMethod->ShowOnlyForGroups() as $paymentGroup) {
                         if ($memberGroups->find('ID', $paymentGroup->ID)) {
                             $containedInGroup = true;
                             break;
                         }
                     }
                     if ($containedInGroup) {
                         $assumePaymentMethod = true;
                     } else {
                         $assumePaymentMethod = false;
                     }
                 }
                 // Check if access for users or is set positively
                 if ($paymentMethod->ShowOnlyForUsers()->exists()) {
                     if ($paymentMethod->ShowOnlyForUsers()->find('ID', $member->ID)) {
                         $containedInUsers = true;
                     }
                     if ($containedInUsers) {
                         $assumePaymentMethod = true;
                     } else {
                         if (!$containedInGroup) {
                             $assumePaymentMethod = false;
                         }
                     }
                 }
                 // Check if access for groups is set negatively
                 if ($paymentMethod->ShowNotForGroups()->exists()) {
                     foreach ($paymentMethod->ShowNotForGroups() as $paymentGroup) {
                         if ($memberGroups->find('ID', $paymentGroup->ID)) {
                             if (!$containedInUsers) {
                                 $assumePaymentMethod = false;
                             }
                         }
                     }
                 }
                 // Check if access for users is set negatively
                 if ($paymentMethod->ShowNotForUsers()->exists()) {
                     if ($paymentMethod->ShowNotForUsers()->find('ID', $member->ID)) {
                         if (!$containedInUsers) {
                             $assumePaymentMethod = false;
                         }
                     }
                 }
             }
             if ($assumePaymentMethod) {
                 $allowedPaymentMethods[] = $paymentMethod;
             }
         }
     }
     $allowedPaymentMethods = new ArrayList($allowedPaymentMethods);
     return $allowedPaymentMethods;
 }
 /**
  * Get all the workflows that this user is responsible for
  * 
  * @param Member $user 
  *				The user to get workflows for
  * 
  * @return DataObjectSet
  *				The list of workflow instances this user owns
  */
 public function usersWorkflows(Member $user)
 {
     $all = new DataObjectSet();
     $groupIds = $user->Groups()->column('ID');
     $groupJoin = ' INNER JOIN "WorkflowInstance_Groups" "wig" ON "wig"."WorkflowInstanceID" = "WorkflowInstance"."ID"';
     if (is_array($groupIds)) {
         $filter = '("WorkflowStatus" = \'Active\' OR "WorkflowStatus"=\'Paused\') AND "wig"."GroupID" IN (' . implode(',', $groupIds) . ')';
         $groupAssigned = DataObject::get('WorkflowInstance', $filter, '"Created" DESC', $groupJoin);
         if ($groupAssigned) {
             $all->merge($groupAssigned);
         }
     }
     $userJoin = ' INNER JOIN "WorkflowInstance_Users" "wiu" ON "wiu"."WorkflowInstanceID" = "WorkflowInstance"."ID"';
     $filter = '("WorkflowStatus" = \'Active\' OR "WorkflowStatus"=\'Paused\') AND "wiu"."MemberID" = ' . $user->ID;
     $userAssigned = DataObject::get('WorkflowInstance', $filter, '"Created" DESC', $userJoin);
     if ($userAssigned) {
         $all->merge($userAssigned);
     }
     return $all;
 }
 /**
  * Creates an anonymous customer if there's no currentMember object.
  *
  * @return Member
  *
  * @author Sebastian Diel <*****@*****.**>,
  *         Sascha Koehler <*****@*****.**>
  * @since 15.11.2014
  */
 public static function createAnonymousCustomer()
 {
     $member = self::currentUser();
     if (!$member) {
         $member = new Member();
         $member->write();
         // Add customer to intermediate group
         $customerGroup = Group::get()->filter('Code', 'anonymous')->first();
         if ($customerGroup) {
             $member->Groups()->add($customerGroup);
         }
         $member->logIn(true);
     }
     return $member;
 }
 /**
  * Adds new member
  * 
  * @param	array	member data. 
  * @return	boolean	true/false
  */
 public function addMember($data)
 {
     if (is_array($data)) {
         $member = new Member();
         $member->Email = $data['ccustemail'];
         $member->FirstName = ucwords(strtolower($data['ccustfirstname']));
         $member->Surname = ucwords(strtolower($data['ccustlastname']));
         $member->ClickBankAccountType = 'Paid';
         $password = Member::create_new_password();
         $member->Password = "******";
         /* link to memberprofilepage module */
         $profilePage = DataObject::get_one('MemberProfilePage');
         $member->ProfilePageID = $profilePage->ID;
         if ($profilePage->EmailType == 'Validation') {
             $email = new MemberConfirmationEmail($member->ProfilePage(), $member);
             $email->send();
             $member->NeedsValidation = true;
         } elseif ($profilePage->EmailType == 'Confirmation') {
             $email = new MemberConfirmationEmail($member->ProfilePage(), $member);
             $email->send();
         }
         /* populate new member profile */
         $clickBankProfile = new ClickBankMemberProfile();
         if ($clickBankProfile) {
             self::populateFields($clickBankProfile, $data);
         }
         $clickBankProfile->write();
         $member->ClickBankProfileID = $clickBankProfile->ID;
         // save new member
         $member->write();
         // assign & update new member to a ClickBank user group
         $clickBankGroupIds = $profilePage->getClickBankMemberGroups();
         if ($clickBankGroupIds) {
             $member->Groups()->setByIDList($clickBankGroupIds);
             $member->write();
         }
         // assign & update new member to a regular memberprofile user group
         $memberGroupIds = $profilePage->getMemberProfileGroups();
         if ($memberGroupIds) {
             $member->Groups()->setByIDList($memberGroupIds);
             $member->write();
         }
         /* Populate log */
         $clickBankIpnLog = new ClickBankIpnLog();
         $clickBankIpnLog->MemberID = $member->ID;
         foreach ($data as $key => $val) {
             if (isset($clickBankIpnLog->{$key})) {
                 $clickBankIpnLog->{$key} = $val;
             }
         }
         $clickBankIpnLog->write();
         return true;
     }
     return false;
 }