コード例 #1
0
ファイル: Categories.php プロジェクト: bohwaz/featherbb
 public function edit_categories()
 {
     if (empty($this->request->post('cat'))) {
         throw new Error(__('Bad request'), '400');
     }
     foreach ($this->request->post('cat') as $cat_id => $properties) {
         $category = array('id' => (int) $cat_id, 'name' => Utils::escape($properties['name']), 'order' => (int) $properties['order']);
         if ($category['name'] == '') {
             Url::redirect($this->feather->urlFor('adminCategories'), __('Must enter name message'));
         }
         $this->model->update_category($category);
     }
     // Regenerate the quick jump cache
     $this->feather->cache->store('quickjump', Cache::get_quickjump());
     Url::redirect($this->feather->urlFor('adminCategories'), __('Categories updated redirect'));
 }
コード例 #2
0
ファイル: Categories.php プロジェクト: featherbb/featherbb
 public function edit($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.admin.categories.edit');
     if (empty(Input::post('cat'))) {
         throw new Error(__('Bad request'), '400');
     }
     foreach (Input::post('cat') as $cat_id => $properties) {
         $category = array('id' => (int) $cat_id, 'name' => Utils::escape($properties['name']), 'order' => (int) $properties['order']);
         if ($category['name'] == '') {
             return Router::redirect(Router::pathFor('adminCategories'), __('Must enter name message'));
         }
         $this->model->update_category($category);
     }
     // Regenerate the quick jump cache
     Container::get('cache')->store('quickjump', Cache::get_quickjump());
     return Router::redirect(Router::pathFor('adminCategories'), __('Categories updated redirect'));
 }
