add domain-bulk-import, fixes #1452
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -1881,5 +1881,60 @@ if ($page == 'domains'
|
||||
eval("echo \"" . getTemplate("domains/domains_edit") . "\";");
|
||||
}
|
||||
}
|
||||
} elseif($action == 'import') {
|
||||
|
||||
if (isset($_POST['send'])
|
||||
&& $_POST['send'] == 'send'
|
||||
) {
|
||||
|
||||
$customerid = intval($_POST['customerid']);
|
||||
$separator = validate($_POST['separator'], 'separator');
|
||||
$offset = intval($_POST['offset']);
|
||||
|
||||
$file_name = $_FILES['file']['tmp_name'];
|
||||
|
||||
$result = array();
|
||||
|
||||
try {
|
||||
$bulk = new DomainBulkAction($file_name, $customerid);
|
||||
$result = $bulk->doImport($separator, $offset);
|
||||
} catch (Exception $e) {
|
||||
standard_error('domain_import_error', $e->getMessage());
|
||||
}
|
||||
|
||||
// @FIXME find a way to display $result['notice'] here somehow,
|
||||
// as it might be important if you've reached your maximum allocation of domains
|
||||
|
||||
// update customer/admin counters
|
||||
updateCounters(false);
|
||||
|
||||
$result_str = $result['imported'] . ' / ' . $result['all'];
|
||||
standard_success('domain_import_successfully', $result_str, array('filename' => $filename, 'action' => '', 'page' => 'domains'));
|
||||
} else {
|
||||
$customers = makeoption($lng['panel']['please_choose'], 0, 0, true);
|
||||
$result_customers_stmt = Database::prepare("
|
||||
SELECT `customerid`, `loginname`, `name`, `firstname`, `company`
|
||||
FROM `" . TABLE_PANEL_CUSTOMERS . "` " .
|
||||
($userinfo['customers_see_all'] ? '' : " WHERE `adminid` = '" . (int)$userinfo['adminid'] . "' ") .
|
||||
" ORDER BY `name` ASC"
|
||||
);
|
||||
$params = array();
|
||||
if ($userinfo['customers_see_all'] == '0') {
|
||||
$params['adminid'] = $userinfo['adminid'];
|
||||
}
|
||||
Database::pexecute($result_customers_stmt, $params);
|
||||
|
||||
while ($row_customer = $result_customers_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$customers.= makeoption(getCorrectFullUserDetails($row_customer) . ' (' . $row_customer['loginname'] . ')', $row_customer['customerid']);
|
||||
}
|
||||
|
||||
$domain_import_data = include_once dirname(__FILE__).'/lib/formfields/admin/domains/formfield.domains_import.php';
|
||||
$domain_import_form = htmlform::genHTMLForm($domain_import_data);
|
||||
|
||||
$title = $domain_import_data['domain_import']['title'];
|
||||
$image = $domain_import_data['domain_import']['image'];
|
||||
|
||||
eval("echo \"" . getTemplate("domains/domains_import") . "\";");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user