/** * @return AbstractObject|\Pimcore\Model\Object\Participation * @throws \Exception */ public function makeParticipation() { $objectFolderPath = Plugin::getConfig()->get(Plugin::CONFIG_OBJECTFOLDERPATH); $objectFolder = AbstractObject::getByPath($objectFolderPath); if (!$objectFolder instanceof Folder) { throw new \Exception("Error: objectFolderPath [{$objectFolderPath}] " . "is not a valid object folder."); } // create basic object stuff $key = $this->createParticipationKey(); $participation = new Participation(); $participation->setKey($key); $participation->setParent($objectFolder); $participation->setPublished(true); $participation->setCreationDate(time()); $participation->SetIpCreated($_SERVER['REMOTE_ADDR']); $confirmation = $this->makeConfirmation(); $participation->setConfirmationCode($confirmation->createCode()); return $participation; }
/** * @param $code string * @return bool */ public function confirmParticipationByCode($code) { $participation = Participation::getByConfirmationCode($code, 1); if (is_object($participation)) { $participation->SetIpConfirmed($_SERVER['REMOTE_ADDR']); $participation->setConfirmed(true); $participation->save(); $note = new Note(); $note->setElement($participation); $note->setDate(time()); $note->setType("confirmation"); $note->setTitle("Code confirmed"); $note->addData("code", "text", $code); $note->setUser(0); $note->save(); return true; } return false; }