modmore / importX

Addon for MODX Revolution which will take your CSV Formatted files (or raw paste) and transforms it into resources. Funded by Working Party (digital agency based in Sydney, @workingparty)
http://www.markhamstra.com/
23 stars 17 forks source link

Issue importing pub_date values #58

Open Mark-H opened 10 years ago

Mark-H commented 10 years ago

I decided to upload a bunch of resources with defined pub_date. Pub_dates were in unix format and were set as “future dates”. I mean I expected the resources to be published later on this month. But when I finished importing, all of the resources were published))))

Reported by Ivan B

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/3453511-issue-importing-pub_date-values?utm_campaign=plugin&utm_content=tracker%2F1511225&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1511225&utm_medium=issues&utm_source=github).
Mark-H commented 10 years ago

resource/create processor:

        $now = time();
        if (isset($scriptProperties['pub_date'])) {
            if (empty($scriptProperties['pub_date'])) {
                $scriptProperties['pub_date'] = 0;
            } else {
                $scriptProperties['pub_date'] = strtotime($scriptProperties['pub_date']);
                if ($scriptProperties['pub_date'] < $now) $scriptProperties['published'] = 1;
                if ($scriptProperties['pub_date'] > $now) $scriptProperties['published'] = 0;
            }
        }

The core expects it to be a time string as indicated by the strtotime function call