コード例 #3
0
ファイル: Groups.php プロジェクト: featherbb/featherbb
 public function add_edit_group($groups)
 {
     if (Input::post('group_id')) {
         $group_id = Input::post('group_id');
     } else {
         $group_id = 0;
     }
     $group_id = Container::get('hooks')->fire('model.admin.groups.add_edit_group_start', $group_id);
     // Is this the admin group? (special rules apply)
     $is_admin_group = Input::post('group_id') && Input::post('group_id') == ForumEnv::get('FEATHER_ADMIN') ? true : false;
     // Set group title
     $title = Utils::trim(Input::post('req_title'));
     if ($title == '') {
         throw new Error(__('Must enter title message'), 400);
     }
     $title = Container::get('hooks')->fire('model.admin.groups.add_edit_group_set_title', $title);
     // Set user title
     $user_title = Utils::trim(Input::post('user_title'));
     $user_title = $user_title != '' ? $user_title : 'NULL';
     $user_title = Container::get('hooks')->fire('model.admin.groups.add_edit_group_set_user_title', $user_title);
     $promote_min_posts = Input::post('promote_min_posts') ? intval(Input::post('promote_min_posts')) : '0';
     if (Input::post('promote_next_group') && isset($groups[Input::post('promote_next_group')]) && !in_array(Input::post('promote_next_group'), array(ForumEnv::get('FEATHER_ADMIN'), ForumEnv::get('FEATHER_GUEST'))) && (Input::post('group_id') || Input::post('promote_next_group') != Input::post('group_id'))) {
         $promote_next_group = Input::post('promote_next_group');
     } else {
         $promote_next_group = '0';
     }
     $moderator = Input::post('moderator') && Input::post('moderator') == '1' ? '1' : '0';
     $mod_edit_users = $moderator == '1' && Input::post('mod_edit_users') == '1' ? '1' : '0';
     $mod_rename_users = $moderator == '1' && Input::post('mod_rename_users') == '1' ? '1' : '0';
     $mod_change_passwords = $moderator == '1' && Input::post('mod_change_passwords') == '1' ? '1' : '0';
     $mod_ban_users = $moderator == '1' && Input::post('mod_ban_users') == '1' ? '1' : '0';
     $mod_promote_users = $moderator == '1' && Input::post('mod_promote_users') == '1' ? '1' : '0';
     $read_board = Input::post('read_board') == 0 ? Input::post('read_board') : '1';
     $view_users = Input::post('view_users') && Input::post('view_users') == '1' || $is_admin_group ? '1' : '0';
     $post_replies = Input::post('post_replies') == 0 ? Input::post('post_replies') : '1';
     $post_topics = Input::post('post_topics') == 0 ? Input::post('post_topics') : '1';
     $edit_posts = Input::post('edit_posts') == 0 ? Input::post('edit_posts') : $is_admin_group ? '1' : '0';
     $delete_posts = Input::post('delete_posts') == 0 ? Input::post('delete_posts') : $is_admin_group ? '1' : '0';
     $delete_topics = Input::post('delete_topics') == 0 ? Input::post('delete_topics') : $is_admin_group ? '1' : '0';
     $post_links = Input::post('post_links') == 0 ? Input::post('post_links') : '1';
     $set_title = Input::post('set_title') == 0 ? Input::post('set_title') : $is_admin_group ? '1' : '0';
     $search = Input::post('search') == 0 ? Input::post('search') : '1';
     $search_users = Input::post('search_users') == 0 ? Input::post('search_users') : '1';
     $send_email = Input::post('send_email') && Input::post('send_email') == '1' || $is_admin_group ? '1' : '0';
     $post_flood = Input::post('post_flood') && Input::post('post_flood') >= 0 ? Input::post('post_flood') : '0';
     $search_flood = Input::post('search_flood') && Input::post('search_flood') >= 0 ? Input::post('search_flood') : '0';
     $email_flood = Input::post('email_flood') && Input::post('email_flood') >= 0 ? Input::post('email_flood') : '0';
     $report_flood = Input::post('report_flood') >= 0 ? Input::post('report_flood') : '0';
     $insert_update_group = array('g_title' => $title, 'g_user_title' => $user_title, 'g_promote_min_posts' => $promote_min_posts, 'g_promote_next_group' => $promote_next_group, 'g_moderator' => $moderator, 'g_mod_edit_users' => $mod_edit_users, 'g_mod_rename_users' => $mod_rename_users, 'g_mod_change_passwords' => $mod_change_passwords, 'g_mod_ban_users' => $mod_ban_users, 'g_mod_promote_users' => $mod_promote_users, 'g_read_board' => $read_board, 'g_view_users' => $view_users, 'g_post_replies' => $post_replies, 'g_post_topics' => $post_topics, 'g_edit_posts' => $edit_posts, 'g_delete_posts' => $delete_posts, 'g_delete_topics' => $delete_topics, 'g_post_links' => $post_links, 'g_set_title' => $set_title, 'g_search' => $search, 'g_search_users' => $search_users, 'g_send_email' => $send_email, 'g_search_flood' => $search_flood, 'g_email_flood' => $email_flood, 'g_report_flood' => $report_flood);
     $insert_update_group = Container::get('hooks')->fire('model.admin.groups.add_edit_group_data', $insert_update_group);
     if (Input::post('mode') == 'add') {
         // Creating a new group
         $title_exists = DB::for_table('groups')->where('g_title', $title)->find_one();
         if ($title_exists) {
             throw new Error(sprintf(__('Title already exists message'), Utils::escape($title)), 400);
         }
         $add = DB::for_table('groups')->create();
         $add->set($insert_update_group)->save();
         $new_group_id = Container::get('hooks')->fire('model.admin.groups.add_edit_group.new_group_id', (int) $add->id());
         // Set new preferences
         Container::get('prefs')->setGroup($new_group_id, array('post.min_interval' => (int) $post_flood));
         // Now lets copy the forum specific permissions from the group which this group is based on
         $select_forum_perms = array('forum_id', 'read_forum', 'post_replies', 'post_topics');
         $result = DB::for_table('forum_perms')->select_many($select_forum_perms)->where('group_id', Input::post('base_group'));
         $result = Container::get('hooks')->fireDB('model.admin.groups.add_edit_group.select_forum_perms_query', $result);
         $result = $result->find_many();
         foreach ($result as $cur_forum_perm) {
             $insert_perms = array('group_id' => $new_group_id, 'forum_id' => $cur_forum_perm['forum_id'], 'read_forum' => $cur_forum_perm['read_forum'], 'post_replies' => $cur_forum_perm['post_replies'], 'post_topics' => $cur_forum_perm['post_topics']);
             DB::for_table('forum_perms')->create()->set($insert_perms)->save();
         }
     } else {
         // We are editing an existing group
         $title_exists = DB::for_table('groups')->where('g_title', $title)->where_not_equal('g_id', Input::post('group_id'))->find_one();
         if ($title_exists) {
             throw new Error(sprintf(__('Title already exists message'), Utils::escape($title)), 400);
         }
         DB::for_table('groups')->find_one(Input::post('group_id'))->set($insert_update_group)->save();
         // Promote all users who would be promoted to this group on their next post
         if ($promote_next_group) {
             DB::for_table('users')->where('group_id', Input::post('group_id'))->where_gte('num_posts', $promote_min_posts)->update_many('group_id', $promote_next_group);
         }
     }
     $group_id = Input::post('mode') == 'add' ? $new_group_id : Input::post('group_id');
     $group_id = Container::get('hooks')->fire('model.admin.groups.add_edit_group.group_id', $group_id);
     // Regenerate the quick jump cache
     Container::get('cache')->store('quickjump', Cache::get_quickjump());
     if (Input::post('mode') == 'edit') {
         return Router::redirect(Router::pathFor('adminGroups'), __('Group edited redirect'));
     } else {
         return Router::redirect(Router::pathFor('adminGroups'), __('Group added redirect'));
     }
 }
