Skip to content

Commit

Permalink
Merge pull request #5840 from concrete5/hotfix/fix-5750
Browse files Browse the repository at this point in the history
Fix #5750
  • Loading branch information
aembler committed Aug 10, 2017
2 parents bb5aec4 + 316e955 commit 1c5e1a1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion concrete/controllers/backend/page/multilingual.php
Expand Up @@ -96,7 +96,7 @@ public function create_new()
$cp = new \Permissions($newParent);
if ($cp->canAddSubCollection($ct)) {
if ($this->page->isPageDraft()) {
$targetParent = \Page::getByPath(\Config::get('concrete.paths.drafts'));
$targetParent = \Page::getDraftsParentPage();
} else {
$targetParent = $newParent;
}
Expand Down
2 changes: 1 addition & 1 deletion concrete/controllers/panel/page/versions.php
Expand Up @@ -90,7 +90,7 @@ public function new_page()
$c->loadVersionObject($_REQUEST['cvID']);
$nc = $c->cloneVersion(t('New Page Created From Version'));
$v = $nc->getVersionObject();
$drafts = Page::getByPath(Config::get('concrete.paths.drafts'));
$drafts = Page::getDraftsParentPage();
$nc = $c->duplicate($drafts);
$nc->deactivate();
$nc->move($drafts);
Expand Down
17 changes: 11 additions & 6 deletions concrete/src/Page/Page.php
Expand Up @@ -564,12 +564,19 @@ public function removePermissions($userOrGroup, $permissions = [])
}
}

public static function getDraftsParentPage(Site $site = null)
{
$db = Database::connection();
$site = $site ? $site : \Core::make('site')->getSite();
$cParentID = $db->fetchColumn('select p.cID from PagePaths pp inner join Pages p on pp.cID = p.cID inner join SiteLocales sl on p.siteTreeID = sl.siteTreeID where cPath = ? and sl.siteID = ?', [Config::get('concrete.paths.drafts'), $site->getSiteID()]);
return Page::getByID($cParentID);
}

public static function getDrafts(Site $site)
{
$db = Database::connection();
$u = new User();
$nc = self::getByPath(Config::get('concrete.paths.drafts'), 'RECENT', $site);
$r = $db->executeQuery('select Pages.cID from Pages inner join Collections c on Pages.cID = c.cID where cParentID = ? and siteTreeID = ? order by cDateAdded desc', [$nc->getCollectionID(), $site->getSiteTreeID()]);
$nc = self::getDraftsParentPage($site);
$r = $db->executeQuery('select Pages.cID from Pages inner join Collections c on Pages.cID = c.cID where cParentID = ? order by cDateAdded desc', [$nc->getCollectionID()]);
$pages = [];
while ($row = $r->FetchRow()) {
$entry = self::getByID($row['cID']);
Expand All @@ -583,9 +590,7 @@ public static function getDrafts(Site $site)

public function isPageDraft()
{
$site = \Core::make('site')->getSite();
$nc = self::getByPath(Config::get('concrete.paths.drafts'), 'RECENT', $site);

$nc = self::getDraftsParentPage();
return $this->getCollectionParentID() == $nc->getCollectionID();
}

Expand Down
3 changes: 1 addition & 2 deletions concrete/src/Page/Type/Type.php
Expand Up @@ -1158,8 +1158,7 @@ public function createDraft(\Concrete\Core\Entity\Page\Template $pt, $u = false)
}
$db = Loader::db();
$ptID = $this->getPageTypeID();
$site = \Core::make('site')->getSite();
$parent = Page::getByPath(Config::get('concrete.paths.drafts'), 'RECENT', $site);
$parent = Page::getDraftsParentPage();
$data = array('cvIsApproved' => 0, 'cIsActive' => false, 'cAcquireComposerOutputControls' => true);
$p = $parent->add($this, $data, $pt);

Expand Down

0 comments on commit 1c5e1a1

Please sign in to comment.