/** * Returns an instance of class (singleton pattern implementation). * * @return BOL_UserApproveDao */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
public function findUsers($groupId, $count, $withPhoto = true) { $userTable = BOL_UserDao::getInstance()->getTableName(); $avatarJoin = !$withPhoto ? '' : "INNER JOIN `" . BOL_AvatarDao::getInstance()->getTableName() . "` as `a`\n \t\t\tON( `u`.`id` = `a`.`userId` )"; $query = "\n SELECT `u`.* FROM `{$userTable}` AS `u`\n\n INNER JOIN `" . GROUPS_BOL_GroupUserDao::getInstance()->getTableName() . "` AS `g`\n ON( `u`.`id` = `g`.`userId` )\n\n LEFT JOIN `" . BOL_UserSuspendDao::getInstance()->getTableName() . "` as `s`\n ON( `u`.`id` = `s`.`userId` )\n\n LEFT JOIN `" . BOL_UserApproveDao::getInstance()->getTableName() . "` as `d`\n ON( `u`.`id` = `d`.`userId` )\n\n {$avatarJoin}\n\n WHERE g.groupId=:g AND `s`.`id` IS NULL AND `d`.`id` IS NULL\n ORDER BY `u`.`activityStamp` DESC\n LIMIT :ls, :le"; return OW::getDbo()->queryForObjectList($query, BOL_UserDao::getInstance()->getDtoClassName(), array('ls' => 0, 'le' => $count, 'g' => $groupId)); }
public function findUnapprovedStatusForUserList($idList) { $unapprovedUsers = $this->userApproveDao->findUnapproveStatusForUserList($idList); $resultArray = array(); foreach ($idList as $userId) { $resultArray[$userId] = in_array($userId, $unapprovedUsers) ? true : false; } return $resultArray; }
public function countDisapproved() { $q = "SELECT COUNT(*) FROM `{$this->getTableName()}` as `u`\n \t\tINNER JOIN `" . BOL_UserApproveDao::getInstance()->getTableName() . '` as `ud` ON(`u`.`id` = `ud`.`userId`) '; return (int) $this->dbo->queryForColumn($q); }
public function getNewUsersThisMonth($first, $count) { $query = "SELECT `u`.* FROM `" . BOL_UserDao::getInstance()->getTableName() . "` as `u`\n\t \tLEFT JOIN `" . BOL_UserSuspendDao::getInstance()->getTableName() . "` as `s`\n\t \t\tON( `u`.`id` = `s`.`userId` )\n LEFT JOIN `" . BOL_UserApproveDao::getInstance()->getTableName() . "` as `d`\n ON( `u`.`id` = `d`.`userId` )\n\t \tWHERE `s`.`id` IS NULL AND `d`.`id` IS NULL\n\t \tAND `u`.`joinStamp` >= :ts\n\t \tORDER BY `u`.`joinStamp` DESC\n\t \tLIMIT :first, :count"; return OW::getDbo()->queryForObjectList($query, BOL_UserDao::getInstance()->getDtoClassName(), array('ts' => time() - 30 * 24 * 3600, 'first' => $first, 'count' => $count)); }
public function findUserListForInvite($eventId, $first, $count, $friendList = null) { $userDao = BOL_UserDao::getInstance(); $eventDao = EVENTX_BOL_EventDao::getInstance(); $eventUserDao = EVENTX_BOL_EventUserDao::getInstance(); $where = ""; if (isset($friendList) && empty($friendList)) { return array(); } else { if (!empty($friendList)) { $where = " AND `u`.id IN ( " . $this->dbo->mergeInClause($friendList) . " ) "; } } $query = "SELECT `u`.`id`\n \t\tFROM `{$userDao->getTableName()}` as `u`\n LEFT JOIN `" . $eventDao->getTableName() . "` as `e`\n \t\t\tON( `u`.`id` = `e`.`userId` AND e.id = :event )\n LEFT JOIN `" . $this->getTableName() . "` as `ei`\n \t\t\tON( `u`.`id` = `ei`.`userId` AND `ei`.eventId = :event )\n\n LEFT JOIN `" . $eventUserDao->getTableName() . "` as `eu`\n \t\t\tON( `u`.`id` = `eu`.`userId` AND `eu`.eventId = :event )\n\n \t\tLEFT JOIN `" . BOL_UserSuspendDao::getInstance()->getTableName() . "` as `s`\n \t\t\tON( `u`.`id` = `s`.`userId` )\n\n \t\tLEFT JOIN `" . BOL_UserApproveDao::getInstance()->getTableName() . "` as `d`\n \t\t\tON( `u`.`id` = `d`.`userId` )\n\n \t\tWHERE `e`.`id` IS NULL AND `ei`.`id` IS NULL AND `s`.`id` IS NULL AND `d`.`id` IS NULL AND `eu`.`id` IS NULL " . $where . "\n \t\tORDER BY `u`.`activityStamp` DESC\n \t\tLIMIT :first, :count "; return $this->dbo->queryForColumnList($query, array('event' => $eventId, 'first' => $first, 'count' => $count)); }
/** * @param $userId * @param $page * @param $limit * @return array|mixed */ public function findGuestUsers($userId, $page, $limit) { $first = ($page - 1) * $limit; $query = "SELECT `u`.*\n FROM `" . $this->getTableName() . "` AS `g`\n INNER JOIN `" . BOL_UserDao::getInstance()->getTableName() . "` as `u`\n ON (`g`.`guestId` = `u`.`id`)\n LEFT JOIN `" . BOL_UserSuspendDao::getInstance()->getTableName() . "` as `s`\n ON( `u`.`id` = `s`.`userId` )\n LEFT JOIN `" . BOL_UserApproveDao::getInstance()->getTableName() . "` as `d`\n ON( `u`.`id` = `d`.`userId` )\n WHERE `s`.`id` IS NULL AND `d`.`id` IS NULL\n AND `g`.`userId` = ?\n ORDER BY `g`.`visitTimestamp` DESC\n LIMIT ?, ?"; return $this->dbo->queryForObjectList($query, BOL_UserDao::getInstance()->getDtoClassName(), array($userId, $first, $limit)); }
public function findCountByEventIdAndStatus($eventId, $status) { $query = " SELECT count(e.id) FROM " . $this->getTableName() . " e\n \t\tLEFT JOIN `" . BOL_UserSuspendDao::getInstance()->getTableName() . "` as `s` ON( `e`.`userId` = `s`.`userId` )\n LEFT JOIN `" . BOL_UserApproveDao::getInstance()->getTableName() . "` as `d` ON( `e`.`userId` = `d`.`userId` )\n WHERE s.Id IS NULL AND d.id IS NULL AND e.`" . self::EVENTX_ID . "` = :eventId AND e.`" . self::STATUS . "` = :status "; return $this->dbo->queryForColumn($query, array('eventId' => (int) $eventId, 'status' => (int) $status), self::CACHE_LIFE_TIME, array(self::CACHE_TAG_EVENTX_USER_LIST . $eventId)); }
public function findByAccountTypes($count, $accountTypes, $withPhoto = true) { if (empty($accountTypes)) { return array(); } $avatarJoin = !$withPhoto ? '' : "INNER JOIN `" . BOL_AvatarDao::getInstance()->getTableName() . "` as `a`\n \t\t\tON( `u`.`id` = `a`.`userId` )"; $query = "\n SELECT DISTINCT `u`.*\n FROM `{$this->getTableName()}` AS `u`\n\n \t\tLEFT JOIN `" . BOL_UserSuspendDao::getInstance()->getTableName() . "` as `s`\n \t\t\tON( `u`.`id` = `s`.`userId` )\n\n \t\tLEFT JOIN `" . BOL_UserApproveDao::getInstance()->getTableName() . "` as `d`\n \t\t\tON( `u`.`id` = `d`.`userId` )\n\n {$avatarJoin}\n \n \t\tWHERE `s`.`id` IS NULL AND `d`.`id` IS NULL AND `u`.`accountType` IN ( '" . implode("', '", $accountTypes) . "' )\n\n ORDER BY `u`.`activityStamp` DESC\n LIMIT ?, ?\n "; return $this->dbo->queryForObjectList($query, $this->getDtoClassName(), array(0, $count)); }