/** * Delete category record * * @author RickG * @return boolean True on success * @todo Add check for store and products assinged to category before allowing delete */ public function delete($pk = null, $children = true) { if (parent::delete($pk, $children)) { return true; } else { return false; } }
public function delete($pk = null, $children = true) { JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judirectory/tables'); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('id'); $query->from('#__judirectory_template_styles'); $query->where('template_id =' . $pk); $db->setQuery($query); $styleIds = $db->loadColumn(); if ($styleIds) { $styleTable = JTable::getInstance("Style", "JUDirectoryTable"); foreach ($styleIds as $styleId) { if (!$styleTable->delete($styleId)) { return false; } } } return parent::delete($pk); }
/** * Method to delete a node and, optionally, its child nodes from the table. * * @param integer $pk The primary key of the node to delete. * @param boolean $children True to delete child nodes, false to move them up a level. * * @return boolean True on success. */ public function delete($pk = null, $children = true) { $dispatcher = RFactory::getDispatcher(); // Import plugin types if ($this->_eventBeforeDelete || $this->_eventAfterDelete) { foreach ($this->_pluginTypesToImport as $type) { JPluginHelper::importPlugin($type); } } // Trigger before delete if ($this->_eventBeforeDelete) { $results = $dispatcher->trigger($this->_eventBeforeDelete, array($this, $pk, $children)); if (count($results) && in_array(false, $results, true)) { return false; } } // Delete if (!parent::delete($pk, $children)) { return false; } // Trigger after delete if ($this->_eventAfterDelete) { $results = $dispatcher->trigger($this->_eventAfterDelete, array($this, $pk, $children)); if (count($results) && in_array(false, $results, true)) { return false; } } return true; }
/** * Method to delete a node and, optionally, its child nodes from the table. * * @param integer $pk The primary key of the node to delete. * @param boolean $children True to delete child nodes, false to move them up a level. * * @return boolean True on success. * * @since 3.1 */ public function delete($pk = null, $children = false) { $return = parent::delete($pk, $children); if ($return) { $helper = new JHelperTags(); $helper->tagDeleteInstances($pk); } return $return; }
/** * Override parent delete method to process tags * * @param integer $pk The primary key of the node to delete. * @param boolean $children True to delete child nodes, false to move them up a level. * * @return boolean True on success. * * @since 3.1 * @throws UnexpectedValueException */ public function delete($pk = null, $children = true) { $result = parent::delete($pk); $this->tagsHelper->typeAlias = $this->extension . '.category'; return $result && $this->tagsHelper->deleteTagData($this, $pk); }
/** * Method to delete a node and, optionally, its child nodes from the table. * * @param integer $pk The primary key of the node to delete. * @param boolean $children True to delete child nodes, false to move them up a level. * * @return boolean True on success. * * @see http://docs.joomla.org/JTableNested/delete */ public function delete($pk = null, $children = false) { return parent::delete($pk, $children); }
/** * Method to delete a node and, optionally, its child nodes from the table. * * @param integer $pk The primary key of the node to delete. * @param boolean $children True to delete child nodes, false to move them up a level. * * @return boolean True on success. */ public function delete($pk = null, $children = true) { // Before delete if (!$this->beforeDelete($pk, $children)) { return false; } // Delete if (!parent::delete($pk, $children)) { return false; } // After delete if (!$this->afterDelete($pk, $children)) { return false; } return true; }
public function delete($pk = null) { $db = JFactory::getDbo(); $k = $this->_tbl_key; $pk = is_null($pk) ? $this->{$k} : $pk; $this->load($pk); if ($this->home == 1 || $this->default == 1) { $this->setError(JText::_('COM_JUDIRECTORY_CAN_NOT_DELETE_DEFAULT_TEMPLATE_STYLE')); return false; } $defaultStyleObject = JUDirectoryFrontHelperTemplate::getDefaultTemplateStyle(); $query = $db->getQuery(true); $query->update('#__judirectory_categories'); $query->set('style_id = -2'); if ($defaultStyleObject->template_id != $this->template_id) { $query->set('template_params = ""'); } $query->where('parent_id = 0'); $query->where('style_id = ' . $pk); $db->setQuery($query); $db->execute(); $query = $db->getQuery(true); $query->select('id'); $query->from('#__judirectory_categories'); $query->where('style_id = ' . $pk); $db->setQuery($query); $categoryArrayAssignedToStyle = $db->loadColumn(); $query = $db->getQuery(true); $query->update('#__judirectory_categories'); $query->set('style_id = -1'); $query->where('parent_id != 0'); $query->where('style_id = ' . $pk); $db->setQuery($query); $db->execute(); foreach ($categoryArrayAssignedToStyle as $categoryIdAssignedToStyle) { $styleObjectOfCategory = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($categoryIdAssignedToStyle); if ($styleObjectOfCategory->template_id != $this->template_id) { $query = $db->getQuery(true); $query->update('#__judirectory_categories'); $query->set('template_params = ""'); $query->where('id = ' . $categoryIdAssignedToStyle); $db->setQuery($query); $db->execute(); $query = $db->getQuery(true); $query->update('#__judirectory_listings AS listing'); $query->set('listing.template_params = ""'); $query->join('', '#__judirectory_listings_xref AS listingxref ON listing.id = listingxref.listing_id AND listingxref.main = 1'); $query->where('listing.style_id = -1'); $query->where('listingxref.cat_id = ' . $categoryIdAssignedToStyle); $db->setQuery($query); $db->execute(); JUDirectoryFrontHelperTemplate::removeTemplateParamsOfInheritedStyleCatListing($categoryIdAssignedToStyle); } } $query = $db->getQuery(true); $query->select('listing.id'); $query->select('listingxref.cat_id AS cat_id'); $query->from('#__judirectory_listings AS listing'); $query->join('', '#__judirectory_listings_xref AS listingxref ON listing.id = listingxref.listing_id AND listingxref.main = 1'); $query->where('listing.style_id = ' . $pk); $db->setQuery($query); $listingObjectListAssignedToStyle = $db->loadObjectList(); $catArrayResetTemplateParams = array(); foreach ($listingObjectListAssignedToStyle as $listingObject) { $styleObjectOfCategory = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($listingObject->cat_id); if ($styleObjectOfCategory->template_id != $this->template_id) { $catArrayResetTemplateParams[] = $listingObject->cat_id; } } $catArrayResetTemplateParams = array_unique($catArrayResetTemplateParams); if (is_array($catArrayResetTemplateParams) && count($catArrayResetTemplateParams)) { $query = $db->getQuery(true); $query->update('#__judirectory_listings AS listing'); $query->join('', '#__judirectory_listings_xref AS listingxref ON listing.id = listingxref.listing_id AND listingxref.main = 1'); $query->set('listing.template_params = ""'); $query->set('listing.style_id = -1'); $query->where('listingxref.cat_id IN (' . implode(',', $catArrayResetTemplateParams) . ')'); $query->where('listing.style_id = ' . $pk); $db->setQuery($query); $db->execute(); } return parent::delete($pk); }