Example #1
0
    $importlabeloutput .= "<strong><font color='red'>" . $clang->gT("Error") . "</font></strong><br />\n";
    $importlabeloutput .= sprintf($clang->gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."), $tempdir) . "<br /><br />\n";
    $importlabeloutput .= "<input type='submit' value='" . $clang->gT("Main Admin Screen") . "' onclick=\"window.open('{$scriptname}', '_self')\"><br /><br />\n";
    return;
}
$importlabeloutput .= "<div class='messagebox ui-corner-all'><div class='successheader'>" . $clang->gT("Success") . "</div><br />\n";
$importlabeloutput .= $clang->gT("File upload succeeded.") . "<br /><br />\n";
$importlabeloutput .= $clang->gT("Reading file..") . "<br /><br />\n";
$options['checkforduplicates'] = 'off';
if (isset($_POST['checkforduplicates'])) {
    $options['checkforduplicates'] = $_POST['checkforduplicates'];
}
if (strtolower($sExtension) == 'csv') {
    $aImportResults = CSVImportLabelset($sFullFilepath, $options);
} elseif (strtolower($sExtension) == 'lsl') {
    $aImportResults = XMLImportLabelsets($sFullFilepath, $options);
} else {
    $importlabeloutput .= "<br />\n<div class='warningheader'>" . $clang->gT("Error") . "</div><br />\n";
    $importlabeloutput .= "<strong><u>" . $clang->gT("Label set import summary") . "</u></strong><br />\n";
    $importlabeloutput .= $clang->gT("Uploaded label set file needs to have an .lsl extension.") . "<br /><br />\n";
    $importlabeloutput .= "<input type='submit' value='" . $clang->gT("Return to label set administration") . "' onclick=\"window.open('{$scriptname}?action=labels', '_self')\" />\n";
    $importlabeloutput .= "</div><br />\n";
}
unlink($sFullFilepath);
if (isset($aImportResults)) {
    if (isset($aImportResults['fatalerror'])) {
        $importlabeloutput .= "<br />\n<div class='warningheader'>" . $clang->gT("Error") . "</div>\n        <p>{$aImportResults['fatalerror']}<br>";
    } else {
        if (count($aImportResults['warnings']) > 0) {
            $importlabeloutput .= "<br />\n<div class='warningheader'>" . $clang->gT("Warnings") . "</div><ul>\n";
            foreach ($aImportResults['warnings'] as $warning) {
Example #2
0
 /**
  * Function to import a label set
  *
  * @access public
  * @return void
  */
 public function import()
 {
     $action = returnGlobal('action');
     $aViewUrls = array();
     if ($action == 'importlabels') {
         Yii::app()->loadHelper('admin/import');
         $sFullFilepath = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . randomChars(20);
         $aPathInfo = pathinfo($_FILES['the_file']['name']);
         $sExtension = !empty($aPathInfo['extension']) ? $aPathInfo['extension'] : '';
         if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $sFullFilepath)) {
             $this->getController()->error(sprintf(gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."), Yii::app()->getConfig('tempdir')));
         }
         $options['checkforduplicates'] = 'off';
         if (isset($_POST['checkforduplicates'])) {
             $options['checkforduplicates'] = $_POST['checkforduplicates'];
         }
         if (strtolower($sExtension) == 'lsl') {
             $aImportResults = XMLImportLabelsets($sFullFilepath, $options);
         } else {
             $this->getController()->error(gT("Uploaded label set file needs to have an .lsl extension."));
         }
         unlink($sFullFilepath);
         $aViewUrls['import_view'][] = array('aImportResults' => $aImportResults);
     }
     $this->_renderWrappedTemplate('labels', $aViewUrls);
 }
Example #3
0
 /**
  * Function to import a label set
  *
  * @access public
  * @return void
  */
 public function import()
 {
     if (!Permission::model()->hasGlobalPermission('labelsets', 'import')) {
         Yii::app()->session['flashmessage'] = gT('Access denied!');
         $this->getController()->redirect(App()->createUrl("/admin"));
     }
     $action = returnGlobal('action');
     $aViewUrls = array();
     if ($action == 'importlabels') {
         Yii::app()->loadHelper('admin/import');
         $sFullFilepath = Yii::app()->getConfig('tempdir') . DIRECTORY_SEPARATOR . randomChars(20);
         $aPathInfo = pathinfo($_FILES['the_file']['name']);
         $sExtension = !empty($aPathInfo['extension']) ? $aPathInfo['extension'] : '';
         if ($_FILES['the_file']['error'] == 1 || $_FILES['the_file']['error'] == 2) {
             Yii::app()->setFlashMessage(sprintf(gT("Sorry, this file is too large. Only files up to %01.2f MB are allowed."), getMaximumFileUploadSize() / 1024 / 1024), 'error');
             $this->getController()->redirect(App()->createUrl("/admin/labels/sa/newlabelset"));
         }
         if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $sFullFilepath)) {
             Yii::app()->setFlashMessage(gT("An error occurred uploading your file. This may be caused by incorrect permissions for the application /tmp folder."), 'error');
             $this->getController()->redirect(App()->createUrl("/admin/labels/sa/newlabelset"));
         }
         $options['checkforduplicates'] = 'off';
         if ($_POST['checkforduplicates'] == 1) {
             $options['checkforduplicates'] = 'on';
         }
         if (strtolower($sExtension) == 'lsl') {
             $aImportResults = XMLImportLabelsets($sFullFilepath, $options);
         } else {
             $this->getController()->error(gT("Uploaded label set file needs to have an .lsl extension."));
         }
         unlink($sFullFilepath);
         $aViewUrls['import_view'][] = array('aImportResults' => $aImportResults);
     }
     $this->_renderWrappedTemplate('labels', $aViewUrls);
 }