english/administrator/components/com_templates/models/style.php
/**
	 * Method to unset a template style as default for a language.
	 *
	 * @param	int		The primary key ID for the style.
	 *
	 * @return	boolean	True if successful.
	 * @throws	Exception
	 */
Method to unset a template style as default for a language.
@param       int             The primary key ID for the style.

@return      boolean True if successful.
@throws      Exception
Method to unset a template style as default for a language . @param int The primary key ID for the style . @return boolean True if successful . @throws Exception
public function unsetHome($id = 0)
	{
		$user	= JFactory::getUser();
		$db		= $this->getDbo();
		if (!$user->authorise('core.edit.state', 'com_templates')) {
			throw new Exception(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
		}
		$db->setQuery(
			'SELECT client_id, home' .
			' FROM #__template_styles' .
			' WHERE id = '.(int) $id
		);
		$style = $db->loadObject();
		if ($error = $db->getErrorMsg()) {
			throw new Exception($error);
		}
		else if (!is_numeric($style->client_id)) {
			throw new Exception(JText::_('COM_TEMPLATES_ERROR_STYLE_NOT_FOUND'));
		}
		else if ($style->home=='1') {
			throw new Exception(JText::_('COM_TEMPLATES_ERROR_CANNOT_UNSET_DEFAULT_STYLE'));
		}
		$db->setQuery(
			'UPDATE #__template_styles' .
			' SET home = \'0\'' .
			' WHERE id = '.(int) $id
		);
		if (!$db->query()) {
			throw new Exception($db->getErrorMsg());
		}
		$this->cleanCache();
		return true;
	}
public function unsetHome ( $ id = 0 ) { $ user = JFactory :: getUser ( ) ; $ db = $ this -> getDbo ( ) ; if ( ! $ user -> authorise ( 'core.edit.state' , 'com_templates' ) ) { throw new Exception ( JText :: _ ( 'JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED' ) ) ; } $ db -> setQuery ( 'SELECT client_id, home' . ' FROM #__template_styles' . ' WHERE id = ' . ( int ) $ id ) ; $ style = $ db -> loadObject ( ) ; if ( $ error = $ db -> getErrorMsg ( ) ) { throw new Exception ( $ error ) ; } else if ( ! is_numeric ( $ style -> client_id ) ) { throw new Exception ( JText :: _ ( 'COM_TEMPLATES_ERROR_STYLE_NOT_FOUND' ) ) ; } else if ( $ style -> home == '1' ) { throw new Exception ( JText :: _ ( 'COM_TEMPLATES_ERROR_CANNOT_UNSET_DEFAULT_STYLE' ) ) ; } $ db -> setQuery ( 'UPDATE #__template_styles' . ' SET home = \'0\'' . ' WHERE id = ' . ( int ) $ id ) ; if ( ! $ db -> query ( ) ) { throw new Exception ( $ db -> getErrorMsg ( ) ) ; } $ this -> cleanCache ( ) ; return true ; }
Method to unset a template style as default for a language.
Method to unset a template style as default for a language .
// Initialise variables. // Access checks. // Lookup the client_id. // Set the new home style. // Clean the cache.