Example #1
0
<?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) {
Example #2
0
 function duplicate($nc, $preserveUserID = false)
 {
     $db = Loader::db();
     // the passed collection is the parent collection
     $cParentID = $nc->getCollectionID();
     $u = new User();
     $uID = $u->getUserID();
     if ($preserveUserID) {
         $uID = $this->getCollectionUserID();
     }
     $dh = Loader::helper('date');
     $cDate = $dh->getSystemDateTime();
     $cobj = parent::getByID($this->cID);
     // create new name
     $newCollectionName = $this->getCollectionName();
     $index = 1;
     $nameCount = 1;
     while ($nameCount > 0) {
         // if we have a node at the new level with the same name, we keep incrementing til we don't
         $nameCount = $db->GetOne('select count(Pages.cID) from CollectionVersions inner join Pages on (CollectionVersions.cID = Pages.cID and CollectionVersions.cvIsApproved = 1) where Pages.cParentID = ? and CollectionVersions.cvName = ?', array($cParentID, $newCollectionName));
         if ($nameCount > 0) {
             $index++;
             $newCollectionName = $this->getCollectionName() . ' ' . $index;
         }
     }
     $newC = $cobj->duplicate();
     $newCID = $newC->getCollectionID();
     $v = array($newCID, $cParentID, $uID, $this->overrideTemplatePermissions(), $this->getPermissionsCollectionID(), $this->getCollectionInheritance(), $this->cFilename, $this->cPointerID, $this->cPointerExternalLink, $this->cPointerExternalLinkNewWindow, $this->cDisplayOrder);
     $q = "insert into Pages (cID, cParentID, uID, cOverrideTemplatePermissions, cInheritPermissionsFromCID, cInheritPermissionsFrom, cFilename, cPointerID, cPointerExternalLink, cPointerExternalLinkNewWindow, cDisplayOrder) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
     $res = $db->query($q, $v);
     Loader::model('page_statistics');
     PageStatistics::incrementParents($newCID);
     if ($res) {
         // rescan the collection path
         $nc->refreshCache();
         $nc2 = Page::getByID($newCID);
         // now with any specific permissions - but only if this collection is set to override
         if ($this->getCollectionInheritance() == 'OVERRIDE') {
             $nc2->acquirePagePermissions($this->getPermissionsCollectionID());
             $nc2->acquireAreaPermissions($this->getPermissionsCollectionID());
         } else {
             if ($this->getCollectionInheritance() == "PARENT") {
                 // we need to clear out any lingering permissions groups (just in case), and set this collection to inherit from the parent
                 $npID = $nc->getPermissionsCollectionID();
                 $q = "update Pages set cInheritPermissionsFromCID = {$npID} where cID = {$newCID}";
                 $r = $db->query($q);
             }
         }
         if ($index > 1) {
             $args['cName'] = $newCollectionName;
             $args['cHandle'] = $nc2->getCollectionHandle() . '-' . $index;
         }
         $nc2->update($args);
         // arguments for event
         // 1. new page
         // 2. old page
         $ret = Events::fire('on_page_duplicate', $nc2, $this);
         $nc2->rescanCollectionPath();
         return $nc2;
     }
 }
Example #3
0
		public function duplicate() {
			$db = Loader::db();
			$dh = Loader::helper('date');
			$cDate = $dh->getSystemDateTime();
			
			$v = array($cDate, $cDate, $this->cHandle);
			$r = $db->query("insert into Collections (cDateAdded, cDateModified, cHandle) values (?, ?, ?)", $v);
			$newCID = $db->Insert_ID();
			
			if ($r) {

				// first, we get the creation date of the active version in this collection
				//$q = "select cvDateCreated from CollectionVersions where cvIsApproved = 1 and cID = {$this->cID}";
				//$dcOriginal = $db->getOne($q);
				// now we create the query that will grab the versions we're going to copy
				
				$qv = "select * from CollectionVersions where cID = '{$this->cID}' order by cvDateCreated asc";
	
				// now we grab all of the current versions
				$rv = $db->query($qv);
				$cvList = array();
				while ($row = $rv->fetchRow()) {
					// insert
					$cvList[] = $row['cvID'];
					$cDate = date("Y-m-d H:i:s", strtotime($cDate) + 1);
					$vv = array($newCID, $row['cvID'], $row['cvName'], $row['cvHandle'], $row['cvDescription'], $row['cvDatePublic'], $cDate, $row['cvComments'], $row['cvAuthorUID'], $row['cvIsApproved']);
					$qv = "insert into CollectionVersions (cID, cvID, cvName, cvHandle, cvDescription, cvDatePublic, cvDateCreated, cvComments, cvAuthorUID, cvIsApproved) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
					$db->query($qv, $vv);
				}
				
				// duplicate layout records 
				$ql = "select * from CollectionVersionAreaLayouts where cID = '{$this->cID}' order by cvalID asc";
				$rl = $db->query($ql);
				while ($row = $rl->fetchRow()) { 
					$vl = array( $newCID, $row['cvID'], $row['arHandle'], $row['layoutID'], $row['position'], $row['areaNameNumber'] );
					$ql = "insert into CollectionVersionAreaLayouts (cID, cvID, arHandle, layoutID, position, areaNameNumber) values ( ?, ?, ?, ?, ?, ?)";
					$db->query($ql, $vl);
				}				

				$ql = "select * from CollectionVersionBlockStyles where cID = '{$this->cID}'";
				$rl = $db->query($ql);
				while ($row = $rl->fetchRow()) { 
					$vl = array( $newCID, $row['cvID'], $row['bID'], $row['arHandle'], $row['csrID'] );
					$ql = "insert into CollectionVersionBlockStyles (cID, cvID, bID, arHandle, csrID) values (?, ?, ?, ?, ?)";
					$db->query($ql, $vl);
				}
				$ql = "select * from CollectionVersionAreaStyles where cID = '{$this->cID}'";
				$rl = $db->query($ql);
				while ($row = $rl->fetchRow()) { 
					$vl = array( $newCID, $row['cvID'], $row['arHandle'], $row['csrID'] );
					$ql = "insert into CollectionVersionAreaStyles (cID, cvID, arHandle, csrID) values (?, ?, ?, ?)";
					$db->query($ql, $vl);
				}
	
				// now we grab all the blocks we're going to need
				$cvList = implode(',',$cvList);
				$q = "select bID, cvID, arHandle, cbDisplayOrder, cbOverrideAreaPermissions, cbIncludeAll from CollectionVersionBlocks where cID = '{$this->cID}' and cvID in ({$cvList})";
				$r = $db->query($q);
				while ($row = $r->fetchRow()) {
					$v = array($newCID, $row['cvID'], $row['bID'], $row['arHandle'], $row['cbDisplayOrder'], 0, $row['cbOverrideAreaPermissions'], $row['cbIncludeAll']);
					$q = "insert into CollectionVersionBlocks (cID, cvID, bID, arHandle, cbDisplayOrder, isOriginal, cbOverrideAreaPermissions, cbIncludeAll) values (?, ?, ?, ?, ?, ?, ?, ?)";
					$db->query($q, $v);
					if ($row['cbOverrideAreaPermissions'] != 0) {
						$q2 = "select gID, uID, cbgPermissions from CollectionVersionBlockPermissions where cID = '{$this->cID}' and bID = '{$row['bID']}' and cvID = '{$row['cvID']}'";
						$r2 = $db->query($q2);
						while ($row2 = $r2->fetchRow()) {
							$db->Replace('CollectionVersionBlockPermissions', 
								array('cID' => $newCID, 'cvID' => $row['cvID'], 'bID' => $row['bID'], 'gID' => $row2['gID'], 'uID' => $row2['uID'], 'cbgPermissions' => $row2['cbgPermissions']),
								array('cID', 'cvID', 'bID', 'gID', 'uID'), true);
						}
					}
				}
	
				// duplicate any attributes belonging to the collection
				
				$v = array($this->getCollectionID());
				$q = "select akID, cvID, avID from CollectionAttributeValues where cID = ?";
				$r = $db->query($q, $v);
				while ($row = $r->fetchRow()) {
					$v2 = array($row['akID'], $row['cvID'], $row['avID'], $newCID);
					$db->query("insert into CollectionAttributeValues (akID, cvID, avID, cID) values (?, ?, ?, ?)", $v2);
				}			
				return Collection::getByID($newCID);
			}
			
		}