コード例 #1
0
ファイル: Data.php プロジェクト: vincium/bourg-la-reine
 public static function loadBySecure($secure, $type)
 {
     $db = new Util\Data();
     $db->buildQuery('select', self::getList());
     $db->buildQuery('from', 'core_user_security user_security');
     $db->buildQuery('where', ['secure = ?', $secure]);
     $user = self::map($db);
     if (isset($user)) {
         if ($type == Model::CONFIRM) {
             $user->getUser()->setStatus(1);
             $user->getUser()->save();
             self::deleteSecure($user->getUserId(), $type);
         } else {
             if ($type == Model::RESET) {
                 self::deleteSecure($user->getUserId(), $type);
             } else {
                 if ($type == Model::REMEMBER) {
                     $expire = time() + 60 * 60 * 24 * 7;
                     // 7 days
                     setcookie('signedUser', $secure, $expire, '/', Util\Nav::removePort(\Rebond\Config::getPath('siteUrl')));
                 }
             }
         }
         return $user->getUser();
     }
     return null;
 }
コード例 #2
0
ファイル: Data.php プロジェクト: vincium/bourg-la-reine
 public static function loadByTitle($title)
 {
     $db = new Util\Data();
     $db->buildQuery('select', self::getList());
     $db->buildQuery('from', 'cms_module module');
     $db->buildQuery('where', ['module.title = ?', $title]);
     return self::map($db);
 }
コード例 #3
0
ファイル: Data.php プロジェクト: vincium/bourg-la-reine
 public static function findNav($nav)
 {
     $db = new Util\Data();
     $db->buildQuery('select', self::getList());
     $db->buildQuery('from', 'cms_page page');
     $db->buildQuery('where', 'page.' . $nav . ' = 1');
     $db->buildQuery('where', 'page.status = 1');
     $db->buildQuery('order', 'page.display_order, page.title');
     return self::mapList($db);
 }
コード例 #4
0
ファイル: Data.php プロジェクト: vincium/bourg-la-reine
 public static function loadByUserId($userId, $options = [])
 {
     $db = new Util\Data();
     $db->buildQuery('select', self::getList());
     $db->buildQuery('from', 'core_role r');
     $db->buildQuery('join', 'core_user_role ur ON ur.role_id = r.id');
     $db->buildQuery('where', 'ur.user_id = ' . $userId);
     $db->extendQuery($options);
     return self::mapList($db);
 }
コード例 #5
0
ファイル: Data.php プロジェクト: vincium/lot
 public static function loadRegistered($playerId)
 {
     $db = new Util\Data();
     $db->buildQuery('clearSelect', true);
     $db->buildQuery('select', self::getList(['tournament_id']));
     $db->buildQuery('from', 'bus_tournament_player `tournament_player`');
     $db->buildQuery('where', ['tournament_player.player_id = ?', $playerId]);
     $result = $db->select();
     if (count($result) > 0) {
         return $result->fetchAll(\PDO::FETCH_COLUMN);
     }
     return [];
 }
コード例 #6
0
ファイル: Data.php プロジェクト: vincium/lot
 public static function loadStats($id)
 {
     $db = new Util\Data();
     $db->buildQuery('select', 'player_match_player.id AS player_matchPlayerId,
         player_match_player.username AS playerUsername,
         MAX(player_match.fastest_serve) AS player_matchFastestServe,
         SUM(player_match.ace) AS player_matchAce,
         SUM(player_match.double_fault) AS player_matchDoubleFault,
         SUM(player_match.serve1_won) as player_matchServe1Won,
         SUM(player_match.serve1_lost) as player_matchServe1Lost,
         SUM(player_match.serve2_won) as player_matchServe2Won,
         SUM(player_match.serve2_lost) as player_matchServe2Lost,
         SUM(player_match.on_serve_won) AS player_matchOnServeWon,
         SUM(player_match.on_serve_lost) AS player_matchOnServeLost,
         SUM(player_match.break_saved) AS player_matchBreakSaved,
         SUM(player_match.break_not_saved) AS player_matchBreakNotSaved,
         SUM(player_match.on_return_won) AS player_matchOnReturnWon,
         SUM(player_match.on_return_lost) AS player_matchOnReturnLost,
         SUM(player_match.break_won) AS player_matchBreakWon,
         SUM(player_match.break_lost) AS player_matchBreakLost,
         SUM(player_match.winner) AS player_matchWinner,
         SUM(player_match.unforced_error) AS player_matchUnforcedError,
         SUM(player_match.important_point_won) AS player_matchImportantPointWon,
         SUM(player_match.important_point_lost) AS player_matchImportantPointLost,
         SUM(player_match.net_won) AS player_matchNetWon,
         SUM(player_match.net_lost) AS player_matchNetLost');
     $db->buildQuery('from', 'bus_player_match player_match');
     $db->buildQuery('join', 'bus_player player_match_player ON player_match_player.id = player_match.player_id');
     $db->buildQuery('join', 'bus_match `match`');
     $db->buildQuery('where', 'player_match.id = match.player_match1_id OR player_match.id = match.player_match2_id');
     $db->buildQuery('where', ['player_match.player_id = ?', $id]);
     $db->buildQuery('where', ['match.status = ?', \Own\Bus\MatchStatus::FINISHED]);
     return self::map($db);
 }
コード例 #7
0
ファイル: Data.php プロジェクト: vincium/resa
 public static function hasMembership($courtId, array $playerIds)
 {
     $today = new \DateTime();
     $today = $today->format('Y-m-d');
     $db = new Util\Data();
     $db->buildQuery('select', 'count(m.id)');
     $db->buildQuery('from', 'bus_membership m');
     $db->buildQuery('join', 'bus_membership_court mc ON mc.membership_id = m.id');
     $db->buildQuery('join', 'bus_player_membership pm ON pm.membership_id = m.id');
     $db->buildQuery('where', ['m.start_date <= ? AND m.end_date >= ?', $today, $today]);
     $db->buildQuery('where', ['mc.court_id = ?', $courtId]);
     $db->buildQuery('where', ['pm.player_id IN (?)', $playerIds]);
     return $db->count();
 }
コード例 #8
0
ファイル: Data.php プロジェクト: vincium/bourg-la-reine
 public static function loadFullComponents($options = [])
 {
     $db = new Util\Data();
     $list = 'component.id AS componentId,
         component.module_id AS componentModuleId,
         CONCAT(module.title, \' - \', component.title) AS componentTitle';
     $db->buildQuery('select', $list);
     $db->buildQuery('from', 'cms_component component');
     $db->buildQuery('join', 'cms_module module ON module.id = component.module_id');
     $db->buildQuery('where', 'component.status = 1');
     $db->buildQuery('where', 'module.status = 1');
     $db->buildQuery('order', 'module.title, component.title');
     $db->extendQuery($options);
     return self::mapList($db);
 }
コード例 #9
0
ファイル: Data.php プロジェクト: vincium/bourg-la-reine
 public static function loadAll(array $options = [])
 {
     $db = new Util\Data();
     $db->buildQuery('select', self::getList());
     $db->buildQuery('from', 'core_user `user`');
     $db->extendQuery($options);
     return self::mapList($db);
 }
コード例 #10
0
ファイル: Data.php プロジェクト: vincium/bourg-la-reine
 protected static function condition(Util\Data $db, $option)
 {
     switch ($option) {
         case 'expiration':
             $db->buildQuery('where', ['content.use_expiration = 0 || (content.go_live_date <= ? AND content.expiry_date >= ?)', Util\Format::date(time(), 'sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]);
             break;
         case 'published':
             $db->buildQuery('where', ['content.version IN (?)', [VersionType::PUBLISHED, VersionType::UPDATING]]);
             break;
         case 'pending':
             $db->buildQuery('where', ['content.version IN (?)', [VersionType::PENDING, VersionType::PUBLISHING]]);
             break;
         case 'preview':
             $db->buildQuery('where', ['content.version IN (?)', [VersionType::PENDING, VersionType::PUBLISHED, VersionType::PUBLISHING]]);
             break;
         case 'deleted':
             $db->buildQuery('where', ['content.version = ?', VersionType::DELETED]);
             break;
     }
 }
コード例 #11
0
ファイル: Data.php プロジェクト: vincium/bourg-la-reine
 public static function hasAccess($userId, $permission, $isAdmin)
 {
     $db = new Util\Data();
     $db->buildQuery('select', 'count(user.id)');
     $db->buildQuery('from', 'core_user user');
     $db->buildQuery('join', 'core_user_role user_role ON user_role.user_id = user.id');
     $db->buildQuery('join', 'core_role role ON role.id = user_role.role_id');
     $db->buildQuery('join', 'core_role_permission role_permission ON role_permission.role_id = user_role.role_id');
     $db->buildQuery('join', 'core_permission permission ON permission.id = role_permission.permission_id');
     $db->buildQuery('where', 'user.id = ' . $userId);
     if ($isAdmin) {
         $db->buildQuery('where', 'user.is_admin = 1');
     }
     $db->buildQuery('where', ['? LIKE CONCAT(permission.title, "%") OR permission.title LIKE CONCAT(?, "%")', $permission, $permission]);
     $db->buildQuery('where', 'user.status = 1');
     $db->buildQuery('where', 'role.status = 1');
     $db->buildQuery('where', 'permission.status = 1');
     return $db->count();
 }
コード例 #12
0
ファイル: Data.php プロジェクト: vincium/bourg-la-reine
 public static function loadByVersion($version = 'published', $onSite = true, array $options = [])
 {
     $db = new Util\Data();
     $db->buildQuery('select', self::getList());
     $db->buildQuery('from', 'app_standard x');
     if (Util\Nav::isPreview()) {
         $version = 'preview';
     }
     if ($onSite && $version != 'preview') {
         self::condition($db, 'expiration');
     }
     self::condition($db, $version);
     Content::autoJoin($db, 'Standard');
     $db->extendQuery($options);
     return self::mapList($db);
 }