示例#1
0
 public function save()
 {
     $this->verify($this->post('ctID'));
     if ($this->post('ctIncludeInComposer')) {
         switch ($this->post('ctComposerPublishPageMethod')) {
             case 'PARENT':
                 $page = Page::getByID($this->post('ctComposerPublishPageParentID'));
                 if ($page->isError()) {
                     $this->error->add(t('Parent page not selected'));
                 } else {
                     $this->ct->saveComposerPublishTargetPage($page);
                 }
                 break;
             case 'PAGE_TYPE':
                 $ct = CollectionType::getByID($this->post('ctComposerPublishPageTypeID'));
                 $this->ct->saveComposerPublishTargetPageType($ct);
                 break;
             default:
                 $this->ct->saveComposerPublishTargetAll();
                 break;
         }
         if (!$this->error->has()) {
             $this->ct->saveComposerAttributeKeys($this->post('composerAKID'));
             $this->redirect('/dashboard/pages/types/composer', 'view', $this->ct->getCollectionTypeID(), 'updated');
         } else {
             $this->view($this->ct->getCollectionTypeID());
         }
     } else {
         $this->ct->resetComposerData();
         $this->redirect("/dashboard/pages/types", "clear_composer");
     }
 }
示例#2
0
 public function createPage()
 {
     Loader::model('page');
     $parent = Page::getByID($this->location);
     $ct = CollectionType::getByID($this->ctID);
     $data = array('cName' => $this->post->title, 'cHandle' => $this->post->page_title, 'cDescription' => $this->post->description, 'cDatePublic' => $this->post->pubDate);
     $p = $parent->add($ct, $data);
     return $p;
 }
示例#3
0
	/** 
	 * Checks to see if the page in question is a valid composer draft for the logged in user
	 */
	protected static function isValidComposerPage($entry) {
		$ct = CollectionType::getByID($entry->getCollectionTypeID());
		if (!$ct->isCollectionTypeIncludedInComposer()) {
			return false;
		}
		$cp = new Permissions($entry);
		if (!$cp->canEditPageContents()) {
			return false;
		}			
		return true;
	}
示例#4
0
	public function delete($ctID, $token = '') {
		$db = Loader::db();
		$valt = Loader::helper('validation/token');
		if (!$valt->validate('delete_page_type', $token)) {
			$this->set('message', $valt->getErrorMessage());
		} else {
			// check to make sure we 
			$pageCount = $db->getOne("SELECT COUNT(*) FROM Pages WHERE cIsTemplate = 0 and ctID = ?",array($ctID));
				
			if($pageCount == 0) {
				$ct = CollectionType::getByID($ctID);
				$ct->delete();
				$this->redirect("/dashboard/pages/types");
			} else {
				$this->set("error", array(t("You must delete all pages of this type before deleting this page type.")));
			}
		}
	}
示例#5
0
 /**
  * Gets a list of all pages of the collection type
  * specified by $ctID
  * 
  * @param int $ctID ID of collection type
  */
 public function show($ctID)
 {
     $hh = Loader::helper('html');
     $th = Loader::helper('text');
     $emptyList = false;
     $this->view(false);
     Loader::model('page_list');
     $pl = new PageList();
     $pl->filterByCollectionTypeID($ctID);
     if (array_key_exists('cvName', $_REQUEST)) {
         $cvName = $th->sanitize($_REQUEST['cvName']);
         $this->set('cvName', $cvName);
         $pl->filterByName($cvName);
         if (count($pl->getPage()) <= 0) {
             $pl = new PageList();
             $emptyList = true;
         }
     }
     if (!$emptyList) {
         $pl->addtoQuery('left join Pages parent ON(p1.cParentID = parent.cID)');
         $pl->sortByMultiple('parent.cDisplayOrder asc', 'p1.cDisplayOrder asc');
         $pages = $pl->getPage();
     } else {
         $pages = '';
         $this->set('emptyList', t('No entries found'));
     }
     $ct = CollectionType::getByID($ctID);
     // add all necessary header items like JavaScript and CSS files
     if (!array_key_exists('cvName', $_REQUEST) || $cvName == '') {
         $this->addHeaderItem($hh->css('composer.sort.css', 'remo_composer_list'));
         $this->addHeaderItem($hh->javascript('composer.sort.js', 'remo_composer_list'));
     }
     $this->addHeaderItem($hh->javascript('composer.overview.js', 'remo_composer_list'));
     // add variables used by view
     $this->set('customColumns', $this->loadCustomColumns($ctID));
     $this->set('ctID', $ctID);
     $this->set('ctPublishMethod', $ct->getCollectionTypeComposerPublishMethod());
     $this->set('pages', $pages);
     $this->set('displaySearchBox', $this->displaySearchBox());
     $this->set('composerListTitel', $ct->getCollectionTypeName());
     $this->set('pagesPagination', $pl->displayPaging(false, true));
 }
