Example #1
0
 public static function get(&$c, $cvID)
 {
     $db = Loader::db();
     if ($c instanceof Page && $c->getCollectionPointerID()) {
         $v = array($c->getCollectionPointerID());
     } else {
         $v = array($c->getCollectionID());
     }
     $q = "select cvID, cvIsApproved, cvIsNew, cvHandle, cvName, cvDescription, cvDateCreated, cvDatePublic, pTemplateID, cvAuthorUID, cvApproverUID, cvComments, pThemeID from CollectionVersions where cID = ?";
     if ($cvID == 'ACTIVE') {
         $q .= ' and cvIsApproved = 1';
     } elseif ($cvID == 'RECENT') {
         $q .= ' order by cvID desc';
     } else {
         $v[] = $cvID;
         $q .= ' and cvID = ?';
     }
     $row = $db->GetRow($q, $v);
     $cv = new static();
     if (is_array($row) && $row['cvID']) {
         $cv->setPropertiesFromArray($row);
     }
     // load the attributes for a particular version object
     $cv->cID = $c->getCollectionID();
     return $cv;
 }
Example #2
0
 public static function getByHandle($btsHandle)
 {
     $db = Loader::db();
     $row = $db->GetRow('select btsID, btsHandle, pkgID, btsName from BlockTypeSets where btsHandle = ?', array($btsHandle));
     if (isset($row['btsID'])) {
         $akc = new static();
         $akc->setPropertiesFromArray($row);
         return $akc;
     }
 }
Example #3
0
 public static function getByHandle($asHandle)
 {
     $db = Loader::db();
     $row = $db->GetRow('select asID, asHandle, pkgID, asName, akCategoryID, asIsLocked from AttributeSets where asHandle = ?', array($asHandle));
     if (isset($row['asID'])) {
         $akc = new static();
         $akc->setPropertiesFromArray($row);
         return $akc;
     }
 }
Example #4
0
 public static function getByHandle($wpCategoryHandle)
 {
     $db = Loader::db();
     $row = $db->GetRow('select wpCategoryID, wpCategoryHandle, pkgID from WorkflowProgressCategories where wpCategoryHandle = ?', array($wpCategoryHandle));
     if (isset($row['wpCategoryID'])) {
         $pkc = new static();
         $pkc->setPropertiesFromArray($row);
         return $pkc;
     }
 }
Example #5
0
 public static function getByID($rowID)
 {
     $db = Loader::db();
     $r = $db->GetRow('select btftc.*, btfc.imageID from btFootballTableCache btftc INNER JOIN btFootballClub btfc ON btfc.sID = btftc.id_team where id = ?', array($rowID));
     if (is_array($r) && $r['id'] == $rowID) {
         $cnv = new static();
         $cnv->setPropertiesFromArray($r);
         return $cnv;
     }
 }
Example #6
0
 public static function getByID($gatTypeID)
 {
     $db = Loader::db();
     $row = $db->GetRow('select gatTypeID, pkgID, gatTypeHandle from GatheringItemTemplateTypes where gatTypeID = ?', array($gatTypeID));
     if ($row['gatTypeID']) {
         $wt = new static();
         $wt->setPropertiesFromArray($row);
         return $wt;
     }
 }
Example #7
0
 public static function getByID($msgID, $mailbox = false)
 {
     $db = Loader::db();
     $row = $db->GetRow('select uAuthorID, msgDateCreated, msgID, msgSubject, msgBody, uToID from UserPrivateMessages where msgID = ?', array($msgID));
     if (!isset($row['msgID'])) {
         return false;
     }
     $upm = new static();
     $upm->setPropertiesFromArray($row);
     if ($mailbox) {
         // we add in some mailbox-specific attributes
         $row = $db->GetRow('select msgID, msgIsNew, msgIsUnread, msgMailboxID, msgIsReplied, uID from UserPrivateMessagesTo where msgID = ? and uID = ?', array($msgID, $mailbox->getMailboxUserID()));
         if (isset($row['msgID'])) {
             $upm->setPropertiesFromArray($row);
         }
         $upm->mailbox = $mailbox;
     }
     return $upm;
 }
 public static function getByHandle($saslHandle)
 {
     $db = Loader::db();
     $r = $db->GetRow('select saslHandle, saslIsActive, pkgID, saslName from SystemAntispamLibraries where saslHandle = ?', array($saslHandle));
     if (is_array($r) && $r['saslHandle']) {
         $sc = new static();
         $sc->setPropertiesFromArray($r);
         return $sc;
     }
 }
Example #9
0
 public static function getByName($gsName)
 {
     $db = Loader::db();
     $row = $db->GetRow('select gsID, pkgID, gsName from GroupSets where gsName = ?', array($gsName));
     if (isset($row['gsID'])) {
         $gs = new static();
         $gs->setPropertiesFromArray($row);
         return $gs;
     }
 }
Example #10
0
 public static function getByID($arLayoutPresetID)
 {
     $db = Loader::db();
     $row = $db->GetRow('select arLayoutID, arLayoutPresetID, arLayoutPresetName from AreaLayoutPresets where arLayoutPresetID = ?', array($arLayoutPresetID));
     if (is_array($row) && $row['arLayoutPresetID']) {
         $preset = new static();
         $preset->setPropertiesFromArray($row);
         return $preset;
     }
 }
Example #11
0
 public static function getByID($cnvDiscussionID)
 {
     $db = Loader::db();
     $r = $db->GetRow('select * from ConversationDiscussions where cnvDiscussionID = ?', array($cnvDiscussionID));
     if (is_array($r) && $r['cnvDiscussionID'] == $cnvDiscussionID) {
         $d = new static();
         $d->setPropertiesFromArray($r);
         return $d;
     }
 }
Example #12
0
 public static function getByID($petID)
 {
     $db = Loader::db();
     $row = $db->GetRow('select petID, pkgID, petHandle, petName from PermissionAccessEntityTypes where petID = ?', array($petID));
     if ($row['petHandle']) {
         $wt = new static();
         $wt->setPropertiesFromArray($row);
         return $wt;
     }
 }
 public static function getByID($ptComposerOutputControlID)
 {
     $db = Loader::db();
     $r = $db->GetRow('select * from PageTypeComposerOutputControls where ptComposerOutputControlID = ?', array($ptComposerOutputControlID));
     if (is_array($r) && $r['ptComposerOutputControlID']) {
         $cm = new static();
         $cm->setPropertiesFromArray($r);
         return $cm;
     }
 }
Example #14
0
 public static function getByID($ptComposerFormLayoutSetID)
 {
     $db = Loader::db();
     $r = $db->GetRow('select * from PageTypeComposerFormLayoutSets where ptComposerFormLayoutSetID = ?', array($ptComposerFormLayoutSetID));
     if (is_array($r) && $r['ptComposerFormLayoutSetID']) {
         $set = new static();
         $set->setPropertiesFromArray($r);
         return $set;
     }
 }
Example #15
0
 public static function getByHandle($treeTypeHandle)
 {
     $db = Database::connection();
     $row = $db->GetRow('select * from TreeTypes where treeTypeHandle = ?', array($treeTypeHandle));
     if (is_array($row) && $row['treeTypeHandle']) {
         $type = new static();
         $type->setPropertiesFromArray($row);
         return $type;
     }
 }
Example #16
0
 public static function getByID($wftID)
 {
     $db = Loader::db();
     $row = $db->GetRow('select wftID, pkgID, wftHandle, wftName from WorkflowTypes where wftID = ?', array($wftID));
     if ($row['wftHandle']) {
         $wt = new static();
         $wt->setPropertiesFromArray($row);
         return $wt;
     }
 }
 public static function getByHandle($akCategoryHandle)
 {
     $db = Loader::db();
     $row = $db->GetRow('select akCategoryID, akCategoryHandle, akCategoryAllowSets, pkgID from AttributeKeyCategories where akCategoryHandle = ?', array($akCategoryHandle));
     if (isset($row['akCategoryID'])) {
         $akc = new static();
         $akc->setPropertiesFromArray($row);
         return $akc;
     }
 }
Example #18
0
 /**
  * @param int $arLayoutColumnID
  *
  * @return static
  */
 public static function getByID($arLayoutColumnID)
 {
     $db = Loader::db();
     $row = $db->GetRow('select * from AreaLayoutCustomColumns where arLayoutColumnID = ?', array($arLayoutColumnID));
     if (is_array($row) && $row['arLayoutColumnID']) {
         $al = new static();
         $al->loadBasicInformation($arLayoutColumnID);
         $al->setPropertiesFromArray($row);
         return $al;
     }
 }
Example #19
0
 protected static function populateCategories()
 {
     $db = Loader::db();
     self::$categories = array();
     $r = $db->Execute('select pkCategoryID, pkCategoryHandle, pkgID from PermissionKeyCategories');
     while ($row = $r->FetchRow()) {
         $pkc = new static();
         $pkc->setPropertiesFromArray($row);
         self::$categories[$pkc->getPermissionKeyCategoryID()] = $pkc;
         self::$categories[$pkc->getPermissionKeyCategoryHandle()] = $pkc;
     }
 }
Example #20
0
 /**
  * @param string $akCategoryHandle
  * @return self|null Returns an AttributeKeyCategory object for the given category handle or null if no category exists with that handle
  */
 public static function getByHandle($akCategoryHandle)
 {
     $db = Database::connection();
     $row = $db->fetchAssoc('SELECT akCategoryID, akCategoryHandle, akCategoryAllowSets, pkgID
          FROM AttributeKeyCategories
          WHERE akCategoryHandle = ?', array($akCategoryHandle));
     if (isset($row['akCategoryID'])) {
         /** @var self $akc */
         $akc = new static();
         $akc->setPropertiesFromArray($row);
         return $akc;
     }
     return null;
 }
Example #21
0
 /** 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 static();
         $nu->setPropertiesFromArray($row);
         $nu->uGroups = $nu->_getUserGroups(true);
         $nu->superUser = $nu->getUserID() == USER_SUPER_ID;
         if ($login) {
             $nu->persist($cacheItemsOnLogin);
             $nu->recordLogin();
         }
     }
     return $nu;
 }
Example #22
0
 public static function getLastMatch($teamID)
 {
     $db = Loader::db();
     $r = $db->GetRow('SELECT
                         fm.*
                         ,ff.id_league
                         ,fch.name home_team_name
                         ,fch.logo_big home_team_logo
                         ,fca.name away_team_name
                         ,fca.logo_big away_team_logo
                       FROM btFootballFixture ff
                       INNER JOIN btFootballMatch fm ON ff.id = fm.id_fixture
                       INNER JOIN btFootballTeam ft ON (fm.id_team_home = ft.id OR fm.id_team_away = ft.id)
                       INNER JOIN (SELECT fc.name name, fc.logo_big logo_big, ft.id id_club FROM btFootballTeam ft INNER JOIN btFootballClub fc ON ft.id_club = fc.sID) fch ON fm.id_team_home = fch.id_club
                       INNER JOIN (SELECT fc.name name, fc.logo_big logo_big, ft.id id_club FROM btFootballTeam ft INNER JOIN btFootballClub fc ON ft.id_club = fc.sID) fca ON fm.id_team_away = fca.id_club
                       WHERE ft.id = ? AND fm.goal_home IS NOT NULL ORDER BY fm.played DESC LIMIT 1', $teamID);
     if (is_array($r)) {
         $cnv = new static();
         $cnv->setPropertiesFromArray($r);
         return $cnv;
     }
 }
Example #23
0
 /**
  * Get a library given its handle.
  *
  * @param string $sclHandle The library handle.
  *
  * @return static|null
  */
 public static function getByHandle($sclHandle)
 {
     $app = Facade::getFacadeApplication();
     $db = $app->make('database')->connection();
     $r = $db->fetchAssoc('select sclHandle, sclIsActive, pkgID, sclName from SystemCaptchaLibraries where sclHandle = ?', array($sclHandle));
     if ($r !== false) {
         $sc = new static();
         $sc->setPropertiesFromArray($r);
         return $sc;
     }
 }
Example #24
0
    public static function getByID($cnvID)
    {
        $db = Loader::db();
        $r = $db->GetRow('select cnvID, cID, cnvDateCreated, cnvDateLastMessage, cnvMessagesTotal, cnvAttachmentsEnabled, cnvAttachmentOverridesEnabled,
		cnvFileExtensions, cnvMaxFileSizeRegistered, cnvMaxFileSizeGuest, cnvMaxFilesRegistered, cnvMaxFilesGuest, cnvOverrideGlobalPermissions,
		cnvNotificationOverridesEnabled, cnvEnableSubscription from Conversations where cnvID = ?', array($cnvID));
        if (is_array($r) && $r['cnvID'] == $cnvID) {
            $cnv = new static();
            $cnv->setPropertiesFromArray($r);
            return $cnv;
        }
    }
Example #25
0
 /**
  * @param string $gPath The group path
  *
  * @return Group
  */
 public static function getByPath($gPath)
 {
     $db = Database::connection();
     $row = $db->getRow("select * from Groups where gPath = ?", [$gPath]);
     if (isset($row['gID'])) {
         $g = new static();
         $g->setPropertiesFromArray($row);
         return $g;
     }
 }
Example #26
0
 public static function getByID($cnvMessageID)
 {
     $db = Loader::db();
     $r = $db->GetRow('select * from ConversationMessages where cnvMessageID = ?', array($cnvMessageID));
     if (is_array($r) && $r['cnvMessageID'] && $r['cnvMessageID'] == $cnvMessageID) {
         $msg = new static();
         $msg->getConversationMessageFlagTypes();
         $msg->setPropertiesFromArray($r);
         $author = new Author();
         $authorUser = $r['uID'] > 0 ? \UserInfo::getByID($r['uID']) : null;
         if ($authorUser !== null) {
             $author->setUser($authorUser);
         } else {
             $author->setName($r['cnvMessageAuthorName']);
             $author->setEmail($r['cnvMessageAuthorEmail']);
             $author->setWebsite($r['cnvMessageAuthorWebsite']);
         }
         $msg->cnvMessageAuthor = $author;
         return $msg;
     }
 }
Example #27
0
 public static function getByHandle($atHandle)
 {
     // Handle legacy handles
     switch ($atHandle) {
         case 'date':
             $atHandle = 'date_time';
             break;
     }
     $db = Database::get();
     $row = $db->GetRow('select atID, pkgID, atHandle, atName from AttributeTypes where atHandle = ?', array($atHandle));
     if ($row && $row['atID']) {
         $at = new static();
         $at->setPropertiesFromArray($row);
         $at->loadController();
         return $at;
     }
 }
Example #28
0
 public static function getByID($ptID)
 {
     $cache = \Core::make('cache/request');
     $item = $cache->getItem(sprintf('pagetype/%s', $ptID));
     if (!$item->isMiss()) {
         return $item->get();
     }
     $db = Loader::db();
     $r = $db->GetRow('select * from PageTypes where ptID = ?', array($ptID));
     if (is_array($r) && isset($r['ptID']) && $r['ptID']) {
         $cm = new static();
         $cm->setPropertiesFromArray($r);
         $cm->ptPublishTargetObject = unserialize($r['ptPublishTargetObject']);
         $item->set($cm);
         return $cm;
     }
 }
Example #29
0
 public static function getByID($ptComposerFormLayoutSetControlID)
 {
     $db = Loader::db();
     $r = $db->GetRow('select * from PageTypeComposerFormLayoutSetControls where ptComposerFormLayoutSetControlID = ?', array($ptComposerFormLayoutSetControlID));
     if (is_array($r) && $r['ptComposerFormLayoutSetControlID']) {
         $control = new static();
         $control->setPropertiesFromArray($r);
         $control->ptComposerControlObject = unserialize($r['ptComposerControlObject']);
         if (!$control->ptComposerControlObject->objectExists()) {
             $control->delete();
             return null;
         } else {
             $control->ptComposerControlObject->setPageTypeComposerFormLayoutSetControlObject($control);
         }
         return $control;
     }
 }
Example #30
0
 /**
  * Get a Version instance given the Collection and a version identifier.
  *
  * @param \Concrete\Core\Page\Collection $c The collection for which you want the version.
  * @param int|string $cvID The specific version ID (or 'ACTIVE', 'SCHEDULED', 'RECENT').
  *
  * @return static
  */
 public static function get($c, $cvID)
 {
     $app = Facade::getFacadeApplication();
     $db = $app->make('database')->connection();
     $cID = false;
     if ($c instanceof \Concrete\Core\Page\Page) {
         $cID = $c->getCollectionPointerID();
     }
     if (!$cID) {
         $cID = $c->getCollectionID();
     }
     $v = array($cID);
     $q = "select cvID, cvIsApproved, cvIsNew, cvHandle, cvName, cvDescription, cvDateCreated, cvDatePublic, " . "pTemplateID, cvAuthorUID, cvApproverUID, cvComments, pThemeID, cvPublishDate from CollectionVersions " . "where cID = ?";
     switch ($cvID) {
         case 'ACTIVE':
             $q .= ' and cvIsApproved = 1 and cvPublishDate is NULL';
             break;
         case 'SCHEDULED':
             $q .= ' and cvIsApproved = 1 and cvPublishDate is not NULL';
             break;
         case 'RECENT':
             $q .= ' order by cvID desc';
             break;
         default:
             $v[] = $cvID;
             $q .= ' and cvID = ?';
             break;
     }
     $row = $db->fetchAssoc($q, $v);
     $cv = new static();
     if ($row !== false) {
         $cv->setPropertiesFromArray($row);
     }
     $cv->cID = $c->getCollectionID();
     return $cv;
 }