/** * Add or update a newsML category * @access private * @global object $objDatabase * @global array $_ARRAYLANG */ function _newsMLSaveCategory() { global $_ARRAYLANG; if (isset($_POST['save'])) { $categoryId = isset($_GET['categoryId']) ? intval($_GET['categoryId']) : 0; $categoryName = isset($_POST['feedNewsMLCategoryName']) ? preg_replace('/[^a-zA-Z0-9-_\\s]+/', '', $_POST['feedNewsMLCategoryName']) : ''; $providerId = isset($_POST['feedNewsMLProviderId']) ? intval($_POST['feedNewsMLProviderId']) : 0; $arrSubjectCodeMethods = array('all', 'only', 'exclude'); $subjectCodeMethod = isset($_POST['feedNewsMLSubjectCode']) && in_array($_POST['feedNewsMLSubjectCode'], $arrSubjectCodeMethods) ? $_POST['feedNewsMLSubjectCode'] : 'all'; $arrTmpSubjectCodes = isset($_POST['feedNewsMLSubjects']) ? explode(',', $_POST['feedNewsMLSubjects']) : array(); $arrSubjectCodes = array(); foreach ($arrTmpSubjectCodes as $subjectCode) { array_push($arrSubjectCodes, intval($subjectCode)); } $msgCount = isset($_POST['feedNewsMLCategoryMsgCount']) ? intval($_POST['feedNewsMLCategoryMsgCount']) : $this->_objNewsML->standardMessageCount; $showPics = isset($_POST['feedNewsMLCategoryShowPics']) ? intval($_POST['feedNewsMLCategoryShowPics']) : 0; $templateHtml = isset($_POST['feedNewsMLCategoryTemplate']) ? contrexx_addslashes($_POST['feedNewsMLCategoryTemplate']) : ''; $templateHtml = preg_replace('/\\[\\[([A-Za-z0-9_]*?)\\]\\]/', '{\\1}', $templateHtml); if ($categoryId != 0) { if ($this->_objNewsML->updateCategory($categoryId, $providerId, $categoryName, $arrSubjectCodes, $subjectCodeMethod, $templateHtml, $msgCount, $showPics) === false) { $_SESSION['strErrMessage'] .= $_ARRAYLANG['TXT_FEED_CATEGORY_COULD_NOT_BE_UPDATED'] . "<br />"; } } else { if ($this->_objNewsML->addCategory($providerId, $categoryName, $arrSubjectCodes, $subjectCodeMethod, $templateHtml, $msgCount, $showPics) === false) { $_SESSION['strErrMessage'] .= $_ARRAYLANG['TXT_FEED_COULD_NOT_ADD_CATEGORY'] . "<br />"; } } $this->_objNewsML->initCategories(); } }