= CURDATE(), 'n', 'y')"); } public static function getMembershipGracePeriodExpiredExpr() { $days = self::getConfig('membershipGracePeriod', 14); return new Zend_Db_Expr( "IF(`expiredOn` IS NULL OR DATE_ADD(`expiredOn`, INTERVAL {$days} DAY) >= CURDATE(), 'n', 'y')" ); } public static function unreadMessagesCountExpr() { $select = Qs_Db::getSelect(); $select->from(Qs_Db::getPair('UserWebMail', 'uwm'), 'COUNT(*)'); $select->where('`uwm`.`toUserId` = `User`.`id`'); $select->where('`uwm`.`read` = "n"'); return new Zend_Db_Expr('(' . $select . ')'); } public static function likeToReceivePm($userId) { $user = (new Qs_Db_Table('User'))->searchBy([ 'id' => $userId, 'status' => Entity::STATUS_ACTIVE, 'pmEnabled' => 'y', ]); return !empty($user); } }