예제 #1
0
function migrateAssets()
{
    $maxImportTime = JComponentHelper::getParams('com_joomleague')->get('max_import_time', 0);
    if (empty($maxImportTime)) {
        $maxImportTime = 9000;
    }
    if ((int) ini_get('max_execution_time') < $maxImportTime) {
        @set_time_limit($maxImportTime);
    }
    $query = "SHOW TABLES LIKE '%_joomleague%'";
    $db = JFactory::getDbo();
    $tables = array();
    $db->setQuery($query);
    $results = $db->loadColumn();
    foreach ($results as $tablename) {
        $fields = $db->getTableColumns($tablename);
        foreach ($fields as $field) {
            if (in_array('asset_id', array_keys($field))) {
                $tables[] = $tablename;
            }
        }
    }
    for ($i = 0; $i < count($tables); $i++) {
        $table = $tables[$i];
        $query = 'SELECT id FROM ' . $table;
        $db->setQuery($query);
        if ($items = $db->loadObjectList()) {
            $table = str_replace($db->getPrefix() . 'joomleague_', '', $table);
            foreach ($items as $item) {
                // TODO: process the $table string such that it reflects the class name
                // JTable::getInstance now expects $type and $prefix with proper capitals (as table class name)
                // Could replace first letter and every letter following an underscore by its capital
                // and removing the underscores, but that would fail for eventtype, position_eventtype
                // and team_trainingdata and template_config
                $tbl = JTable::getInstance(str_replace('_', '', $table), "Table");
                if ($tbl->load($item->id)) {
                }
                $tbl->store(true);
            }
        }
        echo '<br>Migrated ' . count($items) . ' records in ' . $tables[$i] . ' ';
        echo PrintStepResult(true);
    }
    return '';
}
예제 #2
0
function migrateAssets()
{
    $maxImportTime = JComponentHelper::getParams('com_joomleague')->get('max_import_time', 0);
    if (empty($maxImportTime)) {
        $maxImportTime = 9000;
    }
    if ((int) ini_get('max_execution_time') < $maxImportTime) {
        @set_time_limit($maxImportTime);
    }
    $query = "SHOW TABLES LIKE '%_joomleague%'";
    $db = JFactory::getDbo();
    $tables = array();
    $db->setQuery($query);
    $results = $db->loadColumn();
    foreach ($results as $tablename) {
        $fields = $db->getTableColumns($tablename);
        foreach ($fields as $field) {
            if (in_array('asset_id', array_keys($field))) {
                $tables[] = $tablename;
            }
        }
    }
    for ($i = 0; $i < count($tables); $i++) {
        $table = $tables[$i];
        $query = 'SELECT id FROM ' . $table;
        $db->setQuery($query);
        if ($items = $db->loadObjectList()) {
            $table = str_replace($db->getPrefix() . 'joomleague_', '', $table);
            foreach ($items as $item) {
                $tbl = JTable::getInstance(str_replace('_', '', $table), "Table");
                if ($tbl->load($item->id)) {
                }
                $tbl->store(true);
            }
        }
        echo '<br>Migrated ' . count($items) . ' records in ' . $tables[$i] . ' ';
        echo PrintStepResult(true);
    }
    return '';
}
예제 #3
0
function TipResultsToPredictionResults()
{
    $db = JFactory::getDbo();
    $result = true;
    $copied = false;
    $i = 0;
    //$query='TRUNCATE TABLE `#__joomleague_prediction_result`'; $db->setQuery($query); $db->execute();
    echo JText::sprintf('Copying --> Table content of [%1$s] to [%2$s]', '<b>joomleague_tip_results</b>', '<b>joomleague_prediction_result</b>');
    $query = 'SELECT * FROM #__joomleague_tip_results';
    $db->setQuery($query);
    if ($predictiongametipresults = $db->loadObjectList()) {
        $query = 'SELECT prediction_id,tmp_old_pid FROM #__joomleague_prediction_project';
        $db->setQuery($query);
        $dPredProject = $db->loadAssocList('tmp_old_pid');
        //echo '<pre>~'.print_r($dPredProject,true).'~</pre>';
        $query = 'SELECT id,tmp_old_pid FROM #__joomleague_project';
        $db->setQuery($query);
        $dProjects = $db->loadAssocList('tmp_old_pid');
        $query = 'SELECT id,tmp_old_match_id FROM #__joomleague_match';
        $db->setQuery($query);
        $dMatches = $db->loadAssocList('tmp_old_match_id');
        foreach ($predictiongametipresults as $predictiongametipresult) {
            if (isset($dPredProject[$predictiongametipresult->project_id])) {
                $prediction_id = $dPredProject[$predictiongametipresult->project_id]['prediction_id'];
                // get new prediction_id...
                if (isset($dProjects[$predictiongametipresult->project_id])) {
                    $project_id = $dProjects[$predictiongametipresult->project_id]['id'];
                    // get new project id of predProject...
                    if (isset($dMatches[$predictiongametipresult->match_id])) {
                        $match_id = $dMatches[$predictiongametipresult->match_id]['id'];
                        if ($predictiongametipresult->tip != '0') {
                            $tipp = empty($predictiongametipresult->tip) ? 'NULL' : "'" . $predictiongametipresult->tip . "'";
                        } else {
                            $tipp = "'0'";
                        }
                        if ($predictiongametipresult->tip_home != '0') {
                            $tipp_home = empty($predictiongametipresult->tip_home) ? 'NULL' : "'" . $predictiongametipresult->tip_home . "'";
                        } else {
                            $tipp_home = "'0'";
                        }
                        if ($predictiongametipresult->tip_away != '0') {
                            $tipp_away = empty($predictiongametipresult->tip_away) ? 'NULL' : "'" . $predictiongametipresult->tip_away . "'";
                        } else {
                            $tipp_away = "'0'";
                        }
                        if ($predictiongametipresult->joker != '0') {
                            $joker = empty($predictiongametipresult->joker) ? 'NULL' : "'" . $predictiongametipresult->joker . "'";
                        } else {
                            $joker = "'0'";
                        }
                        $copied = true;
                        $result = true;
                        $query = "\tINSERT INTO\t#__joomleague_prediction_result\n\t\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`prediction_id`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`user_id`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`project_id`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`match_id`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`tipp`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`tipp_home`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`tipp_away`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`joker`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`tmp_old_id`\n\t\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$prediction_id}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$predictiongametipresult->user_id}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$project_id}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$match_id}',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$tipp},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$tipp_home},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$tipp_away},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$joker},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'{$predictiongametipresult->id}'\n\t\t\t\t\t\t\t\t\t\t\t\t\t)";
                        $db->setQuery($query);
                        if (!$db->execute()) {
                            $result = false;
                            echo PrintStepResult($result) . '<br />';
                            echo '<br />' . $db->getErrorMsg() . ' <br />';
                        } else {
                            $i++;
                        }
                    } else {
                        $match_id = 0;
                    }
                } else {
                    $project_id = 0;
                }
            } else {
                $prediction_id = 0;
            }
        }
    } else {
        $result = false;
        echo PrintStepResult($result) . '<br />';
        echo '<br />' . $db->getErrorMsg() . ' <br />';
    }
    if ($i == count($predictiongametipresults)) {
        $color = 'green';
    } elseif ($i == 0) {
        $color = 'red';
    } else {
        $color = 'orange';
    }
    echo '<br /><br /><b style="color:' . $color . ';" >' . JText::sprintf('COM_JOOMLEAGUE_DB_UPDATE_COPIED_X_OF_Y_RECORDS', $i, count($predictiongametipresults)) . '</b><br /><br />';
    return '';
}
function UpdateTemplateMasters()
{
    /**********************************
     ******** Update Script for xml template to store the non existing Variable
     ***********************************/
    /*
     * developer: diddipoeler
     * date: 13.01.2011
     * Bugtracker Backend Bug #579
     * change old textname in newtextname
     */
    $convert = array('JL_AGAINST' => 'AGAINST', 'JL_AVG' => 'AVG', 'JL_BONUS' => 'BONUS', 'JL_DIFF' => 'DIFF', 'JL_FOR' => 'FOR', 'JL_GB' => 'GB', 'JL_H2H' => 'H2H', 'JL_H2H_AWAY' => 'H2H_AWAY', 'JL_H2H_DIFF' => 'H2H_DIFF', 'JL_H2H_FOR' => 'H2H_FOR', 'JL_LEGS' => 'LEGS', 'JL_LEGS_DIFF' => 'LEGS_DIFF', 'JL_LEGS_RATIO' => 'LEGS_RATIO', 'JL_LEGS_WIN' => 'LEGS_WIN', 'JL_LOSSES' => 'LOSSES', 'JL_NEGPOINTS' => 'NEGPOINTS', 'JL_OLDNEGPOINTS' => 'OLDNEGPOINTS', 'JL_PLAYED' => 'PLAYED', 'JL_POINTS' => 'POINTS', 'JL_POINTS_RATIO' => 'POINTS_RATIO', 'JL_QUOT' => 'QUOT', 'JL_RESULTS' => 'RESULTS', 'JL_SCOREAGAINST' => 'SCOREAGAINST', 'JL_SCOREFOR' => 'SCOREFOR', 'JL_SCOREPCT' => 'SCOREPCT', 'JL_START' => 'START', 'JL_TIES' => 'TIES', 'JL_WINPCT' => 'WINPCT', 'JL_WINS' => 'WINS');
    echo '<b>' . JText::_('Updating new variables and templates for usage in the Master-Templates') . '</b><br />';
    $db = JFactory::getDBO();
    $query = 'SELECT id,name,master_template FROM #__joomleague_project';
    $db->setQuery($query);
    if ($projects = $db->loadObjectList()) {
        //echo '<br />';
        $xmldir = JPATH_SITE . DS . 'components' . DS . 'com_joomleague' . DS . 'settings' . DS . 'default';
        if ($handle = JFolder::files($xmldir)) {
            # check that each xml template has a corresponding record in the
            # database for this project (except for projects using master templates).
            # If not,create the rows with default values
            # from the xml file
            foreach ($handle as $file) {
                if (strtolower(substr($file, -3)) == 'xml' && substr($file, 0, strlen($file) - 4) != 'table' && substr($file, 0, 10) != 'prediction') {
                    $defaultconfig = array();
                    $template = substr($file, 0, strlen($file) - 4);
                    $out = simplexml_load_file($xmldir . DS . $file, 'SimpleXMLElement', LIBXML_NOCDATA);
                    $temp = '';
                    $arr = obj2Array($out);
                    $outName = JText::_($out->name[0]);
                    echo '<br />' . JText::sprintf('Template: [%1$s] - Name: [%2$s]', "<b>{$template}</b>", "<b>{$outName}</b>") . '<br />';
                    if (isset($arr["fieldset"]["field"])) {
                        foreach ($arr["fieldset"]["field"] as $param) {
                            $temp .= $param["@attributes"]["name"] . "=" . $param["@attributes"]["default"] . "\n";
                            $defaultconfig[$param["@attributes"]["name"]] = $param["@attributes"]["default"];
                        }
                    } else {
                        foreach ($arr["fieldset"] as $paramsgroup) {
                            foreach ($paramsgroup["field"] as $param) {
                                if (!isset($param["@attributes"])) {
                                    if (isset($param["name"])) {
                                        $temp .= $param["name"] . "=" . $param["default"] . "\n";
                                        $defaultconfig[$param["name"]] = $param["default"];
                                    }
                                } else {
                                    if (isset($param["name"])) {
                                        /*
                                         * developer: diddipoeler
                                         * date: change on 13.01.2011
                                         * Bugtracker Backend Bug #579
                                         * error message string to object example template teamstats
                                         */
                                        //$temp .= $param["@attributes"]["name"]."=".$param["@attributes"]["default"]."\n";
                                        $temp .= $param["name"] . "=" . $param["default"] . "\n";
                                        //$defaultconfig[$param["@attributes"]["name"]]=$param["@attributes"]["default"];
                                        $defaultconfig[$param["name"]] = $param["default"];
                                    }
                                }
                            }
                        }
                    }
                    $changeNeeded = false;
                    foreach ($projects as $proj) {
                        $count_diff = 0;
                        $configvalues = array();
                        $query = "SELECT params FROM #__joomleague_template_config WHERE project_id={$proj->id} AND template='" . $template . "'";
                        $db->setQuery($query);
                        if ($id = $db->loadResult()) {
                            //template present in db for this project
                            $string = '';
                            $templateTitle = '';
                            $params = explode("\n", trim($id));
                            foreach ($params as $param) {
                                $row = explode("=", $param);
                                if (isset($row[1])) {
                                    list($name, $value) = $row;
                                    $configvalues[$name] = $value;
                                }
                            }
                            foreach ($defaultconfig as $key => $value) {
                                if (!array_key_exists($key, $configvalues)) {
                                    $count_diff++;
                                    $configvalues[$key] = $value;
                                }
                            }
                            if ($count_diff || $template == 'ranking' || $template == 'overall') {
                                foreach ($configvalues as $key => $value) {
                                    if (preg_match("/%H:%m/i", $value)) {
                                        // change text
                                        $value = 'H:i';
                                    } else {
                                        // text ok
                                    }
                                    /*
                                     * developer: diddipoeler
                                     * date: change on 13.01.2011
                                     * Bugtracker Backend Bug #579
                                     * change old textname in newtextname
                                     */
                                    if (preg_match("/JL_/i", $value)) {
                                        // change text
                                        $value = str_replace(array_keys($convert), array_values($convert), $value);
                                    } else {
                                        // text ok
                                    }
                                    $value = trim($value);
                                    $string .= "{$key}={$value}\n";
                                }
                                echo JText::sprintf('Difference found for project [%1$s]', '<b>' . $proj->name . '</b>') . ' - ';
                                $changeNeeded = true;
                                $query = " UPDATE #__joomleague_template_config ";
                                $query .= " SET ";
                                $query .= " title='" . $out->name[0] . "',";
                                $query .= " params='{$string}' ";
                                $query .= " WHERE template='{$template}' AND project_id=" . $proj->id;
                                $db->setQuery($query);
                                if (!$db->query()) {
                                    echo '<span style="color:red">';
                                    echo JText::sprintf('Problems while saving config for [%1$s] with project-ID [%2$s]!', '<b>' . $template . '</b>', '<b>' . $proj->id . '</b>');
                                    echo '</span>' . '<br />';
                                    echo $db->getErrorMsg() . '<br />';
                                } else {
                                    echo JText::sprintf('Updated template [%1$s] with project-ID [%2$s]', '<span style="color:green;"><b>' . $template . '</b></span>', '<span style="color:green"><b>' . $proj->id . '</b></span>') . PrintStepResult(true) . '<br />';
                                }
                            }
                        } elseif ($proj->master_template == 0) {
                            //check that project has own templates
                            //or if template not present,create a row with default values
                            echo '<br /><span style="color:orange;">' . JText::sprintf('Need to insert into project with project-ID [%1$s] - Project name is [%2$s]', '<b>' . $proj->id . '</b>', '<b>' . $proj->name . '</b>') . '</span><br />';
                            $changeNeeded = true;
                            $temp = trim($temp);
                            $query = "\tINSERT\n\t\t\t\t\t\t\tINTO #__joomleague_template_config\n\t\t\t\t\t\t\t(template,title,params,project_id)\n\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t('{$template}','" . $out->name[0] . "','{$temp}','{$proj->id}')";
                            $db->setQuery($query);
                            //echo error,allows to check if there is a mistake in the template file
                            if (!$db->query()) {
                                echo '<span style="color:red; font-weight:bold; ">' . JText::sprintf('Error with [%s]:', $template) . '</span><br />';
                                echo $db->getErrorMsg() . '<br/>';
                            } else {
                                echo JText::sprintf('Inserted %1$s into project with ID %2$s', '<b>' . $template . '</b>', '<b>' . $proj->id . '</b>') . PrintStepResult(true) . '<br />';
                            }
                        }
                    }
                    if (!$changeNeeded) {
                        echo '<span style="color:green">' . JText::_('No changes needed for this template') . '</span>' . '<br />';
                    }
                }
            }
        } else {
            echo ' - <span style="color:red">' . JText::_('No templates found') . '</span>';
        }
    } else {
        echo ' - <span style="color:green">' . JText::_('No update was needed') . '</span>';
    }
    return '';
}
예제 #5
0
    $praefix = 'COM_JOOMLEAGUE_ST_';
    foreach ($strings as $key => $value) {
        // Add all Sport-types e.g. Soccer to #__joomleague_sports_type
        $pos = strpos($key, $praefix);
        if ($pos !== false) {
            $name = strtolower(substr($key, strlen($praefix)));
            $tblSportsType = JTable::getInstance("SportsType", "Table");
            //fix for existing items
            $tblSportsType->load(array("name" => $key));
            $tblSportsType->name = $key;
            $tblSportsType->icon = JPATH::clean('images/com_joomleague/database/sport_types/' . $name . '.png');
            if (!$tblSportsType->store()) {
                //echo($tblSportsType->getError());
                $status = 2;
            }
            JFolder::create(JPATH::clean(JPATH_ROOT . '/images/com_joomleague/database/events/' . $name));
        }
    }
    return $status;
}
//_checkVersionTable();
$versionData = getVersion();
$major = $versionData->major;
$minor = $versionData->minor;
$build = $versionData->build;
$revision = $versionData->revision;
$version = sprintf('v%1$s.%2$s.%3$s.%4$s', $major, $minor, $build, $revision);
echo PrintStepResult(addGhostPlayer());
echo PrintStepResult(addSportsType());
echo PrintStepResult(updateVersion($versionData));
function addStandardsForSoccer()
{
    $events_player = array();
    $events_staff = array();
    $events_referees = array();
    $events_clubstaff = array();
    $PlayersPositions = array();
    $StaffPositions = array();
    $RefereePositions = array();
    $ClubStaffPositions = array();
    $result = false;
    $db = JFactory::getDbo();
    if ('AddEvents' == 'AddEvents') {
        echo JText::sprintf('Adding standard soccer events to table table [%s]', '<b>' . '#__joomleague_eventtype' . '</b>');
        $squery = 'SELECT * FROM #__joomleague_eventtype WHERE name=`%s`';
        $isquery = 'INSERT INTO #__joomleague_eventtype (`name`,`icon`) VALUES (`%1$s`,`%2$s`)';
        $query = "SELECT * FROM #__joomleague_sports_type WHERE name='COM_JOOMLEAGUE_ST_SOCCER'";
        $db->setQuery($query);
        $sports_type = $db->loadObject();
        $newEventName = 'COM_JOOMLEAGUE_E_GOAL';
        $newEventIcon = 'images/com_joomleague/database/events/soccer/goal.png';
        $suspension = 0;
        $query = build_SelectQuery('eventtype', $newEventName);
        $db->setQuery($query);
        if (!($object = $db->loadObject())) {
            $query = build_InsertQuery_Event('eventtype', $newEventName, $newEventIcon, $suspension, $sports_type->id, 1);
            $db->setQuery($query);
            $result = $db->execute();
            $events_player['0'] = $db->insertid();
        } else {
            $events_player['0'] = $object->id;
        }
        $newEventName = 'COM_JOOMLEAGUE_E_ASSISTS';
        $newEventIcon = 'images/com_joomleague/database/events/soccer/assists.png';
        $suspension = 0;
        $query = build_SelectQuery('eventtype', $newEventName);
        $db->setQuery($query);
        if (!($object = $db->loadObject())) {
            $query = build_InsertQuery_Event('eventtype', $newEventName, $newEventIcon, $suspension, $sports_type->id, 2);
            $db->setQuery($query);
            $result = $db->execute();
            $events_player['1'] = $db->insertid();
        } else {
            $events_player['1'] = $object->id;
        }
        $newEventName = 'COM_JOOMLEAGUE_E_YELLOW_CARD';
        $newEventIcon = 'images/com_joomleague/database/events/soccer/yellow_card.png';
        $suspension = 0;
        $query = build_SelectQuery('eventtype', $newEventName);
        $db->setQuery($query);
        if (!($object = $db->loadObject())) {
            $query = build_InsertQuery_Event('eventtype', $newEventName, $newEventIcon, $suspension, $sports_type->id, 3);
            $db->setQuery($query);
            $result = $db->execute();
            $events_player['2'] = $db->insertid();
            $events_staff['2'] = $db->insertid();
            $events_clubstaff['2'] = $db->insertid();
            $events_referees['2'] = $db->insertid();
        } else {
            $events_player['2'] = $object->id;
            $events_staff['2'] = $object->id;
            $events_clubstaff['2'] = $object->id;
            $events_referees['2'] = $object->id;
        }
        $newEventName = 'COM_JOOMLEAGUE_E_YELLOW-RED_CARD';
        $newEventIcon = 'images/com_joomleague/database/events/soccer/yellow_red_card.png';
        $suspension = 1;
        $query = build_SelectQuery('eventtype', $newEventName);
        $db->setQuery($query);
        if (!($object = $db->loadObject())) {
            $query = build_InsertQuery_Event('eventtype', $newEventName, $newEventIcon, $suspension, $sports_type->id, 4);
            $db->setQuery($query);
            $result = $db->execute();
            $events_player['3'] = $db->insertid();
            $events_staff['3'] = $db->insertid();
            $events_clubstaff['3'] = $db->insertid();
            $events_referees['3'] = $db->insertid();
        } else {
            $events_player['3'] = $object->id;
            $events_staff['3'] = $object->id;
            $events_clubstaff['3'] = $object->id;
            $events_referees['3'] = $object->id;
        }
        $newEventName = 'COM_JOOMLEAGUE_E_RED_CARD';
        $newEventIcon = 'images/com_joomleague/database/events/soccer/red_card.png';
        $suspension = 1;
        $query = build_SelectQuery('eventtype', $newEventName);
        $db->setQuery($query);
        if (!($object = $db->loadObject())) {
            $query = build_InsertQuery_Event('eventtype', $newEventName, $newEventIcon, $suspension, $sports_type->id, 5);
            $db->setQuery($query);
            $result = $db->execute();
            $events_player['4'] = $db->insertid();
            $events_staff['4'] = $db->insertid();
            $events_clubstaff['4'] = $db->insertid();
            $events_referees['4'] = $db->insertid();
        } else {
            $events_player['4'] = $object->id;
            $events_staff['4'] = $object->id;
            $events_clubstaff['4'] = $object->id;
            $events_referees['4'] = $object->id;
        }
        $newEventName = 'COM_JOOMLEAGUE_E_FOUL';
        $newEventIcon = 'images/com_joomleague/database/events/soccer/foul.png';
        $suspension = 0;
        $query = build_SelectQuery('eventtype', $newEventName);
        $db->setQuery($query);
        if (!($object = $db->loadObject())) {
            $query = build_InsertQuery_Event('eventtype', $newEventName, $newEventIcon, $suspension, $sports_type->id, 6);
            $db->setQuery($query);
            $result = $db->execute();
            $events_player['5'] = $db->insertid();
            $events_referees['5'] = $db->insertid();
        } else {
            $events_player['5'] = $object->id;
            $events_referees['5'] = $object->id;
        }
        $newEventName = 'COM_JOOMLEAGUE_E_FOUL_TIME';
        $newEventIcon = 'images/com_joomleague/database/events/soccer/foul_time.png';
        $suspension = 0;
        $query = build_SelectQuery('eventtype', $newEventName);
        $db->setQuery($query);
        if (!($object = $db->loadObject())) {
            $query = build_InsertQuery_Event('eventtype', $newEventName, $newEventIcon, $suspension, $sports_type->id, 7);
            $db->setQuery($query);
            $result = $db->execute();
            $events_player['6'] = $db->insertid();
            $events_referees['6'] = $db->insertid();
        } else {
            $events_player['6'] = $object->id;
            $events_referees['6'] = $object->id;
        }
        $newEventName = 'COM_JOOMLEAGUE_E_OWN_GOAL';
        $newEventIcon = 'images/com_joomleague/database/events/soccer/own_goal.png';
        $suspension = 0;
        $query = build_SelectQuery('eventtype', $newEventName);
        $db->setQuery($query);
        if (!($object = $db->loadObject())) {
            $query = build_InsertQuery_Event('eventtype', $newEventName, $newEventIcon, $suspension, $sports_type->id, 8);
            $db->setQuery($query);
            $result = $db->execute();
            $events_player['7'] = $db->insertid();
        } else {
            $events_player['7'] = $object->id;
        }
        $newEventName = 'COM_JOOMLEAGUE_E_PENALTY_GOAL';
        $newEventIcon = 'images/com_joomleague/database/events/soccer/penalty_goal.png';
        $suspension = 0;
        $query = build_SelectQuery('eventtype', $newEventName);
        $db->setQuery($query);
        if (!($object = $db->loadObject())) {
            $query = build_InsertQuery_Event('eventtype', $newEventName, $newEventIcon, $suspension, $sports_type->id, 9);
            $db->setQuery($query);
            $result = $db->execute();
            $events_player['8'] = $db->insertid();
            $events_referees['8'] = $db->insertid();
        } else {
            $events_player['8'] = $object->id;
            $events_referees['8'] = $object->id;
        }
        $newEventName = 'COM_JOOMLEAGUE_E_INJURY';
        $newEventIcon = 'images/com_joomleague/database/events/soccer/injured.png';
        $suspension = 0;
        $query = build_SelectQuery('eventtype', $newEventName);
        $db->setQuery($query);
        if (!($object = $db->loadObject())) {
            $query = build_InsertQuery_Event('eventtype', $newEventName, $newEventIcon, $suspension, $sports_type->id, 10);
            $db->setQuery($query);
            $result = $db->execute();
            $events_player['9'] = $db->insertid();
            $events_staff['9'] = $db->insertid();
            $events_clubstaff['9'] = $db->insertid();
            $events_referees['9'] = $db->insertid();
        } else {
            $events_player['9'] = $object->id;
            $events_staff['9'] = $object->id;
            $events_clubstaff['9'] = $object->id;
            $events_referees['9'] = $object->id;
        }
        $newEventName = 'COM_JOOMLEAGUE_E_BLUE_CARD';
        $newEventIcon = 'images/com_joomleague/database/events/soccer/blue_card.png';
        $suspension = 0;
        $query = build_SelectQuery('eventtype', $newEventName);
        $db->setQuery($query);
        if (!($object = $db->loadObject())) {
            $query = build_InsertQuery_Event('eventtype', $newEventName, $newEventIcon, $suspension, $sports_type->id, 11);
            $db->setQuery($query);
            $result = $db->execute();
            $events_player['10'] = $db->insertid();
            $events_staff['10'] = $db->insertid();
            $events_clubstaff['10'] = $db->insertid();
            $events_referees['10'] = $db->insertid();
        } else {
            $events_player['10'] = $object->id;
            $events_staff['10'] = $object->id;
            $events_clubstaff['10'] = $object->id;
            $events_referees['10'] = $object->id;
        }
        $newEventName = 'COM_JOOMLEAGUE_E_BLUE_RED_CARD';
        $newEventIcon = 'images/com_joomleague/database/events/soccer/blue_red_card.png';
        $suspension = 1;
        $query = build_SelectQuery('eventtype', $newEventName);
        $db->setQuery($query);
        if (!($object = $db->loadObject())) {
            $query = build_InsertQuery_Event('eventtype', $newEventName, $newEventIcon, $suspension, $sports_type->id, 12);
            $db->setQuery($query);
            $result = $db->execute();
            $events_player['11'] = $db->insertid();
            $events_staff['11'] = $db->insertid();
            $events_clubstaff['11'] = $db->insertid();
            $events_referees['11'] = $db->insertid();
        } else {
            $events_player['11'] = $object->id;
            $events_staff['11'] = $object->id;
            $events_clubstaff['11'] = $object->id;
            $events_referees['11'] = $object->id;
        }
        echo PrintStepResult($result) . '<br />';
        if (!$result) {
            echo JText::_('DO NOT WORRY... Surely at least one of the events was already existing in your database!!!') . '<br />';
        }
        echo '<br />';
    }
    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    $result = false;
    if ('AddPositions' == 'AddPositions') {
        echo JText::sprintf('Adding standard soccer positions to table table [%s]', '<b>' . '#__joomleague_position' . '</b>');
        if ('AddGeneralPlayersPositions' == 'AddGeneralPlayersPositions') {
            // Add new Parent position to PlayersPositions
            $newPosName = 'COM_JOOMLEAGUE_F_PLAYERS';
            $newPosSwitch = 'persontype';
            $newPosParent = '0';
            $newPosContent = '1';
            $query = build_SelectQuery('position', $newPosName);
            $db->setQuery($query);
            if (!($dbresult = $db->loadObject())) {
                $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 1);
                $db->setQuery($query);
                $result = $db->execute();
                $ParentID = $db->insertid();
                $PlayersPositions['0'] = $db->insertid();
            } else {
                $ParentID = $dbresult->id;
                $PlayersPositions['0'] = $dbresult->id;
            }
            if ('AddGeneralPlayersChildPositions' == 'AddGeneralPlayersChildPositions') {
                // Add new Child positions to PlayersPositions
                // New Child position for PlayersPositions
                $newPosName = 'COM_JOOMLEAGUE_P_GOALKEEPER';
                $newPosSwitch = 'persontype';
                $newPosParent = $ParentID;
                $newPosContent = '1';
                $query = build_SelectQuery('position', $newPosName);
                $db->setQuery($query);
                if (!($object = $db->loadObject())) {
                    $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 2);
                    $db->setQuery($query);
                    $result = $db->execute();
                    $PlayersPositions['1'] = $db->insertid();
                } else {
                    $PlayersPositions['1'] = $object->id;
                }
                // New Child position for PlayersPositions
                $newPosName = 'COM_JOOMLEAGUE_P_DEFENDER';
                $newPosSwitch = 'persontype';
                $newPosParent = $ParentID;
                $newPosContent = '1';
                $query = build_SelectQuery('position', $newPosName);
                $db->setQuery($query);
                if (!($object = $db->loadObject())) {
                    $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 3);
                    $db->setQuery($query);
                    $result = $db->execute();
                    $PlayersPositions['2'] = $db->insertid();
                } else {
                    $PlayersPositions['2'] = $object->id;
                }
                // New Child position for PlayersPositions
                $newPosName = 'COM_JOOMLEAGUE_P_MIDFIELDER';
                $newPosSwitch = 'persontype';
                $newPosParent = $ParentID;
                $newPosContent = '1';
                $query = build_SelectQuery('position', $newPosName);
                $db->setQuery($query);
                if (!($object = $db->loadObject())) {
                    $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 4);
                    $db->setQuery($query);
                    $result = $db->execute();
                    $PlayersPositions['3'] = $db->insertid();
                } else {
                    $PlayersPositions['3'] = $object->id;
                }
                // New Child position for PlayersPositions
                $newPosName = 'COM_JOOMLEAGUE_P_FORWARD';
                $newPosSwitch = 'persontype';
                $newPosParent = $ParentID;
                $newPosContent = '1';
                $query = build_SelectQuery('position', $newPosName);
                $db->setQuery($query);
                if (!($object = $db->loadObject())) {
                    $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 5);
                    $db->setQuery($query);
                    $result = $db->execute();
                    $PlayersPositions['4'] = $db->insertid();
                } else {
                    $PlayersPositions['4'] = $object->id;
                }
            }
        }
        //----------------------------------------------------------------------
        if ('AddGeneralStaffPositions' == 'AddGeneralStaffPositions') {
            if ('AddGeneralStaffTeamStaffPositions' == 'AddGeneralStaffTeamStaffPositions') {
                // Add new Parent position to StaffPositions
                $newPosName = 'COM_JOOMLEAGUE_F_TEAM_STAFF';
                $newPosSwitch = 'persontype';
                $newPosParent = '0';
                $newPosContent = '2';
                $query = build_SelectQuery('position', $newPosName);
                $db->setQuery($query);
                if (!($dbresult = $db->loadObject())) {
                    $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 6);
                    $db->setQuery($query);
                    $result = $db->execute();
                    $ParentID = $db->insertid();
                    $StaffPositions['0'] = $db->insertid();
                } else {
                    $ParentID = $dbresult->id;
                    $StaffPositions['0'] = $dbresult->id;
                }
            }
            //----------------------------------------------------------------------
            if ('AddGeneralStaffCoachesPositions' == 'AddGeneralStaffCoachesPositions') {
                // Add new Parent position to StaffPositions
                $newPosName = 'COM_JOOMLEAGUE_F_COACHES';
                $newPosSwitch = 'persontype';
                $newPosParent = '0';
                $newPosContent = '2';
                $query = build_SelectQuery('position', $newPosName);
                $db->setQuery($query);
                if (!($dbresult = $db->loadObject())) {
                    $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 7);
                    $db->setQuery($query);
                    $result = $db->execute();
                    $ParentID = $db->insertid();
                    $StaffPositions['1'] = $db->insertid();
                } else {
                    $ParentID = $dbresult->id;
                    $StaffPositions['1'] = $dbresult->id;
                }
                if ('AddGeneralStaffCoachesChildPositions' == 'AddGeneralStaffCoachesChildPositions') {
                    // New Child position for StaffPositions
                    $newPosName = 'COM_JOOMLEAGUE_F_COACH';
                    $newPosSwitch = 'persontype';
                    $newPosParent = $ParentID;
                    $newPosContent = '2';
                    $query = build_SelectQuery('position', $newPosName);
                    $db->setQuery($query);
                    if (!($object = $db->loadObject())) {
                        $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 8);
                        $db->setQuery($query);
                        $result = $db->execute();
                        $StaffPositions['2'] = $db->insertid();
                    } else {
                        $StaffPositions['2'] = $object->id;
                    }
                    // New Child position for StaffPositions
                    $newPosName = 'COM_JOOMLEAGUE_F_HEAD_COACH';
                    $newPosSwitch = 'persontype';
                    $newPosParent = $ParentID;
                    $newPosContent = '2';
                    $query = build_SelectQuery('position', $newPosName);
                    $db->setQuery($query);
                    if (!($object = $db->loadObject())) {
                        $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 9);
                        $db->setQuery($query);
                        $result = $db->execute();
                        $StaffPositions['3'] = $db->insertid();
                    } else {
                        $StaffPositions['3'] = $object->id;
                    }
                }
            }
            //----------------------------------------------------------------------
            if ('AddGeneralStaffMaintainerteamPositions' == 'AddGeneralStaffMaintainerteamPositions') {
                // Add new Parent position to StaffPositions
                $newPosName = 'COM_JOOMLEAGUE_F_MAINTAINER_TEAM';
                $newPosSwitch = 'persontype';
                $newPosParent = '0';
                $newPosContent = '2';
                $query = build_SelectQuery('position', $newPosName);
                $db->setQuery($query);
                if (!($dbresult = $db->loadObject())) {
                    $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 10);
                    $db->setQuery($query);
                    $result = $db->execute();
                    $ParentID = $db->insertid();
                    $StaffPositions['4'] = $db->insertid();
                } else {
                    $ParentID = $dbresult->id;
                    $StaffPositions['4'] = $dbresult->id;
                }
                if ('AddGeneralStaffMaintainerChildPositions' == 'AddGeneralStaffMaintainerChildPositions') {
                    // New Child position for StaffPositions
                    $newPosName = 'COM_JOOMLEAGUE_F_MAINTAINER';
                    $newPosSwitch = 'persontype';
                    $newPosParent = $ParentID;
                    $newPosContent = '2';
                    $query = build_SelectQuery('position', $newPosName);
                    $db->setQuery($query);
                    if (!($object = $db->loadObject())) {
                        $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 11);
                        $db->setQuery($query);
                        $result = $db->execute();
                        $StaffPositions['5'] = $db->insertid();
                    } else {
                        $StaffPositions['5'] = $object->id;
                    }
                }
            }
            //----------------------------------------------------------------------
            if ('AddGeneralStaffMedicalStaffPositions' == 'AddGeneralStaffMedicalStaffPositions') {
                // Add new Parent position to StaffPositions
                $newPosName = 'COM_JOOMLEAGUE_F_MEDICAL_STAFF';
                $newPosSwitch = 'persontype';
                $newPosParent = '0';
                $newPosContent = '2';
                $query = build_SelectQuery('position', $newPosName);
                $db->setQuery($query);
                if (!($dbresult = $db->loadObject())) {
                    $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 12);
                    $db->setQuery($query);
                    $result = $db->execute();
                    $ParentID = $db->insertid();
                    $StaffPositions['6'] = $db->insertid();
                } else {
                    $ParentID = $dbresult->id;
                    $StaffPositions['6'] = $dbresult->id;
                }
            }
        }
        //----------------------------------------------------------------------
        if ('AddGeneralRefereesPositions' == 'AddGeneralRefereesPositions') {
            // Add new Parent position to RefereesPositions
            $newPosName = 'COM_JOOMLEAGUE_F_REFEREES';
            $newPosSwitch = 'persontype';
            $newPosParent = '0';
            $newPosContent = '3';
            $query = build_SelectQuery('position', $newPosName);
            $db->setQuery($query);
            if (!($dbresult = $db->loadObject())) {
                $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 13);
                $db->setQuery($query);
                $result = $db->execute();
                $ParentID = $db->insertid();
                $RefereePositions['0'] = $db->insertid();
            } else {
                $ParentID = $dbresult->id;
                $RefereePositions['0'] = $dbresult->id;
            }
            if ('AddGeneralRefereesChildPositions' == 'AddGeneralRefereesChildPositions') {
                // New Child position for RefereePositions
                $newPosName = 'COM_JOOMLEAGUE_F_CENTER_REFEREE';
                $newPosSwitch = 'persontype';
                $newPosParent = $ParentID;
                $newPosContent = '3';
                $query = build_SelectQuery('position', $newPosName);
                $db->setQuery($query);
                if (!($object = $db->loadObject())) {
                    $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 14);
                    $db->setQuery($query);
                    $result = $db->execute();
                    $RefereePositions['1'] = $db->insertid();
                } else {
                    $RefereePositions['1'] = $object->id;
                }
                // New Child position for RefereePositions
                $newPosName = 'COM_JOOMLEAGUE_F_LINESMAN';
                $newPosSwitch = 'persontype';
                $newPosParent = $ParentID;
                $newPosContent = '3';
                $query = build_SelectQuery('position', $newPosName);
                $db->setQuery($query);
                if (!($object = $db->loadObject())) {
                    $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 15);
                    $db->setQuery($query);
                    $result = $db->execute();
                    $RefereePositions['2'] = $db->insertid();
                } else {
                    $RefereePositions['2'] = $object->id;
                }
                // New Child position for RefereePositions
                $newPosName = 'COM_JOOMLEAGUE_F_FOURTH_OFFICIAL';
                $newPosSwitch = 'persontype';
                $newPosParent = $ParentID;
                $newPosContent = '3';
                $query = build_SelectQuery('position', $newPosName);
                $db->setQuery($query);
                if (!($object = $db->loadObject())) {
                    $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 16);
                    $db->setQuery($query);
                    $result = $db->execute();
                    $RefereePositions['3'] = $db->insertid();
                } else {
                    $RefereePositions['3'] = $object->id;
                }
                // New Child position for RefereePositions
                $newPosName = 'COM_JOOMLEAGUE_F_FIFTH_OFFICIAL';
                $newPosSwitch = 'persontype';
                $newPosParent = $ParentID;
                $newPosContent = '3';
                $query = build_SelectQuery('position', $newPosName);
                $db->setQuery($query);
                if (!($object = $db->loadObject())) {
                    $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 17);
                    $db->setQuery($query);
                    $result = $db->execute();
                    $RefereePositions['4'] = $db->insertid();
                } else {
                    $RefereePositions['4'] = $object->id;
                }
            }
        }
        //----------------------------------------------------------------------
        if ('AddGeneralClubstaffPositions' == 'AddGeneralClubstaffPositions') {
            // Add new Parent position to ClubStaffPositions
            $newPosName = 'COM_JOOMLEAGUE_F_CLUB_STAFF';
            $newPosSwitch = 'persontype';
            $newPosParent = '0';
            $newPosContent = '4';
            $query = build_SelectQuery('position', $newPosName);
            $db->setQuery($query);
            if (!($dbresult = $db->loadObject())) {
                $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 18);
                $db->setQuery($query);
                $result = $db->execute();
                $ParentID = $db->insertid();
                $ClubStaffPositions['0'] = $db->insertid();
            } else {
                $ParentID = $dbresult->id;
                $ClubStaffPositions['0'] = $dbresult->id;
            }
            if ('AddGeneralClubstaffChildPositions' == 'AddGeneralClubstaffChildPositions') {
                // New Child position for ClubStaffPositions
                $newPosName = 'COM_JOOMLEAGUE_F_CLUB_MANAGER';
                $newPosSwitch = 'persontype';
                $newPosParent = $ParentID;
                $newPosContent = '4';
                $query = build_SelectQuery('position', $newPosName);
                $db->setQuery($query);
                // hier die 4 als newposcontent einf�gen
                if (!($object = $db->loadObject())) {
                    $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 19);
                    $db->setQuery($query);
                    $result = $db->execute();
                    $ClubStaffPositions['1'] = $db->insertid();
                } else {
                    $ClubStaffPositions['1'] = $object->id;
                }
                $newPosName = 'COM_JOOMLEAGUE_F_CLUB_YOUTH_MANAGER';
                $newPosSwitch = 'persontype';
                $newPosParent = $ParentID;
                $newPosContent = '4';
                $query = build_SelectQuery('position', $newPosName);
                $db->setQuery($query);
                // hier die 4 als newposcontent einf�gen
                if (!($object = $db->loadObject())) {
                    $query = build_InsertQuery_Position('position', $newPosName, $newPosSwitch, $newPosParent, $newPosContent, $sports_type->id, 20);
                    $db->setQuery($query);
                    $result = $db->execute();
                    $ClubStaffPositions['2'] = $db->insertid();
                } else {
                    $ClubStaffPositions['2'] = $object->id;
                }
            }
        }
        echo PrintStepResult($result) . '<br />';
        if (!$result) {
            echo JText::_('DO NOT WORRY... Surely at least one of the positions was already existing in your database!!!') . '<br />';
        }
        echo '<br />';
    }
    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    $result = false;
    echo JText::sprintf('Adding standard position-related-events for soccer to table table [%s]', '<b>' . '#__joomleague_position_eventtype' . '</b>');
    foreach ($PlayersPositions as $ppkey => $ppid) {
        foreach ($events_player as $epkey => $epid) {
            $query = build_InsertQuery_PositionEventType($ppid, $epid);
            $db->setQuery($query);
            $result = $db->execute();
        }
    }
    foreach ($StaffPositions as $spkey => $spid) {
        foreach ($events_staff as $eskey => $esid) {
            $query = build_InsertQuery_PositionEventType($spid, $esid);
            $db->setQuery($query);
            $result = $db->execute();
        }
    }
    foreach ($RefereePositions as $rkey => $rid) {
        foreach ($events_referees as $erkey => $erid) {
            $query = build_InsertQuery_PositionEventType($rid, $erid);
            $db->setQuery($query);
            $result = $db->execute();
        }
    }
    foreach ($ClubStaffPositions as $cskey => $csid) {
        foreach ($events_clubstaff as $ecskey => $escid) {
            $query = build_InsertQuery_PositionEventType($csid, $escid);
            $db->setQuery($query);
            $result = $db->execute();
        }
    }
    echo PrintStepResult($result) . '<br />';
    if (!$result) {
        echo JText::_('DO NOT WORRY... Surely at least one of the position related events was already existing in your database!!!') . '<br />';
    }
    return '';
}