public static function getByID($gaID) { $db = Loader::db(); $r = $db->GetRow('select gaID, gaDateCreated, gaDateLastUpdated from Gatherings where gaID = ?', array($gaID)); if (is_array($r) && $r['gaID'] == $gaID) { $ag = new self(); $ag->setPropertiesFromArray($r); return $ag; } }
/** Return an User instance given its id (or null if it's not found) * @param int $uID The id of the user * @param bool $login = false Set to true to make the user the current one * @param bool $cacheItemsOnLogin = false Set to true to cache some items when $login is true * * @return User|null */ public static function getByUserID($uID, $login = false, $cacheItemsOnLogin = true) { $app = Application::getFacadeApplication(); $db = $app['database']->connection(); $v = array($uID); $q = "SELECT uID, uName, uIsActive, uLastOnline, uTimezone, uDefaultLanguage, uLastPasswordChange FROM Users WHERE uID = ? LIMIT 1"; $r = $db->query($q, $v); $row = $r ? $r->FetchRow() : null; $nu = null; if ($row) { $nu = new self(); $nu->setPropertiesFromArray($row); $nu->uGroups = $nu->_getUserGroups(true); $nu->superUser = $nu->getUserID() == USER_SUPER_ID; if ($login) { $nu->persist($cacheItemsOnLogin); $nu->recordLogin(); } } return $nu; }
public static function getByID($bID, $c = null, $a = null) { if ($c == null && $a == null) { $cID = 0; $arHandle = ""; $cvID = 0; $b = CacheLocal::getEntry('block', $bID); } else { if (is_object($a)) { $arHandle = $a->getAreaHandle(); } else { if ($a != null) { $arHandle = $a; $a = Area::getOrCreate($c, $a); } } $cID = $c->getCollectionID(); $cvID = $c->getVersionID(); $b = CacheLocal::getEntry('block', $bID . ':' . $cID . ':' . $cvID . ':' . $arHandle); } if ($b instanceof self) { return $b; } $db = Loader::db(); $b = new self(); if ($c == null && $a == null) { // just grab really specific block stuff $q = "select bID, bIsActive, BlockTypes.btID, Blocks.btCachedBlockRecord, BlockTypes.btHandle, BlockTypes.pkgID, BlockTypes.btName, bName, bDateAdded, bDateModified, bFilename, Blocks.uID from Blocks inner join BlockTypes on (Blocks.btID = BlockTypes.btID) where bID = ?"; $b->isOriginal = 1; $v = array($bID); } else { $b->arHandle = $arHandle; $b->a = $a; $b->cID = $cID; $b->c = $c ? $c : ''; $vo = $c->getVersionObject(); $cvID = $vo->getVersionID(); $v = array($b->arHandle, $cID, $cvID, $bID); $q = "select CollectionVersionBlocks.isOriginal, CollectionVersionBlocks.cbIncludeAll, Blocks.btCachedBlockRecord, BlockTypes.pkgID, CollectionVersionBlocks.cbOverrideAreaPermissions, CollectionVersionBlocks.cbOverrideBlockTypeCacheSettings,\n CollectionVersionBlocks.cbOverrideBlockTypeContainerSettings, CollectionVersionBlocks.cbEnableBlockContainer, CollectionVersionBlocks.cbDisplayOrder, Blocks.bIsActive, Blocks.bID, Blocks.btID, bName, bDateAdded, bDateModified, bFilename, btHandle, Blocks.uID from CollectionVersionBlocks inner join Blocks on (CollectionVersionBlocks.bID = Blocks.bID) inner join BlockTypes on (Blocks.btID = BlockTypes.btID) where CollectionVersionBlocks.arHandle = ? and CollectionVersionBlocks.cID = ? and (CollectionVersionBlocks.cvID = ? or CollectionVersionBlocks.cbIncludeAll=1) and CollectionVersionBlocks.bID = ?"; } $r = $db->query($q, $v); $row = $r->fetchRow(); if (is_array($row)) { $b->setPropertiesFromArray($row); $r->free(); $bt = BlockType::getByID($b->getBlockTypeID()); $class = $bt->getBlockTypeClass(); if ($class == false) { // we can't find the class file, so we return return false; } $b->instance = new $class($b); if ($c != null || $a != null) { CacheLocal::set('block', $bID . ':' . $cID . ':' . $cvID . ':' . $arHandle, $b); } else { CacheLocal::set('block', $bID, $b); } return $b; } }
/** * @param string $where * @param scalar $var * * @return UserInfo|null */ private static function get($where, $var) { $db = Database::get(); $q = "select Users.uID, Users.uLastLogin, Users.uLastIP, Users.uIsValidated, Users.uPreviousLogin, Users.uIsFullRecord, Users.uNumLogins, Users.uDateAdded, Users.uIsActive, Users.uDefaultLanguage, Users.uLastOnline, Users.uHasAvatar, Users.uName, Users.uEmail, Users.uPassword, Users.uTimezone, Users.uLastPasswordChange from Users " . $where; $r = $db->query($q, array($var)); if ($r && $r->numRows() > 0) { $ui = new self(); $row = $r->fetchRow(); $ui->setPropertiesFromArray($row); $r->free(); } if (is_object($ui)) { return $ui; } }
/** * Gets the Area object for the given page and area handle. * * @param Page $c * @param string $arHandle * * @return Area */ public static final function get($c, $arHandle) { if (!is_object($c)) { return false; } $identifier = sprintf('/page/area/%s', $c->getCollectionID()); $cache = \Core::make('cache/request'); $item = $cache->getItem($identifier); if (!$item->isMiss()) { $areas = $item->get(); } else { $areas = array(); $db = Database::connection(); // First, we verify that this is a legitimate area $v = array($c->getCollectionID()); $q = 'select arID, arHandle, cID, arOverrideCollectionPermissions, arInheritPermissionsFromAreaOnCID, arIsGlobal, arParentID from Areas where cID = ?'; $r = $db->executeQuery($q, $v); while ($arRow = $r->FetchRow()) { if ($arRow['arID'] > 0) { if ($arRow['arIsGlobal']) { $obj = new GlobalArea($arHandle); } else { if ($arRow['arParentID']) { $arParentHandle = self::getAreaHandleFromID($arRow['arParentID']); $obj = new SubArea($arHandle, $arParentHandle, $arRow['arParentID']); } else { $obj = new self($arHandle); } } $obj->setPropertiesFromArray($arRow); $obj->c = $c; $arRowHandle = $arRow['arHandle']; $areas[$arRowHandle] = $obj; } } $item->set($areas); } return isset($areas[$arHandle]) ? $areas[$arHandle] : null; }
/** * @param int $cID * @param mixed $version 'RECENT'|'ACTIVE'|version id * * @return Collection */ public static function getByID($cID, $version = 'RECENT') { $db = Loader::db(); $q = 'select Collections.cDateAdded, Collections.cDateModified, Collections.cID from Collections where cID = ?'; $row = $db->getRow($q, array($cID)); $c = new self(); $c->setPropertiesFromArray($row); if ($version != false) { // we don't do this on the front page $c->loadVersionObject($version); } return $c; }
/** * Returns an array of all installed packages. * * @return Package[] */ public static function getInstalledList() { $db = Database::connection(); $r = $db->query("SELECT * FROM Packages WHERE pkgIsInstalled = 1 ORDER BY pkgDateInstalled ASC"); $pkgArray = array(); while ($row = $r->fetchRow()) { $pkg = new self(); $pkg->setPropertiesFromArray($row); $pkgArray[] = $pkg; } return $pkgArray; }