function fetch($option = 'link') { global $init; require_once PATH_CORE . '/classes/template.class.php'; $this->templateObj = new template($this->db); $this->templateObj->registerTemplates(MODULE_ACTIVE, 'postStory'); // build the post story page if (defined('ENABLE_USER_BLOGGING') and ENABLE_USER_BLOGGING === true) { $inside .= $this->buildSubNav($option) . '<br /><br />'; } switch ($option) { case 'auto': $inside .= $this->buildScriptInclude('auto'); if ($this->session->u->isModerator or $this->session->u->isSponsor or $this->session->u->isAdmin) { // auto posting for moderators - a quicker way to post and feature stories require_once PATH_CORE . '/classes/newswire.class.php'; $nwObj = new newswire($this->db); $stories = $nwObj->fetchRawStories(); $inside .= '<p>This is an experimental page viewable only by administrators to speed up posting stories and featuring them.</p><p><a href="' . URL_HOME . '?p=engine&force=syncLog&apiKey=' . $init['apiKey'] . '" target="_cts">Sync photos now</a></p>'; $inside .= '<div id="newswireWrap">'; $inside .= $stories; $inside .= '<!-- end newswireWrap --></div>'; } else { $inside .= $this->page->buildMessage('error', 'Access Denied', 'You do not have permission to view this page.'); } break; case 'blog': $result = false; if (isset($_GET['editid'])) { $editid = $_GET['editid']; $this->fData = $this->loadBlogDraft($editid); if ($this->fData->status == 'published') { // already published, redirect to story $this->facebook->redirect(URL_CANVAS . '?p=read&cid=' . $fData->siteContentId); exit; } } else { $editid = 0; } if (isset($_GET['submit'])) { $this->validate('blog'); if (!$this->fData->result) { $result = false; $inside .= $this->page->buildMessage('error', 'Problems with your blog entry', $this->fData->alert); } else { switch ($_POST['submit']) { default: // save as draft $this->fData->blogid = $this->saveBlogDraft($this->fData); break; case 'Publish': $status = $this->publishBlog($this->fData); $result = $status[result]; if ($result) { $this->facebook->redirect(URL_CANVAS . '?p=read&cid=' . $status[siteContentId] . '&justPosted' . (isset($_GET['popup']) ? '&viaBookmarklet' : '')); exit; } else { $inside .= $this->page->buildMessage('error', 'Problems with your blog entry', $status[msg]); } break; } } } // if preview if (!$result) { $inside .= $this->buildDraftList(); $inside .= $this->buildPostBlogForm($this->fData); } else { // process story submission $inside = 'Your blog entry has been published'; // redirect to the story page // with message offering other options to share with friends } break; default: $result = false; if (isset($_GET['submit'])) { $this->validate('link'); if (!$this->fData->result) { $result = false; $inside .= $this->page->buildMessage('error', 'Problems with your post', $this->fData->alert); } else { $status = $this->addStory($this->fData); $result = $status[result]; if ($result) { $this->facebook->redirect(URL_CANVAS . '?p=read&cid=' . $status[siteContentId] . '&justPosted' . (isset($_GET['popup']) ? '&viaBookmarklet' : '')); exit; } else { $inside .= $this->page->buildMessage('error', 'Problems with your post', $status[msg]); } } } // if preview OR if (!$result) { $inside .= '<div id="col_left"><!-- begin left side -->'; $inside .= $this->buildPostStoryForm($this->fData); $inside .= '<!-- end left side --></div><div id="col_right">'; $inside .= $this->buildSidePanel(); $inside .= '</div> <!-- end right side -->'; } else { // process story submission $inside = 'Story posted'; // redirect to the story page // with message offering other options to share with friends } break; } if ($this->page->isAjax) { return $inside; } $code = $this->page->constructPage('postStory', $inside); return $code; }