} } wpfb_print_json($props); exit; case 'new-cat': if (!WPFB_Core::CurUserCanCreateCat()) { die('-1'); } wpfb_loadclass('Admin'); $result = WPFB_Admin::InsertCategory($_POST); if (isset($result['error']) && $result['error']) { wpfb_print_json(array('error' => $result['error'])); exit; } $cat = $result['cat']; $args = WPFB_Output::fileBrowserArgs($_POST['args']); $filesel = $args['type'] === 'fileselect'; $catsel = $args['type'] === 'catselect'; wpfb_print_json(array('error' => 0, 'id' => $cat->GetId(), 'name' => $cat->GetTitle(), 'id_str' => $args['idp'] . 'cat-' . $cat->cat_id, 'url' => $cat->GetUrl(), 'text' => WPFB_Output::fileBrowserCatItemText($catsel, $filesel, $cat, $args['onselect'], empty($_REQUEST['is_admin']) ? 'filebrowser' : 'filebrowser_admin'), 'classes' => $filesel || $catsel ? 'folder' : null)); exit; case 'change-category': wpfb_loadclass('File', 'Admin'); $item = WPFB_Item::GetById($_POST['id'], $_POST['type']); if ($item && $item->CurUserCanEdit()) { $res = $item->ChangeCategoryOrName($_POST['new_cat_id']); wpfb_print_json($res); } else { die('-1'); } exit; }
private static function actionNewCat($args) { wpfb_loadclass('Category'); $parent_cat = empty($args['cat_parent']) ? null : WPFB_Category::GetCat($args['cat_parent']); if (!WPFB_Core::CurUserCanCreateCat() && !$parent_cat && !$parent_cat->CurUserCanAddFiles()) { die('-1'); } wpfb_loadclass('Admin'); $result = WPFB_Admin::InsertCategory($args); if (isset($result['error']) && $result['error']) { wp_send_json(array('error' => $result['error'])); exit; } $cat = $result['cat']; $fb_args = WPFB_Output::fileBrowserArgs(empty($args['args']) ? array() : $args['args']); $filesel = $fb_args['type'] === 'fileselect'; $catsel = $fb_args['type'] === 'catselect'; $tpl = empty($args['tpl']) ? empty($args['is_admin']) ? 'filebrowser' : 'filebrowser_admin' : $args['tpl']; wp_send_json(array('error' => 0, 'id' => $cat->GetId(), 'name' => $cat->GetTitle(), 'id_str' => $fb_args['idp'] . 'cat-' . $cat->cat_id, 'url' => $cat->GetUrl(), 'text' => WPFB_Output::fileBrowserCatItemText($catsel, $filesel, $cat, $fb_args['onselect'], $tpl), 'classes' => $filesel || $catsel ? 'folder' : null)); }