コード例 #1
0
 /**
  * Method to remove venues
  *
  * @access	public
  * @return	boolean	True on success
  * @since	0.1
  */
 function delete($pks = array())
 {
     $result = false;
     if (count($pks)) {
         //JArrayHelper::toInteger($cid);
         $cids = implode(',', $pks);
         /*
         $query="SELECT id FROM #__joomleague_club WHERE standard_playground IN ($cids)";
         //echo '<pre>'.print_r($query,true).'</pre>';
         $this->_db->setQuery($query);
         if ($this->_db->loadResult())
         {
         	$this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_VENUE_MODEL_ERROR_CLUB_EXISTS'));
         	return false;
         }
         */
         $query = "SELECT id FROM #__joomleague_project_team WHERE standard_playground IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_VENUE_MODEL_ERROR_P_TEAM_EXISTS'));
             return false;
         }
         $query = "SELECT id FROM #__joomleague_match WHERE playground_id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_VENUE_MODEL_ERROR_MATCH_EXISTS'));
             return false;
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #2
0
 /**
  * Method to remove an event
  *
  * @access	public
  * @return	boolean	True on success
  * @since	0.1
  */
 function delete($cid = array())
 {
     $result = false;
     if (count($cid)) {
         JArrayHelper::toInteger($cid);
         $cids = implode(',', $cid);
         // first check that it not used in any match events
         $query = ' SELECT ms.id ' . ' FROM #__joomleague_match_statistic AS ms ' . ' WHERE ms.statistic_id IN (' . implode(',', $cid) . ')';
         $this->_db->setQuery($query);
         $this->_db->query();
         if ($this->_db->getAffectedRows()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_STATISTIC_MODEL_CANT_DELETE_STATS_MATCHES'));
             return false;
         }
         // then check that it is not assigned to positions
         $query = ' SELECT id ' . ' FROM #__joomleague_position_statistic ' . ' WHERE statistic_id IN (' . implode(',', $cid) . ')';
         $this->_db->setQuery($query);
         $this->_db->query();
         if ($this->_db->getAffectedRows()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_STATISTIC_MODEL_CANT_DELETE_STATS_MATCHES'));
             return false;
         }
         return parent::delete($cids);
     }
     return true;
 }
コード例 #3
0
ファイル: sportstype.php プロジェクト: Heart1010/JoomLeague
 /**
  * Method to remove a sportstype
  *
  * @access	public
  * @return	boolean	True on success
  */
 function delete(&$pks = array())
 {
     if (count($pks)) {
         $cids = implode(',', $pks);
         $query = "SELECT COUNT(id) FROM #__joomleague_sports_type";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult() == count($cid)) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_SPORTTYPE_MODEL_ERROR_LAST_SPORTSTYPE'));
             return false;
         }
         $query = "SELECT id FROM #__joomleague_eventtype WHERE sports_type_id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_SPORTTYPE_MODEL_ERROR_EVENT_EXISTS'));
             return false;
         }
         $query = "SELECT id FROM #__joomleague_position WHERE sports_type_id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_SPORTTYPE_MODEL_ERROR_POSITION_EXISTS'));
             return false;
         }
         $query = "SELECT id FROM #__joomleague_project WHERE sports_type_id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_SPORTTYPE_MODEL_ERROR_PROJECT_EXISTS'));
             return false;
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #4
0
 /**
  * Method to remove a club
  *
  * @access	public
  * @return	boolean	True on success
  * @since	0.1
  */
 function delete($pks = array())
 {
     $mainframe =& JFactory::getApplication();
     $result = false;
     if (count($pks)) {
         //JArrayHelper::toInteger($cid);
         $cids = implode(',', $pks);
         $mainframe->enqueueMessage(JText::_('JoomleagueModelClub-delete id->' . $cids), 'Notice');
         $query = "SELECT id FROM #__joomleague_team WHERE club_id IN ({$cids})";
         //echo '<pre>'.print_r($query,true).'</pre>';
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_CLUB_MODEL_ERROR_TEAM_EXISTS'));
             return false;
         }
         $query = "SELECT id FROM #__joomleague_playground WHERE club_id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_CLUB_MODEL_ERROR_VENUE_EXISTS'));
             return false;
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #5
0
ファイル: playground.php プロジェクト: hfmprs/JoomLeague
 /**
  * Method to remove venues
  *
  * @access	public
  * @return	boolean	True on success
  */
 function delete(&$pks = array())
 {
     if (count($pks)) {
         $cids = implode(',', $pks);
         $db = JFactory::getDbo();
         // check entry Project-Team Table
         $query = $db->getQuery(true);
         $query->select('id');
         $query->from('#__joomleague_project_team');
         $query->where('standard_playground IN (' . $cids . ')');
         $db->setQuery($query);
         if ($db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_VENUE_MODEL_ERROR_P_TEAM_EXISTS'));
             return false;
         }
         // check entry Match-Table
         $query = $db->getQuery(true);
         $query->select('id');
         $query->from('#__joomleague_match');
         $query->where('playground_id IN (' . $cids . ')');
         $db->setQuery($query);
         if ($db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_VENUE_MODEL_ERROR_MATCH_EXISTS'));
             return false;
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #6
0
ファイル: club.php プロジェクト: hfmprs/JoomLeague
 /**
  * Method to remove a club
  *
  * @access	public
  * @return	boolean	True on success
  */
 function delete(&$pks = array())
 {
     $result = false;
     if (count($pks)) {
         $cids = implode(',', $pks);
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('id');
         $query->from('#__joomleague_team');
         $query->where('club_id IN (' . $cids . ')');
         $db->setQuery($query);
         if ($db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_CLUB_MODEL_ERROR_TEAM_EXISTS'));
             return false;
         }
         $query = $db->getQuery(true);
         $query->select('id');
         $query->from('#__joomleague_playground');
         $query->where('club_id IN (' . $cids . ')');
         $db->setQuery($query);
         if ($db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_CLUB_MODEL_ERROR_VENUE_EXISTS'));
             return false;
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #7
0
ファイル: division.php プロジェクト: hfmprs/JoomLeague
 /**
  * Method to remove a division
  *
  * @access	public
  * @return	boolean	True on success
  */
 function delete(&$pks = array())
 {
     if (count($pks)) {
         $cids = implode(',', $pks);
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->update('#__joomleague_project_team');
         $query->set('division_id = 0');
         $query->where('division_id IN (' . $cids . ')');
         $db->setQuery($query);
         if (!$db->execute()) {
             $this->setError($db->getErrorMsg());
             return false;
         }
         $query->update('#__joomleague_treeto');
         $query->set('division_id = 0');
         $query->where('division_id IN (' . $cids . ')');
         $db->setQuery($query);
         if (!$db->execute()) {
             $this->setError($db->getErrorMsg());
             return false;
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #8
0
ファイル: sportstype.php プロジェクト: hfmprs/JoomLeague
 /**
  * Method to remove a sportstype
  *
  * @access	public
  * @return	boolean	True on success
  */
 function delete(&$pks = array())
 {
     if (count($pks)) {
         $cids = implode(',', $pks);
         $total = count($cids);
         $db = JFactory::getDbo();
         // SportsType
         $query = $db->getQuery(true);
         $query->select('COUNT(id)');
         $query->from('#__joomleague_sports_type');
         $db->setQuery($query);
         $qcount = $db->loadResult();
         if ($qcount == $total) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_SPORTTYPE_MODEL_ERROR_LAST_SPORTSTYPE'));
             return false;
         }
         // EventType
         $query = $db->getQuery(true);
         $query->select('id');
         $query->from('#__joomleague_eventtype');
         $query->where('sports_type_id IN (' . $cids . ')');
         $db->setQuery($query);
         if ($db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_SPORTTYPE_MODEL_ERROR_EVENT_EXISTS'));
             return false;
         }
         // Position
         $query = $db->getQuery(true);
         $query->select('id');
         $query->from('#__joomleague_position');
         $query->where('sports_type_id IN (' . $cids . ')');
         $db->setQuery($query);
         if ($db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_SPORTTYPE_MODEL_ERROR_POSITION_EXISTS'));
             return false;
         }
         // Project
         $query = $db->getQuery(true);
         $query->select('id');
         $query->from('#__joomleague_project');
         $query->where('sports_type_id IN (' . $cids . ')');
         $db->setQuery($query);
         if ($db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_SPORTTYPE_MODEL_ERROR_PROJECT_EXISTS'));
             return false;
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #9
0
ファイル: season.php プロジェクト: Heart1010/JoomLeague
 /**
  * Method to remove a season
  *
  * @access	public
  * @return	boolean	True on success
  */
 function delete(&$pks = array())
 {
     if (count($pks)) {
         $cids = implode(',', $pks);
         $query = "SELECT id FROM #__joomleague_project WHERE season_id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_SEASON_MODEL_ERROR_PROJECT_EXISTS'));
             return false;
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #10
0
 /**
  * Method to remove a league
  *
  * @access	public
  * @return	boolean	True on success
  * @since	0.1
  */
 function delete($cid = array())
 {
     $result = false;
     if (count($cid)) {
         JArrayHelper::toInteger($cid);
         $cids = implode(',', $cid);
         $query = "SELECT id FROM #__joomleague_countries WHERE league_id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_LEAGUE_MODEL_ERROR_PROJECT_EXISTS'));
             return false;
         }
         return parent::delete($cids);
     }
     return true;
 }
コード例 #11
0
 /**
  * Method to remove a league
  *
  * @access	public
  * @return	boolean	True on success
  * @since	0.1
  */
 function delete($pks = array())
 {
     $mainframe =& JFactory::getApplication();
     $result = false;
     if (count($pks)) {
         //JArrayHelper::toInteger($cid);
         $cids = implode(',', $pks);
         $mainframe->enqueueMessage(JText::_('JoomleagueModelLeague-delete id->' . $cids), 'Notice');
         $query = "SELECT id FROM #__joomleague_project WHERE league_id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_LEAGUE_MODEL_ERROR_PROJECT_EXISTS'));
             return false;
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #12
0
ファイル: division.php プロジェクト: Heart1010/JoomLeague
 /**
  * Method to remove a division
  *
  * @access	public
  * @return	boolean	True on success
  */
 function delete(&$pks = array())
 {
     if (count($pks)) {
         $cids = implode(',', $pks);
         $query = "UPDATE #__joomleague_project_team SET division_id=0 WHERE division_id IN ({$cids})";
         $this->_db->setQuery($query);
         if (!$this->_db->execute()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $query = "UPDATE #__joomleague_treeto SET division_id=0 WHERE division_id IN ({$cids})";
         $this->_db->setQuery($query);
         if (!$this->_db->execute()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #13
0
ファイル: playground.php プロジェクト: Heart1010/JoomLeague
 /**
  * Method to remove venues
  *
  * @access	public
  * @return	boolean	True on success
  */
 function delete(&$pks = array())
 {
     if (count($pks)) {
         $cids = implode(',', $pks);
         $query = "SELECT id FROM #__joomleague_project_team WHERE standard_playground IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_VENUE_MODEL_ERROR_P_TEAM_EXISTS'));
             return false;
         }
         $query = "SELECT id FROM #__joomleague_match WHERE playground_id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_VENUE_MODEL_ERROR_MATCH_EXISTS'));
             return false;
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #14
0
ファイル: club.php プロジェクト: Heart1010/JoomLeague
 /**
  * Method to remove a club
  *
  * @access	public
  * @return	boolean	True on success
  */
 function delete(&$pks = array())
 {
     $result = false;
     if (count($pks)) {
         $cids = implode(',', $pks);
         $query = "SELECT id FROM #__joomleague_team WHERE club_id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_CLUB_MODEL_ERROR_TEAM_EXISTS'));
             return false;
         }
         $query = "SELECT id FROM #__joomleague_playground WHERE club_id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_CLUB_MODEL_ERROR_VENUE_EXISTS'));
             return false;
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #15
0
ファイル: round.php プロジェクト: Heart1010/JoomLeague
 /**
  * Method to remove a matchday
  *
  * @access	public
  * @return	boolean	True on success
  */
 function deleteMatches($cid = array(), $mdlMatches, $mdlMatch, $onlyMatches = false)
 {
     $result = false;
     if (count($cid)) {
         JArrayHelper::toInteger($cid);
         $cids = implode(',', $cid);
         for ($r = 0; $r < count($cid); $r++) {
             //echo "Deleting Round: ".$cid[$r]."<br>";
             $matches = $mdlMatches->getMatchesByRound($cid[$r]);
             $matchids = array();
             for ($m = 0; $m < count($matches); $m++) {
                 $matchids[] = $matches[$m]->id;
                 //echo "  Deleting Match: ".$matches[$m]->id."<br>";
             }
             $mdlMatch->delete($matchids);
         }
         if (!$onlyMatches) {
             return parent::delete($cids);
         }
     }
     return true;
 }
コード例 #16
0
 /**
  * Method to remove a sportstype
  *
  * @access	public
  * @return	boolean	True on success
  * @since	0.1
  */
 function delete($pks = array())
 {
     $mainframe =& JFactory::getApplication();
     $result = false;
     if (count($pks)) {
         //JArrayHelper::toInteger($pks);
         $cids = implode(',', $pks);
         $mainframe->enqueueMessage(JText::_('JoomleagueModelSportsType-delete id->' . $cids), 'Notice');
         $query = "SELECT COUNT(id) FROM #__joomleague_sports_type";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult() == count($cid)) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_SPORTTYPE_MODEL_ERROR_LAST_SPORTSTYPE'));
             return false;
         }
         $query = "SELECT id FROM #__joomleague_eventtype WHERE sports_type_id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_SPORTTYPE_MODEL_ERROR_EVENT_EXISTS'));
             return false;
         }
         $query = "SELECT id FROM #__joomleague_position WHERE sports_type_id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_SPORTTYPE_MODEL_ERROR_POSITION_EXISTS'));
             return false;
         }
         $query = "SELECT id FROM #__joomleague_project WHERE sports_type_id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_SPORTTYPE_MODEL_ERROR_PROJECT_EXISTS'));
             return false;
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #17
0
ファイル: treeto.php プロジェクト: hfmprs/JoomLeague
 function delete(&$pks = array())
 {
     if (count($pks)) {
         $cids = implode(',', $pks);
         $query = ' DELETE tt, ttn, ttm ';
         $query .= ' FROM #__joomleague_treeto AS tt ';
         $query .= ' LEFT JOIN #__joomleague_treeto_node AS ttn ON ttn.treeto_id=tt.id ';
         $query .= ' LEFT JOIN #__joomleague_treeto_match AS ttm ON ttm.node_id=ttn.id ';
         $query .= ' WHERE tt.id IN (' . $cids . ')';
         $this->_db->setQuery($query);
         if (!$this->_db->execute()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #18
0
 /**
  * Method to remove a position
  *
  * @access	public
  * @return	boolean	True on success
  * @since	0.1
  */
 function delete($cid = array())
 {
     $result = false;
     if (count($cid)) {
         JArrayHelper::toInteger($cid);
         $cids = implode(',', $cid);
         $query = "SELECT pos.id FROM #__joomleague_project_position AS ppos\n              INNER JOIN #__joomleague_position AS pos ON pos.id = ppos.position_id\n              WHERE pos.id IN ({$cids})";
         //echo '<pre>'.print_r($query,true).'</pre>';
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_POSITION_MODEL_ERROR_P_POSITION_EXISTS'));
             return false;
         }
         $query = "SELECT id FROM #__joomleague_project_referee AS pref \n              INNER JOIN #__joomleague_project_position AS ppos ON ppos.id = pref.project_position_id\n              INNER JOIN #__joomleague_position AS pos ON pos.id = ppos.position_id\n              WHERE pos.id IN ({$cids})";
         //echo '<pre>'.print_r($query,true).'</pre>';
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_POSITION_MODEL_ERROR_P_REFEREE_EXISTS'));
             return false;
         }
         $query = "SELECT id FROM #__joomleague_team_player AS tp\n              INNER JOIN #__joomleague_project_position AS ppos ON ppos.id = tp.project_position_id\n              INNER JOIN #__joomleague_position AS pos ON pos.id = ppos.position_id\n              WHERE pos.id IN ({$cids})";
         //echo '<pre>'.print_r($query,true).'</pre>';
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_POSITION_MODEL_ERROR_PLAYER_EXISTS'));
             return false;
         }
         $query = "SELECT id FROM #__joomleague_team_staff AS ts\n              INNER JOIN #__joomleague_project_position AS ppos ON ppos.id = ts.project_position_id\n              INNER JOIN #__joomleague_position AS pos ON pos.id = ppos.position_id\n              WHERE pos.position_id IN ({$cids})";
         //echo '<pre>'.print_r($query,true).'</pre>';
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_POSITION_MODEL_ERROR_STAFF_EXISTS'));
             return false;
         }
         $query = "SELECT id FROM #__joomleague_person \n              WHERE position_id IN ({$cids})";
         //echo '<pre>'.print_r($query,true).'</pre>';
         $this->_db->setQuery($query);
         if ($this->_db->loadResult()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_POSITION_MODEL_ERROR_PERSON_EXISTS'));
             return false;
         }
         return parent::delete($cids);
     }
     return true;
 }
コード例 #19
0
ファイル: match.php プロジェクト: hfmprs/JoomLeague
 /**
  * Method to remove a matchday
  *
  * @access	public
  * @return	boolean	True on success
  */
 function delete(&$pk = array())
 {
     $result = false;
     if (count($pk)) {
         $cids = implode(',', $pk);
         $query = "DELETE FROM #__joomleague_match_statistic WHERE match_id IN ({$cids})";
         $this->_db->setQuery($query);
         if (!$this->_db->execute()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $query = "DELETE FROM #__joomleague_match_staff_statistic WHERE match_id IN ({$cids})";
         $this->_db->setQuery($query);
         if (!$this->_db->execute()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $query = "DELETE FROM #__joomleague_match_staff WHERE match_id IN ({$cids})";
         $this->_db->setQuery($query);
         if (!$this->_db->execute()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $query = "DELETE FROM #__joomleague_match_event WHERE match_id IN ({$cids})";
         $this->_db->setQuery($query);
         if (!$this->_db->execute()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $query = "DELETE FROM #__joomleague_match_referee WHERE match_id IN ({$cids})";
         $this->_db->setQuery($query);
         if (!$this->_db->execute()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $query = "DELETE FROM #__joomleague_match_player WHERE match_id IN ({$cids})";
         $this->_db->setQuery($query);
         if (!$this->_db->execute()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         return parent::delete($pk);
     }
     return true;
 }
コード例 #20
0
    /**
     * Method to remove an event
     *
     * @access	public
     * @return	boolean	True on success
     * @since	0.1
     */
    function delete($cid = array())
    {
        $result = false;
        if (count($cid)) {
            JArrayHelper::toInteger($cid);
            $cids = implode(',', $cid);
            // first check that they are not used in any match events
            $query = '	SELECT event_type_id
						FROM #__joomleague_match_event
						WHERE event_type_id IN (' . implode(',', $cid) . ')';
            $this->_db->setQuery($query);
            $this->_db->query();
            if ($this->_db->getAffectedRows()) {
                $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_EVENT_MODEL_ERROR_MATCHES_EXISTS'));
                return false;
            }
            // then check that they are not assigned to any positions
            $query = '	SELECT eventtype_id
						FROM #__joomleague_position_eventtype
						WHERE eventtype_id IN (' . implode(',', $cid) . ')';
            $this->_db->setQuery($query);
            $this->_db->query();
            if ($this->_db->getAffectedRows()) {
                $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_EVENT_MODEL_ERROR_POSITION_EXISTS'));
                return false;
            }
            return parent::delete($cids);
        }
        return true;
    }
コード例 #21
0
ファイル: position.php プロジェクト: hfmprs/JoomLeague
    /**
     * Method to remove a position
     *
     * @access	public
     * @return	boolean	True on success
     */
    function delete(&$pks = array())
    {
        if (count($pks)) {
            $cids = implode(',', $pks);
            $query = "SELECT pos.id FROM #__joomleague_project_position AS ppos\n\t\t\t\t\tINNER JOIN #__joomleague_position AS pos ON pos.id = ppos.position_id\n\t\t\t\t\tWHERE pos.id IN ({$cids})";
            $this->_db->setQuery($query);
            if ($this->_db->loadResult()) {
                $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_POSITION_MODEL_ERROR_P_POSITION_EXISTS'));
                return false;
            }
            $query = "SELECT id FROM #__joomleague_project_referee AS pref \n\t\t\t\t\tINNER JOIN #__joomleague_project_position AS ppos ON ppos.id = pref.project_position_id\n\t\t\t\t\tINNER JOIN #__joomleague_position AS pos ON pos.id = ppos.position_id\n\t\t\t\t\tWHERE pos.id IN ({$cids})";
            $this->_db->setQuery($query);
            if ($this->_db->loadResult()) {
                $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_POSITION_MODEL_ERROR_P_REFEREE_EXISTS'));
                return false;
            }
            $query = "SELECT id FROM #__joomleague_team_player AS tp\n\t\t\t\t\tINNER JOIN #__joomleague_project_position AS ppos ON ppos.id = tp.project_position_id\n\t\t\t\t\tINNER JOIN #__joomleague_position AS pos ON pos.id = ppos.position_id\n\t\t\t\t\tWHERE pos.id IN ({$cids})";
            $this->_db->setQuery($query);
            if ($this->_db->loadResult()) {
                $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_POSITION_MODEL_ERROR_PLAYER_EXISTS'));
                return false;
            }
            $query = "SELECT id FROM #__joomleague_team_staff AS ts\n\t\t\t\t\tINNER JOIN #__joomleague_project_position AS ppos ON ppos.id = ts.project_position_id\n\t\t\t\t\tINNER JOIN #__joomleague_position AS pos ON pos.id = ppos.position_id\n\t\t\t\t\tWHERE pos.position_id IN ({$cids})";
            $this->_db->setQuery($query);
            if ($this->_db->loadResult()) {
                $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_POSITION_MODEL_ERROR_STAFF_EXISTS'));
                return false;
            }
            $query = "SELECT id FROM #__joomleague_person \n\t\t\t\t\tWHERE position_id IN ({$cids})";
            $this->_db->setQuery($query);
            if ($this->_db->loadResult()) {
                $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_POSITION_MODEL_ERROR_PERSON_EXISTS'));
                return false;
            }
            $query = '	DELETE
						FROM #__joomleague_position_eventtype
						WHERE position_id IN ( ' . $cids . ' )';
            $this->_db->setQuery($query);
            if (!$this->_db->execute()) {
                $this->setError($this->_db->getErrorMsg());
                return false;
            }
            $query = '	DELETE
						FROM #__joomleague_position_statistic
						WHERE position_id IN ( ' . $cids . ' )';
            $this->_db->setQuery($query);
            if (!$this->_db->execute()) {
                $this->setError($this->_db->getErrorMsg());
                return false;
            }
            return parent::delete($pks);
        }
        return true;
    }
コード例 #22
0
 /**
  * Method to remove a person
  *
  * @access	public
  * @return	boolean	True on success
  * @since	0.1
  */
 function delete($pks = array())
 {
     $mainframe =& JFactory::getApplication();
     $result = false;
     if (count($pks)) {
         //JArrayHelper::toInteger($cid);
         $cids = implode(',', $pks);
         //First select all subpersons of the selected ids
         $mainframe->enqueueMessage(JText::_('JoomleagueModelPerson-delete id->' . $cids), 'Notice');
         $query = "SELECT * FROM #__joomleague_person WHERE id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($results = $this->_db->loadObjectList()) {
             foreach ($results as $result) {
                 //Now delete all match-persons assigned as player to subpersons of the selected ids
                 $query = "DELETE FROM #__joomleague_match_event\n\t\t\t\t\t\t\t\tWHERE teamplayer_id in (select id from #__joomleague_team_player where person_id = " . $result->id . ")\n\t\t\t\t\t\t\t\t\tOR teamplayer_id2 in (select id from #__joomleague_team_player where person_id = " . $result->id . ")";
                 $this->_db->setQuery($query);
                 if (!$this->_db->query()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 //Now delete all match-events assigned as referee to subpersons of the selected ids
                 $query = "DELETE FROM #__joomleague_match_referee\n\t\t\t\t\t\t\t\tWHERE project_referee_id in (select id from #__joomleague_project_referee where person_id = " . $result->id . ")";
                 $this->_db->setQuery($query);
                 if (!$this->_db->query()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 //Now delete all match-events assigned as player1 to subpersons of the selected ids
                 $query = "DELETE FROM #__joomleague_match_player\n\t\t\t\t\t\t\t\tWHERE teamplayer_id in (select id from #__joomleague_team_player where person_id = " . $result->id . ")";
                 $this->_db->setQuery($query);
                 if (!$this->_db->query()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 //Now delete all match-events assigned as player2 to subpersons of the selected ids
                 $query = "DELETE FROM #__joomleague_match_staff\n\t\t\t\t\t\t\t\tWHERE team_staff_id in (select id from #__joomleague_team_staff where person_id = " . $result->id . ")";
                 $this->_db->setQuery($query);
                 if (!$this->_db->query()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 $query = "DELETE FROM #__joomleague_match_statistic\n\t\t\t\t\t\t\t\tWHERE teamplayer_id in (select id from #__joomleague_team_player where person_id = " . $result->id . ")";
                 $this->_db->setQuery($query);
                 if (!$this->_db->query()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 $query = "DELETE FROM #__joomleague_match_staff_statistic\n\t\t\t\t\t\t\t\tWHERE team_staff_id in (select id from #__joomleague_team_staff where person_id = " . $result->id . ")";
                 $this->_db->setQuery($query);
                 if (!$this->_db->query()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 //Now delete all person assigned as referee in a project of the selected ids
                 $query = "DELETE FROM #__joomleague_project_referee\n\t\t\t\t\t\t\t\tWHERE person_id=" . $result->id;
                 $this->_db->setQuery($query);
                 if (!$this->_db->query()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 //Now delete all person assigned as player in a team of the selected ids
                 $query = "DELETE FROM #__joomleague_team_player\n\t\t\t\t\t\t\t\tWHERE person_id=" . $result->id;
                 $this->_db->setQuery($query);
                 if (!$this->_db->query()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 //Now delete all person assigned as staff in a team of the selected ids
                 $query = "DELETE FROM #__joomleague_team_staff\n\t\t\t\t\t\t\t\tWHERE person_id=" . $result->id;
                 $this->_db->setQuery($query);
                 if (!$this->_db->query()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
             }
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #23
0
ファイル: eventtype.php プロジェクト: hfmprs/JoomLeague
 /**
  * Method to remove an event
  *
  * @access	public
  * @return	boolean	True on success
  */
 function delete(&$pks = array())
 {
     if (count($pks)) {
         $cids = implode(',', $pks);
         $db = JFactory::getDbo();
         // first check that they are not used in any match events
         $query = $db->getQuery(true);
         $query->select('event_type_id');
         $query->from('#__joomleague_match_event');
         $query->where('event_type_id IN (' . $cids . ')');
         $db->setQuery($query);
         $db->execute();
         if ($db->getAffectedRows()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_EVENT_MODEL_ERROR_MATCHES_EXISTS'));
             return false;
         }
         // then check that they are not assigned to any positions
         $query = $db->getQuery(true);
         $query->select('eventtype_id');
         $query->from('#__joomleague_position_eventtype');
         $query->where('eventtype_id IN (' . $cids . ')');
         $db->setQuery($query);
         $db->execute();
         if ($db->getAffectedRows()) {
             $this->setError(JText::_('COM_JOOMLEAGUE_ADMIN_EVENT_MODEL_ERROR_POSITION_EXISTS'));
             return false;
         }
         return parent::delete($pks);
     }
     return true;
 }
コード例 #24
0
ファイル: person.php プロジェクト: hfmprs/JoomLeague
 /**
  * Method to remove a person
  *
  * @access	public
  * @return	boolean	True on success
  */
 function delete(&$pks = array())
 {
     if (count($pks)) {
         $cids = implode(',', $pks);
         //First select all subpersons of the selected ids
         $query = "SELECT * FROM #__joomleague_person WHERE id IN ({$cids})";
         $this->_db->setQuery($query);
         if ($results = $this->_db->loadObjectList()) {
             foreach ($results as $result) {
                 //Now delete all match-persons assigned as player to subpersons of the selected ids
                 $query = "DELETE FROM #__joomleague_match_event\n\t\t\t\t\t\t\t\tWHERE teamplayer_id in (select id from #__joomleague_team_player where person_id = " . $result->id . ")\n\t\t\t\t\t\t\t\t\tOR teamplayer_id2 in (select id from #__joomleague_team_player where person_id = " . $result->id . ")";
                 $this->_db->setQuery($query);
                 if (!$this->_db->execute()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 //Now delete all match-events assigned as referee to subpersons of the selected ids
                 $query = "DELETE FROM #__joomleague_match_referee\n\t\t\t\t\t\t\t\tWHERE project_referee_id in (select id from #__joomleague_project_referee where person_id = " . $result->id . ")";
                 $this->_db->setQuery($query);
                 if (!$this->_db->execute()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 //Now delete all match-events assigned as player1 to subpersons of the selected ids
                 $query = "DELETE FROM #__joomleague_match_player\n\t\t\t\t\t\t\t\tWHERE teamplayer_id in (select id from #__joomleague_team_player where person_id = " . $result->id . ")";
                 $this->_db->setQuery($query);
                 if (!$this->_db->execute()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 //Now delete all match-events assigned as player2 to subpersons of the selected ids
                 $query = "DELETE FROM #__joomleague_match_staff\n\t\t\t\t\t\t\t\tWHERE team_staff_id in (select id from #__joomleague_team_staff where person_id = " . $result->id . ")";
                 $this->_db->setQuery($query);
                 if (!$this->_db->execute()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 $query = "DELETE FROM #__joomleague_match_statistic\n\t\t\t\t\t\t\t\tWHERE teamplayer_id in (select id from #__joomleague_team_player where person_id = " . $result->id . ")";
                 $this->_db->setQuery($query);
                 if (!$this->_db->execute()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 $query = "DELETE FROM #__joomleague_match_staff_statistic\n\t\t\t\t\t\t\t\tWHERE team_staff_id in (select id from #__joomleague_team_staff where person_id = " . $result->id . ")";
                 $this->_db->setQuery($query);
                 if (!$this->_db->execute()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 //Now delete all person assigned as referee in a project of the selected ids
                 $query = "DELETE FROM #__joomleague_project_referee\n\t\t\t\t\t\t\t\tWHERE person_id=" . $result->id;
                 $this->_db->setQuery($query);
                 if (!$this->_db->execute()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 //Now delete all person assigned as player in a team of the selected ids
                 $query = "DELETE FROM #__joomleague_team_player\n\t\t\t\t\t\t\t\tWHERE person_id=" . $result->id;
                 $this->_db->setQuery($query);
                 if (!$this->_db->execute()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
                 //Now delete all person assigned as staff in a team of the selected ids
                 $query = "DELETE FROM #__joomleague_team_staff\n\t\t\t\t\t\t\t\tWHERE person_id=" . $result->id;
                 $this->_db->setQuery($query);
                 if (!$this->_db->execute()) {
                     $this->setError($this->_db->getErrorMsg());
                     return false;
                 }
             }
         }
         return parent::delete($pks);
     }
     return true;
 }