本文整理汇总了PHP中Note::get_full_list方法的典型用法代码示例。如果您正苦于以下问题:PHP Note::get_full_list方法的具体用法?PHP Note::get_full_list怎么用?PHP Note::get_full_list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Note
的用法示例。
在下文中一共展示了Note::get_full_list方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elseif
}
//// END CAMPAIGNS
///////////////////////////////////////
///////////////////////////////////////
//// ATTACHMENTS
$attachments = '';
if (!empty($focus->id)) {
$etid = $focus->id;
} elseif (!empty($old_id)) {
$xtpl->assign('OLD_ID', $old_id);
$etid = $old_id;
}
if (!empty($etid)) {
$note = new Note();
$where = "notes.parent_id='{$etid}' AND notes.filename IS NOT NULL";
$notes_list = $note->get_full_list("", $where, true);
if (!isset($notes_list)) {
$notes_list = array();
}
for ($i = 0; $i < count($notes_list); $i++) {
$the_note = $notes_list[$i];
if (empty($the_note->filename)) {
continue;
}
$secureLink = 'index.php?entryPoint=download&id=' . $the_note->id . '&type=Notes';
$attachments .= '<input type="checkbox" name="remove_attachment[]" value="' . $the_note->id . '"> ' . $app_strings['LNK_REMOVE'] . ' ';
$attachments .= '<a href="' . $secureLink . '" target="_blank">' . $the_note->filename . '</a><br>';
}
}
$attJs = '<script type="text/javascript">';
$attJs .= 'var file_path = "' . $sugar_config['site_url'] . '/' . $sugar_config['upload_dir'] . '";';
示例2: action_sendinvitemails
public function action_sendinvitemails()
{
global $db;
global $sugar_config;
global $mod_strings;
$id = $_GET['record'];
//get event
$event = new FP_events();
$event->retrieve($id);
$event->load_relationship('fp_events_contacts');
// get related contacts
$event->load_relationship('fp_events_prospects_1');
//get related targets
$event->load_relationship('fp_events_leads_1');
//get related leads
//Count the number of delegates linked to the event that have not yet been invited
$query = "SELECT * FROM fp_events_contacts_c WHERE fp_events_contactsfp_events_ida='" . $event->id . "' AND (invite_status='Not Invited' OR invite_status='' OR invite_status IS NULL) AND deleted='0'";
$result = $db->query($query);
$contact_count = $db->getRowCount($result);
//count contacts
$query = "SELECT * FROM fp_events_prospects_1_c WHERE fp_events_prospects_1fp_events_ida='" . $event->id . "' AND (invite_status='Not Invited' OR invite_status='' OR invite_status IS NULL) AND deleted='0'";
$result = $db->query($query);
$prospect_count = $db->getRowCount($result);
//count targets
$query = "SELECT * FROM fp_events_leads_1_c WHERE fp_events_leads_1fp_events_ida='" . $event->id . "' AND (invite_status='Not Invited' OR invite_status='' OR invite_status IS NULL) AND deleted='0'";
$result = $db->query($query);
$lead_count = $db->getRowCount($result);
//count leads
$delegate_count = $contact_count + $prospect_count + $lead_count;
//Total up delegates
$invite_count = 0;
//used to count the number of emails sent
$error_count = 0;
//used to count the number of failed email attempts
//loop through related contacts
foreach ($event->fp_events_contacts->getBeans() as $contact) {
//Get accept status of contact
$query = 'SELECT invite_status FROM fp_events_contacts_c WHERE fp_events_contactsfp_events_ida="' . $event->id . '" AND fp_events_contactscontacts_idb="' . $contact->id . '"';
$status = $db->getOne($query);
if ($status == null || $status == '' || $status == 'Not Invited') {
$invite_count++;
//set email links
$event->link = "<a href='" . $sugar_config['site_url'] . "/index.php?entryPoint=responseEntryPoint&event=" . $event->id . "&delegate=" . $contact->id . "&type=c&response=accept'>Accept</a>";
$event->link_declined = "<a href='" . $sugar_config['site_url'] . "/index.php?entryPoint=responseEntryPoint&event=" . $event->id . "&delegate=" . $contact->id . "&type=c&response=decline'>Decline</a>";
//Get the TO name and e-mail address for the message
$rcpt_name = $contact->first_name . ' ' . $contact->last_name;
$rcpt_email = $contact->email1;
$emailTemp = new EmailTemplate();
$emailTemp->disable_row_level_security = true;
$emailTemp->retrieve($event->invite_templates);
//Use the ID value of the email template record
//check email template is set, if not return error
if ($emailTemp->id == '') {
SugarApplication::appendErrorMessage($mod_strings['LBL_ERROR_MSG_5']);
SugarApplication::redirect("index.php?module=FP_events&return_module=FP_events&action=DetailView&record=" . $event->id);
die;
}
//parse the lead varibales first
$firstpass = $emailTemp->parse_template_bean($emailTemp->body_html, 'Contacts', $contact);
$email_subject = $emailTemp->parse_template_bean($emailTemp->subject, 'FP_events', $event);
$email_body = from_html($emailTemp->parse_template_bean($firstpass, 'FP_events', $event));
$alt_emailbody = wordwrap($emailTemp->parse_template_bean($firstpass, 'FP_events', $event), 900);
//get attachments
$attachmentBean = new Note();
$attachment_list = $attachmentBean->get_full_list('', "parent_type = 'Emails' AND parent_id = '" . $event->invite_templates . "'");
$attachments = array();
if ($attachment_list != null) {
foreach ($attachment_list as $attachment) {
$attachments[] = $attachment;
}
}
//send the email
$send_invite = $this->sendEmail($rcpt_email, $email_subject, $rcpt_name, $email_body, $alt_emailbody, $contact, $attachments);
//Send the message, log if error occurs
if (!$send_invite) {
$GLOBALS['log']->fatal('ERROR: Invite email failed to send to: ' . $rcpt_name . ' at ' . $rcpt_email);
$error_count++;
} else {
//update contact to invites
$query = 'UPDATE fp_events_contacts_c SET invite_status="Invited" WHERE fp_events_contactsfp_events_ida="' . $event->id . '" AND fp_events_contactscontacts_idb="' . $contact->id . '"';
$res = $db->query($query);
}
}
}
//loop through related targets
foreach ($event->fp_events_prospects_1->getBeans() as $target) {
//Get accept status of contact
$query = 'SELECT invite_status FROM fp_events_prospects_1_c WHERE fp_events_prospects_1fp_events_ida="' . $event->id . '" AND fp_events_prospects_1prospects_idb="' . $target->id . '"';
$status = $db->getOne($query);
if ($status == null || $status == '' || $status == 'Not Invited') {
$invite_count++;
//set email links
$event->link = "<a href='" . $sugar_config['site_url'] . "/index.php?entryPoint=responseEntryPoint&event=" . $event->id . "&delegate=" . $target->id . "&type=t&response=accept'>Accept</a>";
$event->link_declined = "<a href='" . $sugar_config['site_url'] . "/index.php?entryPoint=responseEntryPoint&event=" . $event->id . "&delegate=" . $target->id . "&type=t&response=decline'>Decline</a>";
//Get the TO name and e-mail address for the message
$rcpt_name = $target->first_name . ' ' . $target->last_name;
$rcpt_email = $target->email1;
$emailTemp = new EmailTemplate();
$emailTemp->disable_row_level_security = true;
$emailTemp->retrieve($event->invite_templates);
//.........这里部分代码省略.........
示例3: Email
/**
* This function returns the detail view for email in new 2.0 interface
*
*/
function getDetailViewForEmail2($emailId)
{
require_once 'include/DetailView/DetailView.php';
global $app_strings, $app_list_strings;
global $mod_strings;
$smarty = new Sugar_Smarty();
// SETTING DEFAULTS
$focus = new Email();
$focus->retrieve($emailId);
$detailView->ss = new Sugar_Smarty();
$detailView = new DetailView();
$title = "";
$offset = 0;
if ($focus->type == 'out') {
$title = getClassicModuleTitle('Emails', array($mod_strings['LBL_SENT_MODULE_NAME'], $focus->name), true);
} elseif ($focus->type == 'draft') {
$title = getClassicModuleTitle('Emails', array($mod_strings['LBL_LIST_FORM_DRAFTS_TITLE'], $focus->name), true);
} elseif ($focus->type == 'inbound') {
$title = getClassicModuleTitle('Emails', array($mod_strings['LBL_INBOUND_TITLE'], $focus->name), true);
}
$smarty->assign("emailTitle", $title);
// DEFAULT TO TEXT IF NO HTML CONTENT:
$html = trim(from_html($focus->description_html));
if (empty($html)) {
$smarty->assign('SHOW_PLAINTEXT', 'true');
} else {
$smarty->assign('SHOW_PLAINTEXT', 'false');
}
//if not empty or set to test (from test campaigns)
if (!empty($focus->parent_type) && $focus->parent_type != 'test') {
$smarty->assign('PARENT_MODULE', $focus->parent_type);
$smarty->assign('PARENT_TYPE', $app_list_strings['record_type_display'][$focus->parent_type] . ":");
}
global $gridline;
$smarty->assign('MOD', $mod_strings);
$smarty->assign('APP', $app_strings);
$smarty->assign('GRIDLINE', $gridline);
$smarty->assign('PRINT_URL', 'index.php?' . $GLOBALS['request_string']);
$smarty->assign('ID', $focus->id);
$smarty->assign('TYPE', $focus->type);
$smarty->assign('PARENT_NAME', $focus->parent_name);
$smarty->assign('PARENT_ID', $focus->parent_id);
$smarty->assign('NAME', $focus->name);
$smarty->assign('ASSIGNED_TO', $focus->assigned_user_name);
$smarty->assign('DATE_MODIFIED', $focus->date_modified);
$smarty->assign('DATE_ENTERED', $focus->date_entered);
$smarty->assign('DATE_START', $focus->date_start);
$smarty->assign('TIME_START', $focus->time_start);
$smarty->assign('FROM', $focus->from_addr);
$smarty->assign('TO', nl2br($focus->to_addrs));
$smarty->assign('CC', nl2br($focus->cc_addrs));
$smarty->assign('BCC', nl2br($focus->bcc_addrs));
$smarty->assign('CREATED_BY', $focus->created_by_name);
$smarty->assign('MODIFIED_BY', $focus->modified_by_name);
$smarty->assign('DATE_SENT', $focus->date_entered);
$smarty->assign('EMAIL_NAME', 'RE: ' . $focus->name);
$smarty->assign("TAG", $focus->listviewACLHelper());
$smarty->assign("SUGAR_VERSION", $GLOBALS['sugar_version']);
$smarty->assign("JS_CUSTOM_VERSION", $GLOBALS['sugar_config']['js_custom_version']);
if (!empty($focus->reply_to_email)) {
$replyTo = "\n\t\t\t\t<tr>\n\t\t <td class=\"tabDetailViewDL\"><slot>" . $mod_strings['LBL_REPLY_TO_NAME'] . "</slot></td>\n\t\t <td colspan=3 class=\"tabDetailViewDF\"><slot>" . $focus->reply_to_addr . "</slot></td>\n\t\t </tr>";
$smarty->assign("REPLY_TO", $replyTo);
}
///////////////////////////////////////////////////////////////////////////////
//// JAVASCRIPT VARS
$jsVars = '';
$jsVars .= "var showRaw = '{$mod_strings['LBL_BUTTON_RAW_LABEL']}';";
$jsVars .= "var hideRaw = '{$mod_strings['LBL_BUTTON_RAW_LABEL_HIDE']}';";
$smarty->assign("JS_VARS", $jsVars);
///////////////////////////////////////////////////////////////////////////////
//// NOTES (attachements, etc.)
///////////////////////////////////////////////////////////////////////////////
$note = new Note();
$where = "notes.parent_id='{$focus->id}'";
//take in account if this is from campaign and the template id is stored in the macros.
if (isset($macro_values) && isset($macro_values['email_template_id'])) {
$where = "notes.parent_id='{$macro_values['email_template_id']}'";
}
$notes_list = $note->get_full_list("notes.name", $where, true);
if (!isset($notes_list)) {
$notes_list = array();
}
$attachments = '';
for ($i = 0; $i < count($notes_list); $i++) {
$the_note = $notes_list[$i];
$attachments .= "<a href=\"index.php?entryPoint=download&id={$the_note->id}&type=Notes\">" . $the_note->name . "</a><br />";
$focus->cid2Link($the_note->id, $the_note->file_mime_type);
}
$smarty->assign('DESCRIPTION', nl2br($focus->description));
$smarty->assign('DESCRIPTION_HTML', from_html($focus->description_html));
$smarty->assign("ATTACHMENTS", $attachments);
///////////////////////////////////////////////////////////////////////////////
//// SUBPANELS
///////////////////////////////////////////////////////////////////////////////
$show_subpanels = true;
if ($show_subpanels) {
//.........这里部分代码省略.........
示例4: handleAttachments
/**
* handles attachments of various kinds when sending email
*/
function handleAttachments()
{
global $mod_strings;
///////////////////////////////////////////////////////////////////////////
//// ATTACHMENTS FROM DRAFTS
if (($this->type == 'out' || $this->type == 'draft') && $this->status == 'draft' && isset($_REQUEST['record'])) {
$this->getNotes($_REQUEST['record']);
// cn: get notes from OLD email for use in new email
}
//// END ATTACHMENTS FROM DRAFTS
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//// ATTACHMENTS FROM FORWARDS
// Bug 8034 Jenny - Need the check for type 'draft' here to handle cases where we want to save
// forwarded messages as drafts. We still need to save the original message's attachments.
if (($this->type == 'out' || $this->type == 'draft') && isset($_REQUEST['origType']) && $_REQUEST['origType'] == 'forward' && isset($_REQUEST['return_id']) && !empty($_REQUEST['return_id'])) {
$this->getNotes($_REQUEST['return_id'], true);
}
// cn: bug 8034 - attachments from forward/replies lost when saving in draft
if (isset($_REQUEST['prior_attachments']) && !empty($_REQUEST['prior_attachments']) && $this->new_with_id == true) {
$exIds = explode(",", $_REQUEST['prior_attachments']);
if (!isset($_REQUEST['template_attachment'])) {
$_REQUEST['template_attachment'] = array();
}
$_REQUEST['template_attachment'] = array_merge($_REQUEST['template_attachment'], $exIds);
}
//// END ATTACHMENTS FROM FORWARDS
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//// ATTACHMENTS FROM TEMPLATES
// to preserve individual email integrity, we must dupe Notes and associated files
// for each outbound email - good for integrity, bad for filespace
if (isset($_REQUEST['template_attachment']) && !empty($_REQUEST['template_attachment'])) {
$removeArr = array();
$noteArray = array();
if (isset($_REQUEST['temp_remove_attachment']) && !empty($_REQUEST['temp_remove_attachment'])) {
$removeArr = $_REQUEST['temp_remove_attachment'];
}
foreach ($_REQUEST['template_attachment'] as $noteId) {
if (in_array($noteId, $removeArr)) {
continue;
}
$noteTemplate = new Note();
$noteTemplate->retrieve($noteId);
$noteTemplate->id = create_guid();
$noteTemplate->new_with_id = true;
// duplicating the note with files
$noteTemplate->parent_id = $this->id;
$noteTemplate->parent_type = $this->module_dir;
$noteTemplate->date_entered = '';
$noteTemplate->save();
$noteFile = new UploadFile('none');
$noteFile->duplicate_file($noteId, $noteTemplate->id, $noteTemplate->filename);
$noteArray[] = $noteTemplate;
}
$this->attachments = array_merge($this->attachments, $noteArray);
}
//// END ATTACHMENTS FROM TEMPLATES
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//// ADDING NEW ATTACHMENTS
$max_files_upload = 10;
// Jenny - Bug 8211 Since attachments for drafts have already been processed,
// we don't need to re-process them.
if ($this->status != "draft") {
$notes_list = array();
if (!empty($this->id) && !$this->new_with_id) {
$note = new Note();
$where = "notes.parent_id='{$this->id}'";
$notes_list = $note->get_full_list("", $where, true);
}
$this->attachments = array_merge($this->attachments, $notes_list);
}
// cn: Bug 5995 - rudimentary error checking
$filesError = array(0 => 'UPLOAD_ERR_OK - There is no error, the file uploaded with success.', 1 => 'UPLOAD_ERR_INI_SIZE - The uploaded file exceeds the upload_max_filesize directive in php.ini.', 2 => 'UPLOAD_ERR_FORM_SIZE - The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.', 3 => 'UPLOAD_ERR_PARTIAL - The uploaded file was only partially uploaded.', 4 => 'UPLOAD_ERR_NO_FILE - No file was uploaded.', 5 => 'UNKNOWN ERROR', 6 => 'UPLOAD_ERR_NO_TMP_DIR - Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.', 7 => 'UPLOAD_ERR_CANT_WRITE - Failed to write file to disk. Introduced in PHP 5.1.0.');
for ($i = 0; $i < $max_files_upload; $i++) {
// cn: Bug 5995 - rudimentary error checking
if (!isset($_FILES["email_attachment{$i}"])) {
$GLOBALS['log']->debug("Email Attachment {$i} does not exist.");
continue;
}
if ($_FILES['email_attachment' . $i]['error'] != 0 && $_FILES['email_attachment' . $i]['error'] != 4) {
$GLOBALS['log']->debug('Email Attachment could not be attach due to error: ' . $filesError[$_FILES['email_attachment' . $i]['error']]);
continue;
}
$note = new Note();
$note->parent_id = $this->id;
$note->parent_type = $this->module_dir;
$upload_file = new UploadFile('email_attachment' . $i);
if (empty($upload_file)) {
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;
$this->attachments[] = $note;
//.........这里部分代码省略.........
示例5: 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 {
//.........这里部分代码省略.........
示例6: Note
} else {
$offset = 1;
}
$detailView->processListNavigation($xtpl, "EMAIL", $offset, false);
// adding custom fields:
require_once 'modules/DynamicFields/templates/Files/DetailView.php';
$do_open = true;
if ($do_open) {
$xtpl->parse("main.open_source");
}
///////////////////////////////////////////////////////////////////////////////
//// NOTES (attachements, etc.)
///////////////////////////////////////////////////////////////////////////////
$note = new Note();
$where = "notes.parent_id='{$focus->id}'";
$notes_list = $note->get_full_list("notes.name", $where, true);
if (!isset($notes_list)) {
$notes_list = array();
}
$attachments = '';
for ($i = 0; $i < count($notes_list); $i++) {
$the_note = $notes_list[$i];
//$attachments .= "<a href=\"".UploadFile::get_url($the_note->filename,$the_note->id)."\" target=\"_blank\">".$the_note->name.$the_note->description ."</a><br>";
$attachments .= "<a href=\"download.php?id=" . $the_note->id . "&type=Notes\">" . $the_note->name . "</a><br />";
}
$xtpl->assign("ATTACHMENTS", $attachments);
$xtpl->parse("main");
$xtpl->out("main");
$sub_xtpl = $xtpl;
$old_contents = ob_get_contents();
ob_end_clean();
示例7: Note
}
}
$out['signatures'] = $signatureArray;
$ret = $json->encode($out);
echo $ret;
} else {
die;
}
break;
case "getTemplateAttachments":
$GLOBALS['log']->debug("********** EMAIL 2.0 - Asynchronous - at: getTemplateAttachments");
if (isset($_REQUEST['parent_id']) && !empty($_REQUEST['parent_id'])) {
$where = "parent_id='{$_REQUEST['parent_id']}'";
$order = "";
$seed = new Note();
$fullList = $seed->get_full_list($order, $where, '');
$all_fields = array_merge($seed->column_fields, $seed->additional_column_fields);
$js_fields_arr = array();
$i = 1;
// js doesn't like 0 index?
if (!empty($fullList)) {
foreach ($fullList as $note) {
$js_fields_arr[$i] = array();
foreach ($all_fields as $field) {
if (isset($note->{$field})) {
$note->{$field} = from_html($note->{$field});
$note->{$field} = preg_replace('/\\r\\n/', '<BR>', $note->{$field});
$note->{$field} = preg_replace('/\\n/', '<BR>', $note->{$field});
$js_fields_arr[$i][$field] = addslashes($note->{$field});
}
}
示例8: 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);
//.........这里部分代码省略.........
示例9: getAttachments
function getAttachments(EmailTemplate $template)
{
$attachments = array();
if ($template->id != '') {
$note_bean = new Note();
$notes = $note_bean->get_full_list('', "parent_type = 'Emails' AND parent_id = '" . $template->id . "'");
if ($notes != null) {
foreach ($notes as $note) {
$attachments[] = $note;
}
}
}
return $attachments;
}
示例10: handleAttachments
public function handleAttachments($focus, $redirect, $return_id)
{
///////////////////////////////////////////////////////////////////////////////
//// ATTACHMENT HANDLING
///////////////////////////////////////////////////////////////////////////
//// ADDING NEW ATTACHMENTS
global $mod_strings;
$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='" . htmlspecialchars($_REQUEST['old_id'], ENT_QUOTES) . "'";
}
$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 {
$note->embed_flag = false;
}
}
array_push($focus->attachments, $note);
}
}
$focus->saved_attachments = array();
foreach ($focus->attachments as $note) {
if (!empty($note->id) && $note->new_with_id === FALSE) {
if (empty($_REQUEST['old_id'])) {
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;
$newNote->date_modified = '';
$newNote->date_entered = '';
/* BEGIN - SECURITY GROUPS */
//Need to do this so that attachments show under an EmailTemplate correctly for a normal user
global $current_user;
$newNote->assigned_user_id = $current_user->id;
/* END - SECURITY GROUPS */
$newNoteId = $newNote->save();
UploadFile::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;
/* BEGIN - SECURITY GROUPS */
//Need to do this so that attachments show under an EmailTemplate correctly for a normal user
global $current_user;
$note->assigned_user_id = $current_user->id;
/* END - SECURITY GROUPS */
$note_id = $note->save();
array_push($focus->saved_attachments, $note);
$note->id = $note_id;
if ($note->new_with_id === FALSE) {
$note->file->final_move($note->id);
} else {
$GLOBALS['log']->debug("Not performing final move for note id {$note->id} as it has already been processed");
}
}
//// END NEW ATTACHMENTS
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//// ATTACHMENTS FROM DOCUMENTS
$count = '';
//_pp($_REQUEST);
//_ppd(count($_REQUEST['document']));
//.........这里部分代码省略.........
示例11: 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;
//.........这里部分代码省略.........