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


PHP JUDirectoryHelper::deleteFieldValuesOfListing方法代码示例

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


在下文中一共展示了JUDirectoryHelper::deleteFieldValuesOfListing方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deleteMainData

 public function deleteMainData($pk, $deleteSelf = false)
 {
     $db = JFactory::getDbo();
     JUDirectoryHelper::deleteFieldValuesOfListing($pk);
     $query = "DELETE FROM #__judirectory_listings_relations WHERE listing_id = " . $pk;
     $db->setQuery($query);
     $db->execute();
     $query = "DELETE FROM #__judirectory_listings_xref WHERE listing_id = " . $pk;
     $db->setQuery($query);
     $db->execute();
     if ($deleteSelf) {
         return parent::delete($pk);
     }
     return true;
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:15,代码来源:listing.php

示例2: save

 public function save($data)
 {
     if (!$data['id']) {
         return false;
     }
     $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;
         }
         $db = JFactory::getDbo();
         $fieldgroup_id = $table->id;
         if (!isset($data['assigntocats'])) {
             $data['assigntocats'] = array();
         }
         $query = "SELECT id FROM #__judirectory_categories WHERE fieldgroup_id =" . $fieldgroup_id . ' AND selected_fieldgroup != -1';
         $db->setQuery($query);
         $catid_has_this_exgr = $db->loadColumn();
         $cat_remove_exgr = array_diff($catid_has_this_exgr, $data['assigntocats']);
         if (!empty($cat_remove_exgr)) {
             $query = "UPDATE #__judirectory_categories SET selected_fieldgroup = 0, fieldgroup_id = 0 WHERE id IN (" . implode(',', $cat_remove_exgr) . ")";
             $db->setQuery($query);
             $db->execute();
             foreach ($cat_remove_exgr as $cat_remove) {
                 $listing_id_arr = JUDirectoryHelper::getListingIdsByCatId($cat_remove);
                 foreach ($listing_id_arr as $listingId) {
                     JUDirectoryHelper::deleteFieldValuesOfListing($listingId);
                 }
                 JUDirectoryHelper::changeInheritedFieldGroupId($cat_remove, 0);
             }
         }
         $cat_add_exgr = array_diff($data['assigntocats'], $catid_has_this_exgr);
         if ($cat_add_exgr) {
             $query = "UPDATE #__judirectory_categories SET selected_fieldgroup = {$fieldgroup_id}, fieldgroup_id = {$fieldgroup_id} WHERE id IN (" . implode(', ', $cat_add_exgr) . ")";
             $db->setQuery($query);
             $db->execute();
             foreach ($cat_add_exgr as $add_exgr) {
                 JUDirectoryHelper::changeInheritedFieldGroupId($add_exgr, $fieldgroup_id);
             }
         }
         if ($table->field_ordering_type == 1) {
             $app = JFactory::getApplication();
             $fields_ordering = $app->input->post->get("fields_ordering", array(), 'array');
             if ($fields_ordering) {
                 JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_judirectory/tables');
                 $fieldOrderingTable = JTable::getInstance("FieldOrdering", "JUDirectoryTable");
                 $db = $this->getDbo();
                 $query = "SELECT id FROM #__judirectory_fields WHERE group_id = 1 OR group_id = " . $table->id;
                 $db->setQuery($query);
                 $field_ids = $db->loadColumn();
                 $ordering = 0;
                 foreach ($fields_ordering as $key => $field_id) {
                     if (in_array($field_id, $field_ids)) {
                         $ordering++;
                         $fieldOrderingTable->reset();
                         if ($fieldOrderingTable->load(array("item_id" => $fieldgroup_id, "type" => "fieldgroup", "field_id" => $field_id))) {
                             $fieldOrderingTable->bind(array("ordering" => $ordering));
                         } else {
                             $fieldOrderingTable->bind(array("id" => 0, "item_id" => $fieldgroup_id, "type" => "fieldgroup", "field_id" => $field_id, "ordering" => $ordering));
                         }
                         $fieldOrderingTable->store();
                     }
                 }
             }
         }
         $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);
//.........这里部分代码省略.........
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:101,代码来源:fieldgroup.php

