diff --git a/controller/admin/groups.php b/controller/admin/groups.php index dc2a7826..f2682dc8 100644 --- a/controller/admin/groups.php +++ b/controller/admin/groups.php @@ -109,6 +109,7 @@ public function delete($id) $this->feather->render('admin/groups/delete_group.php', array( 'id' => $id, 'group_info' => $this->model->get_title_members($id), + 'group_list_delete' => $this->model->get_group_list_delete($id), ) ); diff --git a/model/admin/bans.php b/model/admin/bans.php index dad24d44..b7b8fa11 100644 --- a/model/admin/bans.php +++ b/model/admin/bans.php @@ -20,12 +20,15 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; + $this->hook = $this->feather->hooks; } public function add_ban_info($id = null) { $ban = array(); + $id = $this->hook->fire('add_ban_info_start', $id); + // If the ID of the user to ban was provided through GET (a link from profile.php) if (is_numeric($id)) { $ban['user_id'] = $id; @@ -35,8 +38,10 @@ public function add_ban_info($id = null) $select_add_ban_info = array('group_id', 'username', 'email'); $result = DB::for_table('users')->select_many($select_add_ban_info) - ->where('id', $ban['user_id']) - ->find_one(); + ->where('id', $ban['user_id']); + + $result = $this->hook->fireDB('add_ban_info_query', $result); + $result = $result->find_one(); if ($result) { $group_id = $result['group_id']; @@ -54,8 +59,11 @@ public function add_ban_info($id = null) $select_add_ban_info = array('id', 'group_id', 'username', 'email'); $result = DB::for_table('users')->select_many($select_add_ban_info) ->where('username', $ban['ban_user']) - ->where_gt('id', 1) - ->find_one(); + ->where_gt('id', 1); + + $result = $this->hook->fireDB('add_ban_info_query', $result); + $result = $result->find_one(); + if ($result) { $ban['user_id'] = $result['id']; $group_id = $result['group_id']; @@ -95,6 +103,8 @@ public function add_ban_info($id = null) $ban['mode'] = 'add'; + $ban = $this->hook->fire('add_ban_info', $ban); + return $ban; } @@ -102,12 +112,16 @@ public function edit_ban_info($id) { $ban = array(); + $id = $this->hook->fire('edit_ban_info_start', $id); + $ban['id'] = $id; $select_edit_ban_info = array('username', 'ip', 'email', 'message', 'expire'); $result = DB::for_table('bans')->select_many($select_edit_ban_info) - ->where('id', $ban['id']) - ->find_one(); + ->where('id', $ban['id']); + + $result = $this->hook->fireDB('edit_ban_info_query', $result); + $result = $result->find_one(); if ($result) { $ban['ban_user'] = $result['username']; @@ -124,6 +138,8 @@ public function edit_ban_info($id) $ban['mode'] = 'edit'; + $ban = $this->hook->fire('edit_ban_info', $ban); + return $ban; } @@ -135,6 +151,8 @@ public function insert_ban() $ban_message = feather_trim($this->request->post('ban_message')); $ban_expire = feather_trim($this->request->post('ban_expire')); + $this->hook->fire('insert_ban_start', $ban_user, $ban_ip, $ban_email, $ban_message, $ban_expire); + if ($ban_user == '' && $ban_ip == '' && $ban_email == '') { message(__('Must enter message')); } elseif (strtolower($ban_user) == 'guest') { @@ -238,16 +256,18 @@ public function insert_ban() 'expire' => $ban_expire, ); + $insert_update_ban = $this->hook->fire('insert_ban_data', $insert_update_ban); + if ($this->request->post('mode') == 'add') { $insert_update_ban['ban_creator'] = $this->user->id; - DB::for_table('bans') + $result = DB::for_table('bans') ->create() ->set($insert_update_ban) ->save(); } else { - DB::for_table('bans') + $result = DB::for_table('bans') ->where('id', $this->request->post('ban_id')) ->find_one() ->set($insert_update_ban) @@ -262,9 +282,12 @@ public function insert_ban() public function remove_ban($ban_id) { - DB::for_table('bans')->where('id', $ban_id) - ->find_one() - ->delete(); + $ban_id = $this->hook->fire('remove_ban', $ban_id); + + $result = DB::for_table('bans')->where('id', $ban_id) + ->find_one(); + $result = $this->hook->fireDB('remove_ban_query', $result); + $result = $result->delete(); // Regenerate the bans cache $this->feather->cache->store('bans', \model\cache::get_bans()); @@ -276,6 +299,8 @@ public function find_ban($start_from = false) { $ban_info = array(); + $this->hook->fire('find_ban_start'); + // trim() all elements in $form $ban_info['conditions'] = $ban_info['query_str'] = array(); @@ -343,7 +368,7 @@ public function find_ban($start_from = false) ->order_by($ban_info['order_by'], $ban_info['direction']) ->offset($start_from) ->limit(50) - ->find_many(); + ->find_many(); foreach ($result as $cur_ban) { $ban_info['data'][] = $cur_ban; @@ -353,6 +378,8 @@ public function find_ban($start_from = false) $ban_info['num_bans'] = $result->count('id'); } + $this->hook->fire('find_ban', $ban_info); + return $ban_info; } } diff --git a/model/admin/categories.php b/model/admin/categories.php index 7e8010c1..d2ac4352 100644 --- a/model/admin/categories.php +++ b/model/admin/categories.php @@ -20,10 +20,13 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; + $this->hook = $this->feather->hooks; } public function add_category($cat_name) { + $cat_name = $this->hook->fire('add_category', $cat_name); + $set_add_category = array('cat_name' => $cat_name); return DB::for_table('categories') @@ -34,6 +37,8 @@ public function add_category($cat_name) public function update_category(array $category) { + $category = $this->hook->fire('update_category', $category); + $set_update_category = array('cat_name' => $category['name'], 'disp_position' => $category['order']); @@ -45,10 +50,13 @@ public function update_category(array $category) public function delete_category($cat_to_delete) { + $cat_to_delete = $this->hook->fire('delete_category_start', $cat_to_delete); + $forums_in_cat = DB::for_table('forums') ->select('id') - ->where('cat_id', $cat_to_delete) - ->find_many(); + ->where('cat_id', $cat_to_delete); + $forums_in_cat = $this->hook->fireDB('delete_forums_in_cat_query', $forums_in_cat); + $forums_in_cat = $forums_in_cat->find_many(); foreach ($forums_in_cat as $forum) { // Prune all posts and topics @@ -66,17 +74,18 @@ public function delete_category($cat_to_delete) ->table_alias('t1') ->left_outer_join('topics', array('t1.moved_to', '=', 't2.id'), 't2') ->where_null('t2.id') - ->where_not_null('t1.moved_to') - ->find_many(); + ->where_not_null('t1.moved_to'); + $orphans = $this->hook->fireDB('delete_orphan_forums_query', $orphans); + $orphans = $orphans->find_many(); if (count($orphans) > 0) { $orphans->delete_many(); } // Delete category - DB::for_table('categories') - ->find_one($cat_to_delete) - ->delete(); + $result = DB::for_table('categories'); + $result = $this->hook->fireDB('find_forums_in_cat', $result); + $result = $result->find_one($cat_to_delete)->delete(); return true; } @@ -88,8 +97,9 @@ public function get_cat_list() $cat_list = DB::for_table('categories') ->select($select_get_cat_list) - ->order_by_asc('disp_position') - ->find_array(); + ->order_by_asc('disp_position'); + $cat_list = $this->hook->fireDB('get_cat_list', $cat_list); + $cat_list = $cat_list->find_array(); return $cat_list; } diff --git a/model/admin/censoring.php b/model/admin/censoring.php index 7434840b..73e14d85 100644 --- a/model/admin/censoring.php +++ b/model/admin/censoring.php @@ -20,6 +20,7 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; + $this->hook = $this->feather->hooks; } public function add_word() @@ -34,7 +35,9 @@ public function add_word() $set_search_word = array('search_for' => $search_for, 'replace_with' => $replace_with); - DB::for_table('censoring') + $set_search_word = $this->hook->fire('add_censoring_word_data', $set_search_word); + + $result = DB::for_table('censoring') ->create() ->set($set_search_word) ->save(); @@ -60,7 +63,9 @@ public function update_word() $set_search_word = array('search_for' => $search_for, 'replace_with' => $replace_with); - DB::for_table('censoring') + $set_search_word = $this->hook->fire('update_censoring_word_start', $set_search_word); + + $result = DB::for_table('censoring') ->find_one($id) ->set($set_search_word) ->save(); @@ -75,10 +80,11 @@ public function update_word() public function remove_word() { $id = intval(key($this->request->post('remove'))); + $id = $this->hook->fire('remove_censoring_word_start', $id); - DB::for_table('censoring') - ->find_one($id) - ->delete(); + $result = DB::for_table('censoring')->find_one($id); + $result = $this->hook->fireDB('remove_censoring_word', $result); + $result = $result->delete(); // Regenerate the censoring cache $this->feather->cache->store('search_for', \model\cache::get_censoring('search_for')); @@ -92,8 +98,9 @@ public function get_words() $word_data = array(); $word_data = DB::for_table('censoring') - ->order_by_asc('id') - ->find_array(); + ->order_by_asc('id'); + $word_data = $this->hook->fireDB('update_censoring_word_query', $word_data); + $word_data = $word_data->find_array(); return $word_data; } diff --git a/model/admin/forums.php b/model/admin/forums.php index eb332bbe..67bfeb69 100644 --- a/model/admin/forums.php +++ b/model/admin/forums.php @@ -20,6 +20,7 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; + $this->hook = $this->feather->hooks; } // @@ -31,6 +32,8 @@ public function add_forum($cat_id, $forum_name) $set_add_forum = array('forum_name' => $forum_name, 'cat_id' => $cat_id); + $set_add_forum = $this->hook->fire('add_forum', $set_add_forum); + $forum = DB::for_table('forums') ->create() ->set($set_add_forum); @@ -41,10 +44,13 @@ public function add_forum($cat_id, $forum_name) public function update_forum($forum_id, array $forum_data) { - return DB::for_table('forums') + $update_forum = DB::for_table('forums') ->find_one($forum_id) - ->set($forum_data) - ->save(); + ->set($forum_data); + $update_forum = $this->hook->fireDB('update_forum_query', $update_forum); + $update_forum = $update_forum->save(); + + return $update_forum; } public function delete_forum($forum_id) @@ -52,31 +58,34 @@ public function delete_forum($forum_id) // Load the maintenance.php model file for prune public function require FEATHER_ROOT . 'model/admin/maintenance.php'; + $forum_id = $this->hook->fire('delete_forum_start', $forum_id); + // Prune all posts and topics $this->maintenance = new \model\admin\maintenance(); $this->maintenance->prune($forum_id, 1, -1); // Delete the forum - DB::for_table('forums') - ->find_one($forum_id) - ->delete(); + $delete_forum = DB::for_table('forums')->find_one($forum_id); + $delete_forum = $this->hook->fireDB('delete_forum_query', $delete_forum); + $delete_forum->delete(); // Delete forum specific group permissions and subscriptions - DB::for_table('forum_perms') - ->where('forum_id', $forum_id) - ->delete_many(); + $delete_forum_perms = DB::for_table('forum_perms')->where('forum_id', $forum_id); + $delete_forum_perms = $this->hook->fireDB('delete_forum_perms_query', $delete_forum_perms); + $delete_forum_perms->delete_many(); - DB::for_table('forum_subscriptions') - ->where('forum_id', $forum_id) - ->delete_many(); + $delete_forum_subs = DB::for_table('forum_subscriptions')->where('forum_id', $forum_id); + $delete_forum_subs = $this->hook->fireDB('delete_forum_subs_query', $delete_forum_subs); + $delete_forum_subs->delete_many(); // Delete orphaned redirect topics $orphans = DB::for_table('topics') ->table_alias('t1') ->left_outer_join('topics', array('t1.moved_to', '=', 't2.id'), 't2') ->where_null('t2.id') - ->where_not_null('t1.moved_to') - ->find_many(); + ->where_not_null('t1.moved_to'); + $orphans = $this->hook->fireDB('delete_orphan_redirect_topics_query', $orphans); + $orphans = $orphans->find_many(); if (count($orphans) > 0) { $orphans->delete_many(); @@ -88,14 +97,17 @@ public function delete_forum($forum_id) public function get_forum_info($forum_id) { $result = DB::for_table('forums') - ->where('id', $forum_id) - ->find_array(); + ->where('id', $forum_id); + $result = $this->hook->fireDB('get_forum_infos', $result); + $result = $result->find_array(); + return $result[0]; } public function get_forums() { $forum_data = array(); + $forum_data = $this->hook->fire('get_forums_start', $forum_data); $select_get_forums = array('cid' => 'c.id', 'c.cat_name', 'cat_position' => 'c.disp_position', 'fid' => 'f.id', 'f.forum_name', 'forum_position' => 'f.disp_position'); @@ -104,8 +116,9 @@ public function get_forums() ->select_many($select_get_forums) ->inner_join('forums', array('c.id', '=', 'f.cat_id'), 'f') ->order_by_asc('f.disp_position') - ->order_by_asc('c.disp_position') - ->find_array(); + ->order_by_asc('c.disp_position'); + $result = $this->hook->fireDB('get_forums_query', $result); + $result = $result->find_array(); foreach ($result as $forum) { if (!isset($forum_data[$forum['cid']])) { @@ -117,11 +130,15 @@ public function get_forums() 'forum_name' => $forum['forum_name'], 'position' => $forum['forum_position']); } + + $forum_data = $this->hook->fire('get_forums', $forum_data); return $forum_data; } public function update_positions($forum_id, $position) { + $this->hook->fire('update_positions_start', $forum_id, $position); + return DB::for_table('forums') ->find_one($forum_id) ->set('disp_position', $position) @@ -135,6 +152,7 @@ public function update_positions($forum_id, $position) public function get_permissions($forum_id) { $perm_data = array(); + $forum_id = $this->hook->fire('get_permissions_start', $forum_id); $select_permissions = array('g.g_id', 'g.g_title', 'g.g_read_board', 'g.g_post_replies', 'g.g_post_topics', 'fp.read_forum', 'fp.post_replies', 'fp.post_topics'); @@ -143,8 +161,9 @@ public function get_permissions($forum_id) ->select_many($select_permissions) ->left_outer_join('forum_perms', 'g.g_id=fp.group_id AND fp.forum_id='.$forum_id, 'fp') // Workaround ->where_not_equal('g.g_id', FEATHER_ADMIN) - ->order_by_asc('g.g_id') - ->find_many(); + ->order_by_asc('g.g_id'); + $permissions = $this->hook->fireDB('get_permissions_query', $permissions); + $permissions = $permissions->find_many(); foreach($permissions as $cur_perm) { $cur_perm['read_forum'] = ($cur_perm['read_forum'] != '0') ? true : false; @@ -159,6 +178,7 @@ public function get_permissions($forum_id) $perm_data[] = $cur_perm; } + $perm_data = $this->hook->fire('get_permissions', $perm_data); return $perm_data; } @@ -173,11 +193,17 @@ public function get_default_group_permissions($fetch_admin = true) $result->where_not_equal('g_id', FEATHER_ADMIN); } - return $result->order_by_asc('g_id')->find_array(); + $result = $result->order_by_asc('g_id'); + $result = $this->hook->fireDB('get_default_group_permissions_query', $result); + $result = $result->find_array(); + + return $result; } public function update_permissions(array $permissions_data) { + $permissions_data = $this->hook->fire('update_permissions_start', $permissions_data); + $permissions = DB::for_table('forum_perms') ->where('forum_id', $permissions_data['forum_id']) ->where('group_id', $permissions_data['group_id']) @@ -201,6 +227,8 @@ public function delete_permissions($forum_id, $group_id = null) $result->where('group_id', $group_id); } + $result = $this->hook->fireDB('delete_permissions_query', $result); + return $result->delete_many(); } } diff --git a/model/admin/groups.php b/model/admin/groups.php index 40b663a3..04218d1c 100644 --- a/model/admin/groups.php +++ b/model/admin/groups.php @@ -20,16 +20,20 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; + $this->hook = $this->feather->hooks; } public function fetch_groups() { $result = DB::for_table('groups')->order_by('g_id')->find_many(); + $this->hook->fireDB('fetch_groups_query', $result); $groups = array(); foreach ($result as $cur_group) { $groups[$cur_group['g_id']] = $cur_group; } + $groups = $this->hook->fire('fetch_groups', $groups); + return $groups; } @@ -39,6 +43,7 @@ public function info_add_group($groups, $id) if ($this->request->post('add_group')) { $group['base_group'] = intval($this->request->post('base_group')); + $group['base_group'] = $this->hook->fire('add_user_group', $group['base_group']); $group['info'] = $groups[$group['base_group']]; $group['mode'] = 'add'; @@ -48,11 +53,14 @@ public function info_add_group($groups, $id) message(__('Bad request'), '404'); } + $groups[$id] = $this->hook->fire('update_user_group', $groups[$id]); + $group['info'] = $groups[$id]; $group['mode'] = 'edit'; } + $group = $this->hook->fire('info_add_group', $group); return $group; } @@ -70,26 +78,35 @@ public function get_group_list($groups, $group) } } + $output = $this->hook->fire('get_group_list', $output); return $output; } public function get_group_list_delete($group_id) { + $group_id = $this->hook->fire('get_group_list_delete_start', $group_id); + $select_get_group_list_delete = array('g_id', 'g_title'); $result = DB::for_table('groups')->select_many($select_get_group_list_delete) ->where_not_equal('g_id', FEATHER_GUEST) ->where_not_equal('g_id', $group_id) - ->order_by('g_title') - ->find_many(); + ->order_by('g_title'); + $result = $this->hook->fireDB('get_group_list_delete', $result); + $result = $result->find_many(); + + $output = ''; foreach ($result as $cur_group) { if ($cur_group['g_id'] == FEATHER_MEMBER) { // Pre-select the pre-defined Members group - echo "\t\t\t\t\t\t\t\t\t\t".''."\n"; + $output .= "\t\t\t\t\t\t\t\t\t\t".''."\n"; } else { - echo "\t\t\t\t\t\t\t\t\t\t".''."\n"; + $output .= "\t\t\t\t\t\t\t\t\t\t".''."\n"; } } + + $output = $this->hook->fire('get_group_list.output', $output); + return $output; } public function add_edit_group($groups) @@ -100,11 +117,21 @@ public function add_edit_group($groups) $group_id = 0; } + $group_id = $this->hook->fire('add_edit_group_start', $group_id); + // Is this the admin group? (special rules apply) $is_admin_group = ($this->request->post('group_id') && $this->request->post('group_id') == FEATHER_ADMIN) ? true : false; + // Set group title $title = feather_trim($this->request->post('req_title')); + if ($title == '') { + message(__('Must enter title message')); + } + $title = $this->hook->fire('add_edit_group_set_title', $title); + // Set user title $user_title = feather_trim($this->request->post('user_title')); + $user_title = ($user_title != '') ? $user_title : 'NULL'; + $user_title = $this->hook->fire('add_edit_group_set_user_title', $user_title); $promote_min_posts = $this->request->post('promote_min_posts') ? intval($this->request->post('promote_min_posts')) : '0'; if ($this->request->post('promote_next_group') && @@ -139,12 +166,6 @@ public function add_edit_group($groups) $email_flood = ($this->request->post('email_flood') && $this->request->post('email_flood') >= 0) ? $this->request->post('email_flood') : '0'; $report_flood = ($this->request->post('report_flood') >= 0) ? $this->request->post('report_flood') : '0'; - if ($title == '') { - message(__('Must enter title message')); - } - - $user_title = ($user_title != '') ? $user_title : 'NULL'; - $insert_update_group = array( 'g_title' => $title, 'g_user_title' => $user_title, @@ -174,7 +195,10 @@ public function add_edit_group($groups) 'g_report_flood' => $report_flood, ); + $insert_update_group = $this->hook->fire('add_edit_group_data', $insert_update_group); + if ($this->request->post('mode') == 'add') { + // Creating a new group $title_exists = DB::for_table('groups')->where('g_title', $title)->find_one(); if ($title_exists) { message(sprintf(__('Title already exists message'), feather_escape($title))); @@ -185,12 +209,14 @@ public function add_edit_group($groups) ->set($insert_update_group) ->save(); $new_group_id = DB::get_db()->lastInsertId($this->feather->forum_settings['db_prefix'].'groups'); + $new_group_id = $this->hook->fire('add_edit_group.new_group_id', $new_group_id); // 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', $this->request->post('base_group')) - ->find_many(); + ->where('group_id', $this->request->post('base_group')); + $result = $this->hook->fireDB('add_edit_group.select_forum_perms_query', $result); + $result = $result->find_many(); foreach ($result as $cur_forum_perm) { $insert_perms = array( @@ -207,6 +233,7 @@ public function add_edit_group($groups) ->save(); } } else { + // We are editing an existing group $title_exists = DB::for_table('groups')->where('g_title', $title)->where_not_equal('g_id', $this->request->post('group_id'))->find_one(); if ($title_exists) { message(sprintf(__('Title already exists message'), feather_escape($title))); @@ -224,6 +251,9 @@ public function add_edit_group($groups) } } + $group_id = $this->request->post('mode') == 'add' ? $new_group_id : $this->request->post('group_id'); + $group_id = $this->hook->fire('add_edit_group.group_id', $group_id); + // Regenerate the quick jump cache $this->feather->cache->store('quickjump', \model\cache::get_quickjump()); @@ -237,6 +267,7 @@ public function add_edit_group($groups) public function set_default_group($groups) { $group_id = intval($this->request->post('default_group')); + $group_id = $this->hook->fire('set_default_group.group_id', $group_id); // Make sure it's not the admin or guest groups if ($group_id == FEATHER_ADMIN || $group_id == FEATHER_GUEST) { @@ -263,22 +294,28 @@ public function set_default_group($groups) public function check_members($group_id) { + $group_id = $this->hook->fire('check_members_start', $group_id); + $is_member = DB::for_table('groups')->table_alias('g') ->select('g.g_title') ->select_expr('COUNT(u.id)', 'members') ->inner_join('users', array('g.g_id', '=', 'u.group_id'), 'u') ->where('g.g_id', $group_id) ->group_by('g.g_id') - ->group_by('g_title') - ->find_one(); + ->group_by('g_title'); + $is_member = $this->hook->fireDB('check_members', $is_member); + $is_member = $is_member->find_one(); return (bool) $is_member; } public function delete_group($group_id) { + $group_id = $this->hook->fire('delete_group.group_id', $group_id); + if ($this->request->post('del_group')) { $move_to_group = intval($this->request->post('move_to_group')); + $move_to_group = $this->hook->fire('delete_group.move_to_group', $move_to_group); DB::for_table('users')->where('group_id', $group_id) ->update_many('group_id', $move_to_group); } @@ -300,26 +337,33 @@ public function delete_group($group_id) public function get_group_title($group_id) { - $group_title = DB::for_table('groups')->where('g_id', $group_id) - ->find_one_col('g_title'); + $group_id = $this->hook->fireDB('get_group_title.group_id', $group_id); + + $group_title = DB::for_table('groups')->where('g_id', $group_id); + $group_title = $this->hook->fireDB('get_group_title.query', $group_title); + $group_title = $group_title->find_one_col('g_title'); return $group_title; } public function get_title_members($group_id) { + $group_id = $this->hook->fire('get_title_members.group_id', $group_id); + $group = DB::for_table('groups')->table_alias('g') ->select('g.g_title') ->select_expr('COUNT(u.id)', 'members') ->inner_join('users', array('g.g_id', '=', 'u.group_id'), 'u') ->where('g.g_id', $group_id) ->group_by('g.g_id') - ->group_by('g_title') - ->find_one(); + ->group_by('g_title'); + $group = $this->hook->fireDB('get_title_members.query', $group); + $group = $group->find_one(); $group_info['title'] = $group['g_title']; $group_info['members'] = $group['members']; + $group_info = $this->hook->fire('get_title_members.group_info', $group_info); return $group_info; } } diff --git a/model/admin/maintenance.php b/model/admin/maintenance.php index d05fb7ec..92f92461 100644 --- a/model/admin/maintenance.php +++ b/model/admin/maintenance.php @@ -20,11 +20,13 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; + $this->hook = $this->feather->hooks; } - + public function rebuild() { $per_page = $this->request->get('i_per_page') ? intval($this->request->get('i_per_page')) : 0; + $per_page = $this->hook->fire('maintenance.rebuild.per_page', $per_page); // Check per page is > 0 if ($per_page < 1) { @@ -58,7 +60,9 @@ public function get_query_str() $query_str = ''; $per_page = $this->request->get('i_per_page') ? intval($this->request->get('i_per_page')) : 0; + $per_page = $this->hook->fire('maintenance.get_query_str.per_page', $per_page); $start_at = $this->request->get('i_start_at') ? intval($this->request->get('i_start_at')) : 0; + $start_at = $this->hook->fire('maintenance.get_query_str.start_at', $start_at); require FEATHER_ROOT.'include/search_idx.php'; @@ -70,8 +74,9 @@ public function get_query_str() ->inner_join('topics', array('t.id', '=', 'p.topic_id'), 't') ->where_gte('p.id', $start_at) ->order_by_asc('p.id') - ->limit($per_page) - ->find_many(); + ->limit($per_page); + $result = $this->hook->fireDB('maintenance.get_query_str.query', $result); + $result = $result->find_many(); $end_at = 0; foreach ($result as $cur_item) { @@ -100,6 +105,7 @@ public function get_query_str() $pdo = DB::get_db(); $pdo = null; + $query_str = $this->hook->fire('maintenance.get_query_str', $query_str); return $query_str; } @@ -126,6 +132,7 @@ public function prune($forum_id, $prune_sticky, $prune_date) foreach ($topics_id as $row) { $topic_ids[] = $row['id']; } + $topic_ids = $this->hook->fire('maintenance.prune.topic_ids', $topic_ids); if (!empty($topic_ids)) { // Fetch posts to prune @@ -137,6 +144,7 @@ public function prune($forum_id, $prune_sticky, $prune_date) foreach ($posts_id as $row) { $post_ids[] = $row['id']; } + $post_ids = $this->hook->fire('maintenance.prune.post_ids', $post_ids); if ($post_ids != '') { // Delete topics @@ -162,12 +170,15 @@ public function prune($forum_id, $prune_sticky, $prune_date) public function prune_comply($prune_from, $prune_sticky) { $prune_days = intval($this->request->post('prune_days')); + $prune_days = $this->hook->fire('maintenance.prune_comply.prune_days', $prune_days); $prune_date = ($prune_days) ? time() - ($prune_days * 86400) : -1; @set_time_limit(0); if ($prune_from == 'all') { - $result = DB::for_table('forums')->select('id')->find_array(); + $result = DB::for_table('forums')->select('id'); + $result = $this->hook->fireDB('maintenance.prune_comply.query', $result); + $result = $result->find_array(); if (!empty($result)) { foreach ($result as $row) { @@ -186,14 +197,16 @@ public function prune_comply($prune_from, $prune_sticky) ->select('t1.id') ->left_outer_join('topics', array('t1.moved_to', '=', 't2.id'), 't2') ->where_null('t2.id') - ->where_not_null('t1.moved_to') - ->find_array(); + ->where_not_null('t1.moved_to'); + $result = $this->hook->fireDB('maintenance.prune_comply.orphans_query', $result); + $result = $result->find_array(); $orphans = array(); if (!empty($result)) { foreach ($result as $row) { $orphans[] = $row['id']; } + $orphans = $this->hook->fire('maintenance.prune_comply.orphans', $orphans); DB::for_table('topics') ->where_in('id', $orphans) @@ -214,6 +227,8 @@ public function get_info_prune($prune_sticky, $prune_from) $prune['date'] = time() - ($prune['days'] * 86400); + $prune = $this->hook->fire('maintenance.get_info_prune.prune_dates', $prune); + // Concatenate together the query for counting number of topics to prune $query = DB::for_table('topics')->where_lt('last_post', $prune['date']) ->where_null('moved_to'); @@ -226,8 +241,10 @@ public function get_info_prune($prune_sticky, $prune_from) $query = $query->where('forum_id', intval($prune_from)); // Fetch the forum name (just for cosmetic reasons) - $forum = DB::for_table('forums')->where('id', $prune_from) - ->find_one_col('forum_name'); + $forum = DB::for_table('forums')->where('id', $prune_from); + $forum = $this->hook->fireDB('maintenance.get_info_prune.forum_query', $forum); + $forum = $forum->find_one_col('forum_name'); + $prune['forum'] = '"'.feather_escape($forum).'"'; } else { $prune['forum'] = __('All forums'); @@ -239,6 +256,7 @@ public function get_info_prune($prune_sticky, $prune_from) message(sprintf(__('No old topics message'), $prune['days'])); } + $prune = $this->hook->fire('maintenance.get_info_prune.prune', $prune); return $prune; } @@ -254,8 +272,9 @@ public function get_categories() ->select_many($select_get_categories) ->inner_join('forums', array('c.id', '=', 'f.cat_id'), 'f') ->where_null('f.redirect_url') - ->order_by_many($order_by_get_categories) - ->find_many(); + ->order_by_many($order_by_get_categories); + $result = $this->hook->fireDB('maintenance.get_categories.query', $result); + $result = $result->find_many(); $cur_category = 0; foreach ($result as $forum) { @@ -272,10 +291,11 @@ public function get_categories() $output .= "\t\t\t\t\t\t\t\t\t\t\t\t".''."\n"; } - + + $output = $this->hook->fire('maintenance.get_categories.output', $output); return $output; } - + public function get_first_id() { $first_id = ''; @@ -284,7 +304,8 @@ public function get_first_id() if ($first_id_sql) { $first_id = $first_id_sql; } - + + $first_id = $this->hook->fire('maintenance.get_first_id', $first_id); return $first_id; } -} \ No newline at end of file +} diff --git a/model/admin/options.php b/model/admin/options.php index ddfafbe6..d1734ac0 100644 --- a/model/admin/options.php +++ b/model/admin/options.php @@ -20,8 +20,9 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; + $this->hook = $this->feather->hooks; } - + public function update_options() { $form = array( @@ -86,6 +87,8 @@ public function update_options() 'maintenance_message' => feather_trim($this->request->post('form_maintenance_message')), ); + $form = $this->hook->fire('options.update_options.form', $form); + if ($form['board_title'] == '') { message(__('Must enter title message')); } @@ -239,6 +242,7 @@ public function update_options() public function clear_feed_cache() { $d = dir(FORUM_CACHE_DIR); + $d = $this->hook->fire('options.clear_feed_cache.directory', $d); while (($entry = $d->read()) !== false) { if (substr($entry, 0, 10) == 'cache_feed' && substr($entry, -4) == '.php') { @unlink(FORUM_CACHE_DIR.$entry); @@ -251,7 +255,8 @@ public function clear_feed_cache() public function get_styles() { $styles = forum_list_styles(); - + $styles = $this->hook->fire('options.get_styles.styles', $styles); + $output = ''; foreach ($styles as $temp) { @@ -261,20 +266,23 @@ public function get_styles() $output .= "\t\t\t\t\t\t\t\t\t\t\t".''."\n"; } } - + + $output = $this->hook->fire('options.get_styles.output', $output); return $output; } public function get_times() { $times = array(5, 15, 30, 60); - + $times = $this->hook->fire('options.get_times.times', $times); + $output = ''; foreach ($times as $time) { $output .= "\t\t\t\t\t\t\t\t\t\t\t".''."\n"; } - + + $output = $this->hook->fire('options.get_times.output', $output); return $output; } } diff --git a/model/admin/parser.php b/model/admin/parser.php index 260b6f09..71c8b6d9 100644 --- a/model/admin/parser.php +++ b/model/admin/parser.php @@ -21,19 +21,22 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; + $this->hook = $this->feather->hooks; } - + // Helper public function returns array of smiley image files // stored in the img/smilies directory. public function get_smiley_files() { $imgfiles = array(); $filelist = scandir(FEATHER_ROOT.'img/smilies'); + $filelist = $this->hook->fire('parser.get_smiley_files.filelist', $filelist); foreach ($filelist as $file) { if (preg_match('/\.(?:png|gif|jpe?g)$/', $file)) { $imgfiles[] = $file; } } + $imgfiles = $this->hook->fire('parser.get_smiley_files.imgfiles', $imgfiles); return $imgfiles; } -} \ No newline at end of file +} diff --git a/model/admin/permissions.php b/model/admin/permissions.php index 2666f587..19d409fd 100644 --- a/model/admin/permissions.php +++ b/model/admin/permissions.php @@ -20,11 +20,13 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; + $this->hook = $this->feather->hooks; } - + public function update_permissions() { $form = array_map('intval', $this->request->post('form')); + $form = $this->hook->fire('permissions.update_permissions.form', $form); foreach ($form as $key => $input) { // Make sure the input is never a negative value @@ -48,4 +50,4 @@ public function update_permissions() redirect(get_link('admin/permissions/'), __('Perms updated redirect')); } -} \ No newline at end of file +} diff --git a/model/admin/reports.php b/model/admin/reports.php index a6a653a2..d0500dc1 100644 --- a/model/admin/reports.php +++ b/model/admin/reports.php @@ -20,19 +20,22 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; + $this->hook = $this->feather->hooks; } public function zap_report() { $zap_id = intval(key($this->request->post('zap_id'))); + $zap_id = $this->hook->fire('reports.zap_report.zap_id', $zap_id); - $result = DB::for_table('reports') - ->where('id', $zap_id) - ->find_one_col('zapped'); + $result = DB::for_table('reports')->where('id', $zap_id); + $result = $this->hook->fireDB('reports.zap_report.query', $result); + $result = $result->find_one_col('zapped'); - $set_zap_report = array('zapped' => time(), - 'zapped_by' => $this->user->id); + $set_zap_report = array('zapped' => time(), 'zapped_by' => $this->user->id); + $set_zap_report = $this->hook->fire('reports.zap_report.set_zap_report', $set_zap_report); + // Update report to indicate it has been zapped if (!$result) { DB::for_table('reports') ->where('id', $zap_id) @@ -41,6 +44,7 @@ public function zap_report() ->save(); } + // Remove zapped reports to keep only last 10 $threshold = DB::for_table('reports') ->where_not_null('zapped') ->order_by_desc('zapped') @@ -69,16 +73,16 @@ public function get_reports() ->left_outer_join('forums', array('r.forum_id', '=', 'f.id'), 'f') ->left_outer_join('users', array('r.reported_by', '=', 'u.id'), 'u') ->where_null('r.zapped') - ->order_by_desc('created') - ->find_array(); + ->order_by_desc('created'); + $reports = $this->hook->fireDB('reports.get_reports.query', $reports); + $reports = $reports->find_array(); + $reports = $this->hook->fire('reports.get_reports', $reports); return $reports; } public function get_zapped_reports() { - global $lang_admin_reports; - $zapped_reports = array(); $select_zapped_reports = array('r.id', 'r.topic_id', 'r.forum_id', 'r.reported_by', 'r.message', 'r.zapped', 'zapped_by_id' => 'r.zapped_by', 'pid' => 'p.id', 't.subject', 'f.forum_name', 'reporter' => 'u.username', 'zapped_by' => 'u2.username'); $zapped_reports = DB::for_table('reports') @@ -91,9 +95,11 @@ public function get_zapped_reports() ->left_outer_join('users', array('r.zapped_by', '=', 'u2.id'), 'u2') ->where_not_null('r.zapped') ->order_by_desc('zapped') - ->limit(10) - ->find_array(); + ->limit(10); + $zapped_reports = $this->hook->fireDB('reports.get_zapped_reports.query', $zapped_reports); + $zapped_reports = $zapped_reports->find_array(); + $zapped_reports = $this->hook->fire('reports.get_zapped_reports', $zapped_reports); return $zapped_reports; } -} \ No newline at end of file +} diff --git a/model/admin/statistics.php b/model/admin/statistics.php index 225392e0..64417069 100644 --- a/model/admin/statistics.php +++ b/model/admin/statistics.php @@ -20,8 +20,9 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; + $this->hook = $this->feather->hooks; } - + public function get_server_load() { if (@file_exists('/proc/loadavg') && is_readable('/proc/loadavg')) { @@ -38,6 +39,8 @@ public function get_server_load() } $load_averages = @explode(' ', $load_averages); + $load_averages = $this->hook->fire('model.statistics.get_server_load.load_averages', $load_averages); + $server_load = isset($load_averages[2]) ? $load_averages[0].' '.$load_averages[1].' '.$load_averages[2] : __('Not available'); } elseif (!in_array(PHP_OS, array('WINNT', 'WIN32')) && preg_match('%averages?: ([0-9\.]+),?\s+([0-9\.]+),?\s+([0-9\.]+)%i', @exec('uptime'), $load_averages)) { $server_load = $load_averages[1].' '.$load_averages[2].' '.$load_averages[3]; @@ -45,6 +48,7 @@ public function get_server_load() $server_load = __('Not available'); } + $server_load = $this->hook->fire('model.statistics.get_server_load.server_load', $server_load); return $server_load; } @@ -53,6 +57,7 @@ public function get_num_online() $num_online = DB::for_table('online')->where('idle', 0) ->count('user_id'); + $num_online = $this->hook->fire('model.statistics.get_num_online.num_online', $num_online); return $num_online; } @@ -63,6 +68,7 @@ public function get_total_size() if ($this->feather->forum_settings['db_type'] == 'mysql' || $this->feather->forum_settings['db_type'] == 'mysqli' || $this->feather->forum_settings['db_type'] == 'mysql_innodb' || $this->feather->forum_settings['db_type'] == 'mysqli_innodb') { // Calculate total db size/row count $result = DB::for_table('users')->raw_query('SHOW TABLE STATUS LIKE \''.$this->feather->forum_settings['db_prefix'].'%\'')->find_many(); + $result = $this->hook->fire('model.statistics.get_total_size.raw_data', $result); $total['size'] = $total['records'] = 0; foreach ($result as $status) { @@ -73,6 +79,7 @@ public function get_total_size() $total['size'] = file_size($total['size']); } + $total = $this->hook->fire('model.statistics.get_total_size.total', $total); return $total; } @@ -94,6 +101,7 @@ public function get_php_accelerator() $php_accelerator = __('NA'); } + $php_accelerator = $this->hook->fire('model.statistics.get_php_accelerator', $php_accelerator); return $php_accelerator; } -} \ No newline at end of file +} diff --git a/model/admin/users.php b/model/admin/users.php index 738f2e4f..2d5da7f8 100644 --- a/model/admin/users.php +++ b/model/admin/users.php @@ -20,13 +20,14 @@ public function __construct() $this->config = $this->feather->config; $this->user = $this->feather->user; $this->request = $this->feather->request; + $this->hook = $this->feather->hooks; } public function get_num_ip($ip_stats) { - $num_ips = DB::for_table('posts')->where('poster_id', $ip_stats) - ->group_by('poster_ip') - ->count('poster_ip'); + $num_ips = DB::for_table('posts')->where('poster_id', $ip_stats)->group_by('poster_ip'); + $num_ips = $this->hook->fireDB('model.users.get_num_ip', $num_ips); + $num_ips = $num_ips->count('poster_ip'); return $num_ips; } @@ -43,38 +44,46 @@ public function get_ip_stats($ip_stats, $start_from) ->group_by('poster_ip') ->order_by_desc('last_used') ->offset($start_from) - ->limit(50) - ->find_many(); + ->limit(50); + $result = $this->hook->fireDB('model.users.get_ip_stats.query', $result); + $result = $result->find_many(); + if ($result) { foreach ($result as $cur_ip) { $ip_data[] = $cur_ip; } } + $ip_data = $this->hook->fire('model.users.get_ip_stats.ip_data', $ip_data); return $ip_data; } public function get_num_users_ip($ip) { - $num_users = DB::for_table('posts')->where('poster_ip', $ip) - ->distinct() - ->count('poster_id'); + $num_users = DB::for_table('posts')->where('poster_ip', $ip)->distinct(); + $num_users = $this->hook->fireDB('model.users.get_num_users_ip.query', $num_users); + $num_users = $num_users->count('poster_id'); return $num_users; } public function get_num_users_search($conditions) { + $conditions = $this->hook->fire('model.users.get_num_users_search.conditions', $conditions); + $num_users = DB::for_table('users')->table_alias('u') ->left_outer_join('groups', array('g.g_id', '=', 'u.group_id'), 'g') - ->where_raw('u.id>1'.(!empty($conditions) ? ' AND '.implode(' AND ', $conditions) : '')) - ->count('id'); + ->where_raw('u.id>1'.(!empty($conditions) ? ' AND '.implode(' AND ', $conditions) : '')); + $num_users = $this->hook->fireDB('model.users.get_num_users_search.query', $num_users); + $num_users = $num_users->count('id'); return $num_users; } public function get_info_poster($ip, $start_from) { + $ip = $this->hook->fire('model.users.get_info_poster.ip', $ip); + $info = array(); $select_info_get_info_poster = array('poster_id', 'poster'); @@ -84,8 +93,9 @@ public function get_info_poster($ip, $start_from) ->where('poster_ip', $ip) ->order_by_asc('poster') ->offset($start_from) - ->limit(50) - ->find_many(); + ->limit(50); + $result = $this->hook->fireDB('model.users.get_info_poster.select_info_get_info_poster', $result); + $result = $result->find_many(); $info['num_posts'] = count($result); @@ -102,14 +112,16 @@ public function get_info_poster($ip, $start_from) ->select_many($select_get_info_poster) ->inner_join('groups', array('g.g_id', '=', 'u.group_id'), 'g') ->where_gt('u.id', 1) - ->where_in('u.id', $poster_ids) - ->find_many(); + ->where_in('u.id', $poster_ids); + $result = $this->hook->fireDB('model.users.get_info_poster.select_get_info_poster', $result); + $result = $result->find_many(); foreach ($result as $cur_user) { $info['user_data'][$cur_user['id']] = $cur_user; } } + $info = $this->hook->fire('model.users.get_info_poster.info', $info); return $info; } @@ -127,6 +139,8 @@ public function move_users() $move['user_ids'] = array(); } + $move['user_ids'] = $this->hook->fire('model.users.move_users.user_ids', $move['user_ids']); + if (empty($move['user_ids'])) { message(__('No users selected')); } @@ -145,8 +159,9 @@ public function move_users() $result = DB::for_table('groups')->select_many($select_user_groups) ->where_not_in('g_id', $where_not_in) - ->order_by_asc('g_title') - ->find_many(); + ->order_by_asc('g_title'); + $result = $this->hook->fireDB('model.users.move_users.all_user_groups_query', $result); + $result = $result->find_many(); foreach ($result as $row) { $move['all_groups'][$row['g_id']] = $row['g_title']; @@ -154,6 +169,7 @@ public function move_users() if ($this->request->post('move_users_comply')) { $new_group = $this->request->post('new_group') && isset($move['all_groups'][$this->request->post('new_group')]) ? $this->request->post('new_group') : message(__('Invalid group message')); + $new_group = $this->hook->fire('model.users.move_users.new_group', $new_group); // Is the new group a moderator group? $new_group_mod = DB::for_table('groups')->where('g_id', $new_group) @@ -163,8 +179,10 @@ public function move_users() $user_groups = array(); $select_fetch_user_groups = array('id', 'group_id'); $result = DB::for_table('users')->select_many($select_fetch_user_groups) - ->where_in('id', $move['user_ids']) - ->find_many(); + ->where_in('id', $move['user_ids']); + $result = $this->hook->fireDB('model.users.move_users.user_groups_query', $result); + $result = $result->find_many(); + foreach($result as $cur_user) { if (!isset($user_groups[$cur_user['group_id']])) { $user_groups[$cur_user['group_id']] = array(); @@ -185,6 +203,8 @@ public function move_users() } } + $user_groups = $this->hook->fire('model.users.move_users.user_groups', $user_groups); + if (!empty($user_groups) && $new_group != FEATHER_ADMIN && $new_group_mod != '1') { // Fetch forum list and clean up their moderator list $select_mods = array('id', 'moderators'); @@ -220,6 +240,7 @@ public function move_users() redirect(get_link('admin/users/'), __('Users move redirect')); } + $move = $this->hook->fire('model.users.move_users.move', $move); return $move; } @@ -235,6 +256,8 @@ public function delete_users() $user_ids = array(); } + $user_ids = $this->hook->fire('model.users.delete_users.user_ids', $user_ids); + if (empty($user_ids)) { message(__('No users selected')); } @@ -253,7 +276,9 @@ public function delete_users() $select_fetch_user_groups = array('id', 'group_id'); $result = DB::for_table('users')->select_many($select_fetch_user_groups) ->where_in('id', $user_ids) - ->find_many(); + $result = $this->hook->fireDB('model.users.delete_users.user_groups_query', $result); + $result = $result->find_many(); + foreach($result as $cur_user) { if (!isset($user_groups[$cur_user['group_id']])) { @@ -275,6 +300,8 @@ public function delete_users() } } + $user_groups = $this->hook->fire('model.users.delete_users.user_groups', $user_groups); + // Fetch forum list and clean up their moderator list $select_mods = array('id', 'moderators'); $result = DB::for_table('forums') @@ -324,12 +351,14 @@ public function delete_users() $select_user_posts = array('p.id', 'p.topic_id', 't.forum_id'); $result = DB::for_table('posts') - ->table_alias('p') - ->select_many($select_user_posts) - ->inner_join('topics', array('t.id', '=', 'p.topic_id'), 't') - ->inner_join('forums', array('f.id', '=', 't.forum_id'), 'f') - ->where('p.poster_id', $user_ids) - ->find_many(); + ->table_alias('p') + ->select_many($select_user_posts) + ->inner_join('topics', array('t.id', '=', 'p.topic_id'), 't') + ->inner_join('forums', array('f.id', '=', 't.forum_id'), 'f') + ->where('p.poster_id', $user_ids); + $result = $this->hook->fireDB('model.users.delete_users.user_posts_query', $result); + $result = $result->find_many(); + if ($result) { foreach($result as $cur_post) { // Determine whether this post is the "topic post" or not @@ -349,6 +378,7 @@ public function delete_users() } } else { // Set all their posts to guest + // TODO: invert where_in and update_many values ? To test. DB::for_table('posts') ->where_in('poster_id', '1') ->update_many('poster_id', $user_ids); @@ -390,6 +420,8 @@ public function ban_users() $user_ids = array(); } + $user_ids = $this->hook->fire('model.users.ban_users.user_ids', $user_ids); + if (empty($user_ids)) { message(__('No users selected')); } @@ -417,6 +449,8 @@ public function ban_users() $ban_expire = feather_trim($this->request->post('ban_expire')); $ban_the_ip = $this->request->post('ban_the_ip') ? intval($this->request->post('ban_the_ip')) : 0; + $this->hook->fire('model.users.ban_users.comply', $ban_message, $ban_expire, $ban_the_ip); + if ($ban_expire != '' && $ban_expire != 'Never') { $ban_expire = strtotime($ban_expire . ' GMT'); @@ -440,8 +474,10 @@ public function ban_users() $user_info = array(); $select_fetch_user_information = array('id', 'username', 'email', 'registration_ip'); $result = DB::for_table('users')->select_many($select_fetch_user_information) - ->where_in('id', $user_ids) - ->find_many(); + ->where_in('id', $user_ids); + $result = $this->hook->fireDB('model.users.ban_users.user_info_query', $result); + $result = $result->find_many(); + foreach ($result as $cur_user) { $user_info[$cur_user['id']] = array('username' => $cur_user['username'], 'email' => $cur_user['email'], 'ip' => $cur_user['registration_ip']); } @@ -454,6 +490,8 @@ public function ban_users() } } + $user_info = $this->hook->fire('model.users.ban_users.user_info', $user_info); + // And insert the bans! foreach ($user_ids as $user_id) { $ban_username = $user_info[$user_id]['username']; @@ -469,6 +507,8 @@ public function ban_users() 'ban_creator' => $this->user->id, ); + $insert_update_ban = $this->hook->fire('model.users.ban_users.ban_data', $insert_update_ban); + if ($this->request->post('mode') == 'add') { $insert_update_ban['ban_creator'] = $this->user->id; @@ -490,6 +530,7 @@ public function ban_users() public function get_user_search() { $form = $this->request->get('form') ? $this->request->get('form') : array(); + $form = $this->hook->fire('model.users.get_user_search.form', $form); $search = array(); @@ -601,6 +642,7 @@ public function get_user_search() $search['conditions'][] = 'u.group_id='.$user_group; } + $search = $this->hook->fire('model.users.get_user_search.search', $search); return $search; } @@ -610,13 +652,14 @@ public function print_users($conditions, $order_by, $direction, $start_from) $select_print_users = array('u.id', 'u.username', 'u.email', 'u.title', 'u.num_posts', 'u.admin_note', 'g.g_id', 'g.g_user_title'); $result = DB::for_table('users')->table_alias('u') - ->select_many($select_print_users) - ->left_outer_join('groups', array('g.g_id', '=', 'u.group_id'), 'g') - ->where_raw('u.id>1'.(!empty($conditions) ? ' AND '.implode(' AND ', $conditions) : '')) - ->offset($start_from) - ->limit(50) - ->order_by($order_by, $direction) - ->find_many(); + ->select_many($select_print_users) + ->left_outer_join('groups', array('g.g_id', '=', 'u.group_id'), 'g') + ->where_raw('u.id>1'.(!empty($conditions) ? ' AND '.implode(' AND ', $conditions) : '')) + ->offset($start_from) + ->limit(50) + ->order_by($order_by, $direction); + $result = $this->hook->fireDB('model.users.print_users.query', $result); + $result = $result->find_many(); if ($result) { foreach ($result as $cur_user) { @@ -631,6 +674,7 @@ public function print_users($conditions, $order_by, $direction, $start_from) } } + $user_data = $this->hook->fire('model.users.print_users.user_data', $user_data); return $user_data; } @@ -647,6 +691,7 @@ public function get_group_list() $output .= "\t\t\t\t\t\t\t\t\t\t\t".''."\n"; } + $output = $this->hook->fire('model.users.get_group_list.output', $output); return $output; } } diff --git a/style/FeatherBB/view/admin/groups/delete_group.php b/style/FeatherBB/view/admin/groups/delete_group.php index 693baab1..aea315d0 100644 --- a/style/FeatherBB/view/admin/groups/delete_group.php +++ b/style/FeatherBB/view/admin/groups/delete_group.php @@ -6,7 +6,7 @@ * and Rickard Andersson (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ - + // Make sure no one attempts to run this script "directly" if (!defined('FEATHER')) { exit; @@ -25,7 +25,7 @@

@@ -36,4 +36,4 @@
- \ No newline at end of file + diff --git a/view/admin/groups/delete_group.php b/view/admin/groups/delete_group.php index 693baab1..aea315d0 100644 --- a/view/admin/groups/delete_group.php +++ b/view/admin/groups/delete_group.php @@ -6,7 +6,7 @@ * and Rickard Andersson (C) 2002-2008 PunBB * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */ - + // Make sure no one attempts to run this script "directly" if (!defined('FEATHER')) { exit; @@ -25,7 +25,7 @@

@@ -36,4 +36,4 @@
- \ No newline at end of file +