From e5a21be974569e2714c443a1e2501694dd72f25b Mon Sep 17 00:00:00 2001 From: diddipoeler Date: Mon, 30 Dec 2024 14:31:00 +0100 Subject: [PATCH] korrektur --- site/models/staff.php | 74 ++++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/site/models/staff.php b/site/models/staff.php index 06b0dd631..630b11983 100644 --- a/site/models/staff.php +++ b/site/models/staff.php @@ -29,12 +29,6 @@ class sportsmanagementModelStaff extends BaseDatabaseModel static $personid = 0; static $teamplayerid = 0; static $teamid = 0; - - /** - * data array for staff history - * - * @var array - */ static $_history = null; static $_inproject = null; static $cfg_which_database = 0; @@ -67,34 +61,31 @@ function getPresenceStats($project_id, $person_id) { $app = Factory::getApplication(); $option = Factory::getApplication()->input->getCmd('option'); - - // Create a new query object. $db = sportsmanagementHelper::getDBConnection(true, self::$cfg_which_database); + $inoutstat = 0; $query = $db->getQuery(true); -/** - $query = ' SELECT count(mp.id) AS present - FROM #__sportsmanagement_match_staff AS mp - INNER JOIN #__sportsmanagement_match AS m ON mp.match_id=m.id - INNER JOIN #__sportsmanagement_team_staff AS tp ON tp.id=mp.team_staff_id - INNER JOIN #__sportsmanagement_project_team AS pt ON m.projectteam1_id=pt.id - WHERE tp.person_id=' . $this->_db->Quote((int) $person_id) . ' - AND pt.project_id=' . $this->_db->Quote((int) $project_id) . ' - AND tp.published = 1'; - */ - -$query = ' SELECT count(mp.id) AS present - FROM #__sportsmanagement_match_staff AS mp - INNER JOIN #__sportsmanagement_match AS m ON mp.match_id=m.id - INNER JOIN #__sportsmanagement_season_team_person_id AS tp ON -tp.id=mp.team_staff_id - INNER JOIN #__sportsmanagement_project_team AS pt ON -m.projectteam1_id=pt.id - WHERE tp.person_id=' . $this->_db->Quote((int) $person_id) . ' - AND pt.project_id=' . $this->_db->Quote((int) $project_id) . ' - AND tp.published = 1'; - + $query->select('count(mp.id) AS present'); + $query->from('#__sportsmanagement_match_staff AS mp'); + $query->join('INNER', '#__sportsmanagement_match AS m ON mp.match_id = m.id'); + $query->join('INNER', '#__sportsmanagement_season_team_person_id AS tp ON tp.id = mp.team_staff_id'); + $query->join('INNER', '#__sportsmanagement_project_team AS pt ON m.projectteam1_id = pt.id'); + $query->where('pt.project_id = ' . $projectid); + $query->where('tp.person_id = ' . $personid); + $query->where('tp.published = 1'); + + + try + { $db->setQuery($query, 0, 1); $inoutstat = $db->loadResult(); + } +catch (Exception $e) +{ +$app->enqueueMessage(Text::sprintf('COM_SPORTSMANAGEMENT_DATABASE_ERROR_FUNCTION_FAILED', $e->getCode(), $e->getMessage()), 'notice'); +$app->enqueueMessage(Text::sprintf('COM_SPORTSMANAGEMENT_FILE_ERROR_FUNCTION_FAILED', __FILE__, __LINE__), 'notice'); +} + +$db->disconnect(); // See: http://api.joomla.org/cms-3/classes/JDatabaseDriver.html#method_disconnect return $inoutstat; } @@ -127,8 +118,6 @@ function getTeamStaff() { $app = Factory::getApplication(); $option = Factory::getApplication()->input->getCmd('option'); - - // Create a new query object. $db = sportsmanagementHelper::getDBConnection(true, self::$cfg_which_database); $query = $db->getQuery(true); @@ -147,10 +136,19 @@ function getTeamStaff() $query->where('pt.project_id = ' . self::$projectid); $query->where('ts.person_id = ' . self::$personid); $query->where('ts.published = 1'); - +try +{ $db->setQuery($query); self::$_inproject = $db->loadObject(); + } +catch (Exception $e) +{ +$app->enqueueMessage(Text::sprintf('COM_SPORTSMANAGEMENT_DATABASE_ERROR_FUNCTION_FAILED', $e->getCode(), $e->getMessage()), 'notice'); +$app->enqueueMessage(Text::sprintf('COM_SPORTSMANAGEMENT_FILE_ERROR_FUNCTION_FAILED', __FILE__, __LINE__), 'notice'); +} } + + $db->disconnect(); // See: http://api.joomla.org/cms-3/classes/JDatabaseDriver.html#method_disconnect return self::$_inproject; } @@ -236,12 +234,22 @@ function getStaffHistory($order = 'DESC') $query->where('o.persontype = 2'); //$query->order('s.ordering ' . $order . ', l.ordering ASC, p.name ASC '); $query->order('s.name '. $order.', p.name '. $order ); + try + { $db->setQuery($query); self::$_history = $db->loadObjectList(); + } +catch (Exception $e) +{ +$app->enqueueMessage(Text::sprintf('COM_SPORTSMANAGEMENT_DATABASE_ERROR_FUNCTION_FAILED', $e->getCode(), $e->getMessage()), 'notice'); +$app->enqueueMessage(Text::sprintf('COM_SPORTSMANAGEMENT_FILE_ERROR_FUNCTION_FAILED', __FILE__, __LINE__), 'notice'); +} if (!self::$_history) { } + + $db->disconnect(); // See: http://api.joomla.org/cms-3/classes/JDatabaseDriver.html#method_disconnect return self::$_history; }