示例#6
0
 public function update()
 {
     $valt = Loader::helper('validation/token');
     $ct = CollectionType::getByID($_REQUEST['ctID']);
     $ctName = $_POST['ctName'];
     $ctHandle = $_POST['ctHandle'];
     $vs = Loader::helper('validation/strings');
     if (!$ctHandle) {
         $this->error->add(t("Handle required."));
     } else {
         if (!$vs->handle($ctHandle)) {
             $this->error->add(t('Handles must contain only letters, numbers or the underscore symbol.'));
         }
     }
     if (!$ctName) {
         $this->error->add(t("Name required."));
     } else {
         if (preg_match('/[<>;{}?"`]/i', $ctName)) {
             $this->error->add(t('Invalid characters in page type name.'));
         }
     }
     if (!$valt->validate('update_page_type')) {
         $this->error->add($valt->getErrorMessage());
     }
     if (!$this->error->has()) {
         try {
             if (is_object($ct)) {
                 $ct->update($_POST);
                 $this->redirect('/dashboard/pages/types', 'page_type_updated');
             }
         } catch (Exception $e1) {
             $this->error->add($e1->getMessage());
         }
     }
     $this->view();
 }
示例#7
0
        } else {
            if ($striped == '') {
                $striped = 'ccm-list-record-alt';
            }
        }
        $canEditPageProperties = $cpobj->canEditPageProperties();
        $canEditPageSpeedSettings = $cpobj->canEditPageSpeedSettings();
        $canEditPagePermissions = $cpobj->canEditPagePermissions();
        $canEditPageDesign = $cpobj->canEditPageTheme() || $cpobj->canEditPageType();
        $canViewPageVersions = $cpobj->canViewPageVersions();
        $canDeletePage = $cpobj->canDeletePage();
        $canAddSubpages = $cpobj->canAddSubpage();
        $canAddExternalLinks = $cpobj->canAddExternalLink();
        $permissionArray = array('canEditPageProperties' => $canEditPageProperties, 'canEditPageSpeedSettings' => $canEditPageSpeedSettings, 'canEditPagePermissions' => $canEditPagePermissions, 'canEditPageDesign' => $canEditPageDesign, 'canViewPageVersions' => $canViewPageVersions, 'canDeletePage' => $canDeletePage, 'canAddSubpages' => $canAddSubpages, 'canAddExternalLinks' => $canAddExternalLinks);
        $canCompose = false;
        $ct = CollectionType::getByID($cobj->getCollectionTypeID());
        if (is_object($ct)) {
            if ($ct->isCollectionTypeIncludedInComposer()) {
                if ($canEditPageProperties && $h->canAccessComposer()) {
                    $canCompose = 1;
                }
            }
        }
        ?>
			<tr class="ccm-list-record <?php 
        echo $striped;
        ?>
" 
				cName="<?php 
        echo htmlentities($cobj->getCollectionName(), ENT_QUOTES, APP_CHARSET);
        ?>
示例#8
0
 protected function setBlockComposerProperties()
 {
     $this->bIncludeInComposerIsSet = true;
     $db = Loader::db();
     if ($this->c != null) {
         $ct = CollectionType::getByID($this->c->getCollectionTypeID());
         if (is_object($ct)) {
             if ($ct->isCollectionTypeIncludedInComposer()) {
                 if ($this->c->isMasterCollection()) {
                     $ctID = $this->c->getCollectionTypeID();
                     $ccbID = $this->bID;
                 } else {
                     $tempBID = $this->getBlockID();
                     while ($tempBID != false && $tempBID != 0) {
                         $originalBID = $tempBID;
                         $tempBID = $db->GetOne('select distinct br.originalBID from BlockRelations br inner join CollectionVersionBlocks cvb on cvb.bID = br.bID where br.bID = ? and cvb.cID = ?', array($tempBID, $this->c->getCollectionID()));
                     }
                     if ($originalBID && is_object($this->c)) {
                         $ctID = $this->c->getCollectionTypeID();
                         $ccbID = $originalBID;
                     }
                 }
                 if ($ctID && $ccbID) {
                     $cb = $db->GetRow('select bID, ccFilename from ComposerContentLayout where ctID = ? and bID = ?', array($ctID, $ccbID));
                     if (is_array($cb) && $cb['bID'] == $ccbID) {
                         $this->bIncludeInComposer = 1;
                         $this->cbFilename = $cb['ccFilename'];
                     }
                 }
             }
         }
     }
 }
 protected function validate()
 {
     $vt = Loader::helper('validation/strings');
     $vn = Loader::Helper('validation/numbers');
     $dt = Loader::helper("form/date_time");
     if (!$vn->integer($this->post('cParentID'))) {
         $this->error->add(t('You must choose a parent page for this News entry.'));
     }
     if (!$vn->integer($this->post('ctID'))) {
         $this->error->add(t('You must choose a page type for this News entry.'));
     }
     if (!$vt->notempty($this->post('newsTitle'))) {
         $this->error->add(t('Title is required'));
     }
     if (!$this->error->has()) {
         Loader::model('collection_types');
         $ct = CollectionType::getByID($this->post('ctID'));
         $parent = Page::getByID($this->post('cParentID'));
         $parentPermissions = new Permissions($parent);
         if (!$parentPermissions->canAddSubCollection($ct)) {
             $this->error->add(t('You do not have permission to add a page of that type to that area of the site.'));
         }
     }
 }
