Skip to content

Commit

Permalink
Fixed unpublished entry bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stardog committed Feb 21, 2019
1 parent 1637680 commit 4cf8bde
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion boost/boost.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* MA 02110-1301 USA
*/
$proper_name = 'Stories';
$version = '1.6.1';
$version = '1.6.2';
$register = false;
$unregister = false;
$import_sql = false;
Expand Down
8 changes: 8 additions & 0 deletions boost/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public function run()
$this->update('1.6.0');
case $this->compare('1.6.1'):
$this->update('1.6.1');
case $this->compare('1.6.2'):
$this->update('1.6.2');
}
return $this->content;
}
Expand Down Expand Up @@ -351,6 +353,12 @@ private function v1_6_1()
$changes[] = 'Fixed bugs with publish date.';
$this->addContent('1.6.1', $changes);
}

private function v1_6_2()
{
$changes[] = 'Fixed bug with unpublished entry.';
$this->addContent('1.6.2', $changes);
}

private function addContent($version, array $changes)
{
Expand Down
2 changes: 1 addition & 1 deletion class/Controller/Entry/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function deleteCommand(Request $request)
protected function viewJsonCommand(Request $request)
{
$entry = $this->factory->load($this->id);
return array('entry' => $this->factory->data($entry));
return array('entry' => $entry->getStringVars(true));
}

protected function viewHtmlCommand(Request $request)
Expand Down
8 changes: 0 additions & 8 deletions class/Factory/EntryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -639,14 +639,6 @@ public function shareData(Resource $entry)
['authorEmail', 'authorId', 'content', 'deleted', 'expirationDate', 'updateDate', 'createDateRelative', 'createDate', 'published']);
}

public function data(Resource $entry, $publishOnly = true)
{
if ($publishOnly && (!$entry->published && $entry->publishDate < time())) {
return null;
}
return $entry->getStringVars(true);
}

/**
* Flips the deleted flag on the entry. Tags are not touched as the
* entry will not be pulled. Features will be purged however.
Expand Down
17 changes: 8 additions & 9 deletions class/View/EntryView.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function form(Resource $entry, $new = false)
$tagFactory = new TagFactory();

$sourceHttp = PHPWS_SOURCE_HTTP;
$status = $new ? 'Draft' : 'Last updated ' . $entry->relativeTime($entry->updateDate);
$status = $new || empty($entry->updateDate) ? 'Draft' : 'Last updated ' . $entry->relativeTime($entry->updateDate);
$entryVars = $entry->getStringVars();
$entryVars['content'] = $this->prepareFormContent($entryVars['content']);
$tags = $tagFactory->listTags(true);
Expand Down Expand Up @@ -132,7 +132,6 @@ private function includeCards(Resource $entry)
\Layout::addJSHeader($this->includeTwitterCards($entry));
}


/**
* Medium editor insert doesn't initialize the Twitter embed. Has to be done
* manually. The editor includes a script call to widgets BUT that is stripped
Expand Down Expand Up @@ -196,10 +195,10 @@ public function inListView($id)

\Layout::addJSHeader($this->mediumCSSOverride());
$entry = $this->factory->load($id);
$data = $this->factory->data($entry, !$this->isAdmin);
if (empty($data)) {
throw new ResourceNotFound($id);
if (!$this->isAdmin && (!$entry->published && $entry->publishDate < time())) {
return null;
}
$data = $entry->getStringVars(true);
$this->includeCards($entry);

if ($entry->listView == 1) {
Expand All @@ -216,7 +215,7 @@ public function inListView($id)
} else {
$data['summaryAnchor'] = '';
}

$templateFile = 'Entry/SummaryListView.html';
}
// Removed the summary break tag
Expand Down Expand Up @@ -248,10 +247,10 @@ public function view($id)
try {
$this->includeCss();
$entry = $this->factory->load($id);
$data = $this->factory->data($entry, !$this->isAdmin);
if (empty($data)) {
throw new ResourceNotFound;
if (!$this->isAdmin && (!$entry->published && $entry->publishDate < time())) {
return null;
}
$data = $entry->getStringVars(true);
$this->includeCards($entry);
if (stristr($entry->content, 'twitter')) {
$this->loadTwitterScript(true);
Expand Down

0 comments on commit 4cf8bde

Please sign in to comment.