* @author Thorsten Rinne <*****@*****.**> * @copyright 2003-2010 phpMyFAQ Team * @license http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License Version 1.1 * @link http://www.phpmyfaq.de * @since 2003-12-20 */ if (!defined('IS_VALID_PHPMYFAQ')) { header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])); exit; } print "<h2>" . $PMF_LANG["ad_categ_new"] . "</h2>\n"; if ($permission["addcateg"]) { $parentId = PMF_Filter::filterInput(INPUT_GET, 'cat', FILTER_VALIDATE_INT, 0); $categoryNode = new PMF_Category_Node(); $categoryUser = new PMF_Category_User(); $categoryGroup = new PMF_Category_Group(); $categoryData = $categoryNode->fetch($parentId); ?> <form action="?action=savecategory" method="post"> <fieldset> <legend><?php print $PMF_LANG["ad_categ_new"]; ?> </legend> <input type="hidden" id="lang" name="lang" value="<?php print $LANGCODE; ?> " /> <input type="hidden" name="parent_id" value="<?php print $parent_id; ?>
* @copyright 2003-2010 phpMyFAQ Team */ if (!defined('IS_VALID_PHPMYFAQ_ADMIN')) { header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])); exit; } printf('<h2>%s</h2>', $PMF_LANG['ad_menu_categ_edit']); print "<p>\n"; printf('<img src="images/arrow.gif" width="11" height="11" alt="" border="0" /> <a href="?action=addcategory">%s</a>', $PMF_LANG['ad_kateg_add']); print " "; printf('<img src="images/arrow.gif" width="11" height="11" alt="" border="0" /> <a href="?action=showcategory">%s</a>', $PMF_LANG['ad_categ_show']); print "</p>\n"; if ($permission['editcateg']) { $categoryNode = new PMF_Category_Node(); $categoryUser = new PMF_Category_User(); $categoryGroup = new PMF_Category_Group(); $categoryRelations = new PMF_Category_Relations(); $categoryHelper = new PMF_Category_Helper(); // Save a new category if ($action == 'savecategory') { $categoryData = array('id' => null, 'lang' => PMF_Filter::filterInput(INPUT_POST, 'lang', FILTER_SANITIZE_STRING), 'parent_id' => PMF_Filter::filterInput(INPUT_POST, 'parent_id', FILTER_VALIDATE_INT), 'name' => PMF_Filter::filterInput(INPUT_POST, 'name', FILTER_SANITIZE_STRING), 'description' => PMF_Filter::filterInput(INPUT_POST, 'description', FILTER_SANITIZE_STRING), 'user_id' => PMF_Filter::filterInput(INPUT_POST, 'user_id', FILTER_VALIDATE_INT)); $userperm = PMF_Filter::filterInput(INPUT_POST, 'userpermission', FILTER_SANITIZE_STRING); $userAllowed = 'all' == $userperm ? -1 : PMF_Filter::filterInput(INPUT_POST, 'restricted_users', FILTER_VALIDATE_INT); $groupperm = PMF_Filter::filterInput(INPUT_POST, 'grouppermission', FILTER_SANITIZE_STRING); $groupAllowed = 'all' == $groupperm ? -1 : PMF_Filter::filterInput(INPUT_POST, 'restricted_groups', FILTER_VALIDATE_INT); if ($categoryNode->create($categoryData)) { $userPermission = array('category_id' => $categoryNode->getCategoryId(), 'user_id' => $userAllowed); $groupPermission = array('category_id' => $categoryNode->getCategoryId(), 'group_id' => $groupAllowed); $categoryUser->create($userPermission); $categoryGroup->create($groupPermission); printf('<p class="message">%s</p>', $PMF_LANG['ad_categ_added']);
$categoryRelations = new PMF_Category_Relations(); // Insert the tags if ($tags != '') { $tagging = new PMF_Tags(); $tagging->saveTags($recordId, explode(',', $tags)); } // Set record permissions $faqUser = new PMF_Faq_User(); $faqUser->create(array('record_id' => $recordId, 'user_id' => $restricted_users)); if ($groupSupport) { $faqGroup = new PMF_Faq_Group(); $faqGroup->create(array('record_id' => $recordId, 'group_id' => $restricted_groups)); } // Loop the categories $categoryUser = new PMF_Category_User(); $categoryGroup = new PMF_Category_Group(); $categoryRelations = new PMF_Category_Relations(); $categoryRelations->setLanguage($recordData['lang']); foreach ($categories['rubrik'] as $categoryId) { // Insert the new category relations $categoryData = array('category_id' => $categoryId, 'category_lang' => $categoryRelations->getLanguage(), 'record_id' => $recordId, 'record_lang' => $recordData['lang']); // save or update the category relations $categoryRelations->create($categoryData); // Add user permissions $userPermission = array('category_id' => $categoryId, 'user_id' => $restricted_users); $categoryUser->delete($categoryId); $categoryUser->create($userPermission); // Add group permission if ($groupSupport) { $groupPermission = array('category_id' => $categoryId, 'group_id' => $restricted_groups); $categoryGroup->delete($categoryId);
* @package Administration * @author Thorsten Rinne <*****@*****.**> * @copyright 2003-2010 phpMyFAQ Team * @license http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License Version 1.1 * @link http://www.phpmyfaq.de * @since 2003-03-10 */ if (!defined('IS_VALID_PHPMYFAQ_ADMIN')) { header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])); exit; } if ($permission['editcateg']) { $categoryId = PMF_Filter::filterInput(INPUT_GET, 'cat', FILTER_VALIDATE_INT, 0); $categoryNode = new PMF_Category_Node(); $categoryUser = new PMF_Category_User(); $categoryGroup = new PMF_Category_Group(); $categoryData = $categoryNode->fetch($categoryId); $userPermission = $categoryUser->fetch($categoryId); if ($userPermission->user_id == -1) { $allUsers = true; $restrictedUsers = false; } else { $allUsers = false; $restrictedUsers = true; } $groupPermission = $categoryGroup->fetch($categoryId); if ($groupPermission->group_id == -1) { $allGroups = true; $restrictedGroups = false; } else { $allGroups = false;
$tagging = new PMF_Tags(); if ($tags != '') { $tagging->saveTags($record_id, explode(',', $tags)); } else { $tagging->deleteTagsFromRecordId($record_id); } // 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); }