public static function getFeature($feHandle, $item)
 {
     $db = Loader::db();
     $faID = $db->GetOne('select ca.faID from GatheringItemFeatureAssignments as inner join FeatureAssignments fa on as.faID = fa.faID inner join Features fe on fa.feID = fe.feID where gaiID = ? and fe.feHandle = ?', array($item->getGatheringItemID(), $feHandle));
     if ($faID && $faID > 0) {
         $fa = Assignment::getByID($faID, $item);
         if (is_object($fa)) {
             return $fa;
         }
     }
 }
 public static function getList($page)
 {
     $db = Loader::db();
     $r = $db->Execute('select faID from CollectionVersionFeatureAssignments where cID = ? and cvID = ?', array($page->getCollectionID(), $page->getVersionID()));
     $list = array();
     while ($row = $r->FetchRow()) {
         $fa = Assignment::getByID($row['faID'], $page);
         if (is_object($fa)) {
             $list[] = $fa;
         }
     }
     return $list;
 }
Exemplo n.º 3
0
 public function deleteBlock($forceDelete = false)
 {
     $db = Loader::db();
     if ($this->bID < 1) {
         return false;
     }
     $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 \Concrete\Core\Page\Page && $c->isMasterCollection() && !$this->isAlias() || $forceDelete) {
         // forceDelete is used by the administration console
         // this is an original. We're deleting it, and everything else having to do with it
         $q = "delete from CollectionVersionBlocks where bID = ?";
         $r = $db->query($q, array($bID));
         $q = "delete from BlockPermissionAssignments where bID = ?";
         $r = $db->query($q, array($bID));
         $q = "delete from CollectionVersionBlockStyles where bID = ?";
         $r = $db->query($q, array($bID));
         $q = "delete from CollectionVersionBlocksCacheSettings where bID = ?";
         $r = $db->query($q, array($bID));
     } else {
         $q = "delete from CollectionVersionBlocks where cID = ? and (cvID = ? or cbIncludeAll=1) and bID = ? and arHandle = ?";
         $r = $db->query($q, array($cID, $cvID, $bID, $arHandle));
         // next, we delete the groups instance of this block
         $q = "delete from BlockPermissionAssignments where bID = ? and cvID = ? and cID = ?";
         $r = $db->query($q, array($bID, $cvID, $cID));
         $q = "delete from CollectionVersionBlockStyles where cID = ? and cvID = ? and bID = ? and arHandle = ?";
         $r = $db->query($q, array($cID, $cvID, $bID, $arHandle));
         $q = "delete from CollectionVersionBlocksCacheSettings where cID = ? and cvID = ? and bID = ? and arHandle = ?";
         $r = $db->query($q, array($cID, $cvID, $bID, $arHandle));
     }
     // delete any feature assignments that have been attached to this block to the collection version
     $faIDs = $db->GetCol('select faID from BlockFeatureAssignments where cID = ? and cvID = ? and bID = ?', array($cID, $cvID, $bID));
     foreach ($faIDs as $faID) {
         $fa = FeatureAssignment::getByID($faID, $c);
         $fa->delete();
     }
     //then, we see whether or not this block is aliased to anything else
     $totalBlocks = $db->GetOne('select count(*) from CollectionVersionBlocks where bID = ?', array($bID));
     $totalBlocks += $db->GetOne('select count(*) from btCoreScrapbookDisplay where bOriginalID = ?', array($bID));
     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 = self::getByID($row['bID'], $c, $row['arHandle']);
             $b->delete();
         }
     }
 }