本文整理汇总了PHP中JUDirectoryHelper::changeInheritedCriteriaGroupId方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDirectoryHelper::changeInheritedCriteriaGroupId方法的具体用法?PHP JUDirectoryHelper::changeInheritedCriteriaGroupId怎么用?PHP JUDirectoryHelper::changeInheritedCriteriaGroupId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUDirectoryHelper
的用法示例。
在下文中一共展示了JUDirectoryHelper::changeInheritedCriteriaGroupId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save($data)
{
$dispatcher = JDispatcher::getInstance();
$table = $this->getTable();
$key = $table->getKeyName();
$pk = !empty($data[$key]) ? $data[$key] : (int) $this->getState($this->getName() . '.id');
$isNew = true;
JPluginHelper::importPlugin('content');
try {
if ($pk > 0) {
$table->load($pk);
$isNew = false;
}
if (!$table->bind($data)) {
$this->setError($table->getError());
return false;
}
$this->prepareTable($table);
if (!$table->check()) {
$this->setError($table->getError());
return false;
}
$result = $dispatcher->trigger($this->event_before_save, array($this->option . '.' . $this->name, &$table, $isNew));
if (in_array(false, $result, true)) {
$this->setError($table->getError());
return false;
}
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
if (!isset($data['assigntocats'])) {
$data['assigntocats'] = array();
}
$db = JFactory::getDbo();
$query = "SELECT id FROM #__judirectory_categories WHERE criteriagroup_id =" . $table->id;
$db->setQuery($query);
$assignedCats = $db->loadColumn();
$unassignedCats = array_diff($assignedCats, $data['assigntocats']);
if (!empty($unassignedCats)) {
$query = "UPDATE #__judirectory_categories SET selected_criteriagroup = 0, criteriagroup_id = 0 WHERE id IN (" . implode(',', $unassignedCats) . ")";
$db->setQuery($query);
$db->execute();
foreach ($unassignedCats as $unassignedCat) {
$query = "DELETE FROM #__judirectory_criterias_values WHERE rating_id IN" . "\n (SELECT r.id FROM" . "\n #__judirectory_rating AS r" . "\n JOIN #__judirectory_listings AS listing" . "\n ON listing.id = r.listing_id " . "\n JOIN #__judirectory_listings_xref AS listingxref" . "\n ON (" . "\n listing.id = listingxref.listing_id" . "\n AND listingxref.main = 1" . "\n )" . "\n WHERE listingxref.cat_id = " . $unassignedCat . ")";
$db->setQuery($query);
$db->execute();
JUDirectoryHelper::changeInheritedCriteriaGroupId($unassignedCat, 0);
}
}
$catsToAddNewCriteriaGroup = array_diff($data['assigntocats'], $assignedCats);
if ($catsToAddNewCriteriaGroup) {
$query = "UPDATE #__judirectory_categories SET selected_criteriagroup = {$table->id}, criteriagroup_id = {$table->id} WHERE id IN (" . implode(',', $catsToAddNewCriteriaGroup) . ")";
$db->setQuery($query);
$db->execute();
foreach ($catsToAddNewCriteriaGroup as $catToAddNewCriteriaGroup) {
JUDirectoryHelper::changeInheritedCriteriaGroupId($catToAddNewCriteriaGroup, $table->id);
}
}
$this->cleanCache();
$dispatcher->trigger($this->event_after_save, array($this->option . '.' . $this->name, &$table, $isNew));
} catch (Exception $e) {
$this->setError($e->getMessage());
return false;
}
$pkName = $table->getKeyName();
if (isset($table->{$pkName})) {
$this->setState($this->getName() . '.id', $table->{$pkName});
}
$this->setState($this->getName() . '.new', $isNew);
return true;
}
示例2: saveCategoryChangeCriteriaGroup
public function saveCategoryChangeCriteriaGroup($tableBeforeSave, $table, $isNew)
{
if (!$isNew) {
if ($tableBeforeSave->criteriagroup_id != $table->criteriagroup_id) {
JUDirectoryHelper::changeInheritedCriteriaGroupId($table->id, $table->criteriagroup_id);
}
}
}