function eventAddUpdateDraft(EventControler $evtcl) { $id = $evtcl->id; $type = $evtcl->id_type; $text = $evtcl->text; if ($text != '') { $do_note = new Note(); $text = $do_note->htmlCleanUp($text); $q = new sqlQuery($this->getDbCon()); $q->query("SET CHARACTER SET utf8"); $q->query("select * from " . $this->table . " Where id= " . $id . " AND id_type = '" . $type . "' \n AND iduser = "******"idnote_draft"); } $this->getId($idnote_draft); $this->note_content = $text; $this->timestamp = time(); $this->update(); } else { //Insert $this->id = $id; $this->id_type = $type; $this->iduser = $_SESSION['do_User']->iduser; $this->note_content = $text; $this->timestamp = time(); $this->add(); } } }
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; }
/** * 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; }
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; }
public function create($data, $save = true) { $note = new Note($this, $data); if ($save) { $note->save(); } return $note; }
public function hasSharesDebt($id = null) { $options = array('conditions' => array('Condo.' . $this->primaryKey => $id)); $this->contain('Fraction'); $condo = $this->find('first', $options); $fractions = Set::extract('/Fraction/id', $condo); $Note = new Note(); return $hasSharesDebt = $Note->find('count', array('conditions' => array('Note.fraction_id' => $fractions, 'Note.note_type_id =' => 2, 'Note.note_status_id <' => 3, 'Note.document_date < NOW()'))); }
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); } }
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; }
function getNotesByLead($lid) { $db = Database::obtain(); //check if Lead already exist $sql = "SELECT * FROM `" . TBL_NOTES . "` WHERE `lid` = '{$lid}'"; $results = $db->query($sql); $notes = array(); while ($row = mysql_fetch_assoc($results)) { $note = new Note(); $note->noteFromArray($row); $notes[] = $note; } return $notes; }
public function set_recovery_post() { $NoteList = new ObjList(['db_where_Arr' => ['status' => -1], 'db_where_deletenull_Bln' => TRUE, 'model_name_Str' => 'Note', 'limitstart_Num' => 0, 'limitcount_Num' => 100]); foreach ($NoteList->obj_Arr as $key => $value_note) { $Note = new Note(['noteid_Num' => $value_note->noteid_Num]); $Note->recovery(); } if (!empty($NoteList->obj_Arr)) { $this->load->model('Message'); $this->Message->show(['message' => '復原成功', 'url' => 'admin/base/note/set/set']); } else { $this->load->model('Message'); $this->Message->show(['message' => '已無可復原的項目', 'url' => 'admin/base/note/set/set']); } }
public function dashboard() { $user = Auth::user(); $publicnotes = Note::where('user_id', '=', Auth::user()->id)->where('public_or_private', '=', 'public')->get(); $privatenotes = Note::where('user_id', '=', Auth::user()->id)->where('public_or_private', '=', 'private')->get(); $publicsheets = Sheet::where('user_id', '=', Auth::user()->id)->where('public_or_private', '=', 'public')->get(); $privatesheets = Sheet::where('user_id', '=', Auth::user()->id)->where('public_or_private', '=', 'private')->get(); $publicmeetups = Meetup::where('admin_id', '=', Auth::user()->id)->get(); $yournotes = Note::where('user_id', '=', Auth::user()->id)->take(5)->get(); $yoursheets = Sheet::where('user_id', '=', Auth::user()->id)->take(5)->get(); $yourmeetups = Meetup::where('admin_id', '=', Auth::user()->id)->take(5)->get(); $userlists = DB::table('sheets')->where('user_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(5); $usernotes = DB::table('notes')->where('user_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(5); $alladmin = DB::table('meetups')->where('admin_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(5); $allmeetups = DB::table('attendees')->where('attendee_id', Auth::user()->id)->orderBy('created_at', 'desc')->paginate(5); $meetupsyouarepartof = []; if ($allmeetups != null) { foreach ($allmeetups as $individualmeetups) { $meetup = Meetup::find($individualmeetups->meetup_id); array_push($meetupsyouarepartof, $meetup->title); } } else { array_push($meetupsyouarepartof, 'You are not attending any meetups, or you are admin of all of them!'); } return View::make('/users/dashboard')->with('user', $user)->with('userlists', $userlists)->with('usernotes', $usernotes)->with('alladmin', $alladmin)->with('meetupsyouarepartof', $meetupsyouarepartof)->with('publicnotes', $publicnotes)->with('privatenotes', $privatenotes)->with('publicsheets', $publicsheets)->with('privatesheets', $privatesheets)->with('publicmeetups', $publicmeetups)->with('yournotes', $yournotes)->with('yoursheets', $yoursheets)->with('yourmeetups', $yourmeetups); }
public function testLoad() { $this->assertEquals(2, Group::getCount()); $this->assertEquals(0, Role::getCount()); $this->assertEquals(0, Account::getCount()); $this->assertEquals(0, Contact::getCount()); $this->assertEquals(0, Opportunity::getCount()); $this->assertEquals(0, Meeting::getCount()); $this->assertEquals(0, Note::getCount()); $this->assertEquals(0, Task::getCount()); $this->assertEquals(1, User::getCount()); $this->assertEquals(0, ProductCatalog::getCount()); $this->assertEquals(0, ProductCategory::getCount()); $this->assertEquals(0, ProductTemplate::getCount()); $this->assertEquals(0, Product::getCount()); $messageLogger = new MessageLogger(); DemoDataUtil::unsetLoadedModules(); DemoDataUtil::load($messageLogger, 3); $this->assertEquals(8, Group::getCount()); $this->assertEquals(3, Role::getCount()); $this->assertEquals(3, Account::getCount()); $this->assertEquals(16, Contact::getCount()); $this->assertEquals(6, Opportunity::getCount()); $this->assertEquals(18, Meeting::getCount()); $this->assertEquals(12, Note::getCount()); $this->assertEquals(9, Task::getCount()); $this->assertEquals(10, User::getCount()); $this->assertEquals(1, ProductCatalog::getCount()); $this->assertEquals(6, ProductCategory::getCount()); $this->assertEquals(32, ProductTemplate::getCount()); $this->assertEquals(59, Product::getCount()); }
/** * This is construct base of the class. * * A public constructor; initializes the variable $instanceDataBase. * */ public function __construct($instanceDataBase) { parent::__construct($instanceDataBase); Note::setDataOperationBusiness($instanceDataBase); Note::getBusiness(); Note::getDescriptionBusiness(); }
/** * 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; }
/** * Constructor. */ function ArticleNote() { if (Config::getVar('debug', 'deprecation_warnings')) { trigger_error('Deprecated class ArticleNote. Use Note instead'); } parent::Note(); }
public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Note::create([]); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $note = Note::find($id); $note->delete(); Session::flash('message', 'Successfully deleted the Note you have selected!'); return Redirect::to('notes'); }
/** * Function used to create instance of class. */ public static function instance() { if (is_null(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
/** * 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; }
public static function query($sql) { // Connect to the database self::$conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DB); // Execute query $res = self::$conn->query($sql); return $res; }
static function &getInstance($data, $simple = true) { global $gedcom_record_cache, $GEDCOM, $pgv_changes; if (is_array($data)) { $ged_id = $data['ged_id']; $pid = $data['xref']; } else { $ged_id = get_id_from_gedcom($GEDCOM); $pid = $data; } // Check the cache first if (isset($gedcom_record_cache[$pid][$ged_id])) { return $gedcom_record_cache[$pid][$ged_id]; } // Look for the record in the database if (!is_array($data)) { $data = fetch_other_record($pid, $ged_id); // If we didn't find the record in the database, it may be remote if (!$data && strpos($pid, ':')) { list($servid, $remoteid) = explode(':', $pid); $service = ServiceClient::getInstance($servid); if ($service) { // TYPE will be replaced with the type from the remote record $data = $service->mergeGedcomRecord($remoteid, "0 @{$pid}@ TYPE\n1 RFN {$pid}", false); } } // If we didn't find the record in the database, it may be new/pending if (!$data && PGV_USER_CAN_EDIT && isset($pgv_changes[$pid . '_' . $GEDCOM])) { $data = find_updated_record($pid); $fromfile = true; } // If we still didn't find it, it doesn't exist if (!$data) { return null; } } // Create the object $object = new Note($data, $simple); if (!empty($fromfile)) { $object->setChanged(true); } // Store it in the cache $gedcom_record_cache[$object->xref][$object->ged_id] =& $object; return $object; }
/** * @ticket 19499 */ public function testCreateProperNameFieldContainsFirstAndLastName() { require_once "modules/Contacts/Contact.php"; $contact = new Contact(); $contact->first_name = "Josh"; $contact->last_name = "Chi"; $contact->salutation = "Mr"; $contact->title = 'VP Operations'; $contact->disable_row_level_security = true; $contact_id = $contact->save(); $note = new Note(); $note->contact_id = $contact_id; $note->disable_row_level_security = true; $note->fill_in_additional_detail_fields(); $this->assertContains($contact->first_name, $note->contact_name); $this->assertContains($contact->last_name, $note->contact_name); $GLOBALS['db']->query('DELETE FROM contacts WHERE id =\'' . $contact_id . '\''); }
function __construct($id) { $this->note = Note::load(array('id' => $id)); if (!$this->note) { error_exit("That note does not exist"); } $this->note->load_creator(); note_add_to_menu($this->note); }
/** * Action for saving an existing note inline edit form. * @param string or array $redirectUrl */ public function actionInlineEditSave($id, $redirectUrl = null) { $note = Note::getById((int) $id); ControllerSecurityUtil::resolveAccessCanCurrentUserWriteModel($note); if (isset($_POST['ajax']) && $_POST['ajax'] === 'inline-edit-form') { $this->actionInlineEditValidate($note, 'Note'); } $this->attemptToSaveModelFromPost($note, $redirectUrl); }
/** * Selects a note from the table and returns the contents. * * @param string $id The ID of this note. * @return A string containing the note. */ function getNote($id) { $note = Note::getDetails($id); if (!empty($_GET["ec_id"])) { return Link_Filter::processText(Auth::getCurrentProject(), nl2br($_GET["ec_id"] . ":" . $id . ":" . Misc::highlightQuotedReply($note["not_note"]))); } else { return $note["not_note"]; } }
/** * 列出某个课程下的所有笔记 * Enter description here ... * @param unknown_type $courseId */ public function actionNote($courseId) { $courseId = intval($courseId); $course = Course::model()->findByPk($courseId); $sql = "select n.*,l.id as lessonId from ew_course c inner join ew_lesson l on c.id=l.courseId inner join ew_note n on n.noteableEntityId=l.entityId where c.id={$courseId}"; $notes = Note::model()->findAllBySql($sql); $dataProvider = new CArrayDataProvider($notes); $this->render('my_notes', array('dataProvider' => $dataProvider, 'course' => $course)); }
function update_note($title) { Note::save($title, $_POST['note']); if (!$GLOBALS['ajax']) { return view_note($title); } $note = Note::load($title); echo $note->note; }
function newSaveFile($note, $portal = false) { global $sugar_config; $focus = new Note(); if (!empty($note['id'])) { $focus->retrieve($note['id']); if (empty($focus->id)) { return '-1'; } } 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->save(); } $return_id = $focus->id; if (!empty($note['file'])) { $this->upload_file->final_move($focus->id); } if (!empty($note['related_module_id']) && !empty($note['related_module_name'])) { $focus->process_save_dates = false; $module_name = $note['related_module_name']; $module_id = $note['related_module_id']; if ($module_name != 'Contacts') { $focus->parent_type = $module_name; $focus->parent_id = $module_id; } else { $focus->contact_id = $module_id; } $focus->save(); } // if return $return_id; }
public function isUniqueSlug($slug) { $notes = Note::all(); foreach ($notes as $note) { if ($note->slug == $slug) { return false; } } return true; }
public static function createOrGetTags($tagsArray, $noteId, $noteUmask) { $tagsPublicPrefixCharacter = Config::get('paperwork.tagsPublicPrefixCharacter')[0]; $createdOrFoundIds = array(); if (is_null($tagsArray)) { return null; } $userId = Auth::user()->id; foreach ($tagsArray as $tagItem) { $tagTitle = ''; $tagVisibility = 0; if ($tagItem[0] === $tagsPublicPrefixCharacter) { $tagTitle = strtolower(substr($tagItem, 1)); $tagVisibility = 1; $tag = Tag::where('tags.title', '=', $tagTitle)->where('tags.visibility', '=', $tagVisibility)->first(); } else { $tagTitle = strtolower($tagItem); $tagVisibility = 0; $tag = Tag::where('tags.title', '=', $tagTitle)->where('tags.visibility', '=', $tagVisibility)->where('tags.user_id', '=', $userId)->first(); } // ->where('tags.title', '=', $tagTitle) // ->where('tags.visibility', '=', $tagVisibility) // ->select('tags.id') // ->first(); if (is_null($tag) && ($tagVisibility == 0 || $tagVisibility == 1 && $noteUmask > PaperworkHelpers::UMASK_READONLY)) { $newTag = new Tag(); $newTag->title = $tagTitle; $newTag->visibility = $tagVisibility; $newTag->user_id = $userId; $newTag->save(); //$newTag->users()->attach(Auth::user()->id); $createdOrFoundIds[] = $newTag->id; } else { if ($tagVisibility == 0 || $tagVisibility == 1 && $noteUmask > PaperworkHelpers::UMASK_READONLY) { /*if(is_null($tag->users()->where('users.id', '=', Auth::user()->id)->first())) { $tag->users()->attach(Auth::user()->id); }*/ $createdOrFoundIds[] = $tag->id; } } } //we need to add the other user's private tags to the list. $addtags = Note::find($noteId)->tags()->where('tags.visibility', '=', 0)->where('tags.user_id', '!=', $userId)->get(); foreach ($addtags as $addtag) { $createdOrFoundIds[] = $addtag->id; } //if the user is not writer, he cannot change public tags. if ($noteUmask < PaperworkHelpers::UMASK_READWRITE) { $addpubtags = Note::find($noteId)->tags()->where('tags.visibility', '=', 1)->get(); foreach ($addpubtags as $addtag) { $createdOrFoundIds[] = $addtag->id; } } return $createdOrFoundIds; }