} } print "\n\n<table>\n"; print "<tr>\n"; print " <th>" . $currentLanguage . "</th>\n"; // get languages in use for all categories $allLanguages = PMF_Utils::languageAvailable(0, $table = 'faqcategories'); asort($allLanguages); foreach ($allLanguages as $language) { if ($languageCodes[strtoupper($language)] != $currentLanguage) { print " <th>" . $languageCodes[strtoupper($language)] . "</th>\n"; } } $categoryDataProvider = new PMF_Category_Tree_DataProvider_SingleQuery(); $categoryTreeHelper = new PMF_Category_Tree_Helper(new PMF_Category_Tree($categoryDataProvider)); $categoryHelper = new PMF_Category_Helper(); foreach ($categoryTreeHelper as $categoryId => $categoryName) { $indent = str_repeat(' ', $categoryTreeHelper->indent); $categoryLang = $categoryTreeHelper->getInnerIterator()->current()->getLanguage(); if ($categoryLang == $LANGCODE) { print "</tr>\n"; print "<tr>\n"; } printf(" <td> %s<strong>· %s</strong> </td>\n", $indent, $categoryName); foreach ($allLanguages as $language) { if ($language != $categoryLang && !$categoryHelper->hasTranslation($categoryId, $language)) { // translate category printf(" <td class=\"needsTranslation\"> %s<strong>· %s</strong> ", $indent, $categoryName); printf('<a href="index.php?action=translatecategory&cat=%d&trlang=%s" title="%s">', $categoryId, $LANGCODE, $PMF_LANG['ad_categ_translate']); printf('<img src="images/translate.png" width="13" height="16" border="0" title="%s" alt="%s" /></a>', $PMF_LANG['ad_categ_translate'], $PMF_LANG['ad_categ_translate']); print "</td>\n";
if ($userAction == 'delete') { $message = ''; $user = new PMF_User(); $userId = PMF_Filter::filterInput(INPUT_POST, 'user_id', FILTER_VALIDATE_INT, 0); $userAction = $defaultUserAction; if ($userId == 0) { $message .= '<p class="error">' . $errorMessages['delUser_noId'] . '</p>'; } else { if (!$user->getUserById($userId)) { $message .= '<p class="error">' . $errorMessages['delUser_noId'] . '</p>'; } if (!$user->deleteUser()) { $message .= '<p class="error">' . $errorMessages['delUser'] . '</p>'; } else { // Move the categories ownership to admin (id == 1) $categoryHelper = new PMF_Category_Helper(); $categoryHelper->moveOwnership($userId, 1); // Remove the user from groups if ('medium' == PMF_Configuration::getInstance()->get('main.permLevel')) { $oPerm = PMF_Perm::selectPerm('medium'); $oPerm->removeFromAllGroups($userId); } $message .= '<p class="success">' . $successMessages['delUser'] . '</p>'; } $userError = $user->error(); if ($userError != "") { $message .= '<p>ERROR: ' . $userError . '</p>'; } } } // save new user
$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']); } else { printf('<p class="error">%s</p>', $db->error()); } } // Updates an existing category if ($action == 'updatecategory') { $categoryHelper = new PMF_Category_Helper(); $categoryId = PMF_Filter::filterInput(INPUT_POST, 'id', FILTER_VALIDATE_INT); $categoryData = array('id' => $categoryId, '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 ($categoryHelper->hasTranslation($categoryData['id'], $categoryData['lang'])) { if ($categoryNode->create($categoryData)) { printf('<p class="message">%s</p>', $PMF_LANG['ad_categ_translated']); } else { printf('<p class="error">%s</p>', $db->error()); } } else { if ($categoryNode->update($categoryId, $categoryData)) { $userPermission = array('category_id' => $categoryNode->getCategoryId(), 'user_id' => $userAllowed);
* * @category phpMyFAQ * @package Administration * @author Thorsten Rinne <*****@*****.**> * @author Rudi Ferrari <*****@*****.**> * @copyright 2006-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 2006-09-10 */ if (!defined('IS_VALID_PHPMYFAQ_ADMIN')) { header('Location: http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME'])); exit; } if ($permission["editcateg"]) { $categoryHelper = new PMF_Category_Helper(); $categoryNode = new PMF_Category_Node(); // Set language $categoryNode->setLanguage($LANGCODE); $categoryId = PMF_Filter::filterInput(INPUT_GET, 'cat', FILTER_VALIDATE_INT); $categoryData = $categoryNode->fetch($categoryId); $header = sprintf('%s %s: <em>%s</em>', $PMF_LANG['ad_categ_trans_1'], $PMF_LANG['ad_categ_trans_2'], $categoryData->name); $selectedLanguage = PMF_Filter::filterInput(INPUT_POST, 'trlang', FILTER_SANITIZE_STRING, $LANGCODE); if ($selectedLanguage != $LANGCODE) { $showCategories = 'yes'; } else { $showCategories = 'no'; } printf('<h2>%s</h2>', $header); ?> <form action="?action=updatecategory" method="post">