示例#10
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
$u = new User();
$form = Loader::helper('form');
$sh = Loader::helper('concrete/dashboard/sitemap');
if (!$sh->canRead()) {
    die(t('Access Denied'));
}
if ($_POST['task'] == 'design_pages') {
    $json['error'] = false;
    if ($_POST['plID'] > 0) {
        $pl = PageTheme::getByID($_POST['plID']);
    }
    if ($_POST['ctID'] > 0) {
        $ct = CollectionType::getByID($_POST['ctID']);
    }
    if (is_array($_POST['cID'])) {
        foreach ($_POST['cID'] as $cID) {
            $c = Page::getByID($cID);
            $cp = new Permissions($c);
            if ($cp->canEditPageTheme($pl)) {
                if ($_POST['plID'] > 0) {
                    $c->setTheme($pl);
                }
                if ($_POST['ctID'] > 0 && (!$c->isMasterCollection() && !$c->isGeneratedCollection())) {
                    $parentC = Page::getByID($c->getCollectionParentID());
                    $parentCP = new Permissions($parentC);
                    if ($c->getCollectionID() == HOME_CID || $parentCP->canAddSubCollection($ct)) {
                        $data = array('ctID' => $_POST['ctID']);
                        $c->update($data);
示例#11
0
 public static function add($data, $pkg = null)
 {
     $db = Loader::db();
     $pkgID = $pkg == null ? 0 : $pkg->getPackageID();
     $ctIcon = FILENAME_COLLECTION_TYPE_DEFAULT_ICON;
     if (isset($data['ctIcon'])) {
         $ctIcon = $data['ctIcon'];
     }
     $ctIsInternal = 0;
     if (isset($data['ctIsInternal']) && $data['ctIsInternal']) {
         $ctIsInternal = 1;
     }
     $v = array($data['ctHandle'], $data['ctName'], $ctIcon, $ctIsInternal, $pkgID);
     $q = "insert into PageTypes (ctHandle, ctName, ctIcon, ctIsInternal, pkgID) values (?, ?, ?, ?, ?)";
     $r = $db->prepare($q);
     $res = $db->execute($r, $v);
     if ($res) {
         $ctID = $db->Insert_ID();
         // metadata
         if (is_array($data['akID'])) {
             foreach ($data['akID'] as $ak) {
                 $v2 = array($ctID, $ak);
                 $db->query("insert into PageTypeAttributes (ctID, akID) values (?, ?)", $v2);
             }
         }
         // now that we've created the collection type, we create the master collection
         $dh = Loader::helper('date');
         $cDate = $dh->getSystemDateTime();
         $data['ctID'] = $ctID;
         $cobj = Collection::add($data);
         $cID = $cobj->getCollectionID();
         $mcName = $data['cName'] ? $data['cName'] : "MC: {$data['ctName']}";
         $mcDescription = $data['cDescription'] ? $data['cDescription'] : "Master Collection For {$data['ctName']}";
         $v2 = array($cID, 1, $pkgID);
         $q2 = "insert into Pages (cID, cIsTemplate, pkgID) values (?, ?, ?)";
         $r2 = $db->prepare($q2);
         $res2 = $db->execute($r2, $v2);
         if ($res2) {
             return CollectionType::getByID($ctID);
         }
     }
 }
示例#12
0
文件: view.php 项目: Zyqsempai/amanet
$valt = Loader::helper('validation/token');
$valc = Loader::helper('concrete/validation');
$form = Loader::helper('form');
$ctArray = CollectionType::getList();
$args['section'] = 'collection_types';
$u = new User();
Loader::model('file_set');
$pageTypeIconsFS = FileSet::getByName("Page Type Icons");
$cID = Loader::helper('security')->sanitizeInt($_GET['cID']);
if ($cID && $_GET['task'] == 'load_master') {
    $u->loadMasterCollectionEdit($cID, 1);
    header('Location: ' . BASE_URL . DIR_REL . '/' . DISPATCHER_FILENAME . '?cID=' . $cID . '&mode=edit');
    exit;
}
if ($_REQUEST['task'] == 'edit') {
    $ct = CollectionType::getByID($_REQUEST['ctID']);
    if (is_object($ct)) {
        $ctName = $ct->getCollectionTypeName();
        $ctHandle = $ct->getCollectionTypeHandle();
        $ctName = Loader::helper("text")->entities($ctName);
        $ctHandle = Loader::helper('text')->entities($ctHandle);
        $ctEditMode = true;
    }
}
?>

<?php 
if ($ctEditMode) {
    $ct->populateAvailableAttributeKeys();
    $akIDArray = $_POST['akID'];
    if (!is_array($akIDArray)) {
示例#13
0
 public static function getByID($bID, $c = null, $a = null)
 {
     if ($c == null && $a == null) {
         $cID = 0;
         $arHandle = "";
         $cvID = 0;
         $b = Cache::get('block', $bID);
     } else {
         if (is_object($a)) {
             $arHandle = $a->getAreaHandle();
         } else {
             if ($a != null) {
                 $arHandle = $a;
                 $a = Area::getOrCreate($c, $a);
             }
         }
         $cID = $c->getCollectionID();
         $cvID = $c->getVersionID();
         $b = Cache::get('block', $bID . ':' . $cID . ':' . $cvID . ':' . $arHandle);
         if ($b instanceof Block) {
             return $b;
         }
     }
     if ($b instanceof Block) {
         return $b;
     }
     $db = Loader::db();
     $b = new Block();
     if ($c == null && $a == null) {
         // just grab really specific block stuff
         $q = "select bID, bIsActive, BlockTypes.btID, BlockTypes.btHandle, BlockTypes.pkgID, BlockTypes.btName, bName, bDateAdded, bDateModified, bFilename, Blocks.uID from Blocks inner join BlockTypes on (Blocks.btID = BlockTypes.btID) where bID = ?";
         $b->isOriginal = 1;
         $v = array($bID);
     } else {
         $b->arHandle = $arHandle;
         $b->a = $a;
         $b->cID = $cID;
         $b->c = $c ? $c : '';
         $vo = $c->getVersionObject();
         $cvID = $vo->getVersionID();
         $v = array($b->arHandle, $cID, $cvID, $bID);
         $q = "select CollectionVersionBlocks.isOriginal, BlockTypes.pkgID, CollectionVersionBlocks.cbOverrideAreaPermissions, CollectionVersionBlocks.cbDisplayOrder,\n\t\t\tBlocks.bIsActive, Blocks.bID, Blocks.btID, bName, bDateAdded, bDateModified, bFilename, btHandle, Blocks.uID from CollectionVersionBlocks inner join Blocks on (CollectionVersionBlocks.bID = Blocks.bID)\n\t\t\tinner join BlockTypes on (Blocks.btID = BlockTypes.btID) where CollectionVersionBlocks.arHandle = ? and CollectionVersionBlocks.cID = ? and (CollectionVersionBlocks.cvID = ? or CollectionVersionBlocks.cbIncludeAll=1) and CollectionVersionBlocks.bID = ?";
     }
     $r = $db->query($q, $v);
     $row = $r->fetchRow();
     if (is_array($row)) {
         $b->setPropertiesFromArray($row);
         $b->csrID = $db->GetOne('select csrID from CollectionVersionBlockStyles where cID = ? and cvID = ? and arHandle = ? and bID = ?', array($cID, $cvID, $b->arHandle, $bID));
         $r->free();
         $bt = BlockType::getByID($b->getBlockTypeID());
         $class = $bt->getBlockTypeClass();
         if ($class == false) {
             // we can't find the class file, so we return
             return false;
         }
         $b->instance = new $class($b);
         $b->populateIsGlobal();
         if ($c != null) {
             $ct = CollectionType::getByID($c->getCollectionTypeID());
             if (is_object($ct)) {
                 if ($ct->isCollectionTypeIncludedInComposer()) {
                     if ($c->isMasterCollection()) {
                         $ctID = $c->getCollectionTypeID();
                         $ccbID = $bID;
                     } else {
                         $tempBID = $b->getBlockID();
                         while ($tempBID != false && $tempBID != 0) {
                             $originalBID = $tempBID;
                             $tempBID = $db->GetOne('select distinct br.originalBID from BlockRelations br inner join CollectionVersionBlocks cvb on cvb.bID = br.bID where br.bID = ? and cvb.cID = ?', array($tempBID, $cID));
                         }
                         if ($originalBID && is_object($c)) {
                             $ctID = $c->getCollectionTypeID();
                             $ccbID = $originalBID;
                         }
                     }
                     if ($ctID && $ccbID) {
                         $cb = $db->GetRow('select bID, ccFilename from ComposerContentLayout where ctID = ? and bID = ?', array($ctID, $ccbID));
                         if (is_array($cb) && $cb['bID'] == $ccbID) {
                             $b->bIncludeInComposer = 1;
                             $b->cbFilename = $cb['ccFilename'];
                         }
                     }
                 }
             }
         }
         if ($c != null || $a != null) {
             $ca = new Cache();
             $ca->set('block', $bID . ':' . $cID . ':' . $cvID . ':' . $arHandle, $b);
         } else {
             $ca = new Cache();
             $ca->set('block', $bID, $b);
         }
         return $b;
     }
 }
示例#14
0
	function getNode($cItem, $level = 0, $autoOpenNodes = true) {
		if (!is_object($cItem)) {
			$cID = $cItem;
			$c = Page::getByID($cID, 'RECENT');
		} else {
			$cID = $cItem->getCollectionID();
			$c = $cItem;
		}
		
		/*
		$db = Loader::db();
		$v = array($cID);
		$q = "select cPointerID from Pages where cID = ?";
		$cPointerID = $db->getOne($q, $v);
		if ($cPointerID > 0) {
			$v = array($cPointerID);	
		} else {
			$cPointerID = 0;
		}

		//$q = "select Pages.cPendingAction, Pages.cChildren, CollectionVersions.cID, CollectionVersions.cvName, PageTypes.ctIcon, CollectionVersions.cvIsApproved from Pages left join PageTypes on Pages.ctID = PageTypes.ctID inner join CollectionVersions on Pages.cID = CollectionVersions.cID where CollectionVersions.cID = ? order by CollectionVersions.cvDateCreated desc limit 1";
		//$r = $db->query($q, $v);
		//$row = $r->fetchRow();
		
		*/
		
		
		$cp = new Permissions($c);
		
		/*
		if ($c->isSystemPage() && (!ConcreteDashboardSitemapHelper::showSystemPages())) {
			return false;
		}
		
		if ((!$cp->canRead()) && ($c->getCollectionPointerExternalLink() == null)) {
			return false;
		}
		*/
		
		$canWrite = ($cp->canWrite()) ? true : false;
		
		$nodeOpen = false;
		if (is_array($_SESSION['dsbSitemapNodes'])) {
			if (in_array($cID, $_SESSION['dsbSitemapNodes'])) {
				$nodeOpen = true;
			}
		}
		
		$status = '';
		
		if ($c->getPendingAction() || ( $c->getVersionObject() && $c->getVersionObject()->isApproved()) ) {
			$status = ucfirst($c->getPendingAction());
		}
		
		$cls = ($c->getNumChildren() > 0) ? "folder" : "file";
		$leaf = ($c->getNumChildren() > 0) ? false : true;
		$numSubpages = ($c->getNumChildren()  > 0) ? $c->getNumChildren()  : '';
		
		$cvName = ($c->getCollectionName()) ? $c->getCollectionName() : '(No Title)';
		$selected = (ConcreteDashboardSitemapHelper::isOneTimeActiveNode($cID)) ? true : false;
		
		$ct = CollectionType::getByID($c->getCollectionTypeID());
		$canCompose = false;
		if (is_object($ct)) {
			if ($ct->isCollectionTypeIncludedInComposer()) {
				$h = Loader::helper('concrete/dashboard');
				if ($cp->canWrite() && $h->canAccessComposer()) {
					$canCompose = true;
				}
			}
		}
		$cIcon = $c->getCollectionIcon();
		$cAlias = $c->isAlias();
		$cPointerID = $c->getCollectionPointerID();
		if ($cAlias) {
			if ($cPointerID > 0) {
				$cIcon = ASSETS_URL_IMAGES . '/icons/alias.png';
				$cAlias = 'POINTER';
				$cID = $c->getCollectionPointerOriginalID();
			} else {
				$cIcon = ASSETS_URL_IMAGES . '/icons/alias_external.png';
				$cAlias = 'LINK';
			}
		}
		$node = array(
			'cvName'=> $cvName,
			'cIcon' => $cIcon,
			'cAlias' => $cAlias,
			'numSubpages'=> $numSubpages,
			'status'=> $status,
			'canWrite'=>$canWrite,
			'canCompose' => $canCompose,
			'id'=>$cID,
			'selected'=>$selected
		);
		
		if ($cID == 1 || ($nodeOpen && $autoOpenNodes)) {
			// We open another level
			$node['subnodes'] = $this->getSubNodes($cID, $level, false, $autoOpenNodes);
		}
		
		return $node;
	}
示例#15
0
<?php  defined('C5_EXECUTE') or die("Access Denied.");
$navigation = Loader::helper('navigation');
$th = Loader::helper('text');
$sh = Loader::helper('concrete/dashboard');
if (!$sh->canAccessComposer()) {
	die(t('Access Denied'));
}

$entry = ComposerPage::getByID($_REQUEST['cID'], 'RECENT');
if (!is_object($entry)) {
	die(t('Access Denied'));
}

$ct = CollectionType::getByID($entry->getCollectionTypeID());
$function = 'ccm_composerSelectParentPage';
if ($_REQUEST['submitOnChoose']) {
	$function = 'ccm_composerSelectParentPageAndSubmit';
}

switch($ct->getCollectionTypeComposerPublishMethod()) {
	case 'PAGE_TYPE': 
		Loader::model('page_list');
		$pages = array();
		$pl = new PageList();
		$pl->sortByName();
		$pl->filterByCollectionTypeID($ct->getCollectionTypeComposerPublishPageTypeID());
		$pages = $pl->get();
		
		?>
	
	<h1><?php echo t("Where do you want to publish this page?")?></h1>
示例#16
0
 function update($data)
 {
     $db = Loader::db();
     $vo = $this->getVersionObject();
     $cvID = $vo->getVersionID();
     $this->markModified();
     parent::refreshCache();
     $cName = $this->getCollectionName();
     $cDescription = $this->getCollectionDescription();
     $cDatePublic = $this->getCollectionDatePublic();
     $ctID = $this->getCollectionTypeID();
     $uID = $this->getCollectionUserID();
     $pkgID = $this->getPackageID();
     $cFilename = $this->getCollectionFilename();
     $rescanTemplatePermissions = false;
     $cCacheFullPageContent = $this->cCacheFullPageContent;
     $cCacheFullPageContentLifetimeCustom = $this->cCacheFullPageContentLifetimeCustom;
     $cCacheFullPageContentOverrideLifetime = $this->cCacheFullPageContentOverrideLifetime;
     if (isset($data['cName'])) {
         $cName = $data['cName'];
     }
     if (isset($data['cCacheFullPageContent'])) {
         $cCacheFullPageContent = $data['cCacheFullPageContent'];
     }
     if (isset($data['cCacheFullPageContentLifetimeCustom'])) {
         $cCacheFullPageContentLifetimeCustom = $data['cCacheFullPageContentLifetimeCustom'];
     }
     if (isset($data['cCacheFullPageContentOverrideLifetime'])) {
         $cCacheFullPageContentOverrideLifetime = $data['cCacheFullPageContentOverrideLifetime'];
     }
     if (isset($data['cDescription'])) {
         $cDescription = $data['cDescription'];
     }
     if (isset($data['cDatePublic'])) {
         $cDatePublic = $data['cDatePublic'];
     }
     if (isset($data['uID'])) {
         $uID = $data['uID'];
     }
     if (isset($data['ctID'])) {
         $ctID = $data['ctID'];
         // we grab the package that this ct belongs to
         $pkgID = $db->GetOne("select pkgID from PageTypes where ctID = ?", array($data['ctID']));
         $rescanTemplatePermissions = true;
     }
     $txt = Loader::helper('text');
     if (!isset($data['cHandle']) && $this->getCollectionHandle() != '') {
         $cHandle = $this->getCollectionHandle();
     } else {
         if (!$data['cHandle']) {
             // make the handle out of the title
             $cHandle = $txt->sanitizeFileSystem($cName);
         } else {
             $cHandle = $txt->sanitizeFileSystem($data['cHandle']);
         }
     }
     $cName = $txt->sanitize($cName);
     // Update the non-canonical page paths
     if (isset($data['ppURL'])) {
         $this->rescanPagePaths($data['ppURL']);
     }
     if ($this->isGeneratedCollection()) {
         if (isset($data['cFilename'])) {
             $cFilename = $data['cFilename'];
         }
         // we only update a subset
         $v = array($cName, $cHandle, $cDescription, $cDatePublic, $cvID, $this->cID);
         $q = "update CollectionVersions set cvName = ?, cvHandle = ?, cvDescription = ?, cvDatePublic = ? where cvID = ? and cID = ?";
         $r = $db->prepare($q);
         $res = $db->execute($r, $v);
     } else {
         $v = array($cName, $cHandle, $cDescription, $cDatePublic, $cvID, $this->cID);
         $q = "update CollectionVersions set cvName = ?, cvHandle = ?, cvDescription = ?, cvDatePublic = ? where cvID = ? and cID = ?";
         $r = $db->prepare($q);
         $res = $db->execute($r, $v);
     }
     $db->query("update Pages set uID = ?, ctID = ?, pkgID = ?, cFilename = ?, cCacheFullPageContent = ?, cCacheFullPageContentLifetimeCustom = ?, cCacheFullPageContentOverrideLifetime = ? where cID = ?", array($uID, $ctID, $pkgID, $cFilename, $cCacheFullPageContent, $cCacheFullPageContentLifetimeCustom, $cCacheFullPageContentOverrideLifetime, $this->cID));
     if ($rescanTemplatePermissions) {
         if ($this->cInheritPermissionsFrom == 'TEMPLATE') {
             // we make sure to update the cInheritPermissionsFromCID value
             $ct = CollectionType::getByID($ctID);
             $masterC = $ct->getMasterTemplate();
             $db->Execute('update Pages set cInheritPermissionsFromCID = ? where cID = ?', array($masterC->getCollectionID(), $this->getCollectioniD()));
         }
     }
     // run any internal event we have for page update
     $this->reindex();
     $ret = Events::fire('on_page_update', $this);
 }
示例#17
0
 function approve($doReindexImmediately = true)
 {
     $db = Loader::db();
     $u = new User();
     $uID = $u->getUserID();
     $cvID = $this->cvID;
     $cID = $this->cID;
     $c = Page::getByID($cID, $this->cvID);
     $ov = Page::getByID($cID, 'ACTIVE');
     $oldHandle = $ov->getCollectionHandle();
     $newHandle = $this->cvHandle;
     // update a collection updated record
     $dh = Loader::helper('date');
     $db->query('update Collections set cDateModified = ? where cID = ?', array($dh->getLocalDateTime(), $cID));
     // first we remove approval for the other version of this collection
     $v = array($cID);
     $q = "update CollectionVersions set cvIsApproved = 0 where cID = ?";
     $r = $db->query($q, $v);
     $ov->refreshCache();
     // now we approve our version
     $v2 = array($uID, $cID, $cvID);
     $q2 = "update CollectionVersions set cvIsNew = 0, cvIsApproved = 1, cvApproverUID = ? where cID = ? and cvID = ?";
     $r = $db->query($q2, $v2);
     // next, we rescan our collection paths for the particular collection, but only if this isn't a generated collection
     // I don't know why but this just isn't reliable. It might be a race condition with the cached page objects?
     /*
     if ((($oldHandle != $newHandle) || $oldHandle == '') && (!$c->isGeneratedCollection())) {
     */
     $c->rescanCollectionPath();
     //}
     // check for related version edits. This only gets applied when we edit global areas.
     $r = $db->Execute('select cRelationID, cvRelationID from CollectionVersionRelatedEdits where cID = ? and cvID = ?', array($cID, $cvID));
     while ($row = $r->FetchRow()) {
         $cn = Page::getByID($row['cRelationID'], $row['cvRelationID']);
         $cnp = new Permissions($cn);
         if ($cnp->canApprovePageVersions()) {
             $v = $cn->getVersionObject();
             $v->approve();
             $r = $db->Execute('delete from CollectionVersionRelatedEdits where cID = ? and cvID = ? and cRelationID = ? and cvRelationID = ?', array($cID, $cvID, $row['cRelationID'], $row['cvRelationID']));
         }
     }
     if ($c->getCollectionInheritance() == 'TEMPLATE') {
         // we make sure to update the cInheritPermissionsFromCID value
         $ct = CollectionType::getByID($c->getCollectionTypeID());
         $masterC = $ct->getMasterTemplate();
         $db->Execute('update Pages set cInheritPermissionsFromCID = ? where cID = ?', array($masterC->getCollectionID(), $c->getCollectioniD()));
     }
     Events::fire('on_page_version_approve', $c);
     $c->reindex(false, $doReindexImmediately);
     $this->refreshCache();
 }
示例#18
0
 function getNode($cItem, $level = 0, $autoOpenNodes = true)
 {
     if (!is_object($cItem)) {
         $cID = $cItem;
         $c = Page::getByID($cID, 'RECENT');
     } else {
         $cID = $cItem->getCollectionID();
         $c = $cItem;
     }
     $cp = new Permissions($c);
     $canEditPageProperties = $cp->canEditPageProperties();
     $canEditPageSpeedSettings = $cp->canEditPageSpeedSettings();
     $canEditPagePermissions = $cp->canEditPagePermissions();
     $canEditPageDesign = $cp->canEditPageTheme() || $cp->canEditPageType();
     $canViewPageVersions = $cp->canViewPageVersions();
     $canDeletePage = $cp->canDeletePage();
     $canAddSubpages = $cp->canAddSubpage();
     $canAddExternalLinks = $cp->canAddExternalLink();
     $nodeOpen = false;
     if (is_array($_SESSION['dsbSitemapNodes'])) {
         if (in_array($cID, $_SESSION['dsbSitemapNodes'])) {
             $nodeOpen = true;
         }
     }
     $status = '';
     $cls = $c->getNumChildren() > 0 ? "folder" : "file";
     $leaf = $c->getNumChildren() > 0 ? false : true;
     $numSubpages = $c->getNumChildren() > 0 ? $c->getNumChildren() : '';
     $cvName = $c->getCollectionName() ? $c->getCollectionName() : '(No Title)';
     $cvName = $c->isSystemPage() ? t($cvName) : $cvName;
     $selected = ConcreteDashboardSitemapHelper::isOneTimeActiveNode($cID) ? true : false;
     $ct = CollectionType::getByID($c->getCollectionTypeID());
     $isInTrash = $c->isInTrash();
     $canCompose = false;
     if (is_object($ct)) {
         if ($ct->isCollectionTypeIncludedInComposer()) {
             $h = Loader::helper('concrete/dashboard');
             if ($cp->canEditPageProperties() && $h->canAccessComposer()) {
                 $canCompose = true;
             }
         }
     }
     $isTrash = $c->getCollectionPath() == TRASH_PAGE_PATH;
     if ($isTrash || $isInTrash) {
         $pk = PermissionKey::getByHandle('empty_trash');
         if (!$pk->validate()) {
             return false;
         }
     }
     $cIcon = $c->getCollectionIcon();
     $cAlias = $c->isAlias();
     $cPointerID = $c->getCollectionPointerID();
     if ($cAlias) {
         if ($cPointerID > 0) {
             $cIcon = ASSETS_URL_IMAGES . '/icons/alias.png';
             $cAlias = 'POINTER';
             $cID = $c->getCollectionPointerOriginalID();
         } else {
             $cIcon = ASSETS_URL_IMAGES . '/icons/alias_external.png';
             $cAlias = 'LINK';
         }
     }
     $node = array('cvName' => $cvName, 'cIcon' => $cIcon, 'cAlias' => $cAlias, 'isInTrash' => $isInTrash, 'isTrash' => $isTrash, 'numSubpages' => $numSubpages, 'status' => $status, 'canEditPageProperties' => $canEditPageProperties, 'canEditPageSpeedSettings' => $canEditPageSpeedSettings, 'canEditPagePermissions' => $canEditPagePermissions, 'canEditPageDesign' => $canEditPageDesign, 'canViewPageVersions' => $canViewPageVersions, 'canDeletePage' => $canDeletePage, 'canAddSubpages' => $canAddSubpages, 'canAddExternalLinks' => $canAddExternalLinks, 'canCompose' => $canCompose, 'id' => $cID, 'selected' => $selected);
     if ($cID == 1 || $nodeOpen && $autoOpenNodes) {
         // We open another level
         $node['subnodes'] = $this->getSubNodes($cID, $level, false, $autoOpenNodes);
     }
     return $node;
 }
示例#19
0
 public function create_page()
 {
     Loader::model('section', 'multilingual');
     if (Loader::helper('validation/token')->validate('create_page', $_POST['token'])) {
         $ms = MultilingualSection::getByLocale($_POST['locale']);
         $page = Page::getByID($_POST['sourceID']);
         if (is_object($page) && !$page->isError()) {
             // we get the related parent id
             $cParentID = $page->getCollectionParentID();
             $cParent = Page::getByID($cParentID);
             $cParentRelatedID = $ms->getTranslatedPageID($cParent);
             if ($cParentRelatedID > 0) {
                 // we copy the page underneath it and store it
                 $newParent = Page::getByID($cParentRelatedID);
                 $ct = CollectionType::getByID($page->getCollectionTypeID());
                 $cp = new Permissions($newParent);
                 if ($cp->canAddSubCollection($ct) && $page->canMoveCopyTo($newParent)) {
                     $newPage = $page->duplicate($newParent);
                     if (is_object($newPage)) {
                         print '<a href="' . Loader::helper("navigation")->getLinkToCollection($newPage) . '">' . $newPage->getCollectionName() . '</a>';
                     }
                 } else {
                     print '<span class="ccm-error">' . t("Insufficient permissions.") . '</span>';
                 }
             }
         }
     }
     exit;
 }
<? $form = Loader::helper('form'); ?>
<?
$attribs = array();

$allowedAKIDs = $assignment->getAttributesAllowedArray();

$requiredKeys = array();
$usedKeys = array();
if ($c->getCollectionTypeID() > 0 && !$c->isMasterCollection()) {
	$cto = CollectionType::getByID($c->getCollectionTypeID());
	$aks = $cto->getAvailableAttributeKeys();
	foreach($aks as $ak) {
		$requiredKeys[] = $ak->getAttributeKeyID();
	}
}
$setAttribs = $c->getSetCollectionAttributes();
foreach($setAttribs as $ak) {
	$usedKeys[] = $ak->getAttributeKeyID();
}
$usedKeysCombined = array_merge($requiredKeys, $usedKeys);

?>

<div class="row">
<div id="ccm-attributes-column" class="span3">
	<h6><?php 
echo t("All Attributes");
?>
</h6>
	<div class="ccm-block-type-search-wrapper ">
示例#21
0
 public static function replacePageTypeWithPlaceHolder($ctID)
 {
     if ($ctID > 0) {
         $ct = CollectionType::getByID($ctID);
         return '{ccm:export:pagetype:' . $ct->getCollectionTypeHandle() . '}';
     }
 }
示例#22
0
	$oc = Page::getByID($_REQUEST['origCID']);
}
if (isset($_REQUEST['destCID'] ) && is_numeric($_REQUEST['destCID'])) {
	$dc = Page::getByID($_REQUEST['destCID']);
}

$valt = Loader::helper('validation/token');

$json = array();
$json['error'] = false;
$json['message'] = false;

if (is_object($oc) && is_object($dc)) {
	$ocp = new Permissions($oc);
	$dcp = new Permissions($dc);
	$ct = CollectionType::getByID($dc->getCollectionTypeID());
	if (!$ocp->canRead()) {
		$error = t("You cannot view the source page.");
	} else if (!$dcp->canAddSubContent($ct)) {
		$error = t("You do not have sufficient privileges to add this type of page to this destination.");
	} else if (!$oc->canMoveCopyTo($dc)) {
		$error = t("You may not move/copy/alias the chosen page to that location.");
	} else {
		$error = false;
	}
}

if (!$error) {
	if ($_REQUEST['ctask']) {
		if ($valt->validate()) {
			switch($_REQUEST['ctask']) {
示例#23
0
	protected function setCollectionType($ctID) {
		if (intval($ctID) > 0) {
			$ct = CollectionType::getByID($ctID);
			if (is_object($ct)) {
				if (!$ct->isCollectionTypeIncludedInComposer()) {
					unset($ct);
				}
			}			
		}
		if (is_object($ct)) {
			$this->set('ct', $ct);
			$this->set('contentitems', $ct->getComposerContentItems());
		}
		return $ct;
	}
<?php

defined('C5_EXECUTE') or die("Access Denied.");
global $c;
// grab all the collections belong to the collection type that we're looking at
Loader::model('collection_types');
$ctID = $c->getCollectionTypeID();
$ct = CollectionType::getByID($ctID);
$cList = $ct->getPages();
?>
<div class="ccm-ui">
<form method="post" id="ccmBlockMasterCollectionForm" action="<?php 
echo $b->getBlockMasterCollectionAliasAction();
?>
">

	<?php 
if (count($cList) == 0) {
    ?>
	
	<?php 
    echo t("There are no pages of this type added to your website. If there were, you'd be able to choose which of those pages this block appears on.");
    ?>
	
	<?php 
} else {
    ?>
	
	<p><?php 
    echo t("Choose which pages below this particular block should appear on. Any previously selected blocks may also be removed using the checkbox. Click the checkbox in the header to select/deselect all pages.");
    ?>
示例#25
0
 function buildSiteFromWordPress(array $pages)
 {
     Loader::model('page');
     //this creates the fileset and sets it as a protected property of this controller class so we can reference it without throwing these defines around, i'll get rid of em
     //eventually
     if ($this->createFileSet) {
         Loader::model('file_set');
         $fs = new FileSet();
         $u = new User();
         $uID = User::getUserID();
         $newFs = FileSet::createAndGetSet($this->filesetname, 1, $uID);
         $this->fileset = $newFs;
     }
     $errors = array();
     //$message = '';
     //get our root page
     $pageroot = Page::getByID($this->post('new-root-pages'));
     $postroot = Page::getByID($this->post('new-root-posts'));
     //this is how / where to set another page for page-type pages.
     //ok so basically our keys in our array are wordpress postIDs, which are pages in the system
     //so what we need to do now (thinking here) is that we need to arrange these posts into a tree
     //$pages is in the format of the postID => pageLiteObject
     Loader::model('collection_types');
     $ctPagesID = CollectionType::getByID($this->post('wordpress-pages'));
     $ctBlogID = CollectionType::getByID($this->post('wordpress-blogs'));
     //we want to reference the collection type we are adding based on either a post or a page
     $collectionTypesForWordpress = array("POST" => $ctBlogID, "PAGE" => $ctPagesID);
     $parentIDPageLiteRel = array();
     $createdPages = array();
     $createdPagesReal = array();
     $fakeCreatedPages = array();
     //so our homepage is zero, and we need that in our created page, even though it isn't a page that is created for association issues but it absolutely has to be 0.
     //Then it is a relational mapping issue, this puppy took a bit of thought
     //
     $createdPagesReal[0] = $pageroot;
     //so foreach pages
     foreach ($pages as $xmlID => $pageLite) {
         $ct = $collectionTypesForWordpress[$pageLite->getPostType()];
         //create the pages
         //right now i am only handling posts and pages, we have to ignore attachments as they are posted elsewhere or referenced in posts or pages
         if (is_a($ct, CollectionType)) {
             if ($pageLite->getPostType() == "POST") {
                 $createdPagesReal[$pageLite->getPostID()] = $this->addWordpressPage($postroot, $ct, $pageLite, $xmlID);
             } else {
                 $createdPagesReal[$pageLite->getPostID()] = $this->addWordpressPage($pageroot, $ct, $pageLite, $xmlID);
             }
             //here's how we map our pages to pages
         } else {
             //this is kind of spooky and frustrating to see.
             $errors[] = t("Un-supported post type for post - ") . $pageLite->getTitle();
         }
     }
     $this->set('message', t('Wordpress export pages imported under ') . $pageroot->getCollectionName() . ".<br /> " . t('Wordpress export posts imported under ') . $postroot->getCollectionName() . ".");
     $this->set('errors', $errors);
 }