Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions controller/admin/groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
);

Expand Down
51 changes: 39 additions & 12 deletions model/admin/bans.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'];
Expand All @@ -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'];
Expand Down Expand Up @@ -95,19 +103,25 @@ public function add_ban_info($id = null)

$ban['mode'] = 'add';

$ban = $this->hook->fire('add_ban_info', $ban);

return $ban;
}

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'];
Expand All @@ -124,6 +138,8 @@ public function edit_ban_info($id)

$ban['mode'] = 'edit';

$ban = $this->hook->fire('edit_ban_info', $ban);

return $ban;
}

Expand All @@ -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') {
Expand Down Expand Up @@ -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)
Expand All @@ -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());
Expand All @@ -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();

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
}
28 changes: 19 additions & 9 deletions model/admin/categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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']);

Expand All @@ -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
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
21 changes: 14 additions & 7 deletions model/admin/censoring.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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'));
Expand All @@ -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;
}
Expand Down
Loading