/** * @route ajax/authors_get_photo */ public function getAuthorsPhoto() { $auth_bp = $this->blueprint('Author'); $file_bp = $this->blueprint('Files'); if (IDE_HACKS) { $db = \Airship\get_database(); $auth_bp = new Author($db); $file_bp = new Files($db); } $authorId = (int) ($_POST['author'] ?? 0); 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(['context', 'author'], $_POST)) { \Airship\json_response(['status' => 'ERROR', 'message' => 'Insufficient parameters']); } $file = $auth_bp->getPhotoData($authorId, $_POST['context']); if (empty($file)) { // No file selected \Airship\json_response(['status' => 'OK', 'message' => '', 'photo' => null]); } $cabin = $file_bp->getFilesCabin((int) $file['fileid']); \Airship\json_response(['status' => 'OK', 'message' => '', 'photo' => \Airship\LensFunctions\cabin_url($cabin) . 'files/author/' . $file['slug'] . '/' . $auth_bp->getPhotoDirName() . '/' . $file['filename']]); }