/** * @route / */ public function index() { if ($this->isLoggedIn()) { $this->storeLensVar('showmenu', true); $author_bp = $this->blueprint('Author'); $announce_bp = $this->blueprint('Announcements'); $blog_bp = $this->blueprint('Blog'); $page_bp = $this->blueprint('CustomPages'); if (IDE_HACKS) { $db = \Airship\get_database(); $author_bp = new Author($db); $announce_bp = new Announcements($db); $blog_bp = new Blog($db); $page_bp = new CustomPages($db); } $this->lens('index', ['announcements' => $announce_bp->getForUser($this->getActiveUserId()), 'stats' => ['num_authors' => $author_bp->numAuthors(), 'num_comments' => $blog_bp->numComments(true), 'num_pages' => $page_bp->numCustomPages(true), 'num_posts' => $blog_bp->numPosts(true)], 'title' => \__('Dashboard')]); } else { $this->storeLensVar('showmenu', false); $this->lens('login'); } }
/** * @route ajax/authors_blog_series */ public function getSeriesForAuthor() { $auth_bp = $this->blueprint('Author'); $blog_bp = $this->blueprint('Blog'); if (IDE_HACKS) { $db = \Airship\get_database(); $auth_bp = new Author($db); $blog_bp = new Blog($db); } if (empty($_POST['author'])) { \Airship\json_response(['status' => 'ERROR', 'message' => \__('No author selected.')]); } $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.')]); } } $existing = $_POST['existing'] ?? []; if (!\is1DArray($existing)) { \Airship\json_response(['status' => 'ERROR', 'message' => \__('One-dimensional array expected')]); } foreach ($existing as $i => $e) { $existing[$i] = (int) $e; } $response = ['status' => 'OK']; if (!empty($_POST['add'])) { $add = (int) ($_POST['add'] ?? 0); $newSeries = $blog_bp->getSeries($add); if (!empty($newSeries)) { if ($newSeries['author'] === $authorId) { $existing[] = $add; $response['new_item'] = $this->getLensAsText('ajax/bridge_blog_series_item', ['item' => ['name' => $newSeries['name'], 'series' => $newSeries['seriesid'], 'data-id' => null]]); } } } $existing = $blog_bp->getAllSeriesParents($existing); $series = $blog_bp->getSeriesForAuthor($authorId, $existing); $response['options'] = $this->getLensAsText('ajax/bridge_blog_series_select_series', ['items' => $series]); \Airship\json_response($response); }