Ejemplo n.º 1
0
function sendFormAction()
{
    if (empty($_POST['bID'])) {
        return error(t('Invalid form submission (missing bID)'));
    } else {
        $block = Block::getByID($_POST['bID']);
        $blockController = new FormController($block);
        $blockController->noSubmitFormRedirect = true;
        $redirectURL = '';
        // //Handle redirect-on-success...
        if ($blockController->redirectCID > 0) {
            $redirectPage = Page::getByID($blockController->redirectCID);
            if ($redirectPage->cID) {
                $redirectURL = Loader::helper('navigation')->getLinkToCollection($redirectPage, true);
            }
        }
        $blockController->redirectCID = 0;
        //reset this in block controller, otherwise it will exit before returning the data we need!
        try {
            $success = $blockController->action_submit_form($_POST['bID']);
            if ($success != null && $success == false) {
                return error(t('Invalid form submission (invalid block ids)'));
            }
        } catch (Exception $e) {
            return error($e->getMessage());
        }
        $fieldErrors = $blockController->get('errors');
        if (is_array($fieldErrors)) {
            foreach ($fieldErrors as $key => $value) {
                return error($fieldErrors[$key]);
            }
        }
        return success($blockController->thankyouMsg);
    }
}
Ejemplo n.º 2
0
		public function outputAutoHeaderItems() {
			$b = Block::getByID($this->bOriginalID);
			$bvt = new BlockViewTemplate($b);
			$headers = $bvt->getTemplateHeaderItems();
			if (count($headers) > 0) {
				foreach($headers as $h) {
					$this->addHeaderItem($h);
				}
			}
		}
Ejemplo n.º 3
0
 protected function validateBlock($b)
 {
     $bi = $b->getInstance();
     if ($b->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) {
         $_b = \Block::getByID($bi->getOriginalBlockID());
         $bi = $_b->getInstance();
         // for validation
     }
     $e = $bi->validate($_POST);
     return $e;
 }
 public function execute(ActionInterface $action)
 {
     $target = $action->getTarget();
     $subject = $action->getSubject();
     \Cache::disableAll();
     $c = Page::getByID($subject['cID']);
     $db = \Database::connection();
     if (is_object($c) && !$c->isError()) {
         $blocks = $c->getBlocks();
         $nvc = $c->getVersionToModify();
         $isApproved = $c->getVersionObject()->isApproved();
         foreach ($blocks as $b) {
             $controller = $b->getController();
             $pageColumns = $controller->getBlockTypeExportPageColumns();
             if (count($pageColumns)) {
                 $columns = $db->MetaColumnNames($controller->getBlockTypeDatabaseTable());
                 $data = array();
                 $record = $controller->getBlockControllerData();
                 foreach ($columns as $key) {
                     $data[$key] = $record->{$key};
                 }
                 foreach ($pageColumns as $column) {
                     $cID = $data[$column];
                     if ($cID > 0) {
                         $link = Page::getByID($cID, 'ACTIVE');
                         $section = $target->getSection();
                         if (is_object($section)) {
                             $relatedID = $section->getTranslatedPageID($link);
                             if ($relatedID) {
                                 $data[$column] = $relatedID;
                             }
                         }
                     }
                 }
                 unset($data['bID']);
                 $ob = $b;
                 // replace the block with the version of the block in the later version (if applicable)
                 $b2 = \Block::getByID($b->getBlockID(), $nvc, $b->getAreaHandle());
                 if ($b2->isAlias()) {
                     $nb = $ob->duplicate($nvc);
                     $b2->deleteBlock();
                     $b2 = clone $nb;
                 }
                 $b2->update($data);
             }
         }
         if ($isApproved) {
             $nvc->getVersionObject()->approve();
         }
     }
 }
Ejemplo n.º 5
0
 public function getBodyContentFromPage($c)
 {
     $searchableAreaNamesInitial = $this->getSavedSearchableAreas();
     foreach ($this->searchableAreaNamesManual as $sm) {
         $searchableAreaNamesInitial[] = $sm;
     }
     $searchableAreaNames = array();
     if ($this->getSearchableAreaAction() == 'blacklist') {
         $areas = Area::getHandleList();
         foreach ($areas as $arHandle) {
             if (!in_array($arHandle, $searchableAreaNamesInitial)) {
                 $searchableAreaNames[] = $arHandle;
             }
         }
     } else {
         $searchableAreaNames = $searchableAreaNamesInitial;
     }
     if (count($searchableAreaNames) == 0) {
         return false;
     }
     $text = '';
     $tagsToSpaces = array('<br>', '<br/>', '<br />', '<p>', '</p>', '</ p>', '<div>', '</div>', '</ div>', '&nbsp;');
     $blarray = array();
     $db = Loader::db();
     $r = $db->Execute('select bID, arHandle from CollectionVersionBlocks where cID = ? and cvID = ?', array($c->getCollectionID(), $c->getVersionID()));
     $th = Loader::helper('text');
     while ($row = $r->FetchRow()) {
         if (in_array($row['arHandle'], $searchableAreaNames)) {
             $b = Block::getByID($row['bID'], $c, $row['arHandle']);
             if (!is_object($b)) {
                 continue;
             }
             $bi = $b->getInstance();
             $bi->bActionCID = $c->getCollectionID();
             if (method_exists($bi, 'getSearchableContent')) {
                 $searchableContent = $bi->getSearchableContent();
                 if (strlen(trim($searchableContent))) {
                     $text .= $th->decodeEntities(strip_tags(str_ireplace($tagsToSpaces, ' ', $searchableContent)), ENT_QUOTES, APP_CHARSET) . ' ';
                 }
             }
             unset($b);
             unset($bi);
         }
     }
     $returned_text = Events::fire('on_page_body_index', $c, $text);
     if ($returned_text !== null && $returned_text !== false) {
         $text = $returned_text;
     }
     return $text;
 }
Ejemplo n.º 6
0
 public function edit($cID, $arHandle, $bID, $action)
 {
     $c = \Page::getByID($cID);
     if (is_object($c) && !$c->isError()) {
         $b = \Block::getByID($bID, $c, $arHandle);
         if (is_object($b)) {
             $controller = $b->getController();
             if ($controller->validateEditBlockPassThruAction($b)) {
                 return $this->deliverResponse($controller, $action);
             }
         }
     }
     $response = new Response(t('Access Denied'));
     return $response;
 }
Ejemplo n.º 7
0
 public function edit($cID, $arHandle, $bID, $action)
 {
     $c = \Page::getByID($cID);
     if (is_object($c) && !$c->isError()) {
         $b = \Block::getByID($bID, $c, $arHandle);
         if (is_object($b)) {
             $bp = new \Permissions($b);
             if ($bp->canEditBlock()) {
                 $controller = $b->getController();
                 return $this->deliverResponse($controller, $action);
             }
         }
     }
     $response = new Response(t('Access Denied'));
     return $response;
 }
Ejemplo n.º 8
0
 public function submit()
 {
     if ($this->validateAction() && $this->canAccess()) {
         $a = \Area::get($this->page, $_GET['arHandle']);
         $c = $this->page;
         if (is_object($a)) {
             $b = \Block::getByID($_GET['bID'], $c, $a);
             $p = new \Permissions($b);
             if ($p->canAdminBlock() && $c->isMasterCollection()) {
                 if (is_array($_POST['cIDs'])) {
                     foreach ($_POST['cIDs'] as $cID) {
                         $nc = \Page::getByID($cID);
                         if (!$b->isAlias($nc)) {
                             $bt = $b->getBlockTypeObject();
                             if ($bt->isCopiedWhenPropagated()) {
                                 $b->duplicate($nc, true);
                             } else {
                                 $b->alias($nc);
                             }
                         }
                     }
                 }
                 // now remove any items that WERE checked and now aren't
                 if (is_array($_POST['checkedCIDs'])) {
                     foreach ($_POST['checkedCIDs'] as $cID) {
                         if (!is_array($_POST['cIDs']) || !in_array($cID, $_POST['cIDs'])) {
                             $nc = \Page::getByID($cID, 'RECENT');
                             $nb = \Block::getByID($_GET['bID'], $nc, $a);
                             if (is_object($nb) && !$nb->isError()) {
                                 $nb->deleteBlock();
                             }
                             $nc->rescanDisplayOrder($_REQUEST['arHandle']);
                         }
                     }
                 }
                 $er = new EditResponse();
                 $er->setPage($this->page);
                 $er->setAdditionalDataAttribute('bID', $b->getBlockID());
                 $er->setAdditionalDataAttribute('aID', $a->getAreaID());
                 $er->setAdditionalDataAttribute('arHandle', $a->getAreaHandle());
                 $er->setMessage(t('Defaults updated.'));
                 $er->outputJSON();
             }
         }
     }
 }
Ejemplo n.º 9
0
 public function testPageStylesBlock()
 {
     $ps = new \Concrete\Core\StyleCustomizer\Inline\StyleSet();
     $ps->setBackgroundColor('#aaa');
     $ps->save();
     $c = $this->createPage('This is my test page');
     $bt = BlockType::installBlockType('content');
     $b = $c->addBlock($bt, 'Main', array('content' => 'Sample content.'));
     $b->setCustomStyleSet($ps);
     $this->assertEquals(1, $b->getCustomStyleSetID());
     $b2 = Block::getByID(1, $c, 'Main');
     $this->assertEquals(1, $b2->getBlockID());
     $style = $b2->getCustomStyle();
     $this->assertInstanceOf('\\Concrete\\Core\\Block\\CustomStyle', $style);
     $b2->resetCustomStyle();
     $css = $style->getCSS();
     $this->assertEquals('ccm-custom-style-container ccm-custom-style-main-1', $style->getContainerClass());
     $this->assertEquals('.ccm-custom-style-container.ccm-custom-style-main-1{background-color:#aaa}', $css);
 }
 public function execute(ActionInterface $action)
 {
     $target = $action->getTarget();
     $subject = $action->getSubject();
     \Cache::disableAll();
     $c = Page::getByID($subject['cID']);
     if (is_object($c) && !$c->isError()) {
         $blocks = $c->getBlocks();
         $nvc = $c->getVersionToModify();
         $isApproved = $c->getVersionObject()->isApproved();
         foreach ($blocks as $b) {
             if ($b->getBlockTypeHandle() == 'content') {
                 $content = $b->getController()->content;
                 $content = preg_replace_callback('/{CCM:CID_([0-9]+)}/i', function ($matches) use($subject, $target) {
                     $cID = $matches[1];
                     if ($cID > 0) {
                         $link = Page::getByID($cID, 'ACTIVE');
                         $section = $target->getSection();
                         if (is_object($section)) {
                             $relatedID = $section->getTranslatedPageID($link);
                             if ($relatedID) {
                                 return sprintf('{CCM:CID_%s}', $relatedID);
                             }
                         }
                     }
                 }, $content);
                 $ob = $b;
                 // replace the block with the version of the block in the later version (if applicable)
                 $b2 = \Block::getByID($b->getBlockID(), $nvc, $b->getAreaHandle());
                 if ($b2->isAlias()) {
                     $nb = $ob->duplicate($nvc);
                     $b2->deleteBlock();
                     $b2 = clone $nb;
                 }
                 $data = array('content' => $content);
                 $b2->update($data);
             }
         }
         if ($isApproved) {
             $nvc->getVersionObject()->approve();
         }
     }
 }
 protected function purgeOrphanedScrapbooksBlocks()
 {
     $db = \Database::connection();
     $orphanedCollectionVersionBlocks = $db->fetchAll('
         select cID, cvID, cvb.bID, arHandle
         from CollectionVersionBlocks cvb
             inner join btCoreScrapbookDisplay btCSD on cvb.bID = btCSD.bID
             inner join Blocks b on b.bID = btCSD.bOriginalID
             left join BlockTypes bt on b.btID = bt.btID
         where bt.btID IS NULL', array());
     foreach ($orphanedCollectionVersionBlocks as $row) {
         $nc = \Page::getByID($row['cID'], $row['cvID']);
         if (!is_object($nc) || $nc->isError()) {
             continue;
         }
         $b = \Block::getByID($row['bID'], $nc, $row['arHandle']);
         if (is_object($b)) {
             $b->deleteBlock();
         }
     }
 }
Ejemplo n.º 12
0
 public function submit_all()
 {
     if ($this->validateAction()) {
         if ($this->permissions->canDeleteBlock() && $this->page->isMasterCollection()) {
             $name = sprintf('delete_block_%s', $this->block->getBlockID());
             $queue = \Queue::get($name);
             if ($_POST['process']) {
                 $obj = new \stdClass();
                 $messages = $queue->receive(20);
                 foreach ($messages as $key => $p) {
                     $block = unserialize($p->body);
                     $page = \Page::getByID($block['cID'], $block['cvID']);
                     $b = \Block::getByID($block['bID'], $page, $block['arHandle']);
                     if (is_object($b) && !$b->isError()) {
                         $b->deleteBlock();
                     }
                     $queue->deleteMessage($p);
                 }
                 $obj->totalItems = $queue->count();
                 if ($queue->count() == 0) {
                     $queue->deleteQueue($name);
                 }
                 $obj->bID = $this->block->getBlockID();
                 $obj->aID = $this->area->getAreaID();
                 $obj->message = t('All child blocks deleted successfully.');
                 echo json_encode($obj);
                 $this->app->shutdown();
             } else {
                 $queue = $this->block->queueForDefaultsUpdate($_POST, $queue);
             }
             $totalItems = $queue->count();
             \View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d block", "%d blocks", $totalItems)));
             $this->app->shutdown();
         }
     }
 }
Ejemplo n.º 13
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
//Permissions Check
$nh = Loader::helper('validation/numbers');
if ($_GET['bID'] && $_GET['cID'] && $nh->integer($_GET['bID']) && $nh->integer($_GET['cID'])) {
    $c = Page::getByID($_GET['cID']);
    if (is_object($c) && !$c->isError()) {
        $a = Area::get($c, $_GET['arHandle']);
        //edit survey mode
        $b = Block::getByID($_GET['bID'], $c, $a);
        if ($b->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) {
            $cnt = $b->getController();
            $b = Block::getByID($cnt->getOriginalBlockID());
        }
        $controller = new PageListBlockController($b);
        $rssUrl = $controller->getRssUrl($b);
        $bp = new Permissions($b);
        if ($bp->canViewBlock() && $controller->rss) {
            $cArray = $controller->getPages();
            $nh = Loader::helper('navigation');
            header('Content-type: text/xml');
            echo "<" . "?" . "xml version=\"1.0\"?>\n";
            ?>
			<rss version="2.0">
			  <channel>
				<title><?php 
            echo $controller->rssTitle;
            ?>
</title>
				<link><?php 
Ejemplo n.º 14
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
$area = $b->getBlockAreaObject();
$_bx = Block::getByID($bOriginalID);
if (is_object($_bx)) {
    $_bx->setBlockAreaObject($area);
    $c = Page::getCurrentPage();
    $_bx->setProxyBlock($b);
    $_bx->loadNewCollection($c);
    $bv = new \Concrete\Core\Block\View\BlockView($_bx);
    $bv->setController($controller->getScrapbookBlockController());
    $bv->disableControls();
    $bv->render('view');
}
Ejemplo n.º 15
0
                     $b->alias($nvc);
                 } else {
                     $b->alias($c);
                 }
             }
         }
     }
 } else {
     if (isset($_REQUEST['bID'])) {
         if ($_REQUEST['globalBlock']) {
             $scrapbookHelper = Loader::helper('concrete/scrapbook');
             $c1 = $scrapbookHelper->getGlobalScrapbookPage();
             $a1 = Area::get($c1, $_REQUEST['globalScrapbook']);
             $b = Block::getByID($_REQUEST['bID'], $c1, $a1);
         } else {
             $b = Block::getByID($_REQUEST['bID']);
         }
         $bt = BlockType::getByHandle($b->getBlockTypeHandle());
         if ($ap->canAddBlock($bt)) {
             $b->setBlockAreaObject($a);
             if (!$bt->includeAll()) {
                 $nvc = $c->getVersionToModify();
                 $b->alias($nvc);
             } else {
                 $b->alias($c);
             }
         }
     }
 }
 $obj = new stdClass();
 $obj->aID = $a->getAreaID();
Ejemplo n.º 16
0
 $class .= $b->isAliasOfMasterCollection() || $b->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY ? " ccm-block-alias" : "";
 if ($b->getBlockTypeHandle() == BLOCK_HANDLE_STACK_PROXY) {
     $class .= ' ccm-block-stack ';
 }
 $editInline = false;
 if ($btw->supportsInlineEdit()) {
     $editInline = true;
 }
 $btOriginal = $btw;
 $bID = $b->getBlockID();
 $aID = $a->getAreaID();
 $heightPlus = 20;
 $btHandle = $btw->getBlockTypeHandle();
 if ($btw->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) {
     $_bi = $b->getInstance();
     $_bo = Block::getByID($_bi->getOriginalBlockID());
     $btOriginal = BlockType::getByHandle($_bo->getBlockTypeHandle());
     $btHandle = $btOriginal->getBlockTypeHandle();
     $heightPlus = 80;
     if ($btOriginal->supportsInlineEdit()) {
         $editInline = true;
     }
 }
 $canDesign = $p->canEditBlockDesign() && Config::get('concrete.design.enable_custom') == true;
 $canModifyGroups = $p->canEditBlockPermissions() && Config::get('concrete.permissions.model') != 'simple' && !$a->isGlobalArea();
 $canEditName = $p->canEditBlockName();
 $canEditCacheSettings = $p->canEditBlockCacheSettings();
 $canEditCustomTemplate = $p->canEditBlockCustomTemplate();
 $canScheduleGuestAccess = Config::get('concrete.permissions.model') != 'simple' && $p->canGuestsViewThisBlock() && $p->canScheduleGuestAccess() && !$a->isGlobalArea();
 $canAliasBlockOut = $c->isMasterCollection() && !$a->isGlobalArea();
 if ($canAliasBlockOut) {
Ejemplo n.º 17
0
 function getObject()
 {
     switch ($this->getItemType()) {
         case "COLLECTION":
             $obj = Page::getByID($this->getItemID(), "ACTIVE");
             break;
         case "BLOCK":
             $obj = Block::getByID($this->getItemID());
             break;
     }
     return $obj;
 }
Ejemplo n.º 18
0
 public function setBlockCustomStyle($csr, $updateAll = false)
 {
     $db = Loader::db();
     $c = $this->getBlockCollectionObject();
     $cvID = $c->getVersionID();
     if ($updateAll) {
         $r = $db->Execute('select cID, cvID, bID, arHandle from CollectionVersionBlocks where bID = ?', array($this->bID));
         while ($row = $r->FetchRow()) {
             $c1 = Page::getByID($row['cID'], $row['cvID']);
             $b1 = Block::getByID($row['bID'], $c1, $row['arHandle']);
             $b1->setBlockCustomStyle($csr, false);
         }
     } else {
         $db->Replace('CollectionVersionBlockStyles', array('cID' => $this->getBlockCollectionID(), 'cvID' => $cvID, 'arHandle' => $this->getAreaHandle(), 'bID' => $this->bID, 'csrID' => $csr->getCustomStyleRuleID()), array('cID', 'cvID', 'bID', 'arHandle'), true);
         $this->refreshCache();
     }
 }
Ejemplo n.º 19
0
><?php 
    echo t('Cancel');
    ?>
</a>
	</div>
<?php 
}
?>

	<input type="hidden" name="update" value="1" />
	<input type="hidden" name="rcID" value="<?php 
echo $rcID;
?>
" />
	<input type="submit" name="ccm-edit-block-submit" value="submit" style="display: none" id="ccm-form-submit-button" />
	<input type="hidden" name="processBlock" value="1">

	</form>


<?php 
$cont = $bt->getController();
if ($b->getBlockTypeHandle() == BLOCK_HANDLE_SCRAPBOOK_PROXY) {
    $bx = Block::getByID($b->getController()->getOriginalBlockID());
    $cont = $bx->getController();
}
if ($cont->getBlockTypeWrapperClass() != '') {
    ?>
</div>
<?php 
}
Ejemplo n.º 20
0
	function deleteBlock($forceDelete = false) {
		$db = Loader::db();
					
		if ($this->bID < 1) {
			return false;
		}

		$this->refreshCache();

		$cID = $this->cID;
		$c = $this->getBlockCollectionObject();
		$cvID = $c->getVersionID();
		$bID = $this->bID;
		$arHandle = $this->arHandle;

		// if this block is located in a master collection, we're going to delete all the instances of the block,
		// regardless
		if (($c instanceof Page && $c->isMasterCollection() && !$this->isAlias()) || $forceDelete) {
			// forceDelete is used by the administration console

			$r = $db->Execute('select cID, cvID from CollectionVersionBlocks where bID = ?', array($bID));
			while ($row = $r->FetchRow()) {
				Cache::delete('collection_blocks', $row['cID'] . ':' . $row['cvID']);
			}

			// this is an original. We're deleting it, and everything else having to do with it
			$q = "delete from CollectionVersionBlocks where bID = '$bID'";
			$r = $db->query($q);

			$q = "delete from ComposerContentLayout where bID = '$bID'";
			$r = $db->query($q);

			$q = "delete from BlockPermissionAssignments where bID = '$bID'";
			$r = $db->query($q);
			
			$q = "delete from CollectionVersionBlockStyles where bID = ".intval($bID);
			$r = $db->query($q);
			
		} else {
			$q = "delete from CollectionVersionBlocks where cID = '$cID' and (cvID = '$cvID' or cbIncludeAll=1) and bID = '$bID' and arHandle = '$arHandle'";
			$r = $db->query($q);

			// next, we delete the groups instance of this block
			$q = "delete from BlockPermissionAssignments where bID = '$bID' and cvID = '$cvID' and cID = '$cID'";
			$r = $db->query($q);
			
			$q = "delete from CollectionVersionBlockStyles where cID = '$cID' and cvID = '$cvID' and bID = '$bID' and arHandle = '$arHandle'";
			$r = $db->query($q);				
		}

		//then, we see whether or not this block is aliased to anything else
		$q = "select count(*) as total from CollectionVersionBlocks where bID = '$bID'";
		$totalBlocks = $db->getOne($q);
		if ($totalBlocks < 1) {
			$q = "delete from BlockRelations where originalBID = ? or bID = ?";
			$r = $db->query($q, array($this->bID, $this->bID));
			// this block is not referenced in the system any longer, so we delete the entry in the blocks table, as well as the entries in the corresponding
			// sub-blocks table

			$v = array($this->bID);

			// so, first we delete the block's sub content				
			$bt = BlockType::getByID($this->getBlockTypeID());
			if( $bt && method_exists($bt,'getBlockTypeClass') ){
				$class = $bt->getBlockTypeClass();
				
				$bc = new $class($this);
				$bc->delete();
			}

			// now that the block's subcontent delete() method has been run, we delete the block from the Blocks table
			$q = "delete from Blocks where bID = ?";
			$r = $db->query($q, $v);
			
			// Aaaand then we delete all scrapbooked blocks to this entry
			$r = $db->Execute('select cID, cvID, CollectionVersionBlocks.bID, arHandle from CollectionVersionBlocks inner join btCoreScrapbookDisplay on CollectionVersionBlocks.bID = btCoreScrapbookDisplay.bID where bOriginalID = ?', array($bID));
			while ($row = $r->FetchRow()) {
				$c = Page::getByID($row['cID'], $row['cvID']);
				$b = Block::getByID($row['bID'], $c, $row['arHandle']);
				$b->delete();
			}
			

		}
	}
Ejemplo n.º 21
0
            }
            break;
        case 'output':
            $p = $_REQUEST['pID'] ? Pile::get($_REQUEST['pID']) : Pile::getDefault();
            if (is_object($p)) {
                if ($p->isMyPile()) {
                    $p->output($_REQUEST['module']);
                    exit;
                }
            }
            break;
    }
}
if ($_REQUEST['btask'] == 'add') {
    $a = Area::get($c, $_REQUEST['arHandle']);
    $b = Block::getByID($_REQUEST['bID'], $c, $a);
    if (!$a) {
        echo t('Error: Area not found.');
    } elseif (!intval($b->bID)) {
        echo t('Error: Block not found.');
    } elseif (!$_REQUEST['scrapbookName'] && $_REQUEST['btask'] == 'add') {
        $sp = Pile::getDefault();
        $scrapBookAreasData = $scrapbookHelper->getAvailableScrapbooks();
        $ih = Loader::helper('concrete/interface');
        $defaultScrapbook = $scrapbookHelper->getDefault();
        ?>
		
		<script type="text/javascript">
		if(!ccmSaveToScrapbookDialogTarget)
			var ccmSaveToScrapbookDialogTarget=null;
			
Ejemplo n.º 22
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
//Permissions Check
if ($_GET['bID']) {
    $c = Page::getByID($_GET['cID']);
    $a = Area::get($c, $_GET['arHandle']);
    //edit survey mode
    $b = Block::getByID($_GET['bID'], $c, $a);
    $controller = new PageListBlockController($b);
    $rssUrl = $controller->getRssUrl($b);
    $bp = new Permissions($b);
    if ($bp->canViewBlock() && $controller->rss) {
        $cArray = $controller->getPages();
        $nh = Loader::helper('navigation');
        header('Content-type: text/xml');
        echo "<?php xml version=\"1.0\"?>\n";
        ?>
		<rss version="2.0">
		  <channel>
			<title><?php 
        echo $controller->rssTitle;
        ?>
</title>
			<link><?php 
        echo BASE_URL . DIR_REL . htmlspecialchars($rssUrl);
        ?>
</link>
			<description><?php 
        echo $controller->rssDescription;
        ?>
Ejemplo n.º 23
0
 function _associateMasterCollectionBlocks($newCID, $masterCID)
 {
     $mc = Page::getByID($masterCID, 'ACTIVE');
     $nc = Page::getByID($newCID, 'RECENT');
     $db = Loader::db();
     $mcID = $mc->getCollectionID();
     $mcvID = $mc->getVersionID();
     $q = "select CollectionVersionBlocks.arHandle, BlockTypes.btCopyWhenPropagate, CollectionVersionBlocks.cbOverrideAreaPermissions, CollectionVersionBlocks.bID from CollectionVersionBlocks inner join Blocks on Blocks.bID = CollectionVersionBlocks.bID inner join BlockTypes on Blocks.btID = BlockTypes.btID where CollectionVersionBlocks.cID = '{$mcID}' and CollectionVersionBlocks.cvID = '{$mcvID}' order by CollectionVersionBlocks.cbDisplayOrder asc";
     // ok. This function takes two IDs, the ID of the newly created virgin collection, and the ID of the crusty master collection
     // who will impart his wisdom to the his young learner, by duplicating his various blocks, as well as their permissions, for the
     // new collection
     //$q = "select CollectionBlocks.cbAreaName, Blocks.bID, Blocks.bName, Blocks.bFilename, Blocks.btID, Blocks.uID, BlockTypes.btClassname, BlockTypes.btTablename from CollectionBlocks left join BlockTypes on (Blocks.btID = BlockTypes.btID) inner join Blocks on (CollectionBlocks.bID = Blocks.bID) where CollectionBlocks.cID = '$masterCID' order by CollectionBlocks.cbDisplayOrder asc";
     //$q = "select CollectionVersionBlocks.cbAreaName, Blocks.bID, Blocks.bName, Blocks.bFilename, Blocks.btID, Blocks.uID, BlockTypes.btClassname, BlockTypes.btTablename from CollectionBlocks left join BlockTypes on (Blocks.btID = BlockTypes.btID) inner join Blocks on (CollectionBlocks.bID = Blocks.bID) where CollectionBlocks.cID = '$masterCID' order by CollectionBlocks.cbDisplayOrder asc";
     $r = $db->query($q);
     if ($r) {
         while ($row = $r->fetchRow()) {
             $b = Block::getByID($row['bID'], $mc, $row['arHandle']);
             if ($row['btCopyWhenPropagate']) {
                 $b->duplicate($nc);
             } else {
                 $b->alias($nc);
             }
         }
         $r->free();
     }
 }
Ejemplo n.º 24
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
use Concrete\Core\Conversation\Message\Message as ConversationMessage;
$ax = Loader::helper('ajax');
$vs = Loader::helper('validation/strings');
$ve = Loader::helper('validation/error');
$as = Loader::helper('validation/antispam');
$pageObj = Page::getByID($_POST['cID']);
$areaObj = Area::get($pageObj, $_POST['blockAreaHandle']);
$blockObj = Block::getByID($_POST['bID'], $pageObj, $areaObj);
$form = Loader::helper('form');
$u = new User();
$ui = UserInfo::getByID($u->getUserID());
$val = Loader::helper('validation/token');
if (Loader::helper('validation/numbers')->integer($_POST['cnvMessageID']) && $_POST['cnvMessageID'] > 0) {
    $message = ConversationMessage::getByID($_POST['cnvMessageID']);
    if (is_object($message)) {
        $mp = new Permissions($message);
        if ($mp->canEditConversationMessage()) {
            $editor = \Concrete\Core\Conversation\Editor\Editor::getByID($message->getConversationEditorID());
            $editor->setConversationMessageObject($message);
            if (is_object($conversation)) {
                if ($conversation->getConversationAttachmentOverridesEnabled() > 0) {
                    $attachmentsEnabled = $conversation->getConversationAttachmentsEnabled();
                } else {
                    $attachmentsEnabled = Config::get('conversations.attachments_enabled');
                }
            }
            ?>
Ejemplo n.º 25
0
 public function getComposerContentItems()
 {
     $db = Loader::db();
     $r = $db->Execute('select bID, akID, ccFilename from ComposerContentLayout where ctID = ? order by displayOrder asc', array($this->ctID));
     $items = array();
     while ($row = $r->FetchRow()) {
         if ($row['akID'] > 0) {
             $obj = CollectionAttributeKey::getByID($row['akID']);
             if (is_object($obj)) {
                 $items[] = $obj;
             }
         } else {
             if ($row['bID'] > 0) {
                 $b = Block::getByID($row['bID']);
                 if (is_object($b)) {
                     $items[] = $b;
                 }
             }
         }
     }
     return $items;
 }
Ejemplo n.º 26
0
 public function getComposerBlockInstance($b)
 {
     // this gets a master collection block and finds the current block in the current entry that matches it, complete with area name, etc...
     $db = Loader::db();
     // is the block in the current page with the current id ?
     $arHandle = $db->getOne('select arHandle from CollectionVersionBlocks where cID = ? and cvID = ? and bID = ?', array($this->getCollectionID(), $this->getVersionID(), $b->getBlockID()));
     if (!$arHandle) {
         $tempBID = $b->getBlockID();
         while ($tempBID != false) {
             $bID = $tempBID;
             $tempBID = $db->GetOne('select distinct br.bID from BlockRelations br inner join CollectionVersionBlocks cvb on cvb.bID = br.bID where br.originalBID = ? and cvb.cID = ?', array($bID, $this->getCollectionID()));
         }
         $arHandle = $db->getOne('select arHandle from CollectionVersionBlocks where cID = ? and cvID = ? and bID = ?', array($this->getCollectionID(), $this->getVersionID(), $bID));
     } else {
         $bID = $b->getBlockID();
     }
     if ($arHandle) {
         $c = Page::getByID($this->getCollectionID(), $this->getVersionID());
         $b = Block::getByID($bID, $c, $arHandle);
         return $b;
     }
 }
                <th class="col-sm-5"><?php 
        echo t('Form');
        ?>
</th>
                <th><?php 
        echo t('Submissions');
        ?>
</th>
                <th></th>
            </tr>
            </thead>
            <tbody>

            <?php 
        foreach ($surveys as $qsid => $survey) {
            $block = Block::getByID(intval($survey['bID'], 10));
            if (!is_object($block)) {
                continue;
            }
            $in_use = (int) $db->getOne('SELECT count(*)
                                FROM CollectionVersionBlocks
                                INNER JOIN Pages
                                ON CollectionVersionBlocks.cID = Pages.cID
                                INNER JOIN CollectionVersions
                                ON CollectionVersions.cID = Pages.cID
                                WHERE CollectionVersions.cvIsApproved = 1
                                AND CollectionVersionBlocks.cvID = CollectionVersions.cvID
                                AND CollectionVersionBlocks.bID = ?', array($block->bID));
            $url = $nh->getLinkToCollection($block->getBlockCollectionObject());
            ?>
                <tr>
Ejemplo n.º 28
0
 /**
  * Gets the generic Block object attached to this controller's instance
  * @return Block $b
  */
 public function getBlockObject()
 {
     if (is_object($this->block)) {
         return $this->block;
     }
     return Block::getByID($this->bID);
 }
Ejemplo n.º 29
0
    public function getAllTimedAssignmentsForPage()
    {
        $db = Loader::db();
        $assignments = array();
        $r = $db->Execute('select peID, pkID, pdID from PagePermissionAssignments ppa inner join PermissionAccessList pal on ppa.paID = pal.paID where pdID > 0 and cID = ?', array($this->object->getCollectionID()));
        while ($row = $r->FetchRow()) {
            $pk = PagePermissionKey::getByID($row['pkID']);
            $pae = PermissionAccessEntity::getByID($row['peID']);
            $pd = PermissionDuration::getByID($row['pdID']);
            $ppc = new PageContentPermissionTimedAssignment();
            $ppc->setDurationObject($pd);
            $ppc->setAccessEntityObject($pae);
            $ppc->setPermissionKeyObject($pk);
            $assignments[] = $ppc;
        }
        $r = $db->Execute('select arHandle from Areas where cID = ? and arOverrideCollectionPermissions = 1', array($this->object->getCollectionID()));
        while ($row = $r->FetchRow()) {
            $r2 = $db->Execute('select peID, pdID, pkID from AreaPermissionAssignments apa inner join PermissionAccessList pal on apa.paID = pal.paID where pdID > 0 and cID = ? and arHandle = ?', array($this->object->getCollectionID(), $row['arHandle']));
            while ($row2 = $r2->FetchRow()) {
                $pk = AreaPermissionKey::getByID($row2['pkID']);
                $pae = PermissionAccessEntity::getByID($row2['peID']);
                $area = Area::get($this->getPermissionObject(), $row['arHandle']);
                $pk->setPermissionObject($area);
                $pd = PermissionDuration::getByID($row2['pdID']);
                $ppc = new PageContentPermissionTimedAssignment();
                $ppc->setDurationObject($pd);
                $ppc->setAccessEntityObject($pae);
                $ppc->setPermissionKeyObject($pk);
                $assignments[] = $ppc;
            }
        }
        $r = $db->Execute('select peID, cvb.cvID, cvb.bID, pdID, pkID from BlockPermissionAssignments bpa
		inner join PermissionAccessList pal on bpa.paID = pal.paID inner join CollectionVersionBlocks cvb on cvb.cID = bpa.cID and cvb.cvID = bpa.cvID and cvb.bID = bpa.bID
		where pdID > 0 and cvb.cID = ? and cvb.cvID = ? and cvb.cbOverrideAreaPermissions = 1', array($this->object->getCollectionID(), $this->object->getVersionID()));
        while ($row = $r->FetchRow()) {
            $pk = BlockPermissionKey::getByID($row['pkID']);
            $pae = PermissionAccessEntity::getByID($row['peID']);
            $arHandle = $db->GetOne('select arHandle from CollectionVersionBlocks where bID = ? and cvID = ? and cID = ?', array($row['bID'], $row['cvID'], $this->object->getCollectionID()));
            $b = Block::getByID($row['bID'], $this->object, $arHandle);
            $pk->setPermissionObject($b);
            $pd = PermissionDuration::getByID($row['pdID']);
            $ppc = new PageContentPermissionTimedAssignment();
            $ppc->setDurationObject($pd);
            $ppc->setAccessEntityObject($pae);
            $ppc->setPermissionKeyObject($pk);
            $assignments[] = $ppc;
        }
        return $assignments;
    }
Ejemplo n.º 30
0
    protected function migrateBlockPermissions()
    {
        if (PERMISSIONS_MODEL == 'simple') {
            return;
        }
        $db = Loader::db();
        $tables = $db->MetaTables();
        if (!in_array('CollectionVersionBlockPermissions', $tables)) {
            return false;
        }
        // permissions
        $permissionMap = array('r' => array(PermissionKey::getByHandle('view_block')), 'wa' => array(PermissionKey::getByHandle('edit_block'), PermissionKey::getByHandle('edit_block_custom_template'), PermissionKey::getByHandle('edit_block_design')), 'db' => array(PermissionKey::getByHandle('delete_block'), PermissionKey::getByHandle('schedule_guest_access'), PermissionKey::getByHandle('edit_block_permissions')));
        $r = $db->Execute('select * from CollectionVersionBlockPermissions order by cID asc');
        while ($row = $r->FetchRow()) {
            $pe = $this->migrateAccessEntity($row);
            if (!$pe) {
                continue;
            }
            $permissions = $this->getPermissionsArray($row['cbgPermissions']);
            $co = Page::getByID($row['cID'], $row['cvID']);
            if (!is_object($co) || $co->isError()) {
                continue;
            }
            $arHandle = $db->GetOne('select arHandle from CollectionVersionBlocks cvb where cvb.cID = ? and 
				cvb.cvID = ? and cvb.bID = ?', array($row['cID'], $row['cvID'], $row['bID']));
            $a = Area::get($co, $arHandle);
            $bo = Block::getByID($row['bID'], $co, $a);
            if (is_object($bo)) {
                foreach ($permissions as $p) {
                    $permissionsToApply = $permissionMap[$p];
                    foreach ($permissionsToApply as $pko) {
                        $pko->setPermissionObject($bo);
                        $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, BlockPermissionKey::ACCESS_TYPE_INCLUDE);
                        $pt->assignPermissionAccess($pa);
                    }
                }
            }
        }
    }