Created
March 21, 2013 22:53
-
-
Save hissy/5217552 to your computer and use it in GitHub Desktop.
#concrete5 Check write permission of each composer page types at composer write page controllers/dashboard/composer/write.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('C5_EXECUTE') or die("Access Denied."); | |
class DashboardComposerWriteController extends Concrete5_Controller_Dashboard_Composer_Write { | |
public function view($ctID = false) { | |
$ct = $this->setCollectionType($ctID); | |
if (!is_object($ct)) { | |
$ctArray = CollectionType::getComposerPageTypes(); | |
// check write permission of each composer page types | |
$_ctArray = $ctArray; | |
$ctArray = array(); | |
foreach($_ctArray as $_ct){ | |
$ctMasterCID = $_ct->getMasterCollectionID(); | |
$ctMasterCollection = Page::getByID($ctMasterCID); | |
$p = new Permissions($ctMasterCollection); | |
if($p->canWrite()){ | |
$ctArray[] = $_ct; | |
} | |
} | |
if (count($ctArray) == 1) { | |
$ct = $ctArray[0]; | |
$this->redirect('/dashboard/composer/write', $ct->getCollectionTypeID()); | |
exit; | |
} | |
$this->set('ctArray', $ctArray); | |
//$this->redirect('/dashboard/composer'); | |
} else { | |
// create a new page of this type | |
$entry = ComposerPage::createDraft($ct); | |
if (is_object($entry)) { | |
$this->redirect('/dashboard/composer/write', 'edit', $entry->getCollectionID()); | |
} else { | |
$this->redirect('/dashboard/composer/drafts'); | |
} | |
} | |
}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment