本文整理汇总了PHP中UploadFile::confirm_upload方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadFile::confirm_upload方法的具体用法?PHP UploadFile::confirm_upload怎么用?PHP UploadFile::confirm_upload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadFile
的用法示例。
在下文中一共展示了UploadFile::confirm_upload方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UploadFile
function action_save()
{
require_once 'include/upload_file.php';
$GLOBALS['log']->debug('PERFORMING NOTES SAVE');
$upload_file = new UploadFile('uploadfile');
$do_final_move = 0;
if (isset($_FILES['uploadfile']) && $upload_file->confirm_upload()) {
if (!empty($this->bean->id) && !empty($_REQUEST['old_filename'])) {
$upload_file->unlink_file($this->bean->id, $_REQUEST['old_filename']);
}
$this->bean->filename = $upload_file->get_stored_file_name();
$this->bean->file_mime_type = $upload_file->mime_type;
$do_final_move = 1;
} else {
if (isset($_REQUEST['old_filename'])) {
$this->bean->filename = $_REQUEST['old_filename'];
}
}
$check_notify = false;
if (!empty($_POST['assigned_user_id']) && (empty($this->bean->fetched_row) || $this->bean->fetched_row['assigned_user_id'] != $_POST['assigned_user_id']) && $_POST['assigned_user_id'] != $GLOBALS['current_user']->id) {
$check_notify = true;
}
$this->bean->save($check_notify);
if ($do_final_move) {
$upload_file->final_move($this->bean->id);
} else {
if (!empty($_REQUEST['old_id'])) {
$upload_file->duplicate_file($_REQUEST['old_id'], $this->bean->id, $this->bean->filename);
}
}
}
示例2: addFont
/**
* This method prepares the received data and call the addFont method of the fontManager
* @return boolean true on success
*/
private function addFont()
{
$this->log = "";
$error = false;
$files = array("pdf_metric_file", "pdf_font_file");
foreach ($files as $k) {
// handle uploaded file
$uploadFile = new UploadFile($k);
if (isset($_FILES[$k]) && $uploadFile->confirm_upload()) {
$uploadFile->final_move(basename($_FILES[$k]['name']));
$uploadFileNames[$k] = $uploadFile->get_upload_path(basename($_FILES[$k]['name']));
} else {
$this->log = translate('ERR_PDF_NO_UPLOAD', "Configurator");
$error = true;
}
}
if (!$error) {
require_once 'include/Sugarpdf/FontManager.php';
$fontManager = new FontManager();
$error = $fontManager->addFont($uploadFileNames["pdf_font_file"], $uploadFileNames["pdf_metric_file"], $_REQUEST['pdf_embedded'], $_REQUEST['pdf_encoding_table'], array(), htmlspecialchars_decode($_REQUEST['pdf_cidinfo'], ENT_QUOTES), $_REQUEST['pdf_style_list']);
$this->log .= $fontManager->log;
if ($error) {
$this->log .= implode("\n", $fontManager->errors);
}
}
return $error;
}
示例3: UploadFile
function action_save()
{
require_once 'include/upload_file.php';
$GLOBALS['log']->debug('PERFORMING NOTES SAVE');
$upload_file = new UploadFile('uploadfile');
$do_final_move = 0;
if (isset($_FILES['uploadfile']) && $upload_file->confirm_upload()) {
if (!empty($this->bean->id) && !empty($_REQUEST['old_filename'])) {
$upload_file->unlink_file($this->bean->id, $_REQUEST['old_filename']);
}
$this->bean->filename = $upload_file->get_stored_file_name();
$this->bean->file_mime_type = $upload_file->mime_type;
$do_final_move = 1;
} else {
if (isset($_REQUEST['old_filename'])) {
$this->bean->filename = $_REQUEST['old_filename'];
}
}
$this->bean->save();
if ($do_final_move) {
$upload_file->final_move($this->bean->id);
} else {
if (!empty($_REQUEST['old_id'])) {
$upload_file->duplicate_file($_REQUEST['old_id'], $this->bean->id, $this->bean->filename);
}
}
}
示例4: pre_save
public function pre_save()
{
require_once 'include/upload_file.php';
$upload_file = new UploadFile('filename_file');
if (isset($_FILES['filename_file']) && $upload_file->confirm_upload()) {
$filename = $upload_file->get_stored_file_name();
$file_ext = $upload_file->file_ext;
if (empty($this->bean->id)) {
$this->bean->id = create_guid();
$this->bean->new_with_id = true;
}
$account = null;
if (isset($_POST['xphotobucketaccount_id'])) {
$account = BeanFactory::getBean('xPhotobucketAccounts', $_POST['xphotobucketaccount_id']);
}
// $resp = $account->upload_media('image', $upload_file->temp_file_location, "{$this->bean->id}.{$file_ext}", $_POST['name']);
$resp = $account->upload_media('base64', base64_encode(file_get_contents($upload_file->temp_file_location)), "{$this->bean->id}.{$file_ext}", $_POST['name']);
$this->bean->browse_url = $resp['browseurl'];
$this->bean->image_url = $resp['url'];
$this->bean->thumb_url = $resp['thumb'];
} else {
echo "Upload file error";
sugar_cleanup(true);
}
parent::pre_save();
}
示例5: save
public function save(&$bean, $params, $field, $vardef, $prefix = '')
{
$fakeDisplayParams = array();
$this->fillInOptions($vardef, $fakeDisplayParams);
require_once 'include/upload_file.php';
$upload_file = new UploadFile($prefix . $field . '_file');
//remove file
if (isset($_REQUEST['remove_file_' . $field]) && $params['remove_file_' . $field] == 1) {
$upload_file->unlink_file($bean->{$field});
$bean->{$field} = "";
}
$move = false;
if (isset($_FILES[$prefix . $field . '_file']) && $upload_file->confirm_upload()) {
if ($this->verify_image($upload_file)) {
$bean->{$field} = $upload_file->get_stored_file_name();
$move = true;
} else {
//not valid image.
$GLOBALS['log']->fatal("Image Field : Not a Valid Image.");
$temp = $vardef['vname'];
$temp = translate($temp, $bean->module_name);
SugarApplication::appendErrorMessage($temp . " Field : Not a valid image format.");
}
}
if (empty($bean->id)) {
$bean->id = create_guid();
$bean->new_with_id = true;
}
if ($move) {
$upload_file->final_move($bean->id . '_' . $field);
//BEAN ID IS THE FILE NAME IN THE INSTANCE.
$upload_file->upload_doc($bean, $bean->id, $params[$prefix . $vardef['docType']], $bean->{$field}, $upload_file->mime_type);
} else {
if (!empty($old_id)) {
// It's a duplicate, I think
if (empty($params[$prefix . $vardef['docUrl']])) {
$upload_file->duplicate_file($old_id, $bean->id, $bean->{$field});
} else {
$docType = $vardef['docType'];
$bean->{$docType} = $params[$prefix . $field . '_old_doctype'];
}
} else {
if (!empty($params[$prefix . $field . '_remoteName'])) {
// We aren't moving, we might need to do some remote linking
$displayParams = array();
$this->fillInOptions($vardef, $displayParams);
if (isset($params[$prefix . $vardef['docId']]) && !empty($params[$prefix . $vardef['docId']]) && isset($params[$prefix . $vardef['docType']]) && !empty($params[$prefix . $vardef['docType']])) {
$bean->{$field} = $params[$prefix . $field . '_remoteName'];
require_once 'include/utils/file_utils.php';
$extension = get_file_extension($bean->{$field});
if (!empty($extension)) {
$bean->file_ext = $extension;
$bean->file_mime_type = get_mime_content_type_from_filename($bean->{$field});
}
}
}
}
}
}
示例6: save
function save($check_notify = false)
{
$move = false;
$upload_file = new UploadFile('uploadfile');
if (isset($_FILES['uploadfile']) && $upload_file->confirm_upload()) {
$this->filename = $upload_file->get_stored_file_name();
$this->file_mime_type = $upload_file->mime_type;
$this->file_ext = $upload_file->file_ext;
$move = true;
}
parent::save($check_notify);
if ($move) {
$upload_file->final_move($this->id);
}
return $this->id;
//handleRedirect($return_id, $this->object_name);
}
示例7: File
function action_save()
{
$move = false;
$file = new File();
$file = populateFromPost('', $file);
$upload_file = new UploadFile('uploadfile');
$return_id = '';
if (isset($_FILES['uploadfile']) && $upload_file->confirm_upload()) {
$file->filename = $upload_file->get_stored_file_name();
$file->file_mime_type = $upload_file->mime_type;
$file->file_ext = $upload_file->file_ext;
$move = true;
}
$return_id = $file->save();
if ($move) {
$upload_file->final_move($file->id);
}
handleRedirect($return_id, $this->object_name);
}
示例8: UploadFile
function action_save()
{
require_once 'include/upload_file.php';
// CCL - Bugs 41103 and 43751. 41103 address the issue where the parent_id is set, but
// the relate_id field overrides the relationship. 43751 fixes the problem where the relate_id and
// parent_id are the same value (in which case it should just use relate_id) by adding the != check
if (!empty($_REQUEST['relate_id']) && !empty($_REQUEST['parent_id']) && $_REQUEST['relate_id'] != $_REQUEST['parent_id']) {
$_REQUEST['relate_id'] = false;
}
$GLOBALS['log']->debug('PERFORMING NOTES SAVE');
$upload_file = new UploadFile('uploadfile');
$do_final_move = 0;
if (isset($_FILES['uploadfile']) && $upload_file->confirm_upload()) {
if (!empty($this->bean->id) && !empty($_REQUEST['old_filename'])) {
$upload_file->unlink_file($this->bean->id, $_REQUEST['old_filename']);
}
$this->bean->filename = $upload_file->get_stored_file_name();
$this->bean->file_mime_type = $upload_file->mime_type;
$do_final_move = 1;
} else {
if (isset($_REQUEST['old_filename'])) {
$this->bean->filename = $_REQUEST['old_filename'];
}
}
$check_notify = false;
if (!empty($_POST['assigned_user_id']) && (empty($this->bean->fetched_row) || $this->bean->fetched_row['assigned_user_id'] != $_POST['assigned_user_id']) && $_POST['assigned_user_id'] != $GLOBALS['current_user']->id) {
$check_notify = true;
}
$this->bean->save($check_notify);
if ($do_final_move) {
$upload_file->final_move($this->bean->id);
} else {
if (!empty($_REQUEST['old_id'])) {
$upload_file->duplicate_file($_REQUEST['old_id'], $this->bean->id, $this->bean->filename);
}
}
}
示例9: save
public function save(&$bean, $params, $field, $properties, $prefix = '')
{
require_once 'include/upload_file.php';
$upload_file = new UploadFile($prefix . $field);
//remove file
if (isset($_REQUEST['remove_file_' . $field]) && $_REQUEST['remove_file_' . $field] == 1) {
$upload_file->unlink_file($bean->{$field});
$bean->{$field} = "";
}
$move = false;
if (isset($_FILES[$prefix . $field]) && $upload_file->confirm_upload()) {
$bean->{$field} = $upload_file->get_stored_file_name();
$bean->file_mime_type = $upload_file->mime_type;
$bean->file_ext = $upload_file->file_ext;
$move = true;
}
if ($move) {
if (empty($bean->id)) {
$bean->id = create_guid();
$bean->new_with_id = true;
}
$upload_file->final_move($bean->id);
}
}
示例10: display
/**
* @see SugarView::display()
*/
public function display()
{
global $mod_strings, $app_strings, $current_user;
global $sugar_config, $locale;
$this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
$this->ss->assign("TYPE", !empty($_REQUEST['type']) ? $_REQUEST['type'] : "import");
$this->ss->assign("SOURCE_ID", $_REQUEST['source_id']);
$this->instruction = 'LBL_SELECT_PROPERTY_INSTRUCTION';
$this->ss->assign('INSTRUCTION', $this->getInstruction());
$this->ss->assign("MODULE_TITLE", $this->getModuleTitle(false), ENT_NOQUOTES);
$this->ss->assign("CURRENT_STEP", $this->currentStep);
$sugar_config['import_max_records_per_file'] = empty($sugar_config['import_max_records_per_file']) ? 1000 : $sugar_config['import_max_records_per_file'];
$importSource = isset($_REQUEST['source']) ? $_REQUEST['source'] : 'csv';
// Clear out this user's last import
$seedUsersLastImport = BeanFactory::getBean('Import_2');
$seedUsersLastImport->mark_deleted_by_user_id($current_user->id);
ImportCacheFiles::clearCacheFiles();
// handle uploaded file
$uploadFile = new UploadFile('userfile');
if (isset($_FILES['userfile']) && $uploadFile->confirm_upload()) {
$uploadFile->final_move('IMPORT_' . $this->bean->object_name . '_' . $current_user->id);
$uploadFileName = $uploadFile->get_upload_path('IMPORT_' . $this->bean->object_name . '_' . $current_user->id);
} elseif (!empty($_REQUEST['tmp_file'])) {
$uploadFileName = "upload://" . basename($_REQUEST['tmp_file']);
} else {
$this->_showImportError($mod_strings['LBL_IMPORT_MODULE_ERROR_NO_UPLOAD'], $_REQUEST['import_module'], 'Step2', true, null, true);
return;
}
//check the file size, we dont want to process an empty file
if (isset($_FILES['userfile']['size']) && $_FILES['userfile']['size'] == 0) {
//this file is empty, throw error message
$this->_showImportError($mod_strings['LBL_NO_LINES'], $_REQUEST['import_module'], 'Step2', false, null, true);
return;
}
$mimeTypeOk = true;
//check to see if the file mime type is not a form of text or application octed streramand fire error if not
if (isset($_FILES['userfile']['type']) && strpos($_FILES['userfile']['type'], 'octet-stream') === false && strpos($_FILES['userfile']['type'], 'text') === false && strpos($_FILES['userfile']['type'], 'application/vnd.ms-excel') === false) {
//this file does not have a known text or application type of mime type, issue the warning
$error_msgs[] = $mod_strings['LBL_MIME_TYPE_ERROR_1'];
$error_msgs[] = $mod_strings['LBL_MIME_TYPE_ERROR_2'];
$this->_showImportError($error_msgs, $_REQUEST['import_module'], 'Step2', true, $mod_strings['LBL_OK']);
$mimeTypeOk = false;
}
$this->ss->assign("FILE_NAME", $uploadFileName);
// Now parse the file and look for errors
$importFile = new ImportFile($uploadFileName, $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES), FALSE);
if ($this->shouldAutoDetectProperties($importSource)) {
$GLOBALS['log']->debug("Auto detecing csv properties...");
$autoDetectOk = $importFile->autoDetectCSVProperties();
$importFileMap = array();
$this->ss->assign("SOURCE", 'csv');
if ($autoDetectOk === FALSE) {
//show error only if previous mime type check has passed
if ($mimeTypeOk) {
$this->ss->assign("AUTO_DETECT_ERROR", $mod_strings['LBL_AUTO_DETECT_ERROR']);
}
} else {
$dateFormat = $importFile->getDateFormat();
$timeFormat = $importFile->getTimeFormat();
if ($dateFormat) {
$importFileMap['importlocale_dateformat'] = $dateFormat;
}
if ($timeFormat) {
$importFileMap['importlocale_timeformat'] = $timeFormat;
}
}
} else {
$impotMapSeed = $this->getImportMap($importSource);
$importFile->setImportFileMap($impotMapSeed);
$importFileMap = $impotMapSeed->getMapping($_REQUEST['import_module']);
}
$delimeter = $importFile->getFieldDelimeter();
$enclosure = $importFile->getFieldEnclosure();
$hasHeader = $importFile->hasHeaderRow();
$encodeOutput = TRUE;
//Handle users navigating back through the wizard.
if (!empty($_REQUEST['previous_action']) && $_REQUEST['previous_action'] == 'Confirm') {
$encodeOutput = FALSE;
$importFileMap = $this->overloadImportFileMapFromRequest($importFileMap);
$delimeter = !empty($_REQUEST['custom_delimiter']) ? $_REQUEST['custom_delimiter'] : $delimeter;
$enclosure = isset($_REQUEST['custom_enclosure']) ? $_REQUEST['custom_enclosure'] : $enclosure;
$enclosure = html_entity_decode($enclosure, ENT_QUOTES);
$hasHeader = !empty($_REQUEST['has_header']) ? $_REQUEST['has_header'] : $hasHeader;
if ($hasHeader == 'on') {
$hasHeader = true;
} else {
if ($hasHeader == 'off') {
$hasHeader = false;
}
}
}
$this->ss->assign("IMPORT_ENCLOSURE_OPTIONS", $this->getEnclosureOptions($enclosure));
$this->ss->assign("IMPORT_DELIMETER_OPTIONS", $this->getDelimeterOptions($delimeter));
$this->ss->assign("CUSTOM_DELIMITER", $delimeter);
$this->ss->assign("CUSTOM_ENCLOSURE", htmlentities($enclosure, ENT_QUOTES, 'utf-8'));
$hasHeaderFlag = $hasHeader ? " CHECKED" : "";
$this->ss->assign("HAS_HEADER_CHECKED", $hasHeaderFlag);
//.........这里部分代码省略.........
示例11: saveUpdate
public function saveUpdate($bean, $event, $arguments)
{
if (!isAOPEnabled()) {
return;
}
global $current_user, $app_list_strings;
if (empty($bean->fetched_row) || !$bean->id) {
if (!$bean->state) {
$bean->state = $app_list_strings['case_state_default_key'];
}
if ($bean->status == "New") {
$bean->status = $app_list_strings['case_status_default_key'];
}
//New case - assign
if (!$bean->assigned_user_id) {
$userId = $this->getAssignToUser();
$bean->assigned_user_id = $userId;
$bean->notify_inworkflow = true;
}
return;
}
if ($_REQUEST['module'] == 'Import') {
return;
}
//Grab the update field and create a new update with it.
$text = $bean->update_text;
if (!$text && empty($_FILES['case_update_file'])) {
//No text or files, so nothing really to save.
return;
}
$bean->update_text = "";
$case_update = new AOP_Case_Updates();
$case_update->name = $text;
$case_update->internal = $bean->internal;
$bean->internal = false;
$case_update->assigned_user_id = $current_user->id;
if (strlen($text) > $this->slug_size) {
$case_update->name = substr($text, 0, $this->slug_size) . "...";
}
$case_update->description = nl2br($text);
$case_update->case_id = $bean->id;
$case_update->save();
$fileCount = $this->arrangeFilesArray();
for ($x = 0; $x < $fileCount; $x++) {
if ($_FILES['case_update_file']['error'][$x] == UPLOAD_ERR_NO_FILE) {
continue;
}
$uploadFile = new UploadFile('case_update_file' . $x);
if (!$uploadFile->confirm_upload()) {
continue;
}
$note = $this->newNote($case_update->id);
$note->name = $uploadFile->get_stored_file_name();
$note->file_mime_type = $uploadFile->mime_type;
$note->filename = $uploadFile->get_stored_file_name();
$note->save();
$uploadFile->final_move($note->id);
}
$postPrefix = 'case_update_id_';
foreach ($_POST as $key => $val) {
if (strpos($key, $postPrefix) !== 0 || empty($val)) {
continue;
}
//Val is selected doc id
$doc = BeanFactory::getBean('Documents', $val);
if (!$doc) {
continue;
}
$note = $this->newNote($case_update->id);
$note->name = $doc->document_name;
$note->file_mime_type = $doc->last_rev_mime_type;
$note->filename = $doc->filename;
$note->save();
$srcFile = "upload://{$doc->document_revision_id}";
$destFile = "upload://{$note->id}";
copy($srcFile, $destFile);
}
}
示例12: save
public function save(&$bean, $params, $field, $properties, $prefix = '')
{
require_once 'include/upload_file.php';
$upload_file = new UploadFile($field);
//remove file
if (isset($_REQUEST['remove_imagefile_' . $field]) && $_REQUEST['remove_imagefile_' . $field] == 1) {
$upload_file->unlink_file($bean->{$field});
$bean->{$field} = "";
}
//uploadfile
if (isset($_FILES[$field])) {
//confirm only image file type can be uploaded
if (verify_image_file($_FILES[$field]['tmp_name'])) {
if ($upload_file->confirm_upload()) {
// for saveTempImage API
if (isset($params['temp']) && $params['temp'] === true) {
// Create the new field value
$bean->{$field} = create_guid();
// Move to temporary folder
if (!$upload_file->final_move($bean->{$field}, true)) {
// If this was a fail, reset the bean field to original
$this->error = $upload_file->getErrorMessage();
}
} else {
// Capture the old value in case of error
$oldvalue = $bean->{$field};
// Create the new field value
$bean->{$field} = create_guid();
// Add checking for actual file move for reporting to consumers
if (!$upload_file->final_move($bean->{$field})) {
// If this was a fail, reset the bean field to original
$bean->{$field} = $oldvalue;
$this->error = $upload_file->getErrorMessage();
}
}
} else {
// Added error reporting
$this->error = $upload_file->getErrorMessage();
}
} else {
$imgInfo = getimagesize($_FILES[$field]['tmp_name']);
// if file is image then this image is no longer supported.
if (false !== $imgInfo) {
$ext = end(explode('.', $_FILES[$field]['name']));
$this->error = string_format($GLOBALS['app_strings']['LBL_UPLOAD_IMAGE_FILE_NOT_SUPPORTED'], array($ext));
} else {
$this->error = $GLOBALS['app_strings']["LBL_UPLOAD_IMAGE_FILE_INVALID"];
}
}
}
//Check if we have the duplicate value set and use it if $bean->$field is empty
if (empty($bean->{$field}) && !empty($_REQUEST[$field . '_duplicate'])) {
$bean->{$field} = $_REQUEST[$field . '_duplicate'];
}
// case when we should copy one file to another using merge-duplicate view
// $params[$field . '_duplicateBeanId'] contains id of bean from
// which we should copy file.
if (!empty($params[$field]) && !empty($params[$field . '_duplicateBeanId'])) {
$bean->{$field} = create_guid();
$upload_file->duplicate_file($params[$field], $bean->{$field});
}
}
示例13: PackageManager
require_once 'ModuleInstall/PackageManager.php';
$pm = new PackageManager();
$tempFile = $pm->download('', '', $_REQUEST['release_id']);
$perform = true;
$base_filename = urldecode($tempFile);
} elseif (!empty($_REQUEST['load_module_from_dir'])) {
//copy file to proper location then call performSetup
copy($_REQUEST['load_module_from_dir'] . '/' . $_REQUEST['upgrade_zip_escaped'], "upload://" . $_REQUEST['upgrade_zip_escaped']);
$perform = true;
$base_filename = urldecode($_REQUEST['upgrade_zip_escaped']);
} else {
if (empty($_FILES['upgrade_zip']['tmp_name'])) {
echo $mod_strings['ERR_UW_NO_UPLOAD_FILE'];
} else {
$upload = new UploadFile('upgrade_zip');
if (!$upload->confirm_upload() || strtolower(pathinfo($upload->get_stored_file_name(), PATHINFO_EXTENSION)) != 'zip' || !$upload->final_move($upload->get_stored_file_name())) {
unlinkTempFiles();
sugar_die("Invalid Package");
} else {
$tempFile = "upload://" . $upload->get_stored_file_name();
$perform = true;
$base_filename = urldecode($_REQUEST['upgrade_zip_escaped']);
}
}
}
if ($perform) {
$manifest_file = extractManifest($tempFile);
if (is_file($manifest_file)) {
//SCAN THE MANIFEST FILE TO MAKE SURE NO COPIES OR ANYTHING ARE HAPPENING IN IT
$ms = new ModuleScanner();
$fileIssues = $ms->scanFile($manifest_file);
示例14: UploadFile
$success = TRUE;
if (isset($_FILES['reportfile']) && $upload_file->confirm_upload()) {
$success = $template->set_reportfile($_FILES['reportfile']['tmp_name'], $upload_file->original_file_name);
if (!$success) {
$errors[] = "error compiling report " . $upload_file->original_file_name . " - " . $template->report_output;
}
}
for ($i = 0; $i < 5; $i++) {
$paramName = "subreport" . $i;
$upload_file = new UploadFile($paramName);
if (isset($_FILES[$paramName]) && $upload_file->confirm_upload()) {
$success = $template->add_subreportfile($_FILES[$paramName]['tmp_name'], $upload_file->original_file_name);
if (!$success) {
$errors[] = "error compiling subreport " . $upload_file->original_file_name . " - " . $template->report_output;
}
}
}
for ($i = 0; $i < 5; $i++) {
$paramName = "resource" . $i;
$upload_file = new UploadFile($paramName);
if (isset($_FILES[$paramName]) && $upload_file->confirm_upload()) {
$template->add_resource_file($_FILES[$paramName]['tmp_name'], $upload_file->original_file_name);
}
}
if (empty($errors)) {
$return_id = $template->save();
handleRedirect("", "");
} else {
$_REQUEST["ZR_ERROR_MSG"] = join("<br/>", $errors);
include "modules/ZuckerReportTemplate/EditView.php";
}
示例15: handleSave
function handleSave($prefix, $redirect = true, $useRequired = false)
{
require_once 'include/formbase.php';
require_once 'include/upload_file.php';
global $upload_maxsize, $upload_dir;
global $mod_strings;
global $sugar_config;
$focus = new EmailTemplate();
if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
return null;
}
$focus = populateFromPost($prefix, $focus);
//process the text only flag
if (isset($_POST['text_only']) && $_POST['text_only'] == '1') {
$focus->text_only = 1;
} else {
$focus->text_only = 0;
}
if (!$focus->ACLAccess('Save')) {
ACLController::displayNoAccess(true);
sugar_cleanup(true);
}
if (!isset($_REQUEST['published'])) {
$focus->published = 'off';
}
$emailTemplateBodyHtml = from_html($focus->body_html);
$fileBasePath = "{$sugar_config['cache_dir']}images/";
$filePatternSearch = "{$sugar_config['cache_dir']}";
$filePatternSearch = str_replace("/", "\\/", $filePatternSearch);
$filePatternSearch = $filePatternSearch . "images\\/";
$fileBasePath1 = "\"" . $fileBasePath;
if (strpos($emailTemplateBodyHtml, "\"{$fileBasePath}")) {
$matches = array();
preg_match_all("/{$filePatternSearch}.+?\"/i", $emailTemplateBodyHtml, $matches);
foreach ($matches[0] as $match) {
$filenameUndecoded = str_replace($fileBasePath, '', $match);
$filename = urldecode(substr($filenameUndecoded, 0, -1));
$filenameUndecoded = str_replace("\"", '', $filenameUndecoded);
$cid = $filename;
$file_location = clean_path(getcwd() . "/{$sugar_config['cache_dir']}images/{$filename}");
$mime_type = strtolower(substr($filename, strrpos($filename, ".") + 1, strlen($filename)));
if (file_exists($file_location)) {
$id = create_guid();
$newFileLocation = "{$sugar_config['upload_dir']}{$id}.{$mime_type}";
if (!copy($file_location, $newFileLocation)) {
$GLOBALS['log']->debug("EMAIL Template could not copy attachment to {$sugar_config['upload_dir']} [ {$newFileLocation} ]");
} else {
$emailTemplateBodyHtml = str_replace("{$sugar_config['cache_dir']}images/{$filenameUndecoded}", $newFileLocation, $emailTemplateBodyHtml);
unlink($file_location);
}
}
// if
}
// foreach
}
// if
$focus->body_html = $emailTemplateBodyHtml;
$return_id = $focus->save();
///////////////////////////////////////////////////////////////////////////////
//// ATTACHMENT HANDLING
///////////////////////////////////////////////////////////////////////////
//// ADDING NEW ATTACHMENTS
$max_files_upload = count($_FILES);
if (!empty($focus->id)) {
$note = new Note();
$where = "notes.parent_id='{$focus->id}'";
if (!empty($_REQUEST['old_id'])) {
// to support duplication of email templates
$where .= " OR notes.parent_id='" . $_REQUEST['old_id'] . "'";
}
$notes_list = $note->get_full_list("", $where, true);
}
if (!isset($notes_list)) {
$notes_list = array();
}
if (!is_array($focus->attachments)) {
// PHP5 does not auto-create arrays(). Need to initialize it here.
$focus->attachments = array();
}
$focus->attachments = array_merge($focus->attachments, $notes_list);
//for($i = 0; $i < $max_files_upload; $i++) {
foreach ($_FILES as $key => $file) {
$note = new Note();
$i = preg_replace("/email_attachment(.+)/", '$1', $key);
$upload_file = new UploadFile($key);
if ($upload_file == -1) {
continue;
}
if (isset($_FILES[$key]) && $upload_file->confirm_upload() && preg_match("/^email_attachment/", $key)) {
$note->filename = $upload_file->get_stored_file_name();
$note->file = $upload_file;
$note->name = $mod_strings['LBL_EMAIL_ATTACHMENT'] . ': ' . $note->file->original_file_name;
if (isset($_REQUEST['embedded' . $i]) && !empty($_REQUEST['embedded' . $i])) {
if ($_REQUEST['embedded' . $i] == 'true') {
$note->embed_flag = true;
} else {
$note->embed_flag = false;
}
}
array_push($focus->attachments, $note);
//.........这里部分代码省略.........