public function add_note() { if (!Visitor::current()->group->can("add_note")) { show_403(__("Access Denied"), __("You do not have sufficient privileges to add notes.", "extend")); } $version = new Version($_POST['version_id']); if (empty($_POST['body'])) { Flash::warning(__("Please enter a message.", "extend"), $version->url()); } $note = Note::add($_POST['body'], $_POST['version_id']); $files = array(); foreach ($_FILES['attachment'] as $key => $val) { foreach ($val as $file => $attr) { $files[$file][$key] = $attr; } } foreach ($files as $attachment) { if ($attachment['error'] != 4) { $path = upload($attachment, null, "attachments"); Attachment::add(basename($path), $path, "note", $note->id); } } Flash::notice(__("Note added.", "extend"), $note->url(true)); }
<?php define('NO_SESSION_LOCATION', true); require_once '../kernel/begin.php'; require_once 'media_begin.php'; require_once '../kernel/header_no_display.php'; if (!empty($_GET['note']) && $User->check_level(MEMBER_LEVEL)) { $id = retrieve(POST, 'id', 0); $note = retrieve(POST, 'note', 0); import('content/note'); $Note = new Note('media', $id, '', $MEDIA_CONFIG['note_max'], '', NOTE_DISPLAY_NOTE); if (!empty($note) && !empty($id)) { echo $Note->add($note); } }
/** * Overload the add() method to the contact activity */ function add() { if (strlen($this->date_added) == 0) { $this->date_added = date("Y-m-d"); } $Parsedown = new Parsedown(); $this->note = $Parsedown->text($this->note); parent::add(); // This below was a try that didn't worked as to global. Created the eventFormatNoteInsert eventaction instead. // $this->note = $this->quote(htmlentities($this->note)); // $this->query("INSERT INTO ".$this->getTable()." (`idcontact`, `note`, `date_added`, `document`, `idcompany`, `iduser`) // VALUES ('".$this->idcontact."','".$this->note."','".$this->date_added."','".$this->document."','".$this->company."','".$this->iduser."')"); // $this->setPrimaryKeyValue($this->getInsertId($this->getTable(), $this->getPrimaryKey())); if ($this->getPrimaryKeyValue() > 0) { $contact = $this->getParentContact(); $contact->setActivity(); } }