本文整理汇总了PHP中Note::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Note::save方法的具体用法?PHP Note::save怎么用?PHP Note::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Note
的用法示例。
在下文中一共展示了Note::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Note
function action_AddNote()
{
global $sugar_config;
// $this->view = 'AddNote';
// Creamos una nota
require_once "modules/Notes/Note.php";
$nota = new Note();
$nota->name = "Signed Invoice " . date();
$nota->parent_type = "reg_invoices";
$nota->parent_id = $_POST['record'];
// Guardamos la nota y obtenemos el id
$id = $nota->save();
// Guardamos el archivo ($_POST['doc'])
if ($_POST['type'] == 'XML') {
file_put_contents(trim($sugar_config['upload_dir'], " /") . "/{$id}", trim(html_entity_decode($_POST['doc'])));
$nota->file_mime_type = "text/xml";
$nota->filename = "Factura.xml";
$nota->save();
} else {
if ($_POST['type'] == 'PDF') {
file_put_contents(trim($sugar_config['upload_dir'], " /") . "/{$id}", base64_decode($_POST['doc']));
$nota->file_mime_type = "application/pdf";
$nota->filename = "Factura.pdf";
$nota->save();
}
}
die;
}
示例2: saveFile
function saveFile($note, $portal = false)
{
global $sugar_config;
$focus = new Note();
if (!empty($note['id'])) {
$focus->retrieve($note['id']);
} else {
return '-1';
}
if (!empty($note['file'])) {
$decodedFile = base64_decode($note['file']);
$this->upload_file->set_for_soap($note['filename'], $decodedFile);
$ext_pos = strrpos($this->upload_file->stored_file_name, ".");
$this->upload_file->file_ext = substr($this->upload_file->stored_file_name, $ext_pos + 1);
if (in_array($this->upload_file->file_ext, $sugar_config['upload_badext'])) {
$this->upload_file->stored_file_name .= ".txt";
$this->upload_file->file_ext = "txt";
}
$focus->filename = $this->upload_file->get_stored_file_name();
$focus->file_mime_type = $this->upload_file->getMimeSoap($focus->filename);
$focus->id = $note['id'];
$return_id = $focus->save();
$this->upload_file->final_move($focus->id);
} else {
return '-1';
}
return $return_id;
}
示例3: addNote
public function addNote($noteName, $noteMean, $categoryId, $date, $type, $idx)
{
$note = new Note();
if (!$this->checkExistCategory($categoryId)) {
return array('status' => 304);
}
if (!$this->checkExistNote($noteName, $categoryId)) {
return array('status' => 306);
}
$date = date('Y-m-d H:i:s');
$note->noteName = $noteName;
$note->noteMean = $noteMean;
$note->date = $date;
$note->type = $type;
$note->noteMean = $noteMean;
$note->cateId = $categoryId;
$note->idx = $idx;
$note->status = 0;
$note->created_at = $date;
if ($note->save()) {
$id = Note::where('cateId', $categoryId)->where('noteName', $noteName)->where('date', $date)->first()->noteId;
// Update lasted_update of user table
User::updateLastest(Category::where('categoryId', $categoryId)->first()->userId, $date);
return array('status' => 200, 'noteId' => $id, 'lastedUpdate' => $date);
} else {
return array('status' => 304);
}
}
示例4: registerUser
/**
* This function will create a new user object and return the newly created user object.
*
* @param array $userInfo This should have the properties: username, firstname, lastname, password, ui_language
*
* @return mixed
*/
public function registerUser(array $userInfo, $userLanguage)
{
$user = \User::create($userInfo);
//make the first user an admin
if (\User::all()->count() <= 1) {
$user->is_admin = 1;
}
// Trim trailing whitespace from user first and last name.
$user->firstname = trim($user->firstname);
$user->lastname = trim($user->lastname);
$user->save();
\Setting::create(['ui_language' => $userLanguage, 'user_id' => $user->id]);
/* Add welcome note to user - create notebook, tag and note */
//$notebookCreate = Notebook::create(array('title' => Lang::get('notebooks.welcome_notebook_title')));
$notebookCreate = new \Notebook();
$notebookCreate->title = Lang::get('notebooks.welcome_notebook_title');
$notebookCreate->save();
$notebookCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]);
//$tagCreate = Tag::create(array('title' => Lang::get('notebooks.welcome_note_tag'), 'visibility' => 0));
$tagCreate = new \Tag();
$tagCreate->title = Lang::get('notebooks.welcome_note_tag');
$tagCreate->visibility = 0;
$tagCreate->user_id = $user->id;
$tagCreate->save();
//$tagCreate->users()->attach($user->id);
$noteCreate = new \Note();
$versionCreate = new \Version(['title' => Lang::get('notebooks.welcome_note_title'), 'content' => Lang::get('notebooks.welcome_note_content'), 'content_preview' => mb_substr(strip_tags(Lang::get('notebooks.welcome_note_content')), 0, 255), 'user_id' => $user->id]);
$versionCreate->save();
$noteCreate->version()->associate($versionCreate);
$noteCreate->notebook_id = $notebookCreate->id;
$noteCreate->save();
$noteCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]);
$noteCreate->tags()->sync([$tagCreate->id]);
return $user;
}
示例5: store
public function store()
{
$note = new Note();
$note->body = Input::get('body', 'empty note');
$note->save();
return Response::json(['note' => $note, 'message' => 'Note Created']);
}
示例6: create
public function create($data, $save = true)
{
$note = new Note($this, $data);
if ($save) {
$note->save();
}
return $note;
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$notes = new Note();
$notes->name = Input::get('name');
$notes->text = Input::get('text');
$notes->save();
return Redirect::to('notes');
}
示例8: update_note
function update_note($title)
{
Note::save($title, $_POST['note']);
if (!$GLOBALS['ajax']) {
return view_note($title);
}
$note = Note::load($title);
echo $note->note;
}
示例9: Email
function send_email($module, $module_type, $printable, $file_name, $attach)
{
require_once 'modules/Emails/Email.php';
global $current_user, $mod_strings, $sugar_config;
//First Create e-mail draft
$email = new Email();
// set the id for relationships
$email->id = create_guid();
$email->new_with_id = true;
//subject
$email->name = $mod_strings['LBL_EMAIL_NAME'] . ' ' . $module->name;
//body
$email->description_html = $printable;
//type is draft
$email->type = "draft";
$email->status = "draft";
if (!empty($module->billing_contact_id) && $module->billing_contact_id != "") {
require_once 'modules/Contacts/Contact.php';
$contact = new Contact();
$contact->retrieve($module->billing_contact_id);
$email->parent_type = 'Contacts';
$email->parent_id = $contact->id;
if (!empty($contact->email1)) {
$email->to_addrs_emails = $contact->email1 . ";";
$email->to_addrs = $module->billing_contact_name . " <" . $contact->email1 . ">";
}
}
//team id
$email->team_id = $current_user->default_team;
//assigned_user_id
$email->assigned_user_id = $current_user->id;
//Save the email object
global $timedate;
$email->date_start = $timedate->to_display_date_time(gmdate($GLOBALS['timedate']->get_db_date_time_format()));
$email->save(FALSE);
$email_id = $email->id;
if ($attach) {
$note = new Note();
$note->modified_user_id = $current_user->id;
$note->created_by = $current_user->id;
$note->name = $file_name;
$note->parent_type = 'Emails';
$note->parent_id = $email_id;
$note->file_mime_type = 'application/pdf';
$note->filename = $file_name;
$note->save();
rename($sugar_config['upload_dir'] . 'attachfile.pdf', $sugar_config['upload_dir'] . $note->id);
}
//redirect
if ($email_id == "") {
echo "Unable to initiate Email Client";
exit;
} else {
header("Location: index.php?action=Compose&module=Emails&return_module=" . $module_type . "&return_action=DetailView&return_id=" . $_REQUEST['record'] . "&recordId=" . $email_id);
}
}
示例10: createNoteWithOwnerAndRelatedAccount
public static function createNoteWithOwnerAndRelatedAccount($name, $owner, $account)
{
$occurredOnStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
$note = new Note();
$note->owner = $owner;
$note->occurredOnDateTime = $occurredOnStamp;
$note->description = $name;
$note->activityItems->add($account);
$saved = $note->save();
assert('$saved');
return $note;
}
示例11: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Note();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Note'])) {
$model->attributes = $_POST['Note'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例12: createNote
/**
* Create Note and Version instances
*
* $created_at and $updated_at values we have from parsed xml
*
* @param $title
* @param $content
* @param $created_at
* @param $updated_at
* @return \Note
*/
protected function createNote($title, $content, $created_at, $updated_at)
{
$noteCreate = new \Note();
$noteCreate->created_at = $created_at;
$noteCreate->updated_at = $updated_at;
// Add spaces for strip_tags
$contentPreview = preg_replace('/(<[^>]+>)/', '$1 ', $content);
$contentPreview = strip_tags($contentPreview);
$versionCreate = new \Version(['title' => $title, 'content' => $content, 'content_preview' => mb_substr($contentPreview, 0, 255), 'created_at' => $created_at, 'updated_at' => $updated_at, 'user_id' => \Auth::user()->id]);
$versionCreate->save();
$noteCreate->version()->associate($versionCreate);
$noteCreate->notebook_id = $this->notebook->id;
$noteCreate->save();
$noteCreate->users()->attach(\Auth::user()->id, array('umask' => \PaperworkHelpers::UMASK_OWNER));
return $noteCreate;
}
示例13: createNote
/**
* Set a note (create a new one)
* @param string $note_text note text that will be created
* @return bool feedback (was the note created properly ?)
*/
public static function createNote($note_text)
{
if (!$note_text || strlen($note_text) == 0) {
Session::add('feedback_negative', Text::get('FEEDBACK_NOTE_CREATION_FAILED'));
return false;
}
$note = new Note();
$note->setNoteText($note_text);
$note->setUserId(Session::get('user_id'));
$note->save();
if ($note) {
return true;
}
// default return
Session::add('feedback_negative', Text::get('FEEDBACK_NOTE_CREATION_FAILED'));
return false;
}
示例14: attachPdf
public function attachPdf($name = null)
{
global $sugar_config;
require_once 'modules/reg_invoices/views/view.pdf.php';
require_once 'modules/Notes/Note.php';
if (empty($name)) {
$name = 'Invoice';
}
// We need a note
$note = new Note();
$note->name = $name;
$note->parent_type = "reg_invoices";
$note->parent_id = $this->id;
$note->file_mime_type = "application/pdf";
$note->filename = "{$name}.pdf";
$note->save();
$view = new reg_invoicesViewPdf();
$view->bean = $this;
$view->preDisplay();
$saveToFile = trim($sugar_config['upload_dir'], ' /') . "/{$note->id}";
$view->display("{$saveToFile}.pdf");
rename("{$saveToFile}.pdf", $saveToFile);
}
示例15: 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 {
//.........这里部分代码省略.........