AAAAhome/academiac/www/administrator/components/com_virtuemart/models/manufacturercategories.php000060400000010421151372152370027052 0ustar00setMainTable('manufacturercategories'); $this->addvalidOrderingFieldName(array('mf_category_name')); $config=JFactory::getConfig(); } /** * Retrieve the detail record for the current $id if the data has not already been loaded. * */ // function getManufacturerCategory(){ //// $db = JFactory::getDBO(); // if (empty($this->_data)) { // $this->_data = $this->getTable('manufacturercategories'); // $this->_data->load((int)$this->_id); // } //// print_r( $this->_db->_sql ); // if (!$this->_data) { // $this->_data = new stdClass(); // $this->_id = 0; // $this->_data = null; // } // return $this->_data; // } /** * Delete all record ids selected * * @return boolean True is the remove was successful, false otherwise. */ function remove($categoryIds) { $table = $this->getTable('manufacturercategories'); foreach($categoryIds as $categoryId) { if($table->checkManufacturer($categoryId)) { if (!$table->delete($categoryId)) { vmError($table->getError()); return false; } } else { vmError(get_class( $this ).'::remove '.$categoryId.' '.$table->getError()); return false; } } return true; } /** * Retireve a list of countries from the database. * * @param string $onlyPuiblished True to only retreive the published categories, false otherwise * @param string $noLimit True if no record count limit is used, false otherwise * @return object List of manufacturer categories objects */ function getManufacturerCategories($onlyPublished=false, $noLimit=false) { $this->_noLimit = $noLimit; $select = '* FROM `#__virtuemart_manufacturercategories_'.VMLANG.'` as l'; $joinedTables = ' JOIN `#__virtuemart_manufacturercategories` as mc using (`virtuemart_manufacturercategories_id`)'; $where = array(); if ($onlyPublished) { $where[] = ' `#__virtuemart_manufacturercategories`.`published` = 1'; } // $query .= ' ORDER BY `#__virtuemart_manufacturercategories`.`mf_category_name`'; $whereString = ''; if (count($where) > 0) $whereString = ' WHERE '.implode(' AND ', $where) ; if ( JRequest::getCmd('view') == 'manufacturercategories') { $ordering = $this->_getOrdering(); } else { $ordering = ' order by mf_category_name DESC'; } return $this->_data = $this->exeSortSearchListQuery(0,$select,$whereString,$joinedTables,$ordering); } /** * Build category filter * * @return object List of category to build filter select box */ function getCategoryFilter(){ $db = JFactory::getDBO(); $query = 'SELECT `virtuemart_manufacturercategories_id` as `value`, `mf_category_name` as text' .' FROM #__virtuemart_manufacturercategories_'.VMLANG.'`'; $db->setQuery($query); $categoryFilter[] = JHTML::_('select.option', '0', '- '. JText::_('COM_VIRTUEMART_SELECT_MANUFACTURER_CATEGORY') .' -' ); $categoryFilter = array_merge($categoryFilter, (array)$db->loadObjectList()); return $categoryFilter; } } // pure php no closing taghome/academiac/www/administrator/components/com_virtuemart/tables/manufacturercategories.php000060400000004525151372152460027051 0ustar00setUniqueName('mf_category_name'); $this->setLoggable(); $this->setTranslatable(array('mf_category_name','mf_category_desc')); $this->setSlug('mf_category_name'); } /* * Verify that user have to delete all manufacturers of a particular category before that category can be removed * * @return boolean True if category is ready to be removed, otherwise False */ function checkManufacturer($categoryId = 0) { if($categoryId > 0) { $db = JFactory::getDBO(); $q = 'SELECT count(*)' .' FROM #__virtuemart_manufacturers' .' WHERE virtuemart_manufacturercategories_id = '.$categoryId; $db->setQuery($q); $mCount = $db->loadResult(); if($mCount > 0) { vmInfo('COM_VIRTUEMART_REMOVE_IN_USE'); return false; } } return true; } } // pure php no closing tag home/academiac/www/administrator/components/com_virtuemart/controllers/manufacturercategories.php000060400000002471151372464750030153 0ustar00