public function __construct($db, $i18n, $websoccer)
 {
     $this->_db = $db;
     $this->_i18n = $i18n;
     $this->_websoccer = $websoccer;
     $this->_absence = AbsencesDataService::getCurrentAbsenceOfUser($this->_websoccer, $this->_db, $this->_websoccer->getUser()->id);
 }
 /**
  * (non-PHPdoc)
  * @see IActionController::executeAction()
  */
 public function executeAction($parameters)
 {
     $userId = $this->_websoccer->getUser()->id;
     AbsencesDataService::confirmComeback($this->_websoccer, $this->_db, $userId);
     // success message
     $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("absence_return_success"), ""));
     return "office";
 }
 /**
  * (non-PHPdoc)
  * @see IModel::getTemplateParameters()
  */
 public function getTemplateParameters()
 {
     $absence = AbsencesDataService::getCurrentAbsenceOfUser($this->_websoccer, $this->_db, $this->_websoccer->getUser()->id);
     $deputyName = "";
     if ($absence && $absence['deputy_id']) {
         $result = $this->_db->querySelect('nick', $this->_websoccer->getConfig('db_prefix') . '_user', 'id = %d', $absence['deputy_id']);
         $deputy = $result->fetch_array();
         $result->free();
         $deputyName = $deputy['nick'];
     }
     return array('currentAbsence' => $absence, 'deputyName' => $deputyName);
 }
 /**
  * (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 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);
 }