printf('<p class="message">%s</p>', $PMF_LANG['ad_categ_updated']); } else { printf('<p class="error">%s</p>', $db->error()); } } } // Deletes an existing category if ($permission['delcateg'] && $action == 'removecategory') { $categoryId = PMF_Filter::filterInput(INPUT_POST, 'cat', FILTER_VALIDATE_INT); $categoryLang = PMF_Filter::filterInput(INPUT_POST, 'lang', FILTER_SANITIZE_STRING); $deleteAll = PMF_Filter::filterInput(INPUT_POST, 'deleteall', FILTER_SANITIZE_STRING); if ('yes' == $deleteAll) { $categoryNode->setLanguage($categoryLang); $categoryRelations->setLanguage($categoryLang); } if ($categoryNode->delete($categoryId) && $categoryRelations->delete($categoryId) && $categoryUser->delete($categoryId) && $categoryGroup->delete($categoryId)) { printf('<p class="message">%s</p>', $PMF_LANG['ad_categ_deleted']); } else { printf('<p class="error">%s</p>', $db->error()); } } // Moves a category if ($action == 'changecategory') { $firstCategoryId = PMF_Filter::filterInput(INPUT_POST, 'cat', FILTER_VALIDATE_INT); $secondCategoryId = PMF_Filter::filterInput(INPUT_POST, 'change', FILTER_VALIDATE_INT); if ($categoryHelper->swapCategories($firstCategoryId, $secondCategoryId)) { printf('<p class="message">%s</p>', $PMF_LANG['ad_categ_updated']); } else { printf('<p class="error">%s<br />%s</p>', $PMF_LANG['ad_categ_paste_error'], $db->error()); } }
// Add record permissions $faqUser = new PMF_Faq_User(); $faqUser->update($record_id, array('user_id' => $restricted_users)); if ($groupSupport) { $faqGroup = new PMF_Faq_Group(); $faqGroup->update($recordId, array('group_id' => $restricted_groups)); } // Loop the categories $categoryUser = new PMF_Category_User(); $categoryGroup = new PMF_Category_Group(); $categoryRelations = new PMF_Category_Relations(); $categoryRelations->setLanguage($record_lang); foreach ($categories['rubrik'] as $categoryId) { $categoryData = array('category_id' => $categoryId, 'category_lang' => $categoryRelations->getLanguage(), 'record_id' => $record_id, 'record_lang' => $record_lang); // delete category relations $categoryRelations->delete($categoryId); // save or update the category relations $categoryRelations->create($categoryData); // Add user permissions $userPermission = array('category_id' => $categoryId, 'user_id' => $restricted_users); $categoryUser->update($categoryId, $userPermission); // Add group permission $groupPermission = array('category_id' => $categoryId, 'group_id' => $restricted_groups); $categoryGroup->update($category, $group_permission); } } elseif (isset($submit['submit'][0])) { $faqRecord = new PMF_Faq_Record(); $logging = new PMF_Logging(); $logging->logAdmin($user, 'Deleted record ' . $record_id); $path = PMF_ROOT_DIR . DIRECTORY_SEPARATOR . PMF_ATTACHMENTS_DIR . DIRECTORY_SEPARATOR . $record_id . '/'; if (@is_dir($path)) {