Ejemplo n.º 1
0
 /**
  * fetch CjwNewsletterImport object by remoteId
  * return false if not found
  *
  * @param string $remoteId
  * @param boolean $asObject
  * @return CjwNewsletterMailboxItem or false
  */
 public static function fetchByRemoteId($remoteId, $asObject = true)
 {
     return eZPersistentObject::fetchObject(CjwNewsletterImport::definition(), null, array('remote_id' => $remoteId), $asObject);
 }
    //$siteDir =  eZSys::siteDir();
    $dir = eZSys::varDirectory() . $fileSep . 'cjw_newsletter' . $fileSep . 'csvimport';
    $importId = $importObject->attribute('id');
    $fileName = $importId . '-' . date("Ymd-His", $importObject->attribute('created')) . '-' . $binaryFile->attribute('original_filename');
    $csvFilePath = $dir . $fileSep . $fileName;
    $importObject->setAttribute('data_text', $csvFilePath);
    $importObject->setAttribute('note', $note);
    // create dir
    eZDir::mkdir($dir, false, true);
    $createResult = copy($filePathUpload, $csvFilePath);
    $importObject->store();
    // after import object is created redirect to view with import_id
    //return $module->redirectToView( 'subscription_list_csvimport', array( $nodeId, $importId ) );
} else {
    if ($importId != 0) {
        $importObject = CjwNewsletterImport::fetch($importId);
        if (!is_object($importObject)) {
            return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
        }
        // get stored csv filepath from db
        $csvFilePath = $importObject->attribute('data_text');
    }
}
// read import result
if (file_exists(getImportResultFilePath($importId))) {
    $listSubscriptionArray = getImportResultFromFile($importId);
    $csvParserObject = new CjwNewsletterCsvParser($csvFilePath, $csvDelimiter, $firstRowIsLabel, $csvFieldMappingArray, $utf8Encode);
    $csvDataArray = $csvParserObject->getCsvDataArray();
} else {
    if (file_exists($csvFilePath)) {
        $csvParserObject = new CjwNewsletterCsvParser($csvFilePath, $csvDelimiter, $firstRowIsLabel, $csvFieldMappingArray, $utf8Encode);
Ejemplo n.º 3
0
 * @filesource
 */
// Blacklist User by nl user id or by email
// update all nessesarry status fields to blacklisted
$module = $Params['Module'];
$templateFile = 'design:newsletter/import_list.tpl';
require_once 'kernel/common/i18n.php';
include_once 'kernel/common/template.php';
$http = eZHTTPTool::instance();
$tpl = templateInit();
$http = eZHTTPTool::instance();
$db = eZDB::instance();
$viewParameters = array('offset' => 0, 'namefilter' => '');
$userParameters = $Params['UserParameters'];
$viewParameters = array_merge($viewParameters, $userParameters);
$limit = 10;
$limitArray = array(10, 10, 25, 50);
$limitArrayKey = eZPreferences::value('admin_import_list_limit');
// get user limit preference
if (isset($limitArray[$limitArrayKey])) {
    $limit = $limitArray[$limitArrayKey];
}
$importList = CjwNewsletterImport::fetchAllImportItems($limit, $viewParameters['offset']);
$importListCount = CjwNewsletterImport::fetchAllImportItemsCount();
$tpl->setVariable('view_parameters', $viewParameters);
$tpl->setVariable('import_list', $importList);
$tpl->setVariable('import_list_count', $importListCount);
$tpl->setVariable('limit', $limit);
$Result = array();
$Result['content'] = $tpl->fetch($templateFile);
$Result['path'] = array(array('url' => 'newsletter/index', 'text' => ezi18n('cjw_newsletter/path', 'Newsletter')), array('url' => false, 'text' => ezi18n('cjw_newsletter/import_list', 'Imports')));