Commit 22026c14 authored by Stefan Busemann's avatar Stefan Busemann
Browse files

[FEATURE] Add dropbox import

parent d97d5f21
<?php
namespace T3o\T3oMembership\Task;
use \TYPO3\CMS\Core\Utility\GeneralUtility;
use Dropbox\Dropbox;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* This file is part of the TYPO3 CMS project.
......@@ -25,12 +27,17 @@ class ImportMembersTask extends \TYPO3\CMS\Extbase\Scheduler\Task
/**
* @var string
*/
protected $importFile = '';
public $importFile = '';
/**
* @var string
*/
public $dropboxToken = '';
/**
* @var integer
*/
protected $membershipStoragePid = 0;
public $membershipStoragePid = 0;
/**
* @var array
......@@ -64,6 +71,7 @@ class ImportMembersTask extends \TYPO3\CMS\Extbase\Scheduler\Task
if (!file_exists($importFile)) {
$logger->debug('No importfile', array('filename' => $importFile));
return false;
}
......@@ -106,7 +114,7 @@ class ImportMembersTask extends \TYPO3\CMS\Extbase\Scheduler\Task
'hidden' => $hidden,
'starttime' => 0,
'membership' => $membershipUid,
'pid' => $this->getMembershipStoragePid(),
'pid' => $this->membershipStoragePid,
'crdate' => time(),
'tstamp' => time(),
'invoice_email' => $fields[84],
......@@ -192,6 +200,7 @@ class ImportMembersTask extends \TYPO3\CMS\Extbase\Scheduler\Task
if (empty($this->memberships[$membershipName])) {
return null;
}
return $this->memberships[$membershipName];
}
......@@ -202,28 +211,12 @@ class ImportMembersTask extends \TYPO3\CMS\Extbase\Scheduler\Task
*/
public function getImportFile()
{
return $this->importFile;
}
$dropbox = new Dropbox($this->dropboxToken);
$dropbox->files->download('/TYPO3 Backoffice/Member-Lists/memberlist.txt', $this->importFile);
/**
* Sets importFile
*
* @param string $importFile
*/
public function setImportFile($importFile)
{
$this->importFile = $importFile;
return $this->importFile;
}
/**
* Gets membershipStoragePid
*
* @return int
*/
public function getMembershipStoragePid()
{
return $this->membershipStoragePid;
}
/**
* Instantiates all configured hook objects.
......@@ -244,16 +237,6 @@ class ImportMembersTask extends \TYPO3\CMS\Extbase\Scheduler\Task
}
}
/**
* Sets membershipStoragePid
*
* @param int $membershipStoragePid
*/
public function setMembershipStoragePid($membershipStoragePid)
{
$this->membershipStoragePid = $membershipStoragePid;
}
/**
* @return \TYPO3\CMS\Core\Database\DatabaseConnection
*/
......
......@@ -39,14 +39,14 @@ class ImportMembersTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\A
$additionalFields = array();
// adds field for setting file path for CSV file to import
$fieldID = 'task_importFile';
$fieldCode = '<input type="text" class="form-control" name="tx_scheduler[importFile]" id="' . $fieldID . '" value="' . htmlspecialchars($task->importFile) . '" size="30">';
$fieldCode = '<input type="text" class="form-control" name="tx_scheduler[importFile]" id="' . $fieldID . '" value="' . $task->importFile . '" size="120">';
// adds field for setting storage PID
$additionalFields[$fieldID] = array(
'code' => $fieldCode,
'label' => 'LLL:EXT:t3o_membership/Resources/Private/Language/locallang.xlf:importFile',
);
$fieldID = 'task_storagePid';
$fieldID = 'task_membershipStoragePid';
$fieldCode = '<input type="text" class="form-control" name="tx_scheduler[membershipStoragePid]" id="' . $fieldID . '" value="' . (int)$task->membershipStoragePid . '" size="30">';
// adds field for setting storage PID
$additionalFields[$fieldID] = array(
......@@ -54,6 +54,14 @@ class ImportMembersTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\A
'label' => 'LLL:EXT:t3o_membership/Resources/Private/Language/locallang.xlf:storagePid'
);
$fieldID = 'task_dropboxToken';
$fieldCode = '<input type="text" class="form-control" name="tx_scheduler[dropboxToken]" id="' . $fieldID . '" value="' . $task->dropboxToken . '" size="120">';
// adds field for dropboxToken setting
$additionalFields[$fieldID] = array(
'code' => $fieldCode,
'label' => 'LLL:EXT:t3o_membership/Resources/Private/Language/locallang.xlf:dropboxToken'
);
return $additionalFields;
}
......@@ -82,7 +90,7 @@ class ImportMembersTaskAdditionalFieldProvider implements \TYPO3\CMS\Scheduler\A
public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task){
$task->importFile = $submittedData['importFile'];
$task->membershipStoragePid = $submittedData['membershipStoragePid'];
$task->dropboxToken = $submittedData['dropboxToken'];
}
}
t3o membership
==============
What does it do?
----------------
This extension imports our members from dropbox and displays at the
memberlisting at the Assocation page.
Import Settings
---------------
Installation:
* Set up a scheduler task of type membership import
* set up:
* storage pid: Where should the members be imported
* CSV file to import (path and filename): Full path to the location where the memeber file should be stored. The folder should be secured via .htaccess
* Dropbox Token: Token for accessing the dropbox folder
The expected location within dropbox is:
/TYPO3 Backoffice/Member-Lists/memberlist.txt
The file is endocded with: ISO-8859-15
......@@ -55,6 +55,9 @@
<trans-unit id="storagePid">
<source>Where to store the member records</source>
</trans-unit>
<trans-unit id="dropboxToken">
<source>Dropbox Token</source>
</trans-unit>
<trans-unit id="allMemberships">
<source>All memberships</source>
</trans-unit>
......
......@@ -9,7 +9,8 @@
"issues": "https://git-t3o.typo3.org/t3o/t3o_membership/issues"
},
"require": {
"typo3/cms-core": "8.5.0 - 8.9.99"
"typo3/cms-core": "8.5.0 - 8.9.99",
"lukebaird/dropbox-v2-php-sdk": "^1.1"
},
"autoload": {
"psr-4": {
......
Supports Markdown
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