Esempio n. 1
0
 /**
  * Get a collection type by its ID.
  *
  * @param $ctID
  * @return bool|CollectionType
  * @todo refactor to return null on not found.
  */
 public static function getByID($ctID)
 {
     $ctID = intval($ctID);
     $ct = CacheLocal::getEntry('collection_type_by_id', $ctID);
     if (is_object($ct)) {
         return $ct;
     } else {
         if ($ct === -1) {
             return false;
         }
     }
     $db = Loader::db();
     $q = "SELECT PageTypes.ctID, ComposerTypes.ctID as ctIDc, ctHandle, ctIsInternal, ctName, ctIcon, pkgID, ctComposerPublishPageMethod, ctComposerPublishPageTypeID, ctComposerPublishPageParentID from PageTypes left join ComposerTypes on PageTypes.ctID = ComposerTypes.ctID where PageTypes.ctID = ?";
     $r = $db->query($q, array($ctID));
     if ($r) {
         $row = $r->fetchRow();
         $r->free();
         if (is_array($row)) {
             $ct = new CollectionType();
             $ct->setPropertiesFromArray($row);
             if ($row['ctIDc']) {
                 $ct->ctIncludeInComposer = true;
             }
         }
     }
     CacheLocal::set('collection_type_by_id', $ctID, $ct);
     return $ct;
 }
Esempio n. 2
0
	public static function getByHandle($akHandle) {
		$ak = CacheLocal::getEntry('user_attribute_key_by_handle', $akHandle);
		if (is_object($ak)) {
			return $ak;
		} else if ($ak == -1) {
			return false;
		}
		$ak = -1;
		$db = Loader::db();
		
		$q = "SELECT ak.akID 
			FROM AttributeKeys ak
			INNER JOIN AttributeKeyCategories akc ON ak.akCategoryID = akc.akCategoryID 
			WHERE ak.akHandle = ?
			AND akc.akCategoryHandle = 'user'";
		$akID = $db->GetOne($q, array($akHandle));
		if ($akID > 0) {
			$ak = UserAttributeKey::getByID($akID);
		}

		CacheLocal::set('user_attribute_key_by_handle', $akHandle, $ak);
		if ($ak === -1) {
			return false;
		}
		return $ak;
	}
Esempio n. 3
0
 public static function getByHandle($akHandle)
 {
     $ak = CacheLocal::getEntry('file_attribute_key_by_handle', $akHandle);
     if (is_object($ak)) {
         return $ak;
     } else {
         if ($ak == -1) {
             return false;
         }
     }
     $ak = -1;
     $db = Loader::db();
     $q = "SELECT ak.akID FROM AttributeKeys ak INNER JOIN AttributeKeyCategories akc ON ak.akCategoryID = akc.akCategoryID  WHERE ak.akHandle = ? AND akc.akCategoryHandle = 'file'";
     $akID = $db->GetOne($q, array($akHandle));
     if ($akID > 0) {
         $ak = self::getByID($akID);
     } else {
         // else we check to see if it's listed in the initial registry
         $ia = FileTypeList::getImporterAttribute($akHandle);
         if (is_object($ia)) {
             // we create this attribute and return it.
             $at = AttributeType::getByHandle($ia->akType);
             $args = array('akHandle' => $akHandle, 'akName' => $ia->akName, 'akIsSearchable' => 1, 'akIsAutoCreated' => 1, 'akIsEditable' => $ia->akIsEditable);
             $ak = FileAttributeKey::add($at, $args);
         }
     }
     CacheLocal::set('file_attribute_key_by_handle', $akHandle, $ak);
     if ($ak === -1) {
         return false;
     }
     return $ak;
 }
Esempio n. 4
0
 public static function getByName($stackName, $cvID = 'RECENT')
 {
     $cID = CacheLocal::getEntry('stack_by_name', $stackName);
     if (!$cID) {
         $db = Loader::db();
         $cID = $db->GetOne('select cID from Stacks where stName = ?', array($stackName));
         CacheLocal::set('stack_by_name', $stackName, $cID);
     }
     if ($cID) {
         return self::getByID($cID, $cvID);
     }
 }
Esempio n. 5
0
 /**
  * @param int $cID Collection ID of a page
  * @param string $versionOrig ACTIVE or RECENT
  * @param string $class
  * @return Page
  */
 public static function getByID($cID, $version = 'RECENT', $class = 'Page')
 {
     $c = CacheLocal::getEntry('page', $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
     CacheLocal::set('page', $cID . ':' . $version, $c);
     return $c;
 }
Esempio n. 6
0
 public static function getByID($gID)
 {
     $db = Loader::db();
     $g = CacheLocal::getEntry('group', $gID);
     if (is_object($g)) {
         return $g;
     }
     $row = $db->getRow("select * from Groups where gID = ?", array($gID));
     if (isset($row['gID'])) {
         $g = new Group();
         $g->setPropertiesFromArray($row);
         CacheLocal::set('group', $gID, $g);
         return $g;
     }
 }
Esempio n. 7
0
 public static function get($pkgIsInstalled = 1)
 {
     $pkgList = CacheLocal::getEntry('pkgList', $pkgIsInstalled);
     if ($pkgList != false) {
         return $pkgList;
     }
     $db = Loader::db();
     $r = $db->query("select pkgID, pkgName, pkgIsInstalled, pkgDescription, pkgVersion, pkgHandle, pkgDateInstalled from Packages where pkgIsInstalled = ? order by pkgID asc", array($pkgIsInstalled));
     $list = new PackageList();
     while ($row = $r->fetchRow()) {
         $pkg = new Package();
         $pkg->setPropertiesFromArray($row);
         $list->add($pkg);
     }
     CacheLocal::set('pkgList', $pkgIsInstalled, $list);
     return $list;
 }
Esempio n. 8
0
 public static function getList()
 {
     $gaItemTemplateTypeList = CacheLocal::getEntry('gaItemTemplateTypeList', false);
     if ($gaItemTemplateTypeList != false) {
         return $gaItemTemplateTypeList;
     }
     $db = Loader::db();
     $list = array();
     $r = $db->Execute('select gatTypeID from GatheringItemTemplateTypes order by gatTypeID asc');
     while ($row = $r->FetchRow()) {
         $type = static::getByID($row['gatTypeID']);
         if (is_object($type)) {
             $list[] = $type;
         }
     }
     $r->Close();
     CacheLocal::set('gaItemTemplateTypeList', false, $list);
     return $list;
 }
Esempio n. 9
0
 public static function getByHandle($akHandle)
 {
     $ak = CacheLocal::getEntry('form_attribute_key_by_handle', $akHandle);
     if (is_object($ak)) {
         return $ak;
     } else {
         if ($ak == -1) {
             return false;
         }
     }
     $ak = new FormAttributeKey();
     $ak->load($akHandle, 'akHandle');
     if ($ak->getAttributeKeyID() < 1) {
         $ak = -1;
     }
     CacheLocal::set('form_attribute_key_by_handle', $akHandle, $ak);
     if ($ak === -1) {
         return false;
     }
     return $ak;
 }
Esempio n. 10
0
 static final function getByID($peID)
 {
     $obj = CacheLocal::getEntry('permission_access_entity', $peID);
     if ($obj instanceof PermissionAccessEntity) {
         return $obj;
     }
     $db = Loader::db();
     $r = $db->GetRow('select petID, peID from PermissionAccessEntities where peID = ?', array($peID));
     if (is_array($r)) {
         $pt = PermissionAccessEntityType::getByID($r['petID']);
         if (!is_object($pt)) {
             return false;
         }
         $class = Loader::helper('text')->camelcase($pt->getAccessEntityTypeHandle());
         $class .= 'PermissionAccessEntity';
         $obj = new $class();
         $r['petHandle'] = $pt->getAccessEntityTypeHandle();
         $obj->setPropertiesFromArray($r);
         $obj->load();
     }
     CacheLocal::set('permission_access_entity', $peID, $obj);
     return $obj;
 }
Esempio n. 11
0
 /**
  * Gets the Area object for the given page and area handle
  * @param Page|Collection $c
  * @param string $arHandle
  * @param int|null $arIsGlobal
  * @return Area
  */
 public static function get(&$c, $arHandle, $arIsGlobal = null)
 {
     if (!is_object($c)) {
         return false;
     }
     // Right now we are splitting the cache to deal with times when Areas
     // get converted to GlobalAreas and back the other way
     $globalCache = $arIsGlobal ? ':1' : '';
     $a = CacheLocal::getEntry('area', $c->getCollectionID() . ':' . $arHandle . $globalCache);
     if ($a instanceof Area) {
         return $a;
     }
     $db = Loader::db();
     // First, we verify that this is a legitimate area
     $v = array($c->getCollectionID(), $arHandle);
     $q = "select arID, arOverrideCollectionPermissions, arInheritPermissionsFromAreaOnCID, arIsGlobal from Areas where cID = ? and arHandle = ?";
     $arRow = $db->getRow($q, $v);
     if ($arRow['arID'] > 0) {
         $area = new Area($arHandle);
         $area->arID = $arRow['arID'];
         $area->arOverrideCollectionPermissions = $arRow['arOverrideCollectionPermissions'];
         $area->arIsGlobal = $arRow['arIsGlobal'];
         $area->arInheritPermissionsFromAreaOnCID = $arRow['arInheritPermissionsFromAreaOnCID'];
         $area->cID = $c->getCollectionID();
         $area->c =& $c;
         CacheLocal::set('area', $c->getCollectionID() . ':' . $arHandle . $globalCache, $area);
         return $area;
     }
 }
Esempio n. 12
0
	public function getAccessListItems($accessType = PermissionKey::ACCESS_TYPE_INCLUDE, $filterEntities = array()) {
		if (count($this->paIDList) > 0) {
			$q = 'select paID, peID, pdID, accessType from PermissionAccessList where paID in (' . implode(',', $this->paIDList) . ')';
			return $this->deliverAccessListItems($q, $accessType, $filterEntities);
		} else {
			$filter = $accessType . ':';
			foreach($filterEntities as $pae) {
				$filter .= $pae->getAccessEntityID() . ':';
			}
			$filter = trim($filter, ':');
			$items = CacheLocal::getEntry('permission_access_list_items', $this->getPermissionAccessID() . $filter . strtolower(get_class($this->pk)));
			if (is_array($items)) {
				return $items;
			}				
			$q = 'select paID, peID, pdID, accessType from PermissionAccessList where paID = ' . $this->getPermissionAccessID();
			$items = $this->deliverAccessListItems($q, $accessType, $filterEntities);
			CacheLocal::set('permission_access_list_items', $this->getPermissionAccessID() . $filter . strtolower(get_class($this->pk)), $items);
			return $items;
		}
	}
Esempio n. 13
0
		/**
		 * List the block IDs in a collection or area within a collection
		 * @param string $arHandle. If specified, returns just the blocks in an area
		 * @return array
		 */
		public function getBlockIDs($arHandle = false) {
			$blockIDs = CacheLocal::getEntry('collection_block_ids', $this->getCollectionID() . ':' . $this->getVersionID());
			$blocks = array();
		
			if (!is_array($blockIDs)) {
				$v = array($this->getCollectionID(), $this->getVersionID());
				$db = Loader::db();
				$q = "select Blocks.bID, CollectionVersionBlocks.arHandle from CollectionVersionBlocks inner join Blocks on (CollectionVersionBlocks.bID = Blocks.bID) inner join BlockTypes on (Blocks.btID = BlockTypes.btID) where CollectionVersionBlocks.cID = ? and (CollectionVersionBlocks.cvID = ? or CollectionVersionBlocks.cbIncludeAll=1) order by CollectionVersionBlocks.cbDisplayOrder asc";
				$r = $db->GetAll($q, $v);
				$blockIDs = array();
				if (is_array($r)) {
					foreach($r as $bl) {
						$blockIDs[strtolower($bl['arHandle'])][] = $bl;
					}
				}
				CacheLocal::set('collection_block_ids', $this->getCollectionID() . ':'. $this->getVersionID(), $blockIDs);
			}
			

			if ($arHandle != false) {
				$blockIDsTmp = $blockIDs[strtolower($arHandle)];
				$blockIDs = $blockIDsTmp;
			} else {
				$blockIDsTmp = $blockIDs;
				$blockIDs = array();
				foreach($blockIDsTmp as $arHandle => $row) {
					foreach($row as $brow) {
						if (!in_array($brow, $blockIDs)) {
							$blockIDs[] = $brow;
						}
					}
				}
			}
			return $blockIDs;
		}
Esempio n. 14
0
 public function getBlockCustomStyleRuleID()
 {
     $db = Loader::db();
     if (!isset($this->csrID)) {
         $co = $this->getBlockCollectionObject();
         $csrCheck = CacheLocal::getEntry('csrCheck', $co->getCollectionID() . ':' . $co->getVersionID());
         $csrObject = CacheLocal::getEntry('csrObject', $co->getCollectionID() . ':' . $co->getVersionID() . ':' . $this->getAreaHandle() . ':' . $this->getBlockID());
         if (is_object($csrObject)) {
             $this->csrID = $csrObject->getCustomStyleRuleID();
             return $csrObject->getCustomStyleRuleID();
         } else {
             if ($csrCheck) {
                 return false;
             }
         }
         $arHandle = $this->getAreaHandle();
         if ($arHandle) {
             $a = $this->getBlockAreaObject();
             if ($a->isGlobalArea()) {
                 // then we need to check against the global area name. We currently have the wrong area handle passed in
                 $arHandle = STACKS_AREA_NAME;
             }
             $v = array($co->getCollectionID(), $co->getVersionID(), $arHandle, $this->bID);
             $this->csrID = $db->GetOne('select csrID from CollectionVersionBlockStyles where cID = ? and cvID = ? and arHandle = ? and bID = ?', $v);
         } else {
             $this->csrID = 0;
         }
     }
     return $this->csrID;
 }
Esempio n. 15
0
		/**
		 * Gets the BlockType for a given Block Type ID
		 * @param int $btID
		 * @return BlockType
		 */
		public static function getByID($btID) {
			$bt = CacheLocal::getEntry('blocktype', $btID);
			if ($bt === -1) {
				return false;
			} else if (!is_object($bt)) {
				$where = 'btID = ?';
				$bt = BlockType::get($where, array($btID));			
				if (is_object($bt)) {
					CacheLocal::set('blocktype', $btID, $bt);
				} else {
					CacheLocal::set('blocktype', $btID, -1);
				}
			}
			$bt->controller = Loader::controller($bt);
			return $bt;
		}
Esempio n. 16
0
	/**
	 * returns the FileVersion object for the provided fvID
	 * if none provided returns the approved version
	 * @param int $fvID
	 * @return FileVersion
	 */
	public function getVersion($fvID = null) {

		if ($fvID == null) {
			$fvID = $this->fvID; // approved version
		}
		$fv = CacheLocal::getEntry('file', $this->getFileID() . ':' . $fvID);
		if ($fv === -1) {
			return false;
		}
		if ($fv) {
			return $fv;
		}

		$db = Loader::db();
		$row = $db->GetRow("select * from FileVersions where fvID = ? and fID = ?", array($fvID, $this->fID));
		$row['fvAuthorName'] = $db->GetOne("select uName from Users where uID = ?", array($row['fvAuthorUID']));
		
		$fv = new FileVersion();
		$row['fslID'] = $this->fslID;
		$fv->setPropertiesFromArray($row);
		
		CacheLocal::set('file', $this->getFileID() . ':' . $fvID, $fv);
		return $fv;
	}
Esempio n. 17
0
 public static function getByHandle($pkHandle)
 {
     $keys = CacheLocal::getEntry('permission_keys', false);
     if (!is_array($keys)) {
         $keys = self::loadAll();
     }
     return $keys[$pkHandle];
 }