Beispiel #1
0
 function _save_sections_related()
 {
     $sections_related = $this->_getSectionsRelatedBase();
     $active_related = $this->_getSectionsRelatedDB();
     if (!$active_related && !$sections_related) {
         return false;
     }
     if (!$sections_related) {
         $sections_related = array();
     }
     if ($active_related) {
         $deleted_items = array_diff($active_related, $sections_related);
         $new_items = array_diff($sections_related, $active_related);
     } else {
         $deleted_items = array();
         $new_items = $sections_related;
     }
     if (empty($deleted_items) && empty($new_items)) {
         return false;
     }
     require_once 'AMP/Content/Section/RelatedSet.inc.php';
     $related_section_set = new SectionRelatedSet($this->dbcon);
     if (!empty($deleted_items)) {
         $delete_crit = $this->_makeRelatedSectionCriteria($deleted_items);
         $related_section_set->deleteData($delete_crit);
         foreach ($deleted_items as $section_id) {
             AMPContentLookup_RelatedArticles::clear_cache($section_id);
         }
     }
     if (!empty($new_items)) {
         foreach ($new_items as $section_id) {
             $insert_values = array('typeid' => $section_id, 'articleid' => $this->id);
             $related_section_set->insertData($insert_values);
             AMPContentLookup_RelatedArticles::clear_cache($section_id);
         }
     }
     AMPContentLookup_SectionsByArticle::clear_cache($this->id);
 }
Beispiel #2
0
 function _getRelatedSections($data, $fieldname)
 {
     $id = isset($data['id']) && $data['id'] ? $data['id'] : false;
     if (!$id) {
         return false;
     }
     $related_sections = AMPContentLookup_SectionsByArticle::instance($id);
     if (!$related_sections) {
         return false;
     }
     return join(',', array_keys($related_sections));
 }