Skip to content

Instantly share code, notes, and snippets.

@hissy
Created March 21, 2013 22:53
Show Gist options
  • Save hissy/5217552 to your computer and use it in GitHub Desktop.
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
<?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