/**
  * (non-PHPdoc)
  * @see IUserLoginMethod::authenticateWithEmail()
  */
 public function authenticateWithEmail($email, $password)
 {
     // connect to a data base
     // Note: If your source application shares the same data base, you can simply use $this->_db, rather than open another connection.
     $mysqli = new mysqli($this->_websoccer->getConfig('db_host'), $this->_websoccer->getConfig('db_user'), $this->_websoccer->getConfig('db_passwort'), $this->_websoccer->getConfig('db_name'));
     // get user from your source table
     $escapedEMail = $mysqli->real_escape_string($email);
     $dbresult = $mysqli->query('SELECT password FROM mydummy_table WHERE email = \'' . $escapedEMail . '\'');
     if (!$dbresult) {
         throw new Exception('Database Query Error: ' . $mysqli->error);
     }
     $myUser = $dbresult->fetch_array();
     $dbresult->free();
     $mysqli->close();
     // could not find user
     if (!$myUser) {
         return FALSE;
     }
     // check is password is correct (in this sample case a simple MD5 hashing is applied).
     if ($myUser['password'] != md5($password)) {
         return FALSE;
     }
     // user is valid user according to custom authentication check. Now test if user already exists in local DB and return its ID.
     $existingUserId = UsersDataService::getUserIdByEmail($this->_websoccer, $this->_db, strtolower($email));
     if ($existingUserId > 0) {
         return $existingUserId;
     }
     // if user does not exist, create a new one. Nick name can be entered by user later.
     return UsersDataService::createLocalUser($this->_websoccer, $this->_db, null, $email);
 }
 private function _authenticate($queryWhereCondition, $loginStr, $password)
 {
     // query user in Joomla table
     $result = $this->_db->querySelect('username,email,password', $this->_websoccer->getConfig('joomlalogin_tableprefix') . 'users', 'block < 1 AND ' . $queryWhereCondition, $loginStr);
     $joomlaUser = $result->fetch_array();
     $result->free();
     // user does not exist
     if (!$joomlaUser) {
         return FALSE;
     }
     // check password. Joomla password has two parts: 0. password hash; 1. salt
     $passwordParts = explode(':', $joomlaUser['password']);
     $hashedPassword = md5($password . $passwordParts[1]);
     if ($hashedPassword != $passwordParts[0]) {
         return FALSE;
     }
     // valid user, check if he exists
     $userEmail = strtolower($joomlaUser['email']);
     $userId = UsersDataService::getUserIdByEmail($this->_websoccer, $this->_db, $userEmail);
     if ($userId > 0) {
         return $userId;
     }
     // create new user
     return UsersDataService::createLocalUser($this->_websoccer, $this->_db, $joomlaUser['username'], $userEmail);
 }
 private function _authenticate($queryWhereCondition, $loginStr, $password)
 {
     // query user in Joomla table
     $result = $this->_db->querySelect('user_login,user_email,user_pass', $this->_websoccer->getConfig('wordpresslogin_tableprefix') . 'users', 'user_status = 0 AND ' . $queryWhereCondition, $loginStr);
     $wpUser = $result->fetch_array();
     $result->free();
     // user does not exist
     if (!$wpUser) {
         return FALSE;
     }
     // check password.
     require BASE_FOLDER . '/classes/phpass/PasswordHash.php';
     $hasher = new PasswordHash(8, TRUE);
     if (!$hasher->CheckPassword($password, $wpUser['user_pass'])) {
         return FALSE;
     }
     // valid user, check if he exists
     $userEmail = strtolower($wpUser['user_email']);
     $userId = UsersDataService::getUserIdByEmail($this->_websoccer, $this->_db, $userEmail);
     if ($userId > 0) {
         return $userId;
     }
     // create new user
     return UsersDataService::createLocalUser($this->_websoccer, $this->_db, $wpUser['user_login'], $userEmail);
 }
 /**
  * @see AbstractJob::execute()
  */
 function execute()
 {
     // only consider highscore users since we assume that they are actually playing and not waiting for a team assignment or something.
     $users = UsersDataService::getActiveUsersWithHighscore($this->_websoccer, $this->_db, 0, 1000);
     foreach ($users as $user) {
         UserInactivityDataService::computeUserInactivity($this->_websoccer, $this->_db, $user['id']);
     }
 }
 /**
  * Creates a new direct transfer offer and notifications.
  * 
  * @param WebSoccer $websoccer Application context
  * @param DbConnection $db DB connection.
  * @param int $playerId ID of player to transfer.
  * @param int $senderUserId ID of user who made the offer.
  * @param int $senderClubId ID of user's team.
  * @param int $receiverUserId ID of player's manager.
  * @param int $receiverClubId ID of player's team.
  * @param int $offerAmount amount to offer.
  * @param string $offerMessage optional message from user.
  * @param int $offerPlayerId1 optional ID of an exchange player.
  * @param int $offerPlayerId2 another optional ID of an exchange player.
  */
 public static function createTransferOffer(WebSoccer $websoccer, DbConnection $db, $playerId, $senderUserId, $senderClubId, $receiverUserId, $receiverClubId, $offerAmount, $offerMessage, $offerPlayerId1 = null, $offerPlayerId2 = null)
 {
     $columns = array("player_id" => $playerId, "sender_user_id" => $senderUserId, "sender_club_id" => $senderClubId, "receiver_club_id" => $receiverClubId, "submitted_date" => $websoccer->getNowAsTimestamp(), "offer_amount" => $offerAmount, "offer_message" => $offerMessage, "offer_player1" => $offerPlayerId1, "offer_player2" => $offerPlayerId2);
     $db->queryInsert($columns, $websoccer->getConfig("db_prefix") . "_transfer_offer");
     $sender = UsersDataService::getUserById($websoccer, $db, $senderUserId);
     // create notification
     NotificationsDataService::createNotification($websoccer, $db, $receiverUserId, "transferoffer_notification_offerreceived", array("sendername" => $sender["nick"]), NOTIFICATION_TYPE, NOTIFICATION_TARGETPAGE, null, $receiverClubId);
 }
 public function getTemplateParameters()
 {
     $count = UsersDataService::countActiveUsersWithHighscore($this->_websoccer, $this->_db);
     $eps = $this->_websoccer->getConfig("entries_per_page");
     $paginator = new Paginator($count, $eps, $this->_websoccer);
     if ($count > 0) {
         $users = UsersDataService::getActiveUsersWithHighscore($this->_websoccer, $this->_db, $paginator->getFirstIndex(), $eps);
     } else {
         $users = array();
     }
     return array("users" => $users, "paginator" => $paginator);
 }
 private function _getUserInfoByTeam($teamId)
 {
     $columns = 'U.id AS user_id, nick, email, picture';
     $fromTable = $this->_websoccer->getConfig('db_prefix') . '_user AS U INNER JOIN ' . $this->_websoccer->getConfig('db_prefix') . '_verein AS C ON C.user_id = U.id';
     $result = $this->_db->querySelect($columns, $fromTable, 'C.id = %d', $teamId);
     $user = $result->fetch_array();
     $result->free();
     if ($user) {
         $user['picture'] = UsersDataService::getUserProfilePicture($this->_websoccer, $user['picture'], $user['email'], 120);
     }
     return $user;
 }
 /**
  * Deletes user's absence report and gives back his teams.
  * Deputy gets notification.
  * 
  * @param WebSoccer $websoccer Application context.
  * @param DbConnection $db DB connection.
  * @param int $userId ID of user who returned.
  */
 public static function confirmComeback(WebSoccer $websoccer, DbConnection $db, $userId)
 {
     $absence = self::getCurrentAbsenceOfUser($websoccer, $db, $userId);
     if (!$absence) {
         return;
     }
     // give back teams
     $db->queryUpdate(array('user_id' => $userId, 'user_id_actual' => NULL), $websoccer->getConfig('db_prefix') . '_verein', 'user_id_actual = %d', $userId);
     // delete absence(s)
     $db->queryDelete($websoccer->getConfig('db_prefix') . '_userabsence', 'user_id', $userId);
     // notify deputy
     if ($absence['deputy_id']) {
         $user = UsersDataService::getUserById($websoccer, $db, $userId);
         NotificationsDataService::createNotification($websoccer, $db, $absence['deputy_id'], 'absence_comeback_notification', array('user' => $user['nick']), 'absence', 'user');
     }
 }
 /**
  * (non-PHPdoc)
  * @see IActionController::executeAction()
  */
 public function executeAction($parameters)
 {
     $userId = $this->_websoccer->getUser()->id;
     // find deputy
     $deputyId = UsersDataService::getUserIdByNick($this->_websoccer, $this->_db, $parameters["deputynick"]);
     if ($deputyId < 1) {
         throw new Exception($this->_i18n->getMessage("absence_err_invaliddeputy"));
     }
     // cannot assign to himself
     if ($userId == $deputyId) {
         throw new Exception($this->_i18n->getMessage("absence_err_deputyisself"));
     }
     AbsencesDataService::makeUserAbsent($this->_websoccer, $this->_db, $userId, $deputyId, $parameters['days']);
     // success message
     $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("absence_report_success"), ""));
     return null;
 }
 /**
  * (non-PHPdoc)
  * @see IActionController::executeAction()
  */
 public function executeAction($parameters)
 {
     $senderId = $this->_websoccer->getUser()->id;
     // check if messages is enabled
     if (!$this->_websoccer->getConfig("messages_enabled")) {
         throw new Exception($this->_i18n->getMessage("messages_err_messagesdisabled"));
     }
     // find user
     $recipientId = UsersDataService::getUserIdByNick($this->_websoccer, $this->_db, $parameters["nick"]);
     if ($recipientId < 1) {
         throw new Exception($this->_i18n->getMessage("messages_send_err_invalidrecipient"));
     }
     // cannot send to yourself
     if ($senderId == $recipientId) {
         throw new Exception($this->_i18n->getMessage("messages_send_err_sendtoyourself"));
     }
     $now = $this->_websoccer->getNowAsTimestamp();
     // check when sent last message (needs x minutes break in order to prevent spam)
     $lastMessage = MessagesDataService::getLastMessageOfUserId($this->_websoccer, $this->_db, $senderId);
     $timebreakBoundary = $now - $this->_websoccer->getConfig("messages_break_minutes") * 60;
     if ($lastMessage != null && $lastMessage["date"] >= $timebreakBoundary) {
         throw new Exception($this->_i18n->getMessage("messages_send_err_timebreak", $this->_websoccer->getConfig("messages_break_minutes")));
     }
     // create message
     $columns["empfaenger_id"] = $recipientId;
     $columns["absender_id"] = $senderId;
     $columns["datum"] = $now;
     $columns["betreff"] = $parameters["subject"];
     $columns["nachricht"] = $parameters["msgcontent"];
     $fromTable = $this->_websoccer->getConfig("db_prefix") . "_briefe";
     // create message in inbox of recipient
     $columns["typ"] = "eingang";
     $this->_db->queryInsert($columns, $fromTable);
     // create message in outbox of sender
     $columns["typ"] = "ausgang";
     $this->_db->queryInsert($columns, $fromTable);
     // success message
     $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("messages_send_success"), ""));
     // clear fields
     $_REQUEST["subject"] = "";
     $_REQUEST["msgcontent"] = "";
     $_REQUEST["nick"] = "";
     return null;
 }
 /**
  * (non-PHPdoc)
  * @see IModel::getTemplateParameters()
  */
 public function getTemplateParameters()
 {
     $userId = (int) $this->_websoccer->getRequestParameter('id');
     if ($userId < 1) {
         $userId = $this->_websoccer->getUser()->id;
     }
     $user = UsersDataService::getUserById($this->_websoccer, $this->_db, $userId);
     if (!isset($user['id'])) {
         throw new Exception($this->_i18n->getMessage(MSG_KEY_ERROR_PAGENOTFOUND));
     }
     // get teams of user
     $fromTable = $this->_websoccer->getConfig('db_prefix') . '_verein';
     $whereCondition = 'user_id = %d AND status = \'1\' AND nationalteam != \'1\' ORDER BY name ASC';
     $result = $this->_db->querySelect('id,name', $fromTable, $whereCondition, $userId);
     $teams = array();
     while ($team = $result->fetch_array()) {
         $teams[] = $team;
     }
     $result->free();
     // get national team of user
     if ($this->_websoccer->getConfig('nationalteams_enabled')) {
         $columns = 'id,name';
         $fromTable = $this->_websoccer->getConfig('db_prefix') . '_verein';
         $whereCondition = 'user_id = %d AND nationalteam = \'1\'';
         $result = $this->_db->querySelect($columns, $fromTable, $whereCondition, $userId, 1);
         $nationalteam = $result->fetch_array();
         $result->free();
         if (isset($nationalteam['id'])) {
             $user['nationalteam'] = $nationalteam;
         }
     }
     // badges
     $result = $this->_db->querySelect('name, description, level, date_rewarded, event', $this->_websoccer->getConfig('db_prefix') . '_badge INNER JOIN ' . $this->_websoccer->getConfig('db_prefix') . '_badge_user ON id = badge_id', 'user_id = %d ORDER BY level DESC, date_rewarded ASC', $userId);
     $badges = array();
     while ($badge = $result->fetch_array()) {
         if (!isset($badges[$badge['event']])) {
             $badges[$badge['event']] = $badge;
         }
     }
     $result->free();
     return array('user' => $user, 'userteams' => $teams, 'absence' => AbsencesDataService::getCurrentAbsenceOfUser($this->_websoccer, $this->_db, $userId), 'badges' => $badges);
 }
 public function executeAction($parameters)
 {
     // authenticate
     $userEmail = FacebookSdk::getInstance($this->_websoccer)->getUserEmail();
     // not authenticated
     if (!strlen($userEmail)) {
         $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_WARNING, $this->_i18n->getMessage("facebooklogin_failure"), ""));
         return "home";
     }
     // authenticated. Check if user exists.
     $userEmail = strtolower($userEmail);
     $userId = UsersDataService::getUserIdByEmail($this->_websoccer, $this->_db, $userEmail);
     // if does not exist, then create new user
     if ($userId < 1) {
         $userId = UsersDataService::createLocalUser($this->_websoccer, $this->_db, null, $userEmail);
     }
     // log in user
     SecurityUtil::loginFrontUserUsingApplicationSession($this->_websoccer, $userId);
     $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("facebooklogin_success"), ""));
     return strlen($this->_websoccer->getUser()->username) ? "office" : "enter-username";
 }
 public static function computeUserInactivity(WebSoccer $websoccer, DbConnection $db, $userId)
 {
     $inactivity = self::getUserInactivity($websoccer, $db, $userId);
     $now = $websoccer->getNowAsTimestamp();
     $checkBoundary = $now - 24 * 3600;
     $updatecolumns = array();
     $user = UsersDataService::getUserById($websoccer, $db, $userId);
     // compute login-activity
     if ($inactivity["login_check"] < $checkBoundary) {
         $inactiveDays = round(($now - $user["lastonline"]) / (24 * 3600));
         $updatecolumns["login"] = min(100, round($inactiveDays * INACTIVITY_PER_DAY_LOGIN));
         $updatecolumns["login_check"] = $now;
         // update tactics activity
         $formationTable = $websoccer->getConfig("db_prefix") . "_aufstellung AS F";
         $formationTable .= " INNER JOIN " . $websoccer->getConfig("db_prefix") . "_verein AS T ON T.id = F.verein_id";
         $result = $db->querySelect("F.datum AS date", $formationTable, "T.user_id = %d", $userId);
         $formation = $result->fetch_array();
         $result->free();
         if ($formation) {
             $inactiveDays = round(($now - $formation["date"]) / (24 * 3600));
             $updatecolumns["aufstellung"] = min(100, round($inactiveDays * INACTIVITY_PER_DAY_TACTICS));
         }
     }
     // compute transfers-activity (check user's bids)
     if ($inactivity["transfer_check"] < $checkBoundary) {
         $bid = TransfermarketDataService::getLatestBidOfUser($websoccer, $db, $userId);
         $transferBenchmark = $user["registration_date"];
         if ($bid) {
             $transferBenchmark = $bid["date"];
         }
         $inactiveDays = round(($now - $transferBenchmark) / (24 * 3600));
         $updatecolumns["transfer"] = min(100, round($inactiveDays * INACTIVITY_PER_DAY_TRANSFERS));
         $updatecolumns["transfer_check"] = $now;
     }
     // update
     if (count($updatecolumns)) {
         $fromTable = $websoccer->getConfig("db_prefix") . "_user_inactivity";
         $db->queryUpdate($updatecolumns, $fromTable, "id = %d", $inactivity["id"]);
     }
 }
 public function getTemplateParameters()
 {
     $query = $this->_websoccer->getRequestParameter("query");
     $users = UsersDataService::findUsernames($this->_websoccer, $this->_db, $query);
     return array("items" => $users);
 }
 /**
  * 
  * @param WebSoccer $websoccer Application Context
  * @param DbConnection $db DB connection
  * @param int $leagueId league id
  * @param string $type table type: null|home|guest
  * @return array array of teams, ordered by table criteria.
  */
 public static function getTeamsOfLeagueOrderedByAlltimeTableCriteria(WebSoccer $websoccer, DbConnection $db, $leagueId, $type = null)
 {
     $fromTable = $websoccer->getConfig('db_prefix') . '_team_league_statistics AS S';
     $fromTable .= ' INNER JOIN ' . $websoccer->getConfig('db_prefix') . '_verein AS C ON C.id = S.team_id';
     $fromTable .= ' INNER JOIN ' . $websoccer->getConfig('db_prefix') . '_saison AS SEASON ON SEASON.id = S.season_id';
     $fromTable .= ' LEFT JOIN ' . $websoccer->getConfig('db_prefix') . '_user AS U ON C.user_id = U.id';
     $whereCondition = 'SEASON.liga_id = %d';
     $parameters = $leagueId;
     $columns['C.id'] = 'id';
     $columns['C.name'] = 'name';
     $columns['C.bild'] = 'picture';
     $fieldPrefix = 'total';
     if ($type == 'home') {
         $fieldPrefix = 'home';
     } else {
         if ($type == 'guest') {
             $fieldPrefix = 'guest';
         }
     }
     $columns['SUM(S.' . $fieldPrefix . '_points)'] = 'score';
     $columns['SUM(S.' . $fieldPrefix . '_goals)'] = 'goals';
     $columns['SUM(S.' . $fieldPrefix . '_goalsreceived)'] = 'goals_received';
     $columns['SUM(S.' . $fieldPrefix . '_goalsdiff)'] = 'goals_diff';
     $columns['SUM(S.' . $fieldPrefix . '_wins)'] = 'wins';
     $columns['SUM(S.' . $fieldPrefix . '_draws)'] = 'draws';
     $columns['SUM(S.' . $fieldPrefix . '_losses)'] = 'defeats';
     $columns['SUM((S.' . $fieldPrefix . '_wins + S.' . $fieldPrefix . '_draws + S.' . $fieldPrefix . '_losses))'] = 'matches';
     $columns['U.id'] = 'user_id';
     $columns['U.nick'] = 'user_name';
     $columns['U.email'] = 'user_email';
     $columns['U.picture'] = 'user_picture';
     $teams = array();
     $whereCondition .= ' GROUP BY C.id ORDER BY score DESC, goals_diff DESC, wins DESC, draws DESC, goals DESC, name ASC';
     $result = $db->querySelect($columns, $fromTable, $whereCondition, $parameters);
     while ($team = $result->fetch_array()) {
         $team['user_picture'] = UsersDataService::getUserProfilePicture($websoccer, $team['user_picture'], $team['user_email'], 20);
         $teams[] = $team;
     }
     $result->free();
     return $teams;
 }
 public function getTemplateParameters()
 {
     return array("usersOnline" => UsersDataService::countOnlineUsers($this->_websoccer, $this->_db), "usersTotal" => UsersDataService::countTotalUsers($this->_websoccer, $this->_db), "numberOfLeagues" => LeagueDataService::countTotalLeagues($this->_websoccer, $this->_db), "numberOfFreeTeams" => TeamsDataService::countTeamsWithoutManager($this->_websoccer, $this->_db));
 }
 /**
  * Debits specified amount from user's premium account (TAKING money).
  * Throws Exception if balance is not enough
  * 
  * @param WebSoccer $websoccer Application context.
  * @param DbConnection $db DB connection.
  * @param int $userId ID of user.
  * @param int $amount Positive amount to debit. If 0, no statement will be created.
  * @param string $subject action ID which triggered the statement.
  * @param array $data (otpional) Array of subject data.
  * @throws Exception if amount is negative, if premium credit is not enough or team could not be found.
  */
 public static function debitAmount(WebSoccer $websoccer, DbConnection $db, $userId, $amount, $subject, $data = null)
 {
     if ($amount == 0) {
         return;
     }
     $user = UsersDataService::getUserById($websoccer, $db, $userId);
     if (!isset($user['premium_balance'])) {
         throw new Exception('user not found: ' . $userId);
     }
     if ($amount < 0) {
         throw new Exception('amount illegal: ' . $amount);
     }
     // is balance enough?
     if ($user['premium_balance'] < $amount) {
         $i18n = I18n::getInstance($websoccer->getConfig('supported_languages'));
         throw new Exception($i18n->getMessage('premium_balance_notenough'));
     }
     $amount = 0 - $amount;
     self::createTransaction($websoccer, $db, $user, $userId, $amount, $subject, $data);
 }
 /**
  * Provides open match requests.
  * 
  * @param WebSoccer $websoccer Application context.
  * @param DbConnection $db DB connection.
  * @param int $startIndex Fetch start index.
  * @param int $entries_per_page Number of items to fetch.
  * @return array list of found requests incl. team and user summary.
  */
 public static function getMatchRequests(WebSoccer $websoccer, DbConnection $db, $startIndex, $entries_per_page)
 {
     $columns = array("R.id" => "request_id", "R.matchdate" => "matchdate", "R.reward" => "reward", "C.name" => "team_name", "C.id" => "team_id", "U.id" => "user_id", "U.nick" => "user_nick", "U.email" => "user_email", "U.picture" => "user_picture");
     $fromTable = $websoccer->getConfig("db_prefix") . "_youthmatch_request AS R";
     $fromTable .= " INNER JOIN " . $websoccer->getConfig("db_prefix") . "_verein AS C ON C.id = R.team_id";
     $fromTable .= " INNER JOIN " . $websoccer->getConfig("db_prefix") . "_user AS U ON U.id = C.user_id";
     $whereCondition = "1=1 ORDER BY R.matchdate ASC";
     $requests = array();
     $limit = $startIndex . "," . $entries_per_page;
     $result = $db->querySelect($columns, $fromTable, $whereCondition, null, $limit);
     while ($request = $result->fetch_array()) {
         $request["user_picture"] = UsersDataService::getUserProfilePicture($websoccer, $request["user_picture"], $request["user_email"]);
         $requests[] = $request;
     }
     $result->free();
     return $requests;
 }
 /**
  * 
  * @param WebSoccer $websoccer
  * @param DbConnection $db
  * @param string $whereCondition
  * @param array $parameters
  * @param string $limit
  * @return array list of matches.
  */
 public static function getMatchesByCondition(WebSoccer $websoccer, DbConnection $db, $whereCondition, $parameters, $limit)
 {
     $fromTable = self::_getFromPart($websoccer);
     // select
     $columns['M.id'] = 'id';
     $columns['M.spieltyp'] = 'type';
     $columns['M.pokalname'] = 'cup_name';
     $columns['M.pokalrunde'] = 'cup_round';
     $columns['M.home_noformation'] = 'home_noformation';
     $columns['M.guest_noformation'] = 'guest_noformation';
     $columns['HOME.name'] = 'home_team';
     $columns['HOME.bild'] = 'home_team_picture';
     $columns['HOME.id'] = 'home_id';
     $columns['HOMEUSER.id'] = 'home_user_id';
     $columns['HOMEUSER.nick'] = 'home_user_nick';
     $columns['HOMEUSER.email'] = 'home_user_email';
     $columns['HOMEUSER.picture'] = 'home_user_picture';
     $columns['GUEST.name'] = 'guest_team';
     $columns['GUEST.bild'] = 'guest_team_picture';
     $columns['GUEST.id'] = 'guest_id';
     $columns['GUESTUSER.id'] = 'guest_user_id';
     $columns['GUESTUSER.nick'] = 'guest_user_nick';
     $columns['GUESTUSER.email'] = 'guest_user_email';
     $columns['GUESTUSER.picture'] = 'guest_user_picture';
     $columns['M.home_tore'] = 'home_goals';
     $columns['M.gast_tore'] = 'guest_goals';
     $columns['M.berechnet'] = 'simulated';
     $columns['M.minutes'] = 'minutes';
     $columns['M.datum'] = 'date';
     $matches = array();
     $result = $db->querySelect($columns, $fromTable, $whereCondition, $parameters, $limit);
     while ($matchinfo = $result->fetch_array()) {
         $matchinfo['home_user_picture'] = UsersDataService::getUserProfilePicture($websoccer, $matchinfo['home_user_picture'], $matchinfo['home_user_email']);
         $matchinfo['guest_user_picture'] = UsersDataService::getUserProfilePicture($websoccer, $matchinfo['guest_user_picture'], $matchinfo['guest_user_email']);
         $matches[] = $matchinfo;
     }
     $result->free();
     return $matches;
 }
