public function run() { $time1 = microtime(); Pap3Compatibility_Migration_OutputWriter::logOnce("Deleting migrated data from existing PAP4 tables<br/>"); try { $this->deleteTable(Pap_Db_Table_Campaigns::getName()); $this->deleteTable(Pap_Db_Table_CommissionGroups::getName()); $this->deleteTable(Pap_Db_Table_CommissionTypes::getName()); $this->deleteTable(Pap_Db_Table_Commissions::getName()); $this->deleteTable(Pap_Db_Table_UserInCommissionGroup::getName()); $this->deleteTable(Gpf_Db_Table_FormFields::getName()); $this->deleteTable(Gpf_Db_Table_FieldGroups::getName()); $this->deleteTable(Pap_Db_Table_Transactions::getName()); $this->deleteTable(Pap_Db_Table_Clicks::getName()); $this->deleteTable(Pap_Db_Table_RawClicks::getName()); $this->deleteTable(Pap_Db_Table_Impressions::getName()); $this->deleteTable(Pap_Db_Table_Banners::getName()); $this->deleteTable(Gpf_Db_Table_FieldGroups::getName()); $this->deleteTable(Pap_Db_Table_PayoutsHistory::getName()); $this->deleteTable(Pap_Db_Table_Payouts::getName()); $this->deleteTable(Gpf_Db_Table_Currencies::getName()); $this->deleteTable(Gpf_Db_Table_MailAccounts::getName()); } catch(Exception $e) { Pap3Compatibility_Migration_OutputWriter::log(" Errror: ".$e->getMessage()."<br/>"); } $time2 = microtime(); Pap3Compatibility_Migration_OutputWriter::logDone($time1, $time2); }
protected function buildFrom() { $this->_selectBuilder->from->add(Gpf_Db_Table_MailOutbox::getName(), 'mo'); $condition = 'mo.' . Gpf_Db_Table_MailOutbox::MAILACCOUNTID . ' = ' . 'ma.' . Gpf_Db_Table_MailAccounts::ID; $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_MailAccounts::getName(), 'ma', $condition); $condition = 'mo.' . Gpf_Db_Table_MailOutbox::MAIL_ID . ' = ' . 'm.' . Gpf_Db_Table_Mails::ID; $this->_selectBuilder->from->addInnerJoin(Gpf_Db_Table_Mails::getName(), 'm', $condition); }
protected function beforeSaveAction() { if ($this->get(Gpf_Db_Table_MailAccounts::IS_DEFAULT) == Gpf::YES) { $update = new Gpf_SqlBuilder_UpdateBuilder(); $update->from->add(Gpf_Db_Table_MailAccounts::getName()); $update->set->add(Gpf_Db_Table_MailAccounts::IS_DEFAULT, Gpf::NO); $update->where->add(Gpf_Db_Table_MailAccounts::ID, '<>', $this->getPrimaryKeyValue()); $update->execute(); } }
/** * * @return Gpf_Data_RecordSet */ private function getPendingEmail($outboxids) { $this->debug('Getting pending email...'); $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add('o.' . Gpf_Db_Table_MailOutbox::ID, Gpf_Db_Table_MailOutbox::ID); $select->select->add('o.' . Gpf_Db_Table_MailOutbox::RETRY_NR, Gpf_Db_Table_MailOutbox::RETRY_NR); $select->select->add('m.*'); $select->select->add('ma.*'); $select->from->add(Gpf_Db_Table_MailOutbox::getName(), 'o'); $select->from->addInnerJoin(Gpf_Db_Table_MailAccounts::getName(), 'ma', 'o.' . Gpf_Db_Table_MailOutbox::MAILACCOUNTID . ' = ma.' . Gpf_Db_Table_MailAccounts::ID); $select->from->addInnerJoin(Gpf_Db_Table_Mails::getName(), 'm', 'o.' . Gpf_Db_Table_MailOutbox::MAIL_ID . ' = m.' . Gpf_Db_Table_Mails::ID); if (!empty($outboxids)) { $select->where->add('o.' . Gpf_Db_Table_MailOutbox::ID, 'IN', $outboxids); } else { $select->where->add('o.' . Gpf_Db_Table_MailOutbox::ID, 'BETWEEN', $this->task->getWorkingAreaFrom() . ' AND ' . $this->task->getWorkingAreaTo(), 'AND', false); } //load just mails with status pending $select->where->add('o.' . Gpf_Db_Table_MailOutbox::STATUS, '=', Gpf_Db_Table_MailOutbox::STATUS_PENDING); // load just mails, which are already scheduled $select->where->add('o.' . Gpf_Db_Table_MailOutbox::SCHNEDULET_AT, '<=', $this->createDatabase()->getDateString()); //if retry number is too high, don't repeat sending $select->where->add('o.' . Gpf_Db_Table_MailOutbox::RETRY_NR, '<', Gpf_Db_Table_MailOutbox::MAX_RETRY_NR); $this->debug('email select: ' . $select->toString()); $select->limit->set(0, 1); return $select->getAllRows(); }
private function getUnsentEmails() { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add('COUNT(o.'.Gpf_Db_Table_MailOutbox::ID.')', 'unsentEmails'); $select->from->add(Gpf_Db_Table_MailOutbox::getName(), 'o'); $select->from->addLeftJoin(Gpf_Db_Table_MailAccounts::getName(), 'ma', 'ma.'.Gpf_Db_Table_MailAccounts::ID.' = o.'.Gpf_Db_Table_MailOutbox::MAILACCOUNTID); $select->where->add('o.'.Gpf_Db_Table_MailOutbox::STATUS, '=', Gpf_Db_Table_MailOutbox::STATUS_PENDING); Gpf_Plugins_Engine::extensionPoint('AffiliateNetwork.modifyWhere', new Gpf_Common_SelectBuilderCompoundRecord($select, new Gpf_Data_Record(array('columnPrefix'), array('ma')))); $result = $select->getOneRow(); return $result->get('unsentEmails'); }