コード例 #4
0
ファイル: View.php プロジェクト: featherbb/featherbb
 protected function getDefaultPageInfo()
 {
     // Check if config file exists to avoid error when installing forum
     if (!Container::get('cache')->isCached('quickjump') && is_file(ForumEnv::get('FORUM_CONFIG_FILE'))) {
         Container::get('cache')->store('quickjump', \FeatherBB\Model\Cache::get_quickjump());
     }
     $title = Container::get('forum_settings') ? ForumSettings::get('o_board_title') : 'FeatherBB';
     $data = array('title' => Utils::escape($title), 'page_number' => null, 'active_page' => 'index', 'focus_element' => null, 'is_indexed' => true, 'admin_console' => false, 'page_head' => null, 'paging_links' => null, 'required_fields' => null, 'footer_style' => null, 'quickjump' => Container::get('cache')->retrieve('quickjump'), 'fid' => null, 'pid' => null, 'tid' => null);
     if (is_object(User::get()) && User::get()->is_admmod) {
         $data['has_reports'] = \FeatherBB\Model\Admin\Reports::has_reports();
     }
     if (ForumEnv::get('FEATHER_SHOW_INFO')) {
         $data['exec_info'] = \FeatherBB\Model\Debug::get_info();
         if (ForumEnv::get('FEATHER_SHOW_QUERIES')) {
             $data['queries_info'] = \FeatherBB\Model\Debug::get_queries();
         }
     }
     return $data;
 }
コード例 #5
0
ファイル: View.php プロジェクト: bohwaz/featherbb
 protected function getDefaultPageInfo()
 {
     // Check if config file exists to avoid error when installing forum
     if (!$this->app->cache->isCached('quickjump') && is_file($this->app->forum_env['FORUM_CONFIG_FILE'])) {
         $this->app->cache->store('quickjump', \FeatherBB\Model\Cache::get_quickjump());
     }
     $data = array('title' => Utils::escape($this->app->forum_settings['o_board_title']), 'page_number' => null, 'active_page' => 'index', 'focus_element' => null, 'is_indexed' => true, 'admin_console' => false, 'page_head' => null, 'paging_links' => null, 'required_fields' => null, 'footer_style' => null, 'quickjump' => $this->app->cache->retrieve('quickjump'), 'fid' => null, 'pid' => null, 'tid' => null);
     if (is_object($this->app->user) && $this->app->user->is_admmod) {
         $data['has_reports'] = \FeatherBB\Model\Header::get_reports();
     }
     if ($this->app->forum_env['FEATHER_SHOW_INFO']) {
         $data['exec_info'] = \FeatherBB\Model\Debug::get_info();
         if ($this->app->forum_env['FEATHER_SHOW_QUERIES']) {
             $data['queries_info'] = \FeatherBB\Model\Debug::get_queries();
         }
     }
     return $data;
 }
コード例 #6
0
ファイル: Forums.php プロジェクト: featherbb/featherbb
 public function edit_positions($req, $res, $args)
 {
     Container::get('hooks')->fire('controller.admin.forums.edit_positions');
     foreach (Input::post('position') as $args['forum_id'] => $position) {
         $position = (int) Utils::trim($position);
         $this->model->update_positions($args['forum_id'], $position);
     }
     // Regenerate the quick jump cache
     Container::get('cache')->store('quickjump', Cache::get_quickjump());
     return Router::redirect(Router::pathFor('adminForums'), __('Forums updated redirect'));
 }
コード例 #7
0
ファイル: Forums.php プロジェクト: bohwaz/featherbb
 public function edit_positions()
 {
     foreach ($this->request->post('position') as $forum_id => $position) {
         $position = (int) Utils::trim($position);
         $this->model->update_positions($forum_id, $position);
     }
     // Regenerate the quick jump cache
     $this->feather->cache->store('quickjump', Cache::get_quickjump());
     Url::redirect($this->feather->urlFor('adminForums'), __('Forums updated redirect'));
 }