public function updateUpdateuserId(Lyric $lyric) { // update only on new lyric if ($lyric->getId()) { return false; } // @TODO fix $user = $this->securityContext->getToken()->getUser(); if (!$user instanceof \Tekstove\ApiBundle\Model\User) { return false; } $lyric->setUser($user); }
/** * @param Lyric $lyric * @return array */ public function getAllowedLyricFields(Lyric $lyric) { $allowedFields = []; $owner = false; // $this->getId is check if user is guest if ($this->getId() && $lyric->getsendBy() === $this->getId()) { $owner = true; } if (!$lyric->getId()) { $owner = true; } if ($owner) { $allowedFields[] = 'title'; $allowedFields[] = 'artists'; $allowedFields[] = 'text'; $allowedFields[] = 'textBg'; $allowedFields[] = 'languages'; $allowedFields[] = 'extraInfo'; $allowedFields[] = 'videoYoutube'; $allowedFields[] = 'videoVbox7'; $allowedFields[] = 'videoMetacafe'; // do not allow delete on new lyric if ($lyric->getId()) { $allowedFields[] = 'delete'; } } $permissions = $this->getPermissions(); if (array_key_exists(Permission::LYRIC_EDIT_DOWNLOAD, $permissions)) { $allowedFields[] = 'download'; } if ($lyric->isForbidden()) { $hasTextField = array_search('text', $allowedFields); if (false !== $hasTextField) { unset($allowedFields[$hasTextField]); } } return $allowedFields; }
/** * Filter the query by a related \Tekstove\ApiBundle\Model\Lyric object * * @param \Tekstove\ApiBundle\Model\Lyric|ObjectCollection $lyric The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @throws \Propel\Runtime\Exception\PropelException * * @return ChildLyricVoteQuery The current query, for fluid interface */ public function filterByLyric($lyric, $comparison = null) { if ($lyric instanceof \Tekstove\ApiBundle\Model\Lyric) { return $this->addUsingAlias(LyricVoteTableMap::COL_LYRIC_ID, $lyric->getId(), $comparison); } elseif ($lyric instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(LyricVoteTableMap::COL_LYRIC_ID, $lyric->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByLyric() only accepts arguments of type \\Tekstove\\ApiBundle\\Model\\Lyric or Collection'); } }
/** * Exclude object from result * * @param ChildLyric $lyric Object to remove from the list of results * * @return $this|ChildLyricQuery The current query, for fluid interface */ public function prune($lyric = null) { if ($lyric) { $this->addUsingAlias(LyricTableMap::COL_ID, $lyric->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Declares an association between this object and a Lyric object. * * @param Lyric $v * @return $this|\Tekstove\ApiBundle\Model\Artist\ArtistLyric The current object (for fluent API support) * @throws PropelException */ public function setLyric(Lyric $v = null) { if ($v === null) { $this->setLyricId(NULL); } else { $this->setLyricId($v->getId()); } $this->aLyric = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the Lyric object, it will not be re-added. if ($v !== null) { $v->addArtistLyric($this); } return $this; }