protected function insertSummarizedTransaction($record) { $obj = new Pap_Common_Transaction(); $obj->setUserId($record->get('affiliateid')); $obj->setCampaignId($record->get('campaignid')); $obj->setDateInserted($record->get('dateinserted')); $obj->setType(Pap3Compatibility_Migration_Pap3Constants::translateTransType($record->get('transtype'))); $obj->setAllowFirstClickData(GPF::YES); $obj->setAllowLastClickData(GPF::YES); $obj->setStatus(Pap3Compatibility_Migration_Pap3Constants::translateStatus($record->get('rstatus'))); if($record->get('rstatus') == Pap3Compatibility_Migration_Pap3Constants::STATUS_APPROVED) { $obj->setDateApproved($record->get('dateinserted')); } $obj->setCommission($record->get('commission')); $obj->setSystemNote("Migrated from PAP3"); if($record->get('payoutstatus') == 2) { $obj->setPayoutStatus('P'); } else { $obj->setPayoutStatus('U'); } $obj->setClickCount($record->get('count')); $transKind = $record->get('transkind'); if($transKind > Pap3Compatibility_Migration_Pap3Constants::TRANSKIND_SECONDTIER) { $tier = $transKind - Pap3Compatibility_Migration_Pap3Constants::TRANSKIND_SECONDTIER; } else { $tier = 1; } $obj->setTier($tier); $obj->set('commtypeid', $record->get('campcategoryid')); $obj->save(); }
protected function migrateUsersInCampaigns() { Pap3Compatibility_Migration_OutputWriter::log(" Migrating users in campaigns....."); $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add('*'); $selectBuilder->from->add('wd_pa_affiliatescampaigns'); $count = 0; foreach($selectBuilder->getAllRowsIterator() as $record) { if($record->get('affiliateid') == '' || $record->get('campcategoryid') == '') { continue; } $count++; try { $obj = new Pap_Db_UserInCommissionGroup(); $obj->setUserId($record->get('affiliateid')); $obj->setCommissionGroupId($record->get('campcategoryid')); $obj->setStatus(Pap3Compatibility_Migration_Pap3Constants::translateStatus($record->get('rstatus'))); $obj->setDateAdded(Gpf_Common_DateUtils::now()); $obj->save(); } catch(Gpf_Exception $e) { // non important error, don't display it } } Pap3Compatibility_Migration_OutputWriter::log(" ($count) ..... DONE<br/>"); }
protected function migrateBanners() { Pap3Compatibility_Migration_OutputWriter::log(" Migrating banners....."); $selectBuilder = new Gpf_SqlBuilder_SelectBuilder(); $selectBuilder->select->add('*'); $selectBuilder->from->add('wd_pa_banners', 'b'); $selectBuilder->where->add('b.deleted', '=', '0' ); $result = $selectBuilder->getAllRows(); $count = 0; foreach($result as $record) { $obj = new Pap_Common_Banner(); $obj->setId($record->get('bannerid')); $obj->setCampaignId($record->get('campaignid')); $obj->setAccountId(Pap3Compatibility_Migration_Pap3Constants::DEFAULT_ACCOUNT_ID); if($record->get('destinationurl') != '') { $obj->setDestinationUrl($record->get('destinationurl')); } else { $obj->setDestinationUrl(' '); } $obj->setName($record->get('name')); if($record->get('dateinserted') != '') { $obj->set('dateinserted', $record->get('dateinserted')); } else { $obj->set('dateinserted', Gpf_Common_DateUtils::now()); } $obj->setStatus(($record->get('hidden') == 1 ? 'H' : 'A')); $bannerType = Pap3Compatibility_Migration_Pap3Constants::translateBannerType($record->get('bannertype')); switch($bannerType) { case Pap_Common_Banner_Factory::BannerTypeText: $obj->setData1($record->get('sourceurl')); $obj->setData2($this->replaceVariables($record->get('description'))); break; case Pap_Common_Banner_Factory::BannerTypeImage: $obj->setData1($record->get('sourceurl')); break; case Pap_Common_Banner_Factory::BannerTypeHtml: $obj->setData1('N'); $obj->setData2($this->replaceVariables($record->get('description'))); break; case Pap_Common_Banner_Factory::BannerTypePopup: case Pap_Common_Banner_Factory::BannerTypePopunder: // these banners are not yet supported in PAP4 continue; case Pap_Common_Banner_Factory::BannerTypePromoEmail: $obj->setData1($record->get('sourceurl')); $obj->setData2($this->replaceVariables($record->get('description'))); break; } $obj->setBannerType($bannerType); try { $obj->save(); } catch (Gpf_Exception $e) { Pap3Compatibility_Migration_OutputWriter::log( sprintf(' Warning: banner %s not migrated. Reason: %s', $obj->getId(), $e->getMessage())); } $count++; } Pap3Compatibility_Migration_OutputWriter::log(" ($count) ..... DONE<br/>"); }
private function migrateTrackingAndCookies() { echo " Migrating tracking & cookies settings....."; // link method Gpf_Settings::set(Pap_Settings::SETTING_LINKING_METHOD, ($this->getPap3Setting('Aff_link_style') == 1 ? Pap_Tracking_ClickTracker::LINKMETHOD_REDIRECT : Pap_Tracking_ClickTracker::LINKMETHOD_URLPARAMETERS)); // tracking by IP Gpf_Settings::set(Pap_Settings::TRACK_BY_IP_SETTING_NAME, $this->convert1ToY($this->getPap3Setting('Aff_track_by_ip'))); Gpf_Settings::set(Pap_Settings::IP_VALIDITY_SETTING_NAME, $this->getPap3Setting('Aff_ip_validity')); Gpf_Settings::set(Pap_Settings::IP_VALIDITY_FORMAT_SETTING_NAME, Pap3Compatibility_Migration_Pap3Constants::translateIpValidity($this->getPap3Setting('Aff_ip_validity_type'))); // save unreferred affiliate if($this->getPap3Setting('Aff_referred_affiliate') != '') { Gpf_Settings::set(Pap_Settings::SAVE_UNREFERED_SALE_LEAD_SETTING_NAME, $this->convert1ToY($this->getPap3Setting('Aff_referred_affiliate_allow'))); Gpf_Settings::set(Pap_Settings::DEFAULT_AFFILIATE_SETTING_NAME, $this->getPap3Setting('Aff_referred_affiliate')); } Gpf_Settings::set(Pap_Settings::URL_TO_P3P, $this->getPap3Setting('Aff_p3p_xml')); Gpf_Settings::set(Pap_Settings::P3P_POLICY_COMPACT, $this->getPap3Setting('Aff_p3p_compact')); Gpf_Settings::set(Pap_Settings::OVERWRITE_COOKIE, $this->convert1ToY($this->getPap3Setting('Aff_overwrite_cookie'))); Gpf_Settings::set(Pap_Settings::DELETE_COOKIE, $this->convert1ToY($this->getPap3Setting('Aff_delete_cookie'))); echo "DONE<br/>"; }
private function insertUser($record) { $user = new Pap_Affiliates_User(); $user->setId($record->get('userid')); $user->setRefId(($record->get('refid') != '' ? $record->get('refid') : $record->get('userid'))); $user->setPassword($record->get('rpassword')); $user->setUserName($record->get('username')); $user->setFirstName($record->get('name')); $user->setLastName($record->get('surname')); $user->setAccountId(Pap3Compatibility_Migration_Pap3Constants::DEFAULT_ACCOUNT_ID); $user->setDateInserted($record->get('dateinserted')); if ($record->get('minimumpayout') != NULL) { $user->setMinimumPayout($record->get('minimumpayout')); } else { $user->setMinimumPayout(Gpf_Settings::get(Pap_Settings::PAYOUTS_MINIMUM_PAYOUT_SETTING_NAME)); } if($record->get('dateapproved') != null && $record->get('dateapproved') != '') { $user->setDateApproved($record->get('dateapproved')); } if (Pap3Compatibility_Migration_Pap3Constants::translateStatus($record->get('rstatus')) == Pap_Common_Constants::STATUS_APPROVED && $user->getDateApproved() == null) { $actualDate = new Gpf_DateTime(); $user->setDateApproved($actualDate->toDateTime()); } $user->setStatus(Pap3Compatibility_Migration_Pap3Constants::translateStatus($record->get('rstatus'))); $user->setType('A'); $user->set('numberuserid',1); $this->setAffiliateField($user, $record, 'street'); $this->setAffiliateField($user, $record, 'city'); $this->setAffiliateField($user, $record, 'company_name'); $this->setAffiliateField($user, $record, 'state'); $this->setAffiliateField($user, $record, 'zipcode'); $this->setAffiliateField($user, $record, 'weburl'); $this->setAffiliateField($user, $record, 'phone'); $this->setAffiliateField($user, $record, 'fax'); $this->setAffiliateField($user, $record, 'tax_ssn'); $this->setAffiliateField($user, $record, 'country'); $this->setAffiliateField($user, $record, 'data1'); $this->setAffiliateField($user, $record, 'data2'); $this->setAffiliateField($user, $record, 'data3'); $this->setAffiliateField($user, $record, 'data4'); $this->setAffiliateField($user, $record, 'data5'); $user->setSendNotification(false); $user->setPayoutOptionId($this->savePayoutData($record->get('userid'))); $user->save(); // handle parent id $parentUserId = $record->get('parentuserid'); if($parentUserId != '') { $updateBuilder = new Gpf_SqlBuilder_UpdateBuilder(); $updateBuilder->from->add(Pap_Db_Table_Users::getName()); $updateBuilder->set->add(Pap_Db_Table_Users::PARENTUSERID, $parentUserId); $updateBuilder->where->add(Pap_Db_Table_Users::ID, '=', $record->get('userid')); try { $updateBuilder->executeOne(); } catch (Gpf_Exception $e) { Pap3Compatibility_Migration_OutputWriter::log("<br/>Error setting parentuserid: ".$e->getMessage()); } } $this->countUsers++; }
protected function insertTransaction($record) { $obj = new Pap_Db_Transaction(); $obj->setId($record->get('transid')); $obj->setUserId($record->get('affiliateid')); $obj->setCampaignId($record->get('campaignid')); $obj->setDateInserted($record->get('dateinserted')); if($record->get('dateapproved') != '') { $obj->setDateApproved($record->get('dateapproved')); } $obj->setSystemNote("Migrated from PAP3"); $obj->set('countrycode', $record->get('countrycode')); $obj->set('ip', $record->get('ip')); $obj->set('refererurl', $record->get('refererurl')); $obj->set('browser', $record->get('browser')); $obj->setCommission($record->get('commission')); $obj->set('data1', $record->get('data1')); $obj->set('data2', $record->get('data2')); $obj->set('data3', $record->get('data3')); $obj->setFixedCost(0); $obj->setTotalCost($record->get('totalcost')); $obj->setOrderId($record->get('orderid')); $obj->setProductId($record->get('productid')); $obj->setAllowFirstClickData(GPF::YES); $obj->setAllowLastClickData(GPF::YES); if($record->get('payoutstatus') == 2) { $obj->setPayoutStatus('P'); } else { $obj->setPayoutStatus('U'); } $obj->setClickCount(1); $obj->setStatus(Pap3Compatibility_Migration_Pap3Constants::translateStatus($record->get('rstatus'))); $obj->setType(Pap3Compatibility_Migration_Pap3Constants::translateTransType($record->get('transtype'))); $transKind = $record->get('transkind'); if($transKind > Pap3Compatibility_Migration_Pap3Constants::TRANSKIND_SECONDTIER) { $tier = $transKind - Pap3Compatibility_Migration_Pap3Constants::TRANSKIND_SECONDTIER; } else { $tier = 1; } $obj->setTier($tier); $obj->set('bannerid', $record->get('bannerid')); $obj->set('commtypeid', $record->get('campcategoryid')); if($record->get('accountingid') != '') { $obj->set('payouthistoryid', $record->get('accountingid')); } $obj->save(); //bannerid char(8) utf8_general_ci YES MUL (NULL) select,insert,update,references //parentbannerid varchar(8) utf8_general_ci YES MUL (NULL) select,insert,update,references //parenttransid char(8) utf8_general_ci YES MUL (NULL) select,insert,update,references //recurringcommid char(8) utf8_general_ci YES (NULL) select,insert,update,references //firstclicktime datetime (NULL) YES (NULL) select,insert,update,references //firstclickreferer varchar(250) utf8_general_ci YES (NULL) select,insert,update,references //firstclickip varchar(15) utf8_general_ci YES (NULL) select,insert,update,references //firstclickdata1 varchar(40) utf8_general_ci YES (NULL) select,insert,update,references //firstclickdata2 varchar(40) utf8_general_ci YES (NULL) select,insert,update,references //lastclicktime datetime (NULL) YES (NULL) select,insert,update,references //lastclickreferer varchar(250) utf8_general_ci YES (NULL) select,insert,update,references //lastclickip varchar(15) utf8_general_ci YES (NULL) select,insert,update,references //lastclickdata1 varchar(40) utf8_general_ci YES (NULL) select,insert,update,references //lastclickdata2 varchar(40) utf8_general_ci YES (NULL) select,insert,update,references //trackmethod char(1) utf8_general_ci YES U select,insert,update,references //commtypeid char(8) utf8_general_ci YES MUL (NULL) select,insert,update,references //payouthistoryid char(8) utf8_general_ci YES MUL (NULL) select,insert,update,references $this->countSales++; }