function loadVersionObject($cvID = "ACTIVE") { $cvID = CollectionVersion::getNumericalVersionID($this->getCollectionID(), $cvID); $this->vObj = CollectionVersion::get($this, $cvID); $vp = new Permissions($this->vObj); return $vp; }
public function testPageUpdateSubpagePaths() { $about = self::createPage('About'); $me = self::createPage('Me', $about); foreach (array('Interests', 'Social', 'Foo', 'Other', 'Page') as $name) { self::createPage($name, $me); } $foo = Page::getByPath('/about/me/foo'); self::createPage('Bar', $foo); $social = Page::getByPath('/about/me/social'); $this->assertFalse($social->isError()); $this->assertEquals(5, $social->getCollectionID()); $nvc = $me->getVersionToModify(); $this->assertEquals(2, $nvc->getVersionID()); $nvc->update(array("cHandle" => 'about-me')); $test = Page::getByPath('/about/me'); $this->assertFalse($test->isError()); $this->assertEquals(3, $test->getCollectionID()); $this->assertEquals('/about/me', $test->getCollectionPath()); $v = CollectionVersion::get($nvc, $nvc->getVersionID()); $v->approve(false); $test = Page::getByPath('/about/me'); $this->assertEquals(COLLECTION_NOT_FOUND, $test->isError()); $test = Page::getByPath('/about/about-me'); $this->assertFalse($test->isError()); $this->assertEquals('/about/about-me', $test->getCollectionPath()); $subpage = Page::getByPath('/about/about-me/foo/bar'); $this->assertFalse($subpage->isError()); $this->assertEquals('/about/about-me/foo/bar', $subpage->getCollectionPath()); }
public function approve(WorkflowProgress $wp) { $c = Page::getByID($this->getRequestedPageID()); $v = CollectionVersion::get($c, $this->cvID); $v->approve(false); $wpr = new WorkflowProgressResponse(); $wpr->setWorkflowProgressResponseURL(BASE_URL . DIR_REL . '/' . DISPATCHER_FILENAME . '?cID=' . $c->getCollectionID()); return $wpr; }
public function approve(WorkflowProgress $wp) { $s = Stack::getByID($this->getRequestedPageID()); $v = CollectionVersion::get($s, $this->cvID); $v->approve(false); if ($s->getStackName() != $v->getVersionName()) { // The stack name has changed so we need to // update that for the stack object as well. $s->update(array('stackName' => $v->getVersionName())); } Events::fire('on_page_version_submit_approve', $s); $wpr = new WorkflowProgressResponse(); $wpr->setWorkflowProgressResponseURL(BASE_URL . DIR_REL . '/' . DISPATCHER_FILENAME . '?cID=' . $s->getCollectionID()); return $wpr; }
/** * @param int $cID Collection ID of a page * @param string $versionOrig ACTIVE or RECENT * @param string $class * @return Page */ public static function getByID($cID, $versionOrig = 'RECENT', $class = 'Page') { if ($versionOrig == 'RECENT' || $versionOrig == 'ACTIVE') { $c = Cache::get(strtolower($class . '_' . $versionOrig), $cID); if ($c instanceof $class) { return $c; } } $version = CollectionVersion::getNumericalVersionID($cID, $versionOrig); $where = "where Pages.cID = ?"; $c = new $class(); $c->populatePage($cID, $where, $version); // must use cID instead of c->getCollectionID() because cID may be the pointer to another page if ($versionOrig == 'RECENT' || $versionOrig == 'ACTIVE') { Cache::set(strtolower($class . '_' . $versionOrig), $cID, $c); } return $c; }
/** * @param int $cID Collection ID of a page * @param string $versionOrig ACTIVE or RECENT * @param string $class * @return Page */ public static function getByID($cID, $versionOrig = 'RECENT', $class = 'Page') { if ($versionOrig) { $version = CollectionVersion::getNumericalVersionID($cID, $versionOrig); } $ca = new Cache(); $c = $version > 0 ? $ca->get(strtolower($class), $cID . ':' . $version) : ''; if ($c instanceof $class) { return $c; } $where = "where Pages.cID = ?"; $c = new $class(); $c->populatePage($cID, $where, $version); // must use cID instead of c->getCollectionID() because cID may be the pointer to another page if ($version > 0) { $ca->set(strtolower($class), $cID . ':' . $version, $c); } return $c; }
$ct = CollectionType::getByID($_POST['ctID']); if ($cp->canAddSubContent($ct)) { // the $c below identifies that we're adding a collection _to_ that particular collection object //$newCollectionID = $ct->addCollection($c); $dt = Loader::helper('form/date_time'); $dh = Loader::helper('date'); $data = $_POST; $data['cvIsApproved'] = 0; $data['cDatePublic'] = $dh->getSystemDateTime($dt->translate('cDatePublic')); $nc = $c->add($ct, $data); $nvc = $nc->getVersionToModify(); processMetaData($nvc); if (is_object($nc)) { if ($_POST['rel'] == 'SITEMAP') { if ($cp->canApproveCollection()) { $v = CollectionVersion::get($nc, "RECENT"); $v->approve(); } $u = new User(); $u->unloadCollectionEdit(); if ($_POST['mode'] == 'explore') { header('Location: ' . BASE_URL . View::url('/dashboard/sitemap/explore', $c->getCollectionID())); exit; } else { if ($_POST['mode'] == 'search') { header('Location: ' . BASE_URL . DIR_REL . '/' . DISPATCHER_FILENAME . '?cID=' . $nc->getCollectionID() . '&mode=edit&ctask=check-out-first' . $step . $token); exit; } else { header('Location: ' . URL_SITEMAP); exit; }
echo t('Cancel'); ?> </a> <button type="submit" class="btn pull-right btn-primary"><?php echo t('Duplicate'); ?> </button> </div> </div> </form> <?php } elseif (isset($renamePage)) { /* @var Concrete\Core\Page\Page $renamePage */ /* @var bool $isFolder */ /* @var string $oldName */ $sv = CollectionVersion::get($renamePage, 'ACTIVE'); ?> <form action="<?php echo $view->action('rename', $renamePage->getCollectionID()); ?> " method="POST"> <legend><?php echo $isFolder ? t('Rename Stack Folder') : t('Rename Stack'); ?> </legend> <?php echo $token->output('rename_stack'); ?> <div class="form-group"> <?php echo $form->label('newName', t("Name"));
<?php defined('C5_EXECUTE') or die("Access Denied."); $datetime = loader::helper('form/date_time'); $publishDate = ''; if (isset($page) && is_object($page)) { $v = CollectionVersion::get($page, "RECENT"); $publishDate = $v->getPublishDate(); } if (Config::get('concrete.misc.user_timezones')) { $user = new User(); $userInfo = $user->getUserInfoObject(); $timezone = $userInfo->getUserTimezone(); } else { $timezone = Config::get('app.timezone'); } ?> <div class="form-group form-group-last"> <label class="control-label"><?php echo t('Date/Time'); ?> </label> <?php echo $datetime->datetime('check-in-scheduler', $publishDate, false, true, 'dark-panel-calendar'); ?> <span class="help-block" style="display: block"><?php echo t('Time Zone: %s', $timezone); ?> </span> </div>
print t('No global areas created yet.'); print '</p>'; } ?> </div> <h4><?php echo t('Other Stacks'); ?> </h4> <div class="ccm-stack-content-wrapper"> <?php if (count($useradded) > 0) { foreach ($useradded as $st) { $sv = CollectionVersion::get($st, 'ACTIVE'); ?> <div class="ccm-stack ccm-group" id="stID_<?php echo $st->getCollectionID(); ?> "> <?php if ($canMoveStacks) { ?> <img class="ccm-group-sort" src="<?php echo ASSETS_URL_IMAGES; ?> /icons/up_down.png" width="14" height="14" /><?php } ?>
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); $pkgHandle = 'easy_news'; Loader::library('controller', $pkgHandle); //Get info about category $cat = (int) $_GET['c']; Loader::model('page_list'); Loader::model("collection_types"); $ct = Collection::getByID($cat); //$a=$ct->getAttribute('easynews_section'); //if(empty($a)||(!$a)){ // die(); //} $cvID = CollectionVersion::getNumericalVersionID($ct->getCollectionID(), 'ACTIVE'); $vObj = CollectionVersion::get($ct, $cvID); $newsList = new PageList(); $newsList->filterByParentID($cat); $newsList->sortBy('cvDatePublic', 'desc'); $newsPage = $newsList->getPage(); //Start creation Loader::library('3rdparty/feedcreator/include/feedcreator.class', $pkgHandle); //define channel $rss = new UniversalFeedCreator(); $rss->useCached(); $rss->title = SITE . ' - ' . $vObj->cvName; $rss->description = $vObj->cvName . ' updates'; $rss->link = SITE_URL; $rss->syndicationURL = EasyNewsController::getRssPagePath() . '?c=' . $cat; //channel items/entries foreach ($newsPage as $page) {
public function save() { session_write_close(); if ($this->isPost()) { if (intval($this->post('entryID')) > 0) { $entry = ComposerPage::getByID($this->post('entryID'), 'RECENT'); } if (!is_object($entry)) { $this->error->add(t('Invalid page.')); } else { $ct = CollectionType::getByID($entry->getCollectionTypeID()); } $valt = Loader::helper('validation/token'); $vtex = Loader::helper('validation/strings'); if (!$valt->validate('composer')) { $this->error->add($valt->getErrorMessage()); } if ($this->post("ccm-submit-publish")) { if (!$vtex->notempty($this->post('cName'))) { $this->error->add(t('You must provide a name for your page before you can publish it.')); } if ($entry->isComposerDraft()) { if ($ct->getCollectionTypeComposerPublishMethod() == 'CHOOSE' || $ct->getCollectionTypeComposerPublishMethod() == 'PAGE_TYPE') { $parent = Page::getByID($entry->getComposerDraftPublishParentID()); if (!is_object($parent) || $parent->isError()) { $this->error->add(t('Invalid parent page.')); } else { $cp = new Permissions($parent); if (!$cp->canAddSubCollection($ct)) { $this->error->add(t('You do not have permissions to add this page type in that location.')); } } } else if ($ct->getCollectionTypeComposerPublishMethod() == 'PARENT') { $parent = Page::getByID($ct->getCollectionTypeComposerPublishPageParentID()); } } } else if ($this->post('ccm-submit-discard') && !$this->error->has()) { if ($entry->isComposerDraft()) { $entry->delete(); $this->redirect('/dashboard/composer/drafts', 'draft_discarded'); } else { // we just discard the most recent changes Events::fire('on_composer_delete_draft', $entry); $v = CollectionVersion::get($entry, 'RECENT'); $v->discard(); $this->redirect('?cID=' . $entry->getCollectionID()); } } if (!$this->error->has()) { $data = array('cDatePublic' => Loader::helper('form/date_time')->translate('cDatePublic'), 'cHandle' => Loader::helper('text')->sanitizeFileSystem($this->post('cName')), 'cName' => $this->post('cName'), 'cDescription' => $this->post('cDescription')); $entry->getVersionToModify(); // this is a pain. we have to use composerpage::getbyid again because // getVersionToModify is hard-coded to return a page object $entry = ComposerPage::getByID($entry->getCollectionID(), 'RECENT'); $entry->update($data); $this->saveData($entry); if ($this->post('ccm-submit-publish')) { $v = CollectionVersion::get($entry, 'RECENT'); $v->approve(); if ($entry->isComposerDraft()) { $entry->move($parent); Events::fire('on_composer_publish', $entry); $entry->markComposerPageAsPublished(); } $this->redirect('?cID=' . $entry->getCollectionID()); } else if ($this->post('autosave')) { // this is done by javascript. we refresh silently and send a json success back Events::fire('on_composer_save_draft', $entry); $json = Loader::helper('json'); $obj = new stdClass; $dh = Loader::helper('date'); $obj->error = false; $obj->time = $dh->getLocalDateTime('now','g:i a'); $obj->timestamp =date('m/d/Y g:i a'); print $json->encode($obj); exit; } else { $this->redirect('/dashboard/composer/write', 'edit', $entry->getCollectionID(), 'saved'); } } else if (is_object($entry)) { $this->edit($entry->getCollectionID()); } } else { $this->redirect('/dashboard/composer'); } }
} } break; case 'copy_version': $u = new User(); $c->loadVersionObject($_REQUEST['cvID']); $c->cloneVersion(t('Copy of Version: %s', $c->getVersionID())); header("Location: " . REL_DIR_FILES_TOOLS_REQUIRED . "/versions.php?forcereload=1&cID=" . $cID); exit; break; case 'approve': if ($cp->canApprovePageVersions() && !$isCheckedOut) { $u = new User(); $pkr = new ApprovePagePageWorkflowRequest(); $pkr->setRequestedPage($c); $v = CollectionVersion::get($c, $_GET['cvID']); $pkr->setRequestedVersionID($v->getVersionID()); $pkr->setRequesterUserID($u->getUserID()); $u->unloadCollectionEdit($c); $response = $pkr->trigger(); if (!$response instanceof WorkflowProgressResponse) { header("Location: " . REL_DIR_FILES_TOOLS_REQUIRED . "/versions.php?forcereload=1&deferred=true&cID=" . $cID . "&cvID=" . $_GET['cvID']); exit; } else { // we only get this response if we have skipped workflows and jumped straight in to an approve() step. header("Location: " . REL_DIR_FILES_TOOLS_REQUIRED . "/versions.php?forcereload=1&cID=" . $cID . "&cvID=" . $_GET['cvID']); exit; } } break; }
if ($cp->canApprovePageVersions()) { $u = new User(); $pkr = new \Concrete\Core\Workflow\Request\ApprovePageRequest(); $pkr->setRequestedPage($c); $v = CollectionVersion::get($c, "RECENT"); $pkr->setRequestedVersionID($v->getVersionID()); $pkr->setRequesterUserID($u->getUserID()); $u->unloadCollectionEdit($c); $response = $pkr->trigger(); header('Location: ' . \Core::getApplicationURL() . '/' . DISPATCHER_FILENAME . '?cID=' . $c->getCollectionID() . $step); exit; } break; case 'publish-now': if ($cp->canApprovePageVersions()) { $v = CollectionVersion::get($c, "SCHEDULED"); $v->approve(false); header('Location: ' . \Core::getApplicationURL() . '/' . DISPATCHER_FILENAME . '?cID=' . $c->getCollectionID() . $step); exit; } break; } } if (isset($_REQUEST['ptask']) && $_REQUEST['ptask'] && $valt->validate()) { // piles ! switch ($_REQUEST['ptask']) { case 'delete_content': //personal scrapbook if ($_REQUEST['pcID'] > 0) { $pc = PileContent::get($_REQUEST['pcID']); $p = $pc->getPile();
function VersionList(&$c, $limit = -1, $page = false) { $db = Loader::db(); $cID = $c->getCollectionID(); $this->total = $db->GetOne('select count(cvID) from CollectionVersions where cID = ?', $cID); $q = "select cvID from CollectionVersions where cID = '{$cID}' order by cvID desc "; if ($page > 1) { $pl = ($page - 1) * $limit; } if ($page > 1) { $q .= "limit " . $pl . ',' . $limit; } else { if ($limit > -1) { $q .= "limit " . $limit; } } $r = $db->query($q); if ($r) { while ($row = $r->fetchRow()) { $this->vArray[] = CollectionVersion::get($c, $row['cvID'], true); } $r->free(); } return $this; }
<?php defined('C5_EXECUTE') or die("Access Denied."); $c = Page::getByID($_REQUEST['cID']); $cp = new Permissions($c); if (!$cp->canWrite()) { die(_("Access Denied.")); } $v = CollectionVersion::get($c, "RECENT", true); if ($cp->canApproveCollection()) { $approveChecked = ""; if (isset($_SESSION['checkInApprove'])) { if ($_SESSION['checkInApprove'] == true) { $approveChecked = " checked"; } } } Loader::element('pane_header', array('c' => $c)); ?> <div class="ccm-pane-controls"> <div id="ccm-edit-collection"> <form method="post" id="ccm-check-in" action="<?php echo DIR_REL; ?> /<?php echo DISPATCHER_FILENAME; ?> ?cID=<?php echo $c->getCollectionID(); ?> &ctask=check-in">
public function save() { session_write_close(); if ($this->isPost()) { if (intval($this->post('entryID')) > 0) { $entry = ComposerPage::getByID($this->post('entryID'), 'RECENT'); } if (!is_object($entry)) { $this->error->add(t('Invalid page.')); } else { $ct = CollectionType::getByID($entry->getCollectionTypeID()); } $valt = Loader::helper('validation/token'); $vtex = Loader::helper('validation/strings'); if (!$valt->validate('composer')) { $this->error->add($valt->getErrorMessage()); } if ($this->post("ccm-publish-draft")) { if (!$vtex->notempty($this->post('cName'))) { $this->error->add(t('You must provide a name for your page before you can publish it.')); } if ($entry->isComposerDraft()) { if ($ct->getCollectionTypeComposerPublishMethod() == 'CHOOSE' || $ct->getCollectionTypeComposerPublishMethod() == 'PAGE_TYPE') { $parent = Page::getByID($entry->getComposerDraftPublishParentID()); } else { if ($ct->getCollectionTypeComposerPublishMethod() == 'PARENT') { $parent = Page::getByID($ct->getCollectionTypeComposerPublishPageParentID()); } } if (!is_object($parent) || ($parent->isInTrash() || $parent->isError())) { $this->error->add(t('Invalid parent page.')); } else { $cp = new Permissions($parent); if (!$cp->canAddSubCollection($ct)) { $this->error->add(t('You do not have permissions to add this page type in that location.')); } } } } else { if ($this->post('ccm-submit-discard') && !$this->error->has()) { if ($entry->isComposerDraft()) { $entry->delete(); $this->redirect('/dashboard/composer/drafts', 'draft_discarded'); } else { // we just discard the most recent changes Events::fire('on_composer_delete_draft', $entry); $v = CollectionVersion::get($entry, 'RECENT'); $v->discard(); $this->redirect('?cID=' . $entry->getCollectionID()); } } } if (!$this->error->has()) { if ($this->post('cHandle')) { $handle = $this->post('cHandle'); } else { $handle = Loader::helper('text')->urlify($this->post('cName')); } $handle = str_replace('-', PAGE_PATH_SEPARATOR, $handle); $data = array(); $pk = PermissionKey::getByHandle('edit_page_properties'); $pk->setPermissionObject($entry); $asl = $pk->getMyAssignment(); if ($asl->allowEditName()) { $data['cName'] = $this->post('cName'); } if ($asl->allowEditDescription()) { $data['cDescription'] = $this->post('cDescription'); } if ($asl->allowEditPaths()) { $data['cHandle'] = $handle; } if ($asl->allowEditDateTime()) { $data['cDatePublic'] = Loader::helper('form/date_time')->translate('cDatePublic'); } $entry->getVersionToModify(); // this is a pain. we have to use composerpage::getbyid again because // getVersionToModify is hard-coded to return a page object $entry = ComposerPage::getByID($entry->getCollectionID(), 'RECENT'); $entry->update($data); $this->saveData($entry, $asl); $u = new User(); if ($this->post('ccm-publish-draft')) { Cache::disableCache(); Cache::disableLocalCache(); if ($entry->isComposerDraft()) { $entry->move($parent); } $v = CollectionVersion::get($entry, 'RECENT'); $pkr = new ApprovePagePageWorkflowRequest(); $pkr->setRequestedPage($entry); $pkr->setRequestedVersionID($v->getVersionID()); $pkr->setRequesterUserID($u->getUserID()); $pkr->trigger(); Events::fire('on_composer_publish', $entry); $entry->markComposerPageAsPublished(); $this->redirect('?cID=' . $entry->getCollectionID()); } else { if ($this->post('autosave')) { // this is done by javascript. we refresh silently and send a json success back Events::fire('on_composer_save_draft', $entry); $json = Loader::helper('json'); $obj = new stdClass(); $dh = Loader::helper('date'); $obj->error = false; $obj->time = $dh->formatTime('now', false); $obj->timestamp = date('m/d/Y g:i a'); print $json->encode($obj); exit; } else { $this->redirect('/dashboard/composer/write', 'edit', $entry->getCollectionID(), 'saved'); } } } else { if (is_object($entry)) { $this->edit($entry->getCollectionID()); } } } else { $this->redirect('/dashboard/composer'); } }
function loadVersionObject($cvID = 'ACTIVE') { $this->vObj = CollectionVersion::get($this, $cvID); }
public function getNextVersionComments() { $cvID = CollectionVersion::getNumericalVersionID($this->getCollectionID(), 'ACTIVE'); return t("Version %d", $cvID+1); }