$changed = PMF_Filter::filterInput(INPUT_POST, 'changed', FILTER_SANITIZE_STRING); // Permissions $user_permission = PMF_Filter::filterInput(INPUT_POST, 'userpermission', FILTER_SANITIZE_STRING); $restricted_users = 'all' == $user_permission ? -1 : PMF_Filter::filterInput(INPUT_POST, 'restricted_users', FILTER_VALIDATE_INT); $group_permission = PMF_Filter::filterInput(INPUT_POST, 'grouppermission', FILTER_SANITIZE_STRING); $restricted_groups = 'all' == $group_permission ? -1 : PMF_Filter::filterInput(INPUT_POST, 'restricted_groups', FILTER_VALIDATE_INT); if (isset($submit['submit'][1]) && !is_null($question) && !is_null($categories['rubrik'])) { // new entry $logging = new PMF_Logging(); $logging->logAdmin($user, 'Beitragcreatesave'); printf("<h2>%s</h2>\n", $PMF_LANG['ad_entry_aor']); $recordData = array('id' => null, 'lang' => $record_lang, 'active' => $active, 'sticky' => !is_null($sticky) ? 1 : 0, 'thema' => html_entity_decode($question), 'content' => html_entity_decode($content), 'keywords' => $keywords, 'author' => $author, 'email' => $email, 'comment' => !is_null($comment) ? 'y' : 'n', 'date' => date('YmdHis'), 'dateStart' => empty($dateStart) ? '00000000000000' : str_replace('-', '', $dateStart) . '000000', 'dateEnd' => empty($dateEnd) ? '99991231235959' : str_replace('-', '', $dateEnd) . '235959', 'linkState' => '', 'linkDateCheck' => 0); // Add new record and get that ID $faqRecord = new PMF_Faq_Record(); $faqChangelog = new PMF_Faq_Changelog(); if ($faqRecord->create($recordData)) { $recordId = $faqRecord->getRecordId(); // Create ChangeLog entry $changelogData = array('record_id' => $recordId, 'record_lang' => $recordData['lang'], 'revision_id' => 0, 'user_id' => $user->getUserId(), 'date' => $_SERVER['REQUEST_TIME'], 'changelog' => nl2br($changed)); $faqChangelog->create($changelogData); // Create the visit entry $visits = PMF_Visits::getInstance(); $visits->add($recordId, $recordData['lang']); // Insert the new category relations $categoryRelations = new PMF_Category_Relations(); // Insert the tags if ($tags != '') { $tagging = new PMF_Tags(); $tagging->saveTags($recordId, explode(',', $tags)); } // Set record permissions
$newData = array('lang' => $isTranslation == true ? $newLanguage : $LANGCODE, 'thema' => $thema, 'active' => FAQ_SQL_ACTIVE_NO, 'sticky' => 0, 'content' => $content, 'keywords' => $keywords, 'author' => $username, 'email' => $usermail, 'comment' => FAQ_SQL_YES, 'date' => date('YmdHis'), 'dateStart' => '00000000000000', 'dateEnd' => '99991231235959', 'linkState' => '', 'linkDateCheck' => 0); $categoryNode = new PMF_Category_Node(); $categoryRelation = new PMF_Category_Relations(); $faqRecord = new PMF_Faq_Record(); if ($isNew) { $newData['id'] = null; $categories = $categoryNode->fetchAll($categories['rubrik']); } else { $newData['id'] = $faqid; foreach ($categoryRelation->fetchAll() as $relation) { if ($relation->record_id == $newData['id']) { $categories[] = $relation; } } } $faqRecord->create($newData); $recordId = $faqRecord->getSolutionId(); foreach ($categories as $category) { $categoryData = array('category_id' => $category->category_id, 'category_lang' => $newData['lang'], 'record_id' => $recordId, 'record_lang' => $newData['lang']); // save the category relations $categoryRelations->create($categoryData); } $sent = array(); // Let the PMF Administrator and the Category Owner to be informed by email of this new entry foreach ($categories as $category) { $userId = $category->user_id; // Avoid to send multiple emails to the same owner if (!isset($sent[$userId])) { // TODO: Move this code to Category.php $oUser = new PMF_User(); $oUser->getUserById($userId);