示例3: saveCategoryChangeFieldGroup

 public function saveCategoryChangeFieldGroup($tableBeforeSave, $table, $isNew)
 {
     if (!$isNew) {
         $db = JFactory::getDbo();
         if ($tableBeforeSave->fieldgroup_id != $table->fieldgroup_id) {
             $listingId_arr = JUDirectoryHelper::getListingIdsByCatId($table->id);
             foreach ($listingId_arr as $listingId) {
                 JUDirectoryHelper::deleteFieldValuesOfListing($listingId);
             }
             $query = "DELETE FROM #__judirectory_fields_ordering WHERE item_id = {$table->id} AND type = 'category'";
             $db->setQuery($query);
             $db->execute();
             JUDirectoryHelper::changeInheritedFieldGroupId($table->id, $table->fieldgroup_id);
         }
     }
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:16,代码来源:category.php

示例4: moveListings


//.........这里部分代码省略.........
         if (!$canDoEdit) {
             if (!$user->id) {
                 JError::raiseWarning(100, JText::sprintf('COM_JUDIRECTORY_YOU_DONT_HAVE_PERMISSION_TO_ACCESS_LISTING', $table->title));
                 continue;
             } else {
                 if ($user->id == $table->created_by) {
                     $canDoEditOwn = $user->authorise('judir.listing.edit.own', $assetName);
                     if (!$canDoEditOwn) {
                         JError::raiseWarning(100, JText::sprintf('COM_JUDIRECTORY_YOU_DONT_HAVE_PERMISSION_TO_ACCESS_LISTING', $table->title));
                         continue;
                     }
                 }
             }
         }
         $query = "SELECT cat_id FROM #__judirectory_listings_xref WHERE listing_id = " . $listing_id . " AND main=1";
         $db->setQuery($query);
         $cat_id = $db->loadResult();
         if ($tocat_id == $cat_id) {
             continue;
         }
         $result = $dispatcher->trigger($this->onContentBeforeMove, array($this->option . '.' . $this->name, $table, $tocat_id, $move_option_arr));
         if (in_array(false, $result, true)) {
             $this->setError($table->getError());
             return false;
         }
         if ($table->style_id == -1) {
             $oldTemplateStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($cat_id);
             $newTemplateStyleObject = JUDirectoryFrontHelperTemplate::getTemplateStyleOfCategory($tocat_id);
             if ($oldTemplateStyleObject->template_id != $newTemplateStyleObject->template_id) {
                 if (in_array('keep_template_params', $move_option_arr)) {
                     $table->style_id = $oldTemplateStyleObject->id;
                 } else {
                     $query = "UPDATE #__judirectory_listings SET template_params = '' WHERE id=" . $listing_id;
                     $db->setQuery($query);
                     $db->execute();
                 }
             }
         }
         $query = "SELECT COUNT(*) FROM #__judirectory_listings_xref WHERE cat_id=" . $tocat_id . " AND listing_id=" . $listing_id . " AND main=0";
         $db->setQuery($query);
         $is_secondary_cat = $db->loadResult();
         if ($is_secondary_cat) {
             $query = "DELETE FROM #__judirectory_listings_xref WHERE listing_id=" . $listing_id . " AND main=1";
             $db->setQuery($query);
             $db->execute();
             $query = "UPDATE #__judirectory_listings_xref SET main=1 WHERE cat_id=" . $tocat_id . " AND listing_id=" . $listing_id;
             $db->setQuery($query);
             $db->execute();
         } else {
             $query = "UPDATE #__judirectory_listings_xref SET cat_id=" . $tocat_id . " WHERE listing_id=" . $listing_id . " AND main=1";
             $db->setQuery($query);
             $db->execute();
         }
         if (in_array('keep_permission', $move_option_arr)) {
             $query = 'UPDATE #__assets SET `parent_id` = ' . $tocat_asset_id . ' WHERE name="com_judirectory.listing.' . $listing_id . '"';
             $db->setQuery($query);
             $db->execute();
         } else {
             $query = 'UPDATE #__assets SET `parent_id` = ' . $tocat_asset_id . ', `rules` = "{}" WHERE name="com_judirectory.listing.' . $listing_id . '"';
             $db->setQuery($query);
             $db->execute();
         }
         $moved_listings[] = $listing_id;
         $this->cleanCache();
         $dispatcher->trigger($this->onContentAfterMove, array($this->option . '.' . $this->name, $table, $tocat_id, $move_option_arr));
     }
     $total_moved_listings = count($moved_listings);
     if ($total_moved_listings) {
         $old_field_groupid = JUDirectoryHelper::getCategoryById($cat_id)->fieldgroup_id;
         $new_field_groupid = JUDirectoryHelper::getCategoryById($tocat_id)->fieldgroup_id;
         $keep_extra_fields = in_array("keep_extra_fields", $move_option_arr);
         if ($keep_extra_fields) {
             $keep_extra_fields = $old_field_groupid == $new_field_groupid ? true : false;
         }
         if (!$keep_extra_fields) {
             foreach ($moved_listings as $listing_id) {
                 JUDirectoryHelper::deleteFieldValuesOfListing($listing_id);
             }
         }
         $old_criteria_groupid = JUDirectoryHelper::getCategoryById($cat_id)->criteriagroup_id;
         $new_criteria_groupid = JUDirectoryHelper::getCategoryById($tocat_id)->criteriagroup_id;
         $keep_rates = in_array("keep_rates", $move_option_arr);
         if ($keep_rates) {
             $keep_rates = $old_criteria_groupid == $new_criteria_groupid ? true : false;
         }
         if (!$keep_rates) {
             JTable::addIncludePath(JPATH_ADMINISTRATOR . "/components/com_judirectory/tables");
             $ratingTable = JTable::getInstance("Rating", "JUDirectoryTable");
             foreach ($moved_listings as $listing_id) {
                 $query = "SELECT id FROM #__judirectory_rating WHERE listing_id = " . $listing_id;
                 $db->setQuery($query);
                 $ratingIds = $db->loadColumn();
                 foreach ($ratingIds as $ratingId) {
                     $ratingTable->delete($ratingId);
                 }
             }
         }
     }
     return $total_moved_listings;
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:101,代码来源:listing.php


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