public function noteAddAction() { $this->checkPermission("notes_events"); $note = new Element\Note(); $note->setCid((int) $this->getParam("cid")); $note->setCtype($this->getParam("ctype")); $note->setDate(time()); $note->setTitle($this->getParam("title")); $note->setDescription($this->getParam("description")); $note->setType($this->getParam("type")); $note->save(); $this->_helper->json(["success" => true]); }
/** * Creates a note for an action with a transition * @param Element\AbstractElement $element * @param string $type * @param string $title * @param string $description * @param array $noteData * @return Element\Note $note */ public static function createActionNote($element, $type, $title, $description, $noteData, $user = null) { //prepare some vars for creating the note if (!$user) { $user = \Pimcore\Tool\Admin::getCurrentUser(); } $note = new Element\Note(); $note->setElement($element); $note->setDate(time()); $note->setType($type); $note->setTitle($title); $note->setDescription($description); $note->setUser($user->getId()); if (is_array($noteData)) { foreach ($noteData as $row) { $note->addData($row['key'], $row['type'], $row['value']); } } $note->save(); return $note; }