Esempio n. 20
0
 /**
  * 
  * @param WebSoccer $websoccer Application context.
  * @param String $fileName file name of picture.
  */
 public function setProfilePicture(WebSoccer $websoccer, $fileName)
 {
     if (strlen($fileName)) {
         $this->_profilePicture = UsersDataService::getUserProfilePicture($websoccer, $fileName, null);
     }
 }
 /**
  * Provides list of matches of team (including pictures and user info), ordered by date descending.
  * 
  * @param WebSoccer $websoccer Application context.
  * @param DbConnection $db DB connection.
  * @param int $teamId ID of team.
  * @param int $startIndex start fetch index.
  * @param int $entries_per_page number of items to fetch
  * @return array list of matches or empty array if no matches found.
  */
 public static function getMatchesOfTeam(WebSoccer $websoccer, DbConnection $db, $teamId, $startIndex, $entries_per_page)
 {
     $tablePrefix = $websoccer->getConfig("db_prefix");
     $fromTable = $tablePrefix . "_youthmatch AS M";
     $fromTable .= " INNER JOIN " . $tablePrefix . "_verein AS HOME ON M.home_team_id = HOME.id";
     $fromTable .= " INNER JOIN " . $tablePrefix . "_verein AS GUEST ON M.guest_team_id = GUEST.id";
     $fromTable .= " LEFT JOIN " . $tablePrefix . "_user AS HOMEUSER ON HOME.user_id = HOMEUSER.id";
     $fromTable .= " LEFT JOIN " . $tablePrefix . "_user AS GUESTUSER ON GUEST.user_id = GUESTUSER.id";
     // select
     $columns["M.id"] = "match_id";
     $columns["HOME.name"] = "home_team";
     $columns["HOME.bild"] = "home_team_picture";
     $columns["HOME.id"] = "home_id";
     $columns["HOMEUSER.id"] = "home_user_id";
     $columns["HOMEUSER.nick"] = "home_user_nick";
     $columns["HOMEUSER.email"] = "home_user_email";
     $columns["HOMEUSER.picture"] = "home_user_picture";
     $columns["GUEST.name"] = "guest_team";
     $columns["GUEST.bild"] = "guest_team_picture";
     $columns["GUEST.id"] = "guest_id";
     $columns["GUESTUSER.id"] = "guest_user_id";
     $columns["GUESTUSER.nick"] = "guest_user_nick";
     $columns["GUESTUSER.email"] = "guest_user_email";
     $columns["GUESTUSER.picture"] = "guest_user_picture";
     $columns["M.home_goals"] = "home_goals";
     $columns["M.guest_goals"] = "guest_goals";
     $columns["M.simulated"] = "simulated";
     $columns["M.matchdate"] = "date";
     $matches = array();
     $limit = $startIndex . "," . $entries_per_page;
     $result = $db->querySelect($columns, $fromTable, "(home_team_id = %d OR guest_team_id = %d) ORDER BY M.matchdate DESC", array($teamId, $teamId), $limit);
     while ($matchinfo = $result->fetch_array()) {
         $matchinfo["home_user_picture"] = UsersDataService::getUserProfilePicture($websoccer, $matchinfo["home_user_picture"], $matchinfo["home_user_email"]);
         $matchinfo["guest_user_picture"] = UsersDataService::getUserProfilePicture($websoccer, $matchinfo["guest_user_picture"], $matchinfo["guest_user_email"]);
         $matches[] = $matchinfo;
     }
     $result->free();
     return $matches;
 }