当前位置: 首页>>代码示例>>PHP>>正文


PHP JUDownloadHelper::changeInheritedCriteriaGroupId方法代码示例

本文整理汇总了PHP中JUDownloadHelper::changeInheritedCriteriaGroupId方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDownloadHelper::changeInheritedCriteriaGroupId方法的具体用法?PHP JUDownloadHelper::changeInheritedCriteriaGroupId怎么用?PHP JUDownloadHelper::changeInheritedCriteriaGroupId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JUDownloadHelper的用法示例。


在下文中一共展示了JUDownloadHelper::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 #__judownload_categories WHERE criteriagroup_id =" . $table->id;
         $db->setQuery($query);
         $assignedCats = $db->loadColumn();
         $unassignedCats = array_diff($assignedCats, $data['assigntocats']);
         if (!empty($unassignedCats)) {
             $query = "UPDATE #__judownload_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 #__judownload_criterias_values WHERE rating_id IN" . "\n (SELECT r.id FROM" . "\n #__judownload_rating AS r" . "\n JOIN #__judownload_documents AS d" . "\n ON d.id = r.doc_id " . "\n JOIN #__judownload_documents_xref AS dxref" . "\n ON (" . "\n d.id = dxref.doc_id" . "\n AND dxref.main = 1" . "\n )" . "\n WHERE dxref.cat_id = " . $unassignedCat . ")";
                 $db->setQuery($query);
                 $db->execute();
                 JUDownloadHelper::changeInheritedCriteriaGroupId($unassignedCat, 0);
             }
         }
         $catsToAddNewCriteriaGroup = array_diff($data['assigntocats'], $assignedCats);
         if ($catsToAddNewCriteriaGroup) {
             $query = "UPDATE #__judownload_categories SET selected_criteriagroup = {$table->id}, criteriagroup_id = {$table->id}  WHERE id IN (" . implode(',', $catsToAddNewCriteriaGroup) . ")";
             $db->setQuery($query);
             $db->execute();
             foreach ($catsToAddNewCriteriaGroup as $catToAddNewCriteriaGroup) {
                 JUDownloadHelper::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;
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:72,代码来源:criteriagroup.php

示例2: saveCategoryChangeCriteriaGroup

 public function saveCategoryChangeCriteriaGroup($tableBeforeSave, $table, $isNew)
 {
     if (!$isNew) {
         if ($tableBeforeSave->criteriagroup_id != $table->criteriagroup_id) {
             JUDownloadHelper::changeInheritedCriteriaGroupId($table->id, $table->criteriagroup_id);
         }
     }
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:8,代码来源:category.php


注:本文中的JUDownloadHelper::changeInheritedCriteriaGroupId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。