コード例 #1
0
ファイル: category.main.php プロジェクト: nosch/phpMyFAQ
     $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);
             $groupPermission = array('category_id' => $categoryNode->getCategoryId(), 'group_id' => $groupAllowed);
             $categoryUser->update($categoryId, $userPermission);
             $categoryGroup->update($categoryId, $groupPermission);
             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);
     }
コード例 #2
0
ファイル: record.save.php プロジェクト: nosch/phpMyFAQ
     $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)) {
         $do = dir($path);
         while ($dat = $do->read()) {
             if ($dat != "." && $dat != "..") {
                 unlink($path . $dat);
             }
         }
         rmdir($path);
     }