public function save($data) { $ret = parent::save($data); if (isset($data['author'])) { $id = $this->getId(); $authors = explode(";", $data['author']); foreach ($authors as $author) { $a = new Author(); $a->setName($author); $a->commit(); $bookAuthor = new BookAuthor(); $bookAuthor->setBookId($id); $bookAuthor->setAuthorId($a->getId()); $bookAuthor->commit(); } } return $ret; }
public function edit($data) { $cp = CurrentPlayer::getInstance(); if (!$cp->hasAccessTo(ChessRoles::EDIT_USERS) && $cp->getId() !== $this->getId()) { throw new LudoDBUnauthorizedException("You are not allowed to edit this user"); } if (!$cp->hasAccessTo(ChessRoles::EDIT_USERS)) { if (isset($data['user_access'])) { unset($data['user_access']); } } if (isset($values['password']) && !$values['password']) { unset($values['password']); } return parent::save($data); }
public function save($data) { $data = $this->withSpecialMetadataKeysMoved($data); if (isset($data['white'])) { $data['white_id'] = $this->getPlayerIdByName($data['white']); } if (isset($data['black'])) { $data['black_id'] = $this->getPlayerIdByName($data['black']); } return parent::save($data); }