} // make sure we have a valid block id $add_to_block = $add_to_block > 0 ? $add_to_block : 1; $section_id = CAT_Sections::addSection($page_id, $module, $add_to_block); if ($section_id === false) { $backend->print_error('Error adding module'); } else { if (file_exists(CAT_PATH . '/modules/' . $module . '/add.php')) { global $backend, $admin; $admin =& $backend; require CAT_PATH . '/modules/' . $module . '/add.php'; } } } elseif ($delete_section_id != '') { $section_id = $delete_section_id; $section = CAT_Sections::getSection($section_id); if (file_exists(CAT_PATH . '/modules/' . $section['module'] . '/delete.php')) { require CAT_PATH . '/modules/' . $section['module'] . '/delete.php'; } if (CAT_Sections::deleteSection($section_id, $page_id)) { $backend->print_success('Success', CAT_ADMIN_URL . '/pages/modify.php?page_id=' . $page_id); exit; } } elseif ($update_section_id != '') { $block = $val->sanitizeGet('block'); $name = $val->sanitizeGet('name'); $day_from = is_numeric($val->sanitizeGet('day_from')) ? $val->sanitizeGet('day_from') : 0; $month_from = is_numeric($val->sanitizeGet('month_from')) ? $val->sanitizeGet('month_from') : 0; $year_from = is_numeric($val->sanitizeGet('year_from')) ? $val->sanitizeGet('year_from') : 0; $hour_from = is_numeric($val->sanitizeGet('hour_from')) ? $val->sanitizeGet('hour_from') : 0; $minute_from = is_numeric($val->sanitizeGet('minute_from')) ? $val->sanitizeGet('minute_from') : 0;
$options = array(); if ($block) { $options['block'] = $val->add_slashes($block); } if ($name) { $options['name'] = $val->add_slashes($name); } $date_from = $day_from * $month_from * $year_from > 0 ? mktime($hour_from, $minute_from, 0, $month_from, $day_from, $year_from) : 0; $date_to = $day_to * $month_to * $year_to > 0 ? mktime($hour_to, $minute_to, 0, $month_to, $day_to, $year_to) : 0; if ($date_from > $date_to) { $ajax = array('message' => $backend->lang()->translate('Please check your entries for dates.'), 'success' => false); print json_encode($ajax); exit; } else { $options['publ_start'] = $date_from; $options['publ_end'] = $date_to; } if (!CAT_Sections::updateSection($update_section_id, $options)) { $ajax = array('message' => $backend->lang()->translate('Unable to save section: ' . $backend->db()->getError()), 'success' => false); print json_encode($ajax); exit; } $updated_section = CAT_Sections::getSection($update_section_id); $updated_block = $parser->get_template_block_name(CAT_Helper_Page::getPageTemplate($page_id), $updated_section['block']) . ' (' . $backend->lang()->translate('Block number') . ': ' . $updated_section['block'] . ')'; } // ============================================ // ! Check for error or print success message // ============================================ $ajax = array('message' => $backend->lang()->translate('Section properties saved successfully.'), 'updated_section' => isset($updated_section) ? $updated_section : false, 'updated_block' => isset($updated_block) ? $updated_block : false, 'success' => true); print json_encode($ajax); exit;