Commit 52c7fbd0 authored by Chris Graham's avatar Chris Graham

Fixed MANTIS-4221 (Delete ticket/messaging forums when addons removed)

parent 9e5b3331
......@@ -45,6 +45,15 @@ class Module_admin_messaging
*/
public function uninstall()
{
if (get_forum_type() == 'cns') {
require_lang('messaging');
$forum_id = $GLOBALS['FORUM_DB']->query_select_value_if_there('f_forums', 'id', array('f_parent_forum' => db_get_first_id(), 'f_name' => do_lang('MESSAGING_FORUM_NAME', null, null, null, get_site_default_lang())));
if ($forum_id !== null) {
require_code('cns_forums_action');
require_code('cns_forums_action2');
cns_delete_forum($forum_id);
}
}
}
/**
......@@ -55,7 +64,7 @@ class Module_admin_messaging
*/
public function install($upgrade_from = null, $upgrade_from_hack = null)
{
if ((get_forum_type() == 'cns') && (!running_script('upgrader'))) {
if (get_forum_type() == 'cns') {
$moderator_groups = $GLOBALS['FORUM_DRIVER']->get_moderator_groups();
$staff_access = array();
foreach ($moderator_groups as $id) {
......@@ -66,7 +75,7 @@ class Module_admin_messaging
require_code('cns_forums_action2');
$GLOBALS['CNS_DRIVER'] = $GLOBALS['FORUM_DRIVER'];
require_lang('messaging');
cns_make_forum(do_lang('MESSAGING_FORUM_NAME'), '', db_get_first_id() + 1, $staff_access, db_get_first_id());
cns_make_forum(do_lang('MESSAGING_FORUM_NAME', null, null, null, get_site_default_lang()), '', db_get_first_id() + 1, $staff_access, db_get_first_id());
}
}
......
......@@ -55,6 +55,16 @@ class Module_tickets
delete_privilege('support_operator');
$GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => 'tickets'));
if (get_forum_type() == 'cns') {
require_lang('tickets');
$forum_id = $GLOBALS['FORUM_DB']->query_select_value_if_there('f_forums', 'id', array('f_parent_forum' => db_get_first_id(), 'f_name' => do_lang('TICKET_FORUM_NAME', null, null, null, get_site_default_lang())));
if ($forum_id !== null) {
require_code('cns_forums_action');
require_code('cns_forums_action2');
cns_delete_forum($forum_id);
}
}
}
/**
......@@ -125,6 +135,19 @@ class Module_tickets
add_privilege('SUPPORT_TICKETS', 'view_others_tickets', false);
add_privilege('SUPPORT_TICKETS', 'support_operator', false);
if (get_forum_type() == 'cns') {
$moderator_groups = $GLOBALS['FORUM_DRIVER']->get_moderator_groups();
$staff_access = array();
foreach ($moderator_groups as $id) {
$staff_access[$id] = 5;
}
cns_require_all_forum_stuff();
require_code('cns_forums_action');
require_code('cns_forums_action2');
$GLOBALS['CNS_DRIVER'] = $GLOBALS['FORUM_DRIVER'];
cns_make_forum(do_lang('TICKET_FORUM_NAME', null, null, null, get_site_default_lang()), '', db_get_first_id() + 1, $staff_access, db_get_first_id());
}
}
}
......
......@@ -661,10 +661,6 @@ function install_cns($upgrade_from = null)
cns_make_forum(do_lang('REPORTED_POSTS_FORUM'), '', $forum_grouping_id_staff, $staff_access, $root_forum);
$trash_forum_id = cns_make_forum(do_lang('TRASH'), '', $forum_grouping_id_staff, $staff_access, $root_forum);
cns_make_forum(do_lang('COMMENT_FORUM_NAME'), '', $forum_grouping_id, $typical_access, $root_forum, 1, 1, 0, '', '', '', 'last_post', 1);
if (addon_installed('tickets')) {
require_lang('tickets');
cns_make_forum(do_lang('TICKET_FORUM_NAME'), '', $forum_grouping_id_staff, $staff_access, $root_forum);
}
$staff_forum_id = cns_make_forum(do_lang('STAFF'), '', $forum_grouping_id_staff, $staff_access, $root_forum);
$GLOBALS['FORUM_DB']->create_table('f_topics', array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment