Commit 9dc4b029 authored by Thomas Löffler's avatar Thomas Löffler
Browse files

[BUGFIX] Simplifies getting the membership

parent 18f2bd9f
......@@ -24,10 +24,25 @@ class Tx_T3oMembership_Task_ImportMembersTask extends tx_scheduler_Task {
*/
protected $membershipStoragePid = 0;
/**
* @var array
*/
protected $memberships = array();
/**
* @return boolean
*/
public function execute() {
$membershipRecords = $this->getDatabaseConnection()->exec_SELECTgetRows(
'uid, name',
'tx_t3omembership_domain_model_member',
'NOT hidden AND NOT deleted'
);
foreach ($membershipRecords as $membershipRecord) {
$this->memberships[$membershipRecord['name']] = $membershipRecord['uid'];
}
// does the import file exist?
$importFile = t3lib_div::getFileAbsFileName($this->getImportFile());
if (!file_exists($importFile)) {
......@@ -68,31 +83,9 @@ class Tx_T3oMembership_Task_ImportMembersTask extends tx_scheduler_Task {
* @return integer
*/
protected function getMembershipUid($membershipName) {
$membershipName = $this->getDatabaseConnection()
->fullQuoteStr(trim(str_replace('Membership', '', $membershipName)), 'tx_t3omembership_domain_model_membership');
$membershipRecord = $this->getDatabaseConnection()->exec_SELECTgetSingleRow(
'uid',
'tx_t3omembership_domain_model_membership',
'name = ' . $membershipName . ' AND NOT deleted AND NOT hidden'
);
if (!empty($membershipRecord)) {
$membershipUid = $membershipRecord['uid'];
} else {
$newMembership = array(
'name' => mysql_real_escape_string($membershipName),
'pid' => $this->getMembershipStoragePid(),
'crdate' => time(),
'tstamp' => time()
);
$this->getDatabaseConnection()->exec_INSERTquery(
'tx_t3omembership_domain_model_membership',
$newMembership
);
$membershipUid = $this->getDatabaseConnection()->sql_insert_id();
}
$membershipName = trim(str_replace('Membership', '', $membershipName));
return $membershipUid;
return $this->memberships[$membershipName];
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment