public function saveAuthorsPhoto()
{
$auth_bp = $this->blueprint('Author');
if (IDE_HACKS) {
$db = \Airship\get_database();
$auth_bp = new Author($db);
}
$authorId = (int) $_POST['author'];
if (!$this->isSuperUser()) {
$authors = $auth_bp->getAuthorIdsForUser($this->getActiveUserId());
if (!\in_array($authorId, $authors)) {
\Airship\json_response(['status' => 'ERROR', 'message' => \__('You do not have permission to access this author\'s posts.')]);
}
}
if (!\Airship\all_keys_exist(['cabin', 'context', 'author', 'filename'], $_POST)) {
\Airship\json_response(['keys' => array_keys($_POST), 'status' => 'ERROR', 'message' => 'Insufficient parameters']);
}
$result = $auth_bp->savePhotoChoice($authorId, $_POST['context'], $_POST['cabin'], $_POST['filename']);
if (!$result) {
\Airship\json_response(['status' => 'ERROR', 'message' => 'Could not save photo choice.', 'photo' => null]);
}
\Airship\json_response(['status' => 'OK', 'message' => 'Saved!']);
}