public static function addStack($stackName, $type = self::ST_TYPE_USER_ADDED) { $ct = new CollectionType(); $data = array(); $parent = Page::getByPath(STACKS_PAGE_PATH); $data = array(); $data['name'] = $stackName; if (!$stackName) { $data['name'] = t('No Name'); } $pagetype = CollectionType::getByHandle(STACKS_PAGE_TYPE); $page = $parent->add($pagetype, $data); // we have to do this because we need the area to exist before we try and add something to it. $a = Area::getOrCreate($page, STACKS_AREA_NAME); // finally we add the row to the stacks table $db = Loader::db(); $stackCID = $page->getCollectionID(); $v = array($stackName, $stackCID, $type); $db->Execute('insert into Stacks (stName, cID, stType) values (?, ?, ?)', $v); //Return the new stack return self::getByID($stackCID); }
public function on_start() { parent::on_start(); $this->area = \Area::getOrCreate($this->page, $_REQUEST['arHandle']); $this->permissions = new \Permissions($this->area); $this->set('a', $this->area); }
public function run() { $db = Loader::db(); Loader::model('collection_attributes'); Loader::model('single_page'); Loader::model('file_version'); // Add in stuff that may have gotten missed before $p = Page::getByPath('/profile'); if ($p->isError()) { $d1 = SinglePage::add('/profile'); $d2 = SinglePage::add('/profile/edit'); $d3 = SinglePage::add('/profile/avatar'); } $p2 = Page::getByPath('/dashboard/users/registration'); if ($p2->isError()) { $d4 = SinglePage::add('/dashboard/users/registration'); } // Move any global blocks to new scrapbook page. $sc = Page::getByPath("/dashboard/scrapbook/global"); $scn = Page::getByPath('/dashboard/scrapbook'); $scu = Page::getByPath('/dashboard/scrapbook/user'); if (!$sc->isError()) { $blocks = $sc->getBlocks("Global Scrapbook"); if (count($blocks) > 0) { // we create the new shared scrapbook 1 $a = Area::getOrCreate($scn, t('Shared Scrapbook 1')); foreach($blocks as $_b) { // we move them into the area on the new page. $_b->move($scn, $a); $_b->refreshCacheAll(); } } $sc->delete(); } if (!$scu->isError()) { $scu->delete(); } //add the new collection attribute keys $cak=CollectionAttributeKey::getByHandle('header_extra_content'); if(!is_object($cak)) { CollectionAttributeKey::add('header_extra_content', t('Header Extra Content'), true, null, 'TEXT'); } $cak=CollectionAttributeKey::getByHandle('exclude_search_index'); if (!is_object($cak)) { CollectionAttributeKey::add('exclude_search_index', t('Exclude From Search Index'), true, null, 'BOOLEAN'); } //convert file tags to new format, cleaned up with leading and trailing line breaks $fileVersionsData=$db->GetAll('SELECT fID, fvID, fvTags FROM FileVersions'); foreach($fileVersionsData as $fvData){ $vals=array( FileVersion::cleanTags($fvData['fvTags']) , $fvData['fID'] , $fvData['fvID'] ); $db->query('UPDATE FileVersions SET fvTags=? WHERE fID=? AND fvID=?', $vals ); } }
protected function getBlockToEdit() { $ax = $this->area; $cx = $this->page; if ($this->area->isGlobalArea()) { $ax = STACKS_AREA_NAME; $cx = \Stack::getByName($_REQUEST['arHandle']); } $b = \Block::getByID($_REQUEST['bID'], $cx, $ax); $nvc = $cx->getVersionToModify(); if ($this->area->isGlobalArea()) { $xvc = $this->page->getVersionToModify(); // we need to create a new version of THIS page as well. $xvc->relateVersionEdits($nvc); } $b->loadNewCollection($nvc); if ($b->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) { // if we're editing a scrapbook display block, we add a new block in this position for the real block type // set the block to the display order // delete the scrapbook display block, and save the data /* $originalDisplayOrder = $b->getBlockDisplayOrder(); $btx = BlockType::getByHandle($_b->getBlockTypeHandle()); $nb = $nvc->addBlock($btx, $ax, array()); $nb->setAbsoluteBlockDisplayOrder($originalDisplayOrder); $b->deleteBlock(); $b = &$nb; */ $originalDisplayOrder = $b->getBlockDisplayOrder(); $cnt = $b->getController(); $ob = \Block::getByID($cnt->getOriginalBlockID()); $ob->loadNewCollection($nvc); if (!is_object($ax)) { $ax = Area::getOrCreate($cx, $ax); } $ob->setBlockAreaObject($ax); $nb = $ob->duplicate($nvc); $nb->setAbsoluteBlockDisplayOrder($originalDisplayOrder); $b->deleteBlock(); $b =& $nb; } else { if ($b->isAlias()) { // then this means that the block we're updating is an alias. If you update an alias, you're actually going // to duplicate the original block, and update the newly created block. If you update an original, your changes // propagate to the aliases $nb = $b->duplicate($nvc); $b->deleteBlock(); $b = $nb; } } return $b; }
public function duplicate($nc = null, $preserveUserID = false) { if (!is_object($nc)) { // There is not necessarily need to provide the parent // page for the duplicate since for stacks, that is // always the same page. $nc = Page::getByPath(STACKS_PAGE_PATH); } $page = parent::duplicate($nc, $preserveUserID); // we have to do this because we need the area to exist before we try and add something to it. $a = Area::getOrCreate($page, STACKS_AREA_NAME); $db = Loader::db(); $v = array($page->getCollectionName(), $page->getCollectionID(), $this->getStackType()); $db->Execute('insert into Stacks (stName, cID, stType) values (?, ?, ?)', $v); // Make sure we return an up-to-date record return Stack::getByID($page->getCollectionID()); }
public function add($cID, $arHandle, $btID, $action) { $c = \Page::getByID($cID); if (is_object($c) && !$c->isError()) { $a = \Area::getOrCreate($c, $arHandle); if (is_object($a)) { $ap = new \Permissions($a); $bt = \BlockType::getByID($btID); if (is_object($bt) && $ap->canAddBlock($bt)) { $controller = $bt->getController(); return $this->deliverResponse($controller, $action); } } } $response = new Response(t('Access Denied')); return $response; }
public static function getByID($bID, $c = null, $a = null) { if ($c == null && $a == null) { $cID = 0; $arHandle = ""; $cvID = 0; $b = CacheLocal::getEntry('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 = CacheLocal::getEntry('block', $bID . ':' . $cID . ':' . $cvID . ':' . $arHandle); } 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, Blocks.btCachedBlockRecord, 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, Blocks.btCachedBlockRecord, BlockTypes.pkgID, CollectionVersionBlocks.cbOverrideAreaPermissions, CollectionVersionBlocks.cbDisplayOrder, Blocks.bIsActive, Blocks.bID, Blocks.btID, bName, bDateAdded, bDateModified, bFilename, btHandle, Blocks.uID from CollectionVersionBlocks inner join Blocks on (CollectionVersionBlocks.bID = Blocks.bID) inner 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); $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); if ($c != null || $a != null) { CacheLocal::set('block', $bID . ':' . $cID . ':' . $cvID . ':' . $arHandle, $b); } else { $ca = new Cache(); CacheLocal::set('block', $bID, $b); } return $b; } }
// set the block to the display order // delete the scrapbook display block, and save the data /* $originalDisplayOrder = $b->getBlockDisplayOrder(); $btx = BlockType::getByHandle($_b->getBlockTypeHandle()); $nb = $nvc->addBlock($btx, $ax, array()); $nb->setAbsoluteBlockDisplayOrder($originalDisplayOrder); $b->deleteBlock(); $b = &$nb; */ $originalDisplayOrder = $b->getBlockDisplayOrder(); $cnt = $b->getController(); $ob = Block::getByID($cnt->getOriginalBlockID()); $ob->loadNewCollection($nvc); if (!is_object($ax)) { $ax = Area::getOrCreate($cx, $ax); } $ob->setBlockAreaObject($ax); $nb = $ob->duplicate($nvc); $nb->setAbsoluteBlockDisplayOrder($originalDisplayOrder); $b->deleteBlock(); $b =& $nb; } else { if ($b->isAlias()) { // then this means that the block we're updating is an alias. If you update an alias, you're actually going // to duplicate the original block, and update the newly created block. If you update an original, your changes // propagate to the aliases $nb = $ob->duplicate($nvc); $b->deleteBlock(); $b =& $nb; }
public function rescanAreaPermissions() { $db = Loader::db(); $arHandles = $db->GetCol('select arHandle from Areas where cID = ?', $this->getCollectionID()); foreach ($arHandles as $arHandle) { $a = Area::getOrCreate($this, $arHandle); $a->rescanAreaPermissionsChain(); } $blocks = $this->getBlocks(); foreach ($blocks as $b) { $b->refreshCache(); } parent::refreshCache(); }
public function rename_block() { $bID = intval($_REQUEST['bID']); $globalScrapbookC = $this->getCollectionObject(); $scrapbookName = $_REQUEST['scrapbookName']; $globalScrapbookArea = Area::getOrCreate($globalScrapbookC, $scrapbookName); $block = Block::getById($bID, $globalScrapbookC, $globalScrapbookArea); if ($block && strlen($_POST['bName'])) { //&& $block->getAreaHandle()=='Global Scrapbook' //this is needed so the cache clears correctly $bp = new Permissions($block); if ($bp->canAdmin()) { $block->setBlockAreaObject($globalScrapbookArea); $block->updateBlockName($_POST['bName'], 1); } } $this->view(); }
protected function migrateAreaPermissions() { if (PERMISSIONS_MODEL == 'simple') { return; } $db = Loader::db(); $tables = $db->MetaTables(); if (!in_array('AreaGroups', $tables)) { return false; } // permissions $permissionMap = array('r' => array(PermissionKey::getByHandle('view_area')), 'wa' => array(PermissionKey::getByHandle('edit_area_contents'), PermissionKey::getByHandle('add_layout_to_area'), PermissionKey::getByHandle('edit_area_design'), PermissionKey::getByHandle('edit_area_contents')), 'db' => array(PermissionKey::getByHandle('edit_area_permissions'), PermissionKey::getByHandle('schedule_area_contents_guest_access'), PermissionKey::getByHandle('delete_area_contents'))); $r = $db->Execute('select * from AreaGroups order by cID asc'); while ($row = $r->FetchRow()) { $pe = $this->migrateAccessEntity($row); if (!$pe) { continue; } $permissions = $this->getPermissionsArray($row['agPermissions']); $co = Page::getByID($row['cID']); if (!is_object($co) || $co->getCollectionID() <= 0) { continue; } $ax = Area::getOrCreate($co, $row['arHandle']); foreach ($permissions as $p) { $permissionsToApply = $permissionMap[$p]; foreach ($permissionsToApply as $pko) { $pko->setPermissionObject($ax); $pt = $pko->getPermissionAssignmentObject(); $pa = $pko->getPermissionAccessObject(); if (!is_object($pa)) { $pa = PermissionAccess::create($pko); } else { if ($pa->isPermissionAccessInUse()) { $pa = $pa->duplicate(); } } $pa->addListItem($pe, false, AreaPermissionKey::ACCESS_TYPE_INCLUDE); $pt->assignPermissionAccess($pa); } } } }
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; } }
function display(&$c, $alternateBlockArray = null) { if(!intval($c->cID)){ //Invalid Collection return false; } $currentPage = Page::getCurrentPage(); $ourArea = Area::getOrCreate($c, $this->arHandle); if (count($this->customTemplateArray) > 0) { $ourArea->customTemplateArray = $this->customTemplateArray; } if (count($this->attributes) > 0) { $ourArea->attributes = $this->attributes; } if ($this->maximumBlocks > -1) { $ourArea->maximumBlocks = $this->maximumBlocks; } $ap = new Permissions($ourArea); $blocksToDisplay = ($alternateBlockArray) ? $alternateBlockArray : $ourArea->getAreaBlocksArray($c, $ap); $this->totalBlocks = $ourArea->getTotalBlocksInArea(); $u = new User(); $bv = new BlockView(); // now, we iterate through these block groups (which are actually arrays of block objects), and display them on the page if (($this->showControls) && ($c->isEditMode() && ($ap->canAddBlocks() || $u->isSuperUser()))) { $bv->renderElement('block_area_header', array('a' => $ourArea)); } $bv->renderElement('block_area_header_view', array('a' => $ourArea)); //display layouts tied to this area //Might need to move this to a better position $areaLayouts = $this->getAreaLayouts($c); if(is_array($areaLayouts) && count($areaLayouts)){ foreach($areaLayouts as $layout){ $layout->display($c,$this); } if($this->showControls && ($c->isArrangeMode() || $c->isEditMode())) { echo '<div class="ccm-layouts-block-arrange-placeholder ccm-block-arrange"></div>'; } } foreach ($blocksToDisplay as $b) { $bv = new BlockView(); $bv->setAreaObject($ourArea); // this is useful for rendering areas from one page // onto the next and including interactive elements if ($currentPage->getCollectionID() != $c->getCollectionID()) { $b->setBlockActionCollectionID($c->getCollectionID()); } $p = new Permissions($b); if (($p->canWrite() || $p->canDeleteBlock()) && $c->isEditMode() && $this->showControls) { $includeEditStrip = true; } if ($p->canRead()) { if (!$c->isEditMode()) { echo $this->enclosingStart; } if ($includeEditStrip) { $bv->renderElement('block_controls', array( 'a' => $ourArea, 'b' => $b, 'p' => $p )); $bv->renderElement('block_header', array( 'a' => $ourArea, 'b' => $b, 'p' => $p )); } $bv->render($b); if ($includeEditStrip) { $bv->renderElement('block_footer'); } if (!$c->isEditMode()) { echo $this->enclosingEnd; } } } $bv->renderElement('block_area_footer_view', array('a' => $ourArea)); if (($this->showControls) && ($c->isEditMode() && ($ap->canAddBlocks() || $u->isSuperUser()))) { $bv->renderElement('block_area_footer', array('a' => $ourArea)); } }
&cID=<?php echo $page_id; ?> &areaHandle=Features&projectID=<?php echo $c->getCollectionHandle(); ?> &domainHandle=home&volumeHandle=feature&partHandle=na&chapterHandle=na"> <m class="glyphicon glyphicon-circle-plus"></m> </a> </span> </h1> </header> <section class="container-fluid"> <div class="row"> <?php $a = Area::getOrCreate($c, 'Features'); $blocks = $c->getBlocks('Features'); foreach ($blocks as $block) { echo '<section class="col-sm-12 col-md-6">'; $block->display(); echo '</section>'; } ?> </div> </section> </section> <section class="container-fluid"> <div class="row"> <header> <h1><?php
public function submit() { if ($this->validateAction() && $this->canAccess()) { $c = $this->page; $a = \Area::get($this->page, $_REQUEST['arHandle']); $ax = $a; $cx = $c; if ($a->isGlobalArea()) { $ax = STACKS_AREA_NAME; $cx = \Stack::getByName($_REQUEST['arHandle']); } $b = \Block::getByID($_REQUEST['bID'], $cx, $ax); $pr = new \Concrete\Core\Page\EditResponse(); $pr->setPage($this->page); $bi = $b->getInstance(); if ($b->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) { $_b = \Block::getByID($bi->getOriginalBlockID()); $bi = $_b->getInstance(); // for validation } $e = $bi->validate($_POST); $pr->setAdditionalDataAttribute('aID', $a->getAreaID()); $pr->setAdditionalDataAttribute('arHandle', $a->getAreaHandle()); $pr->setError($e); if (!is_object($e) || $e instanceof \Concrete\Core\Error\Error && !$e->has()) { $bt = BlockType::getByHandle($b->getBlockTypeHandle()); if (!$bt->includeAll()) { // we make sure to create a new version, if necessary $nvc = $cx->getVersionToModify(); } else { $nvc = $cx; // keep the same one } if ($a->isGlobalArea()) { $xvc = $c->getVersionToModify(); // we need to create a new version of THIS page as well. $xvc->relateVersionEdits($nvc); } $ob = $b; // replace the block with the version of the block in the later version (if applicable) $b = \Block::getByID($_REQUEST['bID'], $nvc, $ax); if ($b->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) { // if we're editing a scrapbook display block, we add a new block in this position for the real block type // set the block to the display order // delete the scrapbook display block, and save the data /* $originalDisplayOrder = $b->getBlockDisplayOrder(); $btx = BlockType::getByHandle($_b->getBlockTypeHandle()); $nb = $nvc->addBlock($btx, $ax, array()); $nb->setAbsoluteBlockDisplayOrder($originalDisplayOrder); $b->deleteBlock(); $b = &$nb; */ $originalDisplayOrder = $b->getBlockDisplayOrder(); $cnt = $b->getController(); $ob = \Block::getByID($cnt->getOriginalBlockID()); $ob->loadNewCollection($nvc); if (!is_object($ax)) { $ax = Area::getOrCreate($cx, $ax); } $ob->setBlockAreaObject($ax); $nb = $ob->duplicate($nvc); $nb->setAbsoluteBlockDisplayOrder($originalDisplayOrder); $b->deleteBlock(); $b =& $nb; } else { if ($b->isAlias()) { // then this means that the block we're updating is an alias. If you update an alias, you're actually going // to duplicate the original block, and update the newly created block. If you update an original, your changes // propagate to the aliases $nb = $ob->duplicate($nvc); $b->deleteBlock(); $b =& $nb; } } $pr->setAdditionalDataAttribute('bID', $b->getBlockID()); // we can update the block that we're submitting $b->update($_POST); } $pr->outputJSON(); } }
public function addNewSection($author_id, $page_id, $area_handle, $project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle, $type_handle, $section_subject, $section_content, $attached_files) { if (!in_array($domain_handle, $this->mDomainList)) { return self::EC_BAD_DOMAIN; } $page = Page::getByID($page_id); $area = Area::getOrCreate($page, $area_handle); if (!is_object($area)) { return self::EC_BAD_PAGEAREA; } $content_file_name = hash_hmac("md5", microtime() . rand(), $author_id); $full_content_path_name = $this->getSectionContentPath($content_file_name, '0', ''); $fp = fopen($full_content_path_name . 'org', "w"); if ($fp === FALSE) { return self::EC_FILE; } fwrite($fp, "{$author_id}\n"); fwrite($fp, "{$type_handle}\n"); fwrite($fp, "{$attached_files}\n"); fwrite($fp, h5($section_subject) . "\n"); fwrite($fp, h5($section_content)); fclose($fp); $section_content_html = $this->org2html($section_subject, $section_content, $type_handle); $fp = fopen($full_content_path_name . 'html', "w"); if ($fp === FALSE) { return self::EC_FILE; } fwrite($fp, $section_content_html); fclose($fp); $block_type = BlockType::getByHandle("document_section"); $block = $page->addBlock($block_type, $area, array("domainHandle" => $domain_handle, "sectionID" => $content_file_name, "currentVerCode" => 0)); if (!$block instanceof Block) { return self::EC_ON_NEW_BLOCK; } $db = Loader::db(); $doc_lang = substr($project_id, -2); $query = "INSERT IGNORE fsen_document_sections_{$doc_lang} (id, author_id, page_id, area_handle, block_id,\n\t\tproject_id, domain_handle, volume_handle, part_handle, chapter_handle, create_time, update_time)\n\tVALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW())"; $res = $db->Execute($query, array($content_file_name, $author_id, $page_id, $area_handle, $block->getBlockID(), $project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle)); if ($db->Affected_Rows() == 0) { return self::EC_DATABASE; } /* purge the full page cache */ $page_cache = PageCache::getLibrary(); $page_cache->purge($page); return self::EC_OK; }
echo $section_notes[0]['nr_praise']; ?> </p> </div> <div class="col-md-11"> <?php $b = Block::getByID($section_notes[0]['block_id'], $c, $an); if ($b instanceof Block) { $b->display(); } ?> </div> </div> <!-- row --> <?php } $ar = Area::getOrCreate($c, 'References'); if ($nr_references > 0) { ?> <div class="row"> <div class="col-md-1"> <span class="glyphicon glyphicon-link big-glyph text-warning"></span> <p class="text-center text-warning lead"> <?php echo $section_references[0]['nr_praise']; ?> </p> </div> <div class="col-md-11"> <?php $b = Block::getByID($section_references[0]['block_id'], $c, $ar);
function updatePermissions($args = null) { $db = Loader::db(); if (!is_array($args)) { $args = $_POST; // legacy support } if ($args['cInheritPermissionsFrom'] == 'OVERRIDE') { // we're hitting manual override, which means we need to do permissions updates if ($this->getPermissionsCollectionID() != $this->cID) { // that means we're selecting override from some collection that _wasn't_ set to override // we have to grab the existing area permissions for that collection, then, clear out any // area permissions we might have (for some reason) and add them to this collection $this->acquireAreaPermissions($this->getPermissionsCollectionID()); } $v = array('OVERRIDE', $this->cID, $this->cID); $q = "update Pages set cInheritPermissionsFrom = ?, cInheritPermissionsFromCID = ? where cID = ?"; $r = $db->query($q, $v); $this->updateGroups($args); } else { // we're not overriding permissions so we don't do those updates if ($args['cInheritPermissionsFrom'] == 'PARENT') { $cpID = $this->getParentPermissionsCollectionID(); $this->updatePermissionsCollectionID($this->cID, $cpID); } else { if ($args['cInheritPermissionsFrom'] == 'TEMPLATE') { $cpID = $this->getMasterCollectionID(); $this->updatePermissionsCollectionID($this->cID, $cpID); } else { $cpID = $this->getCollectionID(); } } $v = array($args['cInheritPermissionsFrom'], $cpID, $this->cID); $q = "update Pages set cInheritPermissionsFrom = ?, cInheritPermissionsFromCID = ? where cID = ?"; $r = $db->query($q, $v); $this->cInheritPermissionsFrom = $args['cInheritPermissionsFrom']; $this->cInheritPermissionsFromCID = $cpID; // we do this because we may be going from a manual override to inheritance, and we don't // want any orphaned groups $this->clearGroups(); } $cOverrideTemplatePermissions = $args['cOverrideTemplatePermissions'] == 1 ? 1 : 0; $v = array($cOverrideTemplatePermissions, $this->cID); $q = "update Pages set cOverrideTemplatePermissions = ? where cID = ?"; $this->cOverrideTemplatePermissions = $cOverrideTemplatePermissions; $arHandles = $db->GetCol('select arHandle from Areas where cID = ?', $this->getCollectionID()); foreach ($arHandles as $arHandle) { $a = Area::getOrCreate($this, $arHandle); $a->rescanAreaPermissionsChain(); } $blocks = $this->getBlocks(); foreach ($blocks as $b) { $b->refreshCache(); } $db->query($q, $v); parent::refreshCache(); }
?> </ul> </div> <div class="panel-footer"> </div> </div> <?php } ?> </section> <!-- MainAfterword area: Flex columns --> <section class="container-fluid"> <div class="row row-md-flex row-md-flex-wrap"> <?php $a = Area::getOrCreate($c, 'MainAfterword'); $blocks = $c->getBlocks('MainAfterword'); foreach ($blocks as $block) { $block->display(); } ?> <section class="col-md-6 visible-on-edit-document-right alert alert-info alert-dismissible"> <button type="button" class="close" data-dismiss="alert"> <span aria-hidden="true">×</span> <span class="sr-only">Close</span> </button> <?php echo t('<strong>Tip: </strong>This is the afterword area (flex columns).'); ?> <a class="dialog-launch" title="<?php
public function rescanAreaPermissions() { $db = Loader::db(); $r = $db->Execute('select arHandle, arIsGlobal from Areas where cID = ?', $this->getCollectionID()); while ($row = $r->FetchRow()) { $a = Area::getOrCreate($this, $row['arHandle'], $row['arIsGlobal']); $a->rescanAreaPermissionsChain(); } }
<? foreach($items as $item) { if ($item instanceof CSSOutputObject) { ?> // we only support CSS here ccm_addHeaderItem("<?=$item->href?>", 'CSS'); <? } else if ($item instanceof JavaScriptOutputObject) { ?> ccm_addHeaderItem("<?=$item->href?>", 'JAVASCRIPT'); <? } } ?> </script> <? } if ($rarHandle) { $pagec = Page::getByID($_REQUEST['cID']); $a = Area::getOrCreate($pagec, $rarHandle); } $bv->renderElement('block_controls', array( 'a' => $a, 'b' => $b, 'p' => $bp )); $bv->renderElement('block_header', array( 'a' => $a, 'b' => $b, 'p' => $bp )); $bv->render($b); $bv->renderElement('block_footer'); }
public function rename_block(){ $valt = Loader::helper('validation/token'); if(!$valt->validate('rename_scrapbook_block')){ $this->set('error', array($valt->getErrorMessage())); $this->view(); return; } $bID=intval($_REQUEST['bID']); $globalScrapbookC=$this->getCollectionObject(); $scrapbookName = $_REQUEST['scrapbookName']; $globalScrapbookArea = Area::getOrCreate( $globalScrapbookC, $scrapbookName ); $block=Block::getById($bID, $globalScrapbookC, $globalScrapbookArea); if($block && strlen($_POST['bName']) ){ //&& $block->getAreaHandle()=='Global Scrapbook' //this is needed so the cache clears correctly $bp = new Permissions($block); if ($bp->canAdmin()) { $block->setBlockAreaObject($globalScrapbookArea); $block->updateBlockName( $_POST['bName'], 1 ); } } header('Location: ' . View::url('/dashboard/scrapbook', 'view') . '?scrapbookName=' . $scrapbookName); exit; }
public function display() { $c = Page::getCurrentPage(); parent::getOrCreate($c, $this->arHandle, 1); parent::display($c); }
$b = Block::getByID($_REQUEST['bID'], $c, $a); $p = new Permissions($b); if ($p->canWrite()) { $bi = $b->getInstance(); $e = $bi->validate($_POST); $obj = new stdClass(); $obj->aID = $a->getAreaID(); $obj->arHandle = $a->getAreaHandle(); $obj->cID = $c->getCollectionID(); $scrapbookHelper = Loader::helper('concrete/scrapbook'); $c1 = $scrapbookHelper->getGlobalScrapbookPage(); if ($c1->getCollectionID() == $c->getCollectionID()) { $obj->isGlobalBlock = true; $obj->cID = $_REQUEST['rcID']; $obj->arHandle = $_REQUEST['rarHandle']; $a1 = Area::getOrCreate(Page::getByID($obj->cID), $obj->arHandle); $obj->aID = $a1->getAreaID(); } else { $obj->isGlobalBlock = false; } if (!is_object($e) || $e instanceof ValidationErrorHelper && !$e->has()) { $bt = BlockType::getByHandle($b->getBlockTypeHandle()); if (!$bt->includeAll()) { // we make sure to create a new version, if necessary $nvc = $c->getVersionToModify(); } else { $nvc = $c; // keep the same one } $ob = $b; // replace the block with the version of the block in the later version (if applicable)
public function execute(Batch $batch) { $this->batch = $batch; $pages = $this->getPagesOrderedForImport($batch); if (!$pages) { return; } foreach ($pages as $page) { $concretePage = $this->getPageByPath($batch, $page->getBatchPath()); foreach ($page->attributes as $attribute) { $ak = $this->getTargetItem('attribute', $attribute->getAttribute()->getHandle()); if (is_object($ak)) { $value = $attribute->getAttribute()->getAttributeValue(); $publisher = $value->getPublisher(); $publisher->publish($ak, $concretePage, $value); } } $em = \ORM::entityManager("migration_tool"); $r = $em->getRepository('\\PortlandLabs\\Concrete5\\MigrationTool\\Entity\\ContentMapper\\TargetItem'); $controls = $r->findBy(array('item_type' => 'composer_output_content')); $controlHandles = array_map(function ($a) { return $a->getItemID(); }, $controls); $blockSubstitutes = array(); // Now we have our $controls array which we will use to determine if any of the blocks on this page // need to be replaced by another block. foreach ($page->areas as $area) { $styleSet = $area->getStyleSet(); if (is_object($styleSet)) { $styleSetPublisher = $styleSet->getPublisher(); $publishedStyleSet = $styleSetPublisher->publish(); $concreteArea = \Area::getOrCreate($concretePage, $area->getName()); $concretePage->setCustomStyleSet($concreteArea, $publishedStyleSet); } foreach ($area->blocks as $block) { $bt = $this->getTargetItem('block_type', $block->getType()); if (is_object($bt)) { $value = $block->getBlockValue(); $publisher = $value->getPublisher(); $b = $publisher->publish($batch, $bt, $concretePage, $area, $value); $styleSet = $block->getStyleSet(); if (is_object($styleSet)) { $styleSetPublisher = $styleSet->getPublisher(); $publishedStyleSet = $styleSetPublisher->publish(); $b->setCustomStyleSet($publishedStyleSet); } if ($block->getCustomTemplate()) { $b->setCustomTemplate($block->getCustomTemplate()); } if (in_array($bt->getBlockTypeHandle(), $controlHandles)) { $blockSubstitutes[$bt->getBlockTypeHandle()] = $b; } } } } // Loop through all the blocks on the page. If any of them are composer output content blocks // We look in our composer mapping. foreach ($concretePage->getBlocks() as $b) { if ($b->getBlockTypeHandle() == BLOCK_HANDLE_PAGE_TYPE_OUTPUT_PROXY) { foreach ($controls as $targetItem) { if ($targetItem->isMapped() && intval($targetItem->getSourceItemIdentifier()) == intval($b->getBlockID())) { $substitute = $blockSubstitutes[$targetItem->getItemID()]; if ($substitute) { // We move the substitute to where the proxy block was. $blockDisplayOrder = $b->getBlockDisplayOrder(); $substitute->setAbsoluteBlockDisplayOrder($blockDisplayOrder); $control = $b->getController()->getComposerOutputControlObject(); if (is_object($control)) { $control = FormLayoutSetControl::getByID($control->getPageTypeComposerFormLayoutSetControlID()); if (is_object($control)) { $blockControl = $control->getPageTypeComposerControlObject(); if (is_object($blockControl)) { $blockControl->recordPageTypeComposerOutputBlock($substitute); } } } } } } // we delete the proxy block $b->deleteBlock(); } } } }