/** * @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; }