当前位置: 首页>>代码示例>>PHP>>正文


PHP UploadFile::get_stored_file_name方法代码示例

本文整理汇总了PHP中UploadFile::get_stored_file_name方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadFile::get_stored_file_name方法的具体用法?PHP UploadFile::get_stored_file_name怎么用?PHP UploadFile::get_stored_file_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UploadFile的用法示例。


在下文中一共展示了UploadFile::get_stored_file_name方法的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'];
         }
     }
     $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);
         }
     }
 }
开发者ID:klr2003,项目名称:sourceread,代码行数:27,代码来源:controller.php

示例2: 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);
         }
     }
 }
开发者ID:aldridged,项目名称:gtg-sugar,代码行数:31,代码来源:controller.php

示例3: 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();
 }
开发者ID:sunmo,项目名称:snowlotus,代码行数:26,代码来源:controller.php

示例4: 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);
 }
开发者ID:klr2003,项目名称:sourceread,代码行数:17,代码来源:File.php

示例5: 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);
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:19,代码来源:controller.php

示例6: 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);
         }
     }
 }
开发者ID:omusico,项目名称:sugar_work,代码行数:37,代码来源:controller.php

示例7: 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);
     }
 }
开发者ID:aldridged,项目名称:gtg-sugar,代码行数:24,代码来源:SugarFieldFile.php

示例8: handleSave

 function handleSave($prefix, $redirect = true, $useRequired = false)
 {
     require_once 'modules/ClientOrders/Clientorder.php';
     require_once 'log4php/LoggerManager.php';
     require_once 'include/formbase.php';
     require_once 'include/TimeDate.php';
     require_once 'include/upload_file.php';
     require_once 'config.php';
     global $sugar_config;
     $timedate = new TimeDate();
     $focus = new Clientorder();
     if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
         return null;
     }
     $focus = populateFromPost($prefix, $focus);
     if (!ACLController::checkAccess($focus->module_dir, 'edit', $focus->isOwner($current_user->id))) {
         ACLController::displayNoAccess(true);
     }
     $upload_file = new UploadFile('uploadfile');
     if (isset($_FILES['uploadfile']) && $upload_file->confirm_upload()) {
         $focus->stored_file_name = $upload_file->get_stored_file_name();
         $focus->imagename = $upload_file->get_stored_file_name();
         $focus->imagepath = $sugar_config['upload_dir'] . $return_id . $upload_file->get_stored_file_name();
         $do_final_move = 1;
     }
     if (isset($_REQUEST['is_active']) && $_REQUEST['is_active'] == "1") {
         $focus->is_active = 1;
     } else {
         $focus->is_active = 0;
     }
     if (!$focus->ACLAccess('Save')) {
         ACLController::displayNoAccess(true);
         sugar_cleanup(true);
     }
     //Goodwill
     if (empty($_POST['record']) && empty($_POST['dup_checked'])) {
         $duplicateClientOrders = $this->checkForDuplicates($prefix);
         if (isset($duplicateClientOrders)) {
             //$GLOBALS['log']->info("Duplicate Clientorder:".$duplicateClientOrders['id']);
             $this->handleRedirect($return_id, "ClientOrders");
             return null;
         }
     }
     //End Goodwill
     $return_id = $focus->save();
     if ($do_final_move) {
         $upload_file->final_move($return_id);
         $focus->stored_file_name = $sugar_config['upload_dir'] . $return_id . $upload_file->get_stored_file_name();
         $focus->imagename = $upload_file->get_stored_file_name();
         $focus->imagepath = $sugar_config['upload_dir'] . $return_id . $upload_file->get_stored_file_name();
         $focus->save();
         //echo "dir:".$sugar_config['upload_dir']."<br/>";
         //echo $focus->imagepath."<br/>";
     }
     //echo "Saved record with id of ".$return_id;
     $GLOBALS['log']->debug("Saved record with id of " . $return_id);
     if ($redirect) {
         handleRedirect($return_id, "ClientOrders");
     } else {
         return $focus;
     }
 }
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:62,代码来源:ProductFormBase.php

示例9: 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);
     }
 }
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:78,代码来源:CaseUpdatesHook.php

示例10: handleSave

 function handleSave($prefix, $redirect = true, $useRequired = false)
 {
     require_once 'modules/EmailTemplates/EmailTemplate.php';
     require_once 'modules/Documents/Document.php';
     require_once 'modules/DocumentRevisions/DocumentRevision.php';
     require_once 'modules/Notes/Note.php';
     require_once 'include/formbase.php';
     require_once 'include/upload_file.php';
     global $upload_maxsize, $upload_dir;
     global $mod_strings;
     $focus = new EmailTemplate();
     if ($useRequired && !checkRequired($prefix, array_keys($focus->required_fields))) {
         return null;
     }
     $focus = populateFromPost($prefix, $focus);
     if (!$focus->ACLAccess('Save')) {
         ACLController::displayNoAccess(true);
         sugar_cleanup(true);
     }
     if (!isset($_REQUEST['published'])) {
         $focus->published = 'off';
     }
     $return_id = $focus->save();
     ///////////////////////////////////////////////////////////////////////////////
     ////	ATTACHMENT HANDLING
     ///////////////////////////////////////////////////////////////////////////
     ////	ADDING NEW ATTACHMENTS
     $max_files_upload = 10;
     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++) {
         $note = new Note();
         $upload_file = new UploadFile('email_attachment' . $i);
         if ($upload_file == -1) {
             continue;
         }
         if (isset($_FILES['email_attachment' . $i]) && $upload_file->confirm_upload()) {
             $note->filename = $upload_file->get_stored_file_name();
             $note->file = $upload_file;
             $note->name = $mod_strings['LBL_EMAIL_ATTACHMENT'] . ': ' . $note->file->original_file_name;
             array_push($focus->attachments, $note);
         }
     }
     $focus->saved_attachments = array();
     foreach ($focus->attachments as $note) {
         if (!empty($note->id)) {
             if (empty($_REQUEST['old_id'])) {
                 // to support duplication of email templates
                 array_push($focus->saved_attachments, $note);
             } else {
                 // we're duplicating a template with attachments
                 // dupe the file, create a new note, assign the note to the new template
                 $newNote = new Note();
                 $newNote->retrieve($note->id);
                 $newNote->id = create_guid();
                 $newNote->parent_id = $focus->id;
                 $newNote->new_with_id = true;
                 $newNoteId = $newNote->save();
                 $dupeFile = new UploadFile('duplicate');
                 $dupeFile->duplicate_file($note->id, $newNoteId, $note->filename);
             }
             continue;
         }
         $note->parent_id = $focus->id;
         $note->parent_type = 'Emails';
         $note->file_mime_type = $note->file->mime_type;
         $note_id = $note->save();
         array_push($focus->saved_attachments, $note);
         $note->id = $note_id;
         $note->file->final_move($note->id);
     }
     ////	END NEW ATTACHMENTS
     ///////////////////////////////////////////////////////////////////////////
     ///////////////////////////////////////////////////////////////////////////
     ////	ATTACHMENTS FROM DOCUMENTS
     for ($i = 0; $i < 10; $i++) {
         if (isset($_REQUEST['documentId' . $i]) && !empty($_REQUEST['documentId' . $i])) {
             $doc = new Document();
             $docRev = new DocumentRevision();
             $docNote = new Note();
             $noteFile = new UploadFile('none');
             $doc->retrieve($_REQUEST['documentId' . $i]);
             $docRev->retrieve($doc->document_revision_id);
             array_push($focus->saved_attachments, $docRev);
             $docNote->name = $doc->document_name;
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:101,代码来源:EmailTemplateFormBase.php

示例11: 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);
开发者ID:netconstructor,项目名称:sugarcrm_dev,代码行数:31,代码来源:UpgradeWizard.php

示例12: populateFromPost

    $Document->retrieve($_REQUEST['record']);
}
if (!$Document->ACLAccess('Save')) {
    ACLController::displayNoAccess(true);
    sugar_cleanup(true);
}
if (isset($_REQUEST['SaveRevision'])) {
    //fetch the document record.
    $Document->retrieve($_REQUEST['return_id']);
    if ($useRequired && !checkRequired($prefix, array_keys($Revision->required_fields))) {
        return null;
    }
    $Revision = populateFromPost($prefix, $Revision);
    $upload_file = new UploadFile('uploadfile');
    if (isset($_FILES['uploadfile']) && $upload_file->confirm_upload()) {
        $Revision->filename = $upload_file->get_stored_file_name();
        $Revision->file_mime_type = $upload_file->mime_type;
        $Revision->file_ext = $upload_file->file_ext;
        $do_final_move = 1;
    }
    //save revision
    $Revision->document_id = $_REQUEST['return_id'];
    $Revision->save();
    //revsion is the document.
    $Document->document_revision_id = $Revision->id;
    $Document->save();
    $return_id = $Document->id;
}
if ($do_final_move) {
    $upload_file->final_move($Revision->id);
} else {
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:31,代码来源:Save.php

示例13: array

//		Function: name of the function to be called in TreeData.php, the function will be called statically.
//		PARAM prefixed properties: array of these property/values will be passed to the function as parameter.
require_once 'include/JSON.php';
require_once 'include/upload_file.php';
if (!is_dir($cachedir = sugar_cached('images/'))) {
    mkdir_recursive($cachedir);
}
// cn: bug 11012 - fixed some MIME types not getting picked up.  Also changed array iterator.
$imgType = array('image/gif', 'image/png', 'image/x-png', 'image/bmp', 'image/jpeg', 'image/jpg', 'image/pjpeg');
$ret = array();
foreach ($_FILES as $k => $file) {
    if (in_array(strtolower($_FILES[$k]['type']), $imgType) && $_FILES[$k]['size'] > 0) {
        $upload_file = new UploadFile($k);
        // check the file
        if ($upload_file->confirm_upload()) {
            $dest = $cachedir . basename($upload_file->get_stored_file_name());
            // target name
            $guid = create_guid();
            if ($upload_file->final_move($guid)) {
                // move to uploads
                $path = $upload_file->get_upload_path($guid);
                // if file is OK, copy to cache
                if (verify_uploaded_image($path) && copy($path, $dest)) {
                    $ret[] = $dest;
                }
                // remove temp file
                unlink($path);
            }
        }
    }
}
开发者ID:omusico,项目名称:sugar_work,代码行数:31,代码来源:AttachFiles.php

示例14: handleSave

 function handleSave($prefix, $redirect = true, $useRequired = false)
 {
     require_once 'include/formbase.php';
     require_once 'include/upload_file.php';
     global $upload_maxsize;
     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';
     }
     $preProcessedImages = array();
     $emailTemplateBodyHtml = from_html($focus->body_html);
     if (strpos($emailTemplateBodyHtml, '"cache/images/')) {
         $matches = array();
         preg_match_all('#<img[^>]*[\\s]+src[^=]*=[\\s]*["\']cache/images/(.+?)["\']#si', $emailTemplateBodyHtml, $matches);
         foreach ($matches[1] as $match) {
             $filename = urldecode($match);
             $file_location = sugar_cached("images/{$filename}");
             $mime_type = pathinfo($filename, PATHINFO_EXTENSION);
             if (file_exists($file_location)) {
                 $id = create_guid();
                 $newFileLocation = "upload://{$id}";
                 if (!copy($file_location, $newFileLocation)) {
                     $GLOBALS['log']->debug("EMAIL Template could not copy attachment to {$newFileLocation}");
                 } else {
                     $secureLink = "index.php?entryPoint=download&type=Notes&id={$id}";
                     $emailTemplateBodyHtml = str_replace("cache/images/{$match}", $secureLink, $emailTemplateBodyHtml);
                     unlink($file_location);
                     $preProcessedImages[$filename] = $id;
                 }
             }
             // if
         }
         // foreach
     }
     // if
     if (isset($GLOBALS['check_notify'])) {
         $check_notify = $GLOBALS['check_notify'];
     } else {
         $check_notify = FALSE;
     }
     $focus->body_html = $emailTemplateBodyHtml;
     $return_id = $focus->save($check_notify);
     ///////////////////////////////////////////////////////////////////////////////
     ////	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();
         //Images are presaved above so we need to prevent duplicate files from being created.
         if (isset($preProcessedImages[$file['name']])) {
             $oldId = $preProcessedImages[$file['name']];
             $note->id = $oldId;
             $note->new_with_id = TRUE;
             $GLOBALS['log']->debug("Image {$file['name']} has already been processed.");
         }
         $i = preg_replace("/email_attachment(.+)/", '$1', $key);
         $upload_file = new UploadFile($key);
         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 {
//.........这里部分代码省略.........
开发者ID:netconstructor,项目名称:sugarcrm_dev,代码行数:101,代码来源:EmailTemplateFormBase.php

示例15: 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()) {
         $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 (!empty($params['isDuplicate']) && $params['isDuplicate'] == 'true') {
         // This way of detecting duplicates is used in Notes
         $old_id = $params['relate_id'];
     }
     if (!empty($params['duplicateSave']) && !empty($params['duplicateId'])) {
         // It's a duplicate
         $old_id = $params['duplicateId'];
     }
     // Backwards compatibility for fields that still use customCode to handle the file uploads
     if (!$move && empty($old_id) && isset($_FILES['uploadfile'])) {
         $upload_file = new UploadFile('uploadfile');
         if ($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;
         }
     } else {
         if (!$move && !empty($old_id) && isset($_REQUEST['uploadfile']) && !isset($_REQUEST[$prefix . $field . '_file'])) {
             // I think we are duplicating a backwards compatibility module.
             $upload_file = new UploadFile('uploadfile');
         }
     }
     if (empty($bean->id)) {
         $bean->id = create_guid();
         $bean->new_with_id = true;
     }
     if ($move) {
         $upload_file->final_move($bean->id);
         $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});
                     }
                 }
             }
         }
     }
     if ($vardef['allowEapm'] == true && empty($bean->{$field})) {
         $GLOBALS['log']->info("The {$field} is empty, clearing out the lot");
         // Looks like we are emptying this out
         $clearFields = array('docId', 'docType', 'docUrl', 'docDirectUrl');
         foreach ($clearFields as $clearMe) {
             if (!isset($vardef[$clearMe])) {
                 continue;
             }
             $clearField = $vardef[$clearMe];
             $bean->{$clearField} = '';
         }
     }
 }
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:87,代码来源:SugarFieldFile.php


注:本文中的UploadFile::get_stored_file_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。