/**
  * Sort out bbcode and permissions
  * 
  * @return	@e void
  */
 public function permsAndBbcode()
 {
     /* INIT */
     $options = IPSSetUp::getSavedData('custom_options');
     $rootAdmins = $options['core'][30001]['rootAdmins'];
     /* First off, import default BBCode */
     $apps = array();
     $bbcodeOld = array();
     $bbcodeNew = array();
     /* Load apps */
     $this->DB->build(array('select' => '*', 'from' => 'core_applications'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $apps[$row['app_directory']] = $row;
     }
     /* Load old codes */
     $this->DB->build(array('select' => '*', 'from' => 'custom_bbcode_old'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $bbcodeOld[$row['bbcode_tag']] = $row;
     }
     /* Add 'em */
     foreach ($apps as $dir => $data) {
         if (is_file(IPSLib::getAppDir($dir) . '/xml/' . $dir . '_bbcode.xml')) {
             //-----------------------------------------
             // Continue
             //-----------------------------------------
             $classToLoad = IPSLib::loadActionOverloader(IPS_ROOT_PATH . 'applications/core/modules_admin/posts/bbcode.php', 'admin_core_posts_bbcode');
             $bbcode = new $classToLoad();
             $bbcode->makeRegistryShortcuts($this->registry);
             $bbcode->bbcodeImportDo(file_get_contents(IPSLib::getAppDir($dir) . '/xml/' . $dir . '_bbcode.xml'));
         }
         if (is_file(IPSLib::getAppDir($dir) . '/xml/' . $dir . '_mediatag.xml')) {
             //-----------------------------------------
             // Continue
             //-----------------------------------------
             $classToLoad = IPSLib::loadActionOverloader(IPS_ROOT_PATH . 'applications/core/modules_admin/posts/media.php', 'admin_core_posts_media');
             $bbcode = new $classToLoad();
             $bbcode->makeRegistryShortcuts($this->registry);
             $bbcode->doMediaImport(file_get_contents(IPSLib::getAppDir($dir) . '/xml/' . $dir . '_mediatag.xml'));
         }
     }
     /* Load current code */
     $this->DB->build(array('select' => '*', 'from' => 'custom_bbcode'));
     $this->DB->execute();
     while ($row = $this->DB->fetch()) {
         $bbcodeCurrent[$row['bbcode_tag']] = $row;
         //-----------------------------------------
         // Need to take into account aliases too!
         //-----------------------------------------
         if ($row['bbcode_aliases']) {
             $aliases = explode(',', $row['bbcode_aliases']);
             if (count($aliases)) {
                 foreach ($aliases as $alias) {
                     $bbcodeCurrent[$alias] = $row;
                 }
             }
         }
     }
     if (count($bbcodeOld)) {
         foreach ($bbcodeOld as $tag => $row) {
             if (!$bbcodeCurrent[$row['bbcode_tag']]) {
                 $bbcodeNew[$row['bbcode_tag']] = $row;
             }
         }
     }
     $this->registry->output->addMessage("BB-коды обновлены....");
     /* Now see if there's anything we need to move back over */
     if (count($bbcodeNew)) {
         foreach ($bbcodeNew as $tag => $data) {
             $bbarray = array('bbcode_title' => $data['bbcode_title'], 'bbcode_desc' => $data['bbcode_desc'], 'bbcode_tag' => $data['bbcode_tag'], 'bbcode_replace' => IPSText::safeslashes($data['bbcode_replace']), 'bbcode_useoption' => $data['bbcode_useoption'], 'bbcode_example' => $data['bbcode_example'], 'bbcode_switch_option' => $data['bbcode_switch_option'], 'bbcode_menu_option_text' => $data['bbcode_menu_option_text'], 'bbcode_menu_content_text' => $data['bbcode_menu_content_text'], 'bbcode_groups' => 'all', 'bbcode_sections' => 'all', 'bbcode_php_plugin' => '', 'bbcode_parse' => 2, 'bbcode_no_parsing' => 0, 'bbcode_optional_option' => 0, 'bbcode_aliases' => '', 'bbcode_image' => '');
             $this->DB->insert('custom_bbcode', $bbarray);
         }
     }
     /* OK, now onto permissions... */
     /* Insert basic perms for profiles and help */
     $this->DB->insert('permission_index', array('app' => 'members', 'perm_type' => 'profile_view', 'perm_type_id' => 1, 'perm_view' => '*', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => ''));
     $this->DB->insert('permission_index', array('app' => 'core', 'perm_type' => 'help', 'perm_type_id' => 1, 'perm_view' => '*', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => ''));
     /* And now calendars */
     $this->DB->build(array('select' => '*', 'from' => 'cal_calendars'));
     $o = $this->DB->execute();
     while ($row = $this->DB->fetch($o)) {
         if (strstr($row['cal_permissions'], 'a:')) {
             $_perms = unserialize(stripslashes($row['cal_permissions']));
             if (is_array($_perms)) {
                 $_view = $_perms['perm_read'] ? ',' . implode(',', explode(',', $_perms['perm_read'])) . ',' : '';
                 $_start = $_perms['perm_post'] ? ',' . implode(',', explode(',', $_perms['perm_post'])) . ',' : '';
                 $_nomod = $_perms['perm_nomod'] ? ',' . implode(',', explode(',', $_perms['perm_nomod'])) . ',' : '';
                 $this->DB->insert('permission_index', array('app' => 'calendar', 'perm_type' => 'calendar', 'perm_type_id' => $row['cal_id'], 'perm_view' => str_replace(',*,', '*', $_view), 'perm_2' => str_replace(',*,', '*', $_start), 'perm_3' => str_replace(',*,', '*', $_nomod), 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => ''));
             } else {
                 $this->DB->insert('permission_index', array('app' => 'calendar', 'perm_type' => 'calendar', 'perm_type_id' => $row['cal_id'], 'perm_view' => '', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => ''));
             }
         } else {
             $this->DB->insert('permission_index', array('app' => 'calendar', 'perm_type' => 'calendar', 'perm_type_id' => $row['cal_id'], 'perm_view' => '', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => ''));
         }
     }
     /* And now forums */
     $this->DB->build(array('select' => '*', 'from' => 'forums'));
     $o = $this->DB->execute();
     while ($row = $this->DB->fetch($o)) {
         /* Do we need to tidy up the title? */
         if (strstr($row['name'], '&')) {
             $row['name'] = preg_replace("#& #", "& ", $row['name']);
             $this->DB->update('forums', array('name' => $row['name']), 'id=' . $row['id']);
         }
         if (strstr($row['permission_array'], 'a:')) {
             $_perms = unserialize(stripslashes($row['permission_array']));
             if (is_array($_perms)) {
                 $_view = $_perms['show_perms'] ? ',' . implode(',', explode(',', $_perms['show_perms'])) . ',' : '';
                 $_read = $_perms['read_perms'] ? ',' . implode(',', explode(',', $_perms['read_perms'])) . ',' : '';
                 $_reply = $_perms['reply_perms'] ? ',' . implode(',', explode(',', $_perms['reply_perms'])) . ',' : '';
                 $_start = $_perms['start_perms'] ? ',' . implode(',', explode(',', $_perms['start_perms'])) . ',' : '';
                 $_upload = $_perms['upload_perms'] ? ',' . implode(',', explode(',', $_perms['upload_perms'])) . ',' : '';
                 $_download = $_perms['download_perms'] ? ',' . implode(',', explode(',', $_perms['download_perms'])) . ',' : '';
                 $this->DB->insert('permission_index', array('app' => 'forums', 'perm_type' => 'forum', 'perm_type_id' => $row['id'], 'perm_view' => str_replace(',*,', '*', $_view), 'perm_2' => str_replace(',*,', '*', $_read), 'perm_3' => str_replace(',*,', '*', $_reply), 'perm_4' => str_replace(',*,', '*', $_start), 'perm_5' => str_replace(',*,', '*', $_upload), 'perm_6' => str_replace(',*,', '*', $_download), 'perm_7' => ''));
             } else {
                 $this->DB->insert('permission_index', array('app' => 'forums', 'perm_type' => 'forum', 'perm_type_id' => $row['id'], 'perm_view' => '', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => ''));
                 IPSSetUp::addLogMessage("Пропущены права доступа для форума ID: " . $row['id'], '30001', 'core');
             }
         } else {
             $this->DB->insert('permission_index', array('app' => 'forums', 'perm_type' => 'forum', 'perm_type_id' => $row['id'], 'perm_view' => '', 'perm_2' => '', 'perm_3' => '', 'perm_4' => '', 'perm_5' => '', 'perm_6' => '', 'perm_7' => ''));
             IPSSetUp::addLogMessage("Пропущены права доступа для форума ID: " . $row['id'], '30001', 'core');
         }
     }
     $this->registry->output->addMessage("Права доступа обновлены....");
     /* Fix up forum moderators */
     $this->DB->build(array('select' => '*', 'from' => 'moderators'));
     $o = $this->DB->execute();
     while ($r = $this->DB->fetch($o)) {
         $this->DB->update('moderators', array('forum_id' => ',' . IPSText::cleanPermString($r['forum_id']) . ','), 'mid=' . $r['mid']);
     }
     $this->registry->output->addMessage("Модераторы форумов обновлены....");
     /* Root admin reset? */
     if ($rootAdmins) {
         /* Find all admin groups */
         $this->DB->build(array('select' => '*', 'from' => 'groups', 'where' => 'g_id != ' . $this->settings['admin_group'] . ' AND g_access_cp=1'));
         $o = $this->DB->execute();
         while ($row = $this->DB->fetch($o)) {
             /* Insert blank perm row */
             $this->DB->insert('admin_permission_rows', array('row_id' => $row['g_id'], 'row_id_type' => 'group', 'row_perm_cache' => serialize(array()), 'row_updated' => time()));
         }
         $this->registry->output->addMessage("Удалены вторичные группы администраторов....");
     }
     /* Report center reset */
     $canReport = array();
     $canView = array();
     $this->DB->build(array('select' => 'g_id, g_view_board, g_access_cp, g_is_supmod', 'from' => 'groups'));
     $o = $this->DB->execute();
     while ($r = $this->DB->fetch($o)) {
         if ($r['g_access_cp'] or $r['g_is_supmod']) {
             $canView[] = $r['g_id'];
         }
         if ($r['g_view_board'] and $r['g_id'] != $this->settings['guest_group']) {
             $canReport[] = $r['g_id'];
         }
     }
     $this->DB->update('rc_classes', array('group_can_report' => ',' . implode(',', $canReport) . ',', 'mod_group_perm' => ',' . implode(',', $canView) . ','));
     /* Next Page */
     $this->request['workact'] = 'skinlang';
 }
 /**
  * Save a bbcode [add|edit]
  *
  * @param	string		[add|edit]
  * @return	@e void		[Outputs to screen]
  */
 protected function _bbcodeSave($type = 'add')
 {
     if ($type == 'edit') {
         if (!$this->request['id']) {
             $this->registry->output->global_message = $this->lang->words['no_bbcode_found_edit'];
             $this->_bbcodeForm($type);
             return;
         }
         $bbcode = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'custom_bbcode', 'where' => 'bbcode_id=' . intval($this->request['id'])));
         if (!$bbcode['bbcode_id']) {
             $this->registry->output->showError($this->lang->words['no_bbcode_found_edit'], 111162);
         }
         if ($this->request['bbcode_tag']) {
             $duplicate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$this->request['bbcode_tag']}'"));
             if ($duplicate['bbcode_id'] && $duplicate['bbcode_id'] != $this->request['id']) {
                 $this->registry->output->global_message = $this->lang->words['tag_already'];
                 $this->_bbcodeForm($type);
                 return;
             }
             /* Check aliases */
             $this->DB->build(array('select' => '*', 'from' => 'custom_bbcode', 'where' => 'bbcode_aliases LIKE \'%' . $this->DB->addSlashes($this->request['bbcode_tag']) . '%\''));
             $this->DB->execute();
             while ($row = $this->DB->fetch()) {
                 if ($row['bbcode_id'] == $this->request['id']) {
                     continue;
                 }
                 foreach (explode(',', $row['bbcode_aliases']) as $alias) {
                     if (strtolower($alias) == strtolower($this->request['bbcode_tag'])) {
                         $this->registry->output->global_message = sprintf($this->lang->words['tag_already_alias'], $this->request['bbcode_tag'], $row['bbcode_tag']);
                         $this->_bbcodeForm($type);
                         return;
                     }
                 }
             }
         }
     } else {
         $bbcode = array();
         if ($this->request['bbcode_tag']) {
             $duplicate = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$this->request['bbcode_tag']}'"));
             if ($duplicate['bbcode_id']) {
                 $this->registry->output->global_message = $this->lang->words['tag_already'];
                 $this->_bbcodeForm($type);
                 return;
             }
             /* Check aliases */
             $this->DB->build(array('select' => '*', 'from' => 'custom_bbcode', 'where' => 'bbcode_aliases LIKE \'%' . $this->DB->addSlashes($this->request['bbcode_tag']) . '%\''));
             $this->DB->execute();
             while ($row = $this->DB->fetch()) {
                 foreach (explode(',', $row['bbcode_aliases']) as $alias) {
                     if (strtolower($alias) == strtolower($this->request['bbcode_tag'])) {
                         $this->registry->output->global_message = sprintf($this->lang->words['tag_already_alias'], $this->request['bbcode_tag'], $row['bbcode_tag']);
                         $this->_bbcodeForm($type);
                         return;
                     }
                 }
             }
         }
     }
     //-----------------------------------------
     // Fix BR tags
     //-----------------------------------------
     $this->request['bbcode_aliases'] = str_replace(array(' ', "\n"), '', IPSText::br2nl($this->request['bbcode_aliases']));
     //-----------------------------------------
     // check...
     //-----------------------------------------
     if (!$this->request['bbcode_title'] or !$this->request['bbcode_tag'] or !$this->request['bbcode_replace'] and !$this->request['bbcode_php_plugin']) {
         $this->registry->output->global_message = $this->lang->words['complete_form'];
         $this->_bbcodeForm($type);
         return;
     }
     if (!$this->request['bbcode_single_tag'] and !strstr($this->request['bbcode_replace'], '{content}') and !$this->request['bbcode_php_plugin']) {
         $this->registry->output->global_message = $this->lang->words['must_use_content'];
         $this->_bbcodeForm($type);
         return;
     }
     if (!strstr($this->request['bbcode_replace'], '{option}') and $this->request['bbcode_useoption'] and !$this->request['bbcode_php_plugin']) {
         $this->registry->output->global_message = $this->lang->words['must_use_option'];
         $this->_bbcodeForm($type);
         return;
     }
     if (preg_match("/[^a-zA-Z0-9_]/", $this->request['bbcode_tag'])) {
         $this->registry->output->global_message = $this->lang->words['bbcode_alpha_num'];
         $this->_bbcodeForm($type);
         return;
     }
     $_aliases = explode(",", $this->request['bbcode_aliases']);
     foreach ($_aliases as $_alias) {
         if (preg_match("/[^a-zA-Z0-9_]/", $_alias)) {
             $this->registry->output->global_message = $this->lang->words['bbcode_alpha_num'];
             $this->_bbcodeForm($type);
             return;
         }
     }
     $array = array('bbcode_title' => $this->request['bbcode_title'], 'bbcode_desc' => IPSText::safeslashes($_POST['bbcode_desc']), 'bbcode_tag' => preg_replace("/[^a-zA-Z0-9_]/", "", $this->request['bbcode_tag']), 'bbcode_replace' => IPSText::safeslashes($_POST['bbcode_replace']), 'bbcode_example' => IPSText::safeslashes($_POST['bbcode_example']), 'bbcode_useoption' => $this->request['bbcode_useoption'], 'bbcode_switch_option' => intval($this->request['bbcode_switch_option']), 'bbcode_menu_option_text' => trim($this->request['bbcode_menu_option_text']), 'bbcode_menu_content_text' => trim($this->request['bbcode_menu_content_text']), 'bbcode_single_tag' => intval($this->request['bbcode_single_tag']), 'bbcode_groups' => is_array($this->request['bbcode_groups']) ? implode(',', $this->request['bbcode_groups']) : '', 'bbcode_sections' => is_array($this->request['bbcode_sections']) ? implode(',', $this->request['bbcode_sections']) : '', 'bbcode_php_plugin' => trim($this->request['bbcode_php_plugin']), 'bbcode_no_parsing' => intval($this->request['bbcode_no_parsing']), 'bbcode_optional_option' => intval($this->request['bbcode_optional_option']), 'bbcode_aliases' => $this->request['bbcode_aliases'], 'bbcode_image' => $this->request['bbcode_image'], 'bbcode_app' => $this->request['bbcode_app'], 'bbcode_protected' => intval($this->request['bbcode_protected']), 'bbcode_custom_regex' => str_replace("\", '\\', IPSText::stripslashes($_POST['bbcode_custom_regex'])));
     if ($type == 'add') {
         $check = $this->DB->buildAndFetch(array('select' => 'bbcode_tag', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$array['bbcode_tag']}'"));
         if ($check['bbcode_tag']) {
             $this->registry->output->global_message = $this->lang->words['must_use_unique_btag'];
             $this->_bbcodeForm($type);
             return;
         }
         $this->DB->insert('custom_bbcode', $array);
         $this->registry->output->global_message = $this->lang->words['new_bbcode'];
     } else {
         $check = $this->DB->buildAndFetch(array('select' => 'bbcode_tag', 'from' => 'custom_bbcode', 'where' => "bbcode_tag='{$array['bbcode_tag']}' AND bbcode_id<>" . intval($this->request['id'])));
         if ($check['bbcode_tag']) {
             $this->registry->output->global_message = $this->lang->words['must_use_unique_btag'];
             $this->_bbcodeForm($type);
             return;
         }
         if ($this->request['drop_cache']) {
             IPSContentCache::truncate();
         }
         $this->DB->update('custom_bbcode', $array, 'bbcode_id=' . intval($this->request['id']));
         $this->registry->output->global_message = $this->lang->words['edited_bbcode'];
     }
     $this->bbcodeRebuildCache();
     $this->_bbcodeStart();
 }
 /**
  * Save the group [add/edit]
  *
  * @param 	string		'add' or 'edit'
  * @return	@e void		[Outputs to screen]
  */
 protected function _saveGroup($type = 'edit')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $group_id = intval($this->request['id']);
     $oldGroup = $this->caches['group_cache'][$group_id];
     //-----------------------------------------
     // Auth check...
     //-----------------------------------------
     ipsRegistry::getClass('adminFunctions')->checkSecurityKey($this->request['secure_key']);
     //-----------------------------------------
     // Check...
     //-----------------------------------------
     if (!$this->request['g_title']) {
         $this->registry->output->showError($this->lang->words['g_title_error'], 1127);
     }
     if (intval($this->request['g_max_mass_pm']) > 500) {
         $this->registry->output->showError($this->lang->words['g_mass_pm_too_large'], 1127);
     }
     #MSSQL needs a check on this
     if (IPSText::mbstrlen($this->request['g_title']) > 32) {
         $this->registry->output->showError($this->lang->words['g_title_error'], 1127);
     }
     if ($type == 'edit') {
         if (!$group_id) {
             $this->registry->output->showError($this->lang->words['g_whichgroup'], 1128);
         }
         //-----------------------------------------
         // Check restrictions.
         //-----------------------------------------
         if ($this->caches['group_cache'][$group_id]['g_access_cp']) {
             $this->registry->getClass('class_permissions')->checkPermissionAutoMsg('groups_edit_admin');
         }
     }
     //-----------------------------------------
     // Check restrictions.
     //-----------------------------------------
     if (($type == 'add' or !$this->caches['group_cache'][$group_id]['g_access_cp']) and $this->request['g_access_cp']) {
         $this->registry->getClass('class_permissions')->checkPermissionAutoMsg('groups_add_admin');
     }
     //-----------------------------------------
     // Sort out the perm mask id things
     //-----------------------------------------
     $new_perm_set_id = 0;
     if ($this->request['g_new_perm_set']) {
         $this->DB->insert('forum_perms', array('perm_name' => $this->request['g_new_perm_set']));
         $new_perm_set_id = $this->DB->getInsertId();
     } else {
         if (!is_array($this->request['permid'])) {
             $this->registry->output->showError($this->lang->words['g_oneperm'], 1129);
         }
     }
     $this->lang->loadLanguageFile(array('admin_permissions'), 'members');
     //-----------------------------------------
     // Some other generic fields
     //-----------------------------------------
     $promotion_a = '-1';
     // id
     $promotion_b = '-1';
     // posts
     if ($this->request['g_promotion_id'] and $this->request['g_promotion_id'] > 0) {
         $promotion_a = $this->request['g_promotion_id'];
         $promotion_b = $this->request['g_promotion_posts'];
     }
     if ($this->request['g_attach_per_post'] and $this->request['g_attach_max'] > 0) {
         if ($this->request['g_attach_per_post'] > $this->request['g_attach_max']) {
             $this->registry->output->global_message = $this->lang->words['g_pergreater'];
             $this->_groupForm('edit');
             return;
         }
     }
     $this->request['p_max'] = str_replace(":", "", $this->request['p_max']);
     $this->request['p_width'] = str_replace(":", "", $this->request['p_width']);
     $this->request['p_height'] = str_replace(":", "", $this->request['p_height']);
     $this->request['g_attach_max'] = intval($this->request['g_attach_max']);
     $this->request['g_attach_per_post'] = intval($this->request['g_attach_per_post']);
     $this->request['p_max'] = intval($this->request['p_max']);
     $sig_limits = array($this->request['use_signatures'], $this->request['max_images'], $this->request['max_dims_x'], $this->request['max_dims_y'], $this->request['max_urls'], $this->request['max_lines']);
     //-----------------------------------------
     // Set the db array
     //-----------------------------------------
     $db_string = array('g_view_board' => intval($this->request['g_view_board']), 'g_mem_info' => intval($this->request['g_mem_info']), 'g_can_add_friends' => intval($this->request['g_can_add_friends']), 'g_use_search' => intval($this->request['g_use_search']), 'g_edit_profile' => intval($this->request['g_edit_profile']), 'g_use_pm' => intval($this->request['g_use_pm']), 'g_pm_perday' => intval($this->request['g_pm_perday']), 'g_is_supmod' => intval($this->request['g_is_supmod']), 'g_access_cp' => intval($this->request['g_access_cp']), 'g_title' => trim($this->request['g_title']), 'g_access_offline' => intval($this->request['g_access_offline']), 'g_dname_changes' => intval($this->request['g_dname_changes']), 'g_dname_date' => intval($this->request['g_dname_date']), 'prefix' => trim(IPSText::safeslashes($_POST['prefix'])), 'suffix' => trim(IPSText::safeslashes($_POST['suffix'])), 'g_hide_from_list' => intval($this->request['g_hide_from_list']), 'g_perm_id' => $new_perm_set_id ? $new_perm_set_id : implode(",", $this->request['permid']), 'g_icon' => trim(IPSText::safeslashes($_POST['g_icon'])), 'g_attach_max' => $this->request['g_attach_max'] == '' ? 0 : intval($this->request['g_attach_max']), 'g_max_messages' => intval($this->request['g_max_messages']), 'g_max_mass_pm' => intval($this->request['g_max_mass_pm']), 'g_pm_flood_mins' => intval($this->request['g_pm_flood_mins']), 'g_search_flood' => intval($this->request['g_search_flood']), 'g_promotion' => $promotion_a . '&' . $promotion_b, 'g_photo_max_vars' => $this->request['p_max'] . ':' . $this->request['p_width'] . ':' . $this->request['p_height'], 'g_dohtml' => intval($this->request['g_dohtml']), 'g_bypass_badwords' => intval($this->request['g_bypass_badwords']), 'g_can_msg_attach' => intval($this->request['g_can_msg_attach']), 'g_attach_per_post' => intval($this->request['g_attach_per_post']), 'g_rep_max_positive' => intval($this->request['g_rep_max_positive']), 'g_rep_max_negative' => intval($this->request['g_rep_max_negative']), 'g_signature_limits' => implode(':', $sig_limits), 'g_hide_online_list' => intval($this->request['g_hide_online_list']), 'g_displayname_unit' => intval($this->request['g_displayname_unit']), 'g_sig_unit' => intval($this->request['g_sig_unit']), 'g_max_notifications' => intval($this->request['g_max_notifications']), 'g_max_bgimg_upload' => intval($this->request['g_max_bgimg_upload']), 'g_bitoptions' => IPSBWOPtions::freeze($this->request, 'groups', 'global'));
     $this->DB->setDataType('g_title', 'string');
     //-----------------------------------------
     // Ok? Load interface and child classes
     //-----------------------------------------
     IPSLib::loadInterface('admin/group_form.php');
     $_groupPlugins = array();
     foreach (IPSLib::getEnabledApplications() as $app_dir => $app_data) {
         if (is_file(IPSLib::getAppDir($app_dir) . '/extensions/admin/group_form.php')) {
             $_class = IPSLib::loadLibrary(IPSLib::getAppDir($app_dir) . '/extensions/admin/group_form.php', 'admin_group_form__' . $app_dir, $app_dir);
             $_groupPlugins[$_class] = new $_class($this->registry);
             $remote = $_groupPlugins[$_class]->getForSave();
             $db_string = array_merge($db_string, $remote);
         }
     }
     //-----------------------------------------
     // Editing...do an update
     //-----------------------------------------
     if ($type == 'edit') {
         $this->DB->update('groups', $db_string, 'g_id=' . $group_id);
         //-----------------------------------------
         // Update moderator table too
         //-----------------------------------------
         $this->DB->update('moderators', array('group_name' => $db_string['g_title']), 'group_id=' . $group_id);
         $this->cache->rebuildCache('moderators', 'forums');
         ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['g_editedlog'], $db_string['g_title']));
         $this->registry->output->global_message = $this->lang->words['g_edited'];
     } else {
         $this->DB->insert('groups', $db_string);
         $group_id = $this->DB->getInsertId();
         ipsRegistry::getClass('adminFunctions')->saveAdminLog(sprintf($this->lang->words['g_addedlog'], $db_string['g_title']));
         $this->registry->output->global_message = $this->lang->words['g_added'];
     }
     $this->rebuildGroupCache();
     //-----------------------------------------
     // Post save callbacks
     //-----------------------------------------
     if (count($_groupPlugins)) {
         foreach ($_groupPlugins as $_className => $_object) {
             if (method_exists($_object, 'postSave')) {
                 $_object->postSave($group_id);
             }
         }
     }
     if ($new_perm_set_id) {
         $from = '';
         if ($type == 'edit' and $db_string['g_access_cp'] and !$oldGroup['g_access_cp'] or $type == 'add' and $db_string['g_access_cp']) {
             //-----------------------------------------
             // Do they already have restrictions?
             //-----------------------------------------
             $test = $this->DB->buildAndFetch(array('select' => 'row_id', 'from' => 'admin_permission_rows', 'where' => "row_id_type='group' AND row_id=" . $group_id));
             if (!$test['row_id']) {
                 $from = '&amp;_from=group-' . $group_id;
             }
         }
         $this->registry->output->global_message = $this->lang->words['per_saved'];
         $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . 'module=groups&amp;section=permissions&amp;do=edit_set_form' . $from . '&amp;id=' . $new_perm_set_id);
     } else {
         if ($type == 'edit' and $db_string['g_access_cp'] and !$oldGroup['g_access_cp'] or $type == 'add' and $db_string['g_access_cp']) {
             //-----------------------------------------
             // Do they already have restrictions?
             //-----------------------------------------
             $test = $this->DB->buildAndFetch(array('select' => 'row_id', 'from' => 'admin_permission_rows', 'where' => "row_id_type='group' AND row_id=" . $group_id));
             if (!$test['row_id']) {
                 $this->registry->output->html .= $this->html->groupAdminConfirm($group_id);
             }
         }
         $this->_mainScreen();
     }
 }
Beispiel #4
0
 /**
  * This is where you edit an image under a status
  *
  * @return	@e void
  */
 public function _editImage()
 {
     $img_id = intval($this->request['id']);
     //-----------------------------------------
     // Make sure the ID is not zero...
     //-----------------------------------------
     if ($img_id < 1) {
         $this->registry->output->global_error = $this->lang->words['r_noid'];
         $this->_showStatusIndex();
         return;
     }
     if ($_POST['finish'] == 1) {
         //-----------------------------------------
         // Now it's time to send the form...
         //-----------------------------------------
         $this->DB->build(array('select' => '*', 'from' => 'rc_status_sev', 'where' => "status='{$this->request['img_status']}' AND points={$this->request['img_points']} AND id!={$img_id}", 'limit' => 1));
         $this->DB->execute();
         if ($this->DB->getTotalRows() != 0) {
             $this->registry->output->setMessage($this->lang->words['r_changepoints'], 1);
         } else {
             $build_image = array('img' => trim(IPSText::safeslashes($_POST['img_filename'])), 'width' => $this->request['img_width'], 'height' => $this->request['img_height'], 'points' => $this->request['img_points'], 'is_png' => strtolower(strrchr($this->request['img_filename'], '.')) == '.png' ? 1 : 0);
             $this->DB->update('rc_status_sev', $build_image, "id='{$img_id}'");
             $this->registry->output->global_message = $this->lang->words['r_imgsaved'];
             $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . "&amp;do=status");
         }
     }
     $image_data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'rc_status_sev', 'where' => "id='{$img_id}'"));
     //-----------------------------------------
     // Make sure the image actually exists...
     //-----------------------------------------
     if (!$image_data['id']) {
         $this->registry->output->global_error = $this->lang->words['r_noid'];
         $this->_showStatusIndex();
         return;
     }
     //-----------------------------------------
     // Load basic data so we can edit it
     //-----------------------------------------
     $status = $this->DB->buildAndFetch(array('select' => 'title', 'from' => 'rc_status', 'where' => "status='{$image_data['status']}'"));
     $this->registry->output->html .= $this->html->imageForm('edit_image', $status, $image_data);
 }
 /**
  * Update settings
  *
  * @param	array		array('conf_key' => 'new value')
  * @return	true/false
  * @author	MarkWade
  * @access	public
  */
 public static function updateSettings($update = array())
 {
     $fields = array_keys($update);
     ipsRegistry::DB()->build(array('select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_key IN ('" . implode("','", $fields) . "')"));
     ipsRegistry::DB()->execute();
     $db_fields = array();
     while ($r = ipsRegistry::DB()->fetch()) {
         $db_fields[$r['conf_key']] = $r;
     }
     if (empty($db_fields)) {
         return false;
     }
     foreach ($db_fields as $key => $data) {
         $value = str_replace("&#39;", "'", IPSText::safeslashes($update[$key]));
         $value = $value == '' ? "{blank}" : $value;
         ipsRegistry::DB()->update('core_sys_conf_settings', array('conf_value' => $value), 'conf_id=' . $data['conf_id']);
     }
     ipsRegistry::DB()->build(array('select' => '*', 'from' => 'core_sys_conf_settings', 'where' => 'conf_add_cache=1'));
     $info = ipsRegistry::DB()->execute();
     while ($r = ipsRegistry::DB()->fetch($info)) {
         $value = $r['conf_value'] != "" ? $r['conf_value'] : $r['conf_default'];
         if ($value == '{blank}') {
             $value = '';
         }
         $settings[$r['conf_key']] = $value;
     }
     ipsRegistry::cache()->setCache('settings', $settings, array('array' => 1, 'deletefirst' => 1));
     return true;
 }
 /**
  * Save a setting group
  *
  * @access	private
  * @param	string		[add|edit]
  * @return	void
  */
 private function _settingGroupSave($type = 'add')
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     if ($type == 'edit') {
         if (!$this->request['id']) {
             $this->registry->output->global_message = $this->lang->words['s_noid'];
             $this->_settingForm();
             return;
         }
     }
     if (!$this->request['conf_title_title']) {
         $this->registry->output->global_message = $this->lang->words['s_notitle'];
         $this->_settingGroupForm($type);
         return;
     }
     //--------------------------------------------
     // Check...
     //--------------------------------------------
     $array = array('conf_title_title' => $this->request['conf_title_title'], 'conf_title_desc' => IPSText::safeslashes($_POST['conf_title_desc']), 'conf_title_keyword' => IPSText::safeslashes($_POST['conf_title_keyword']), 'conf_title_noshow' => $this->request['conf_title_noshow'], 'conf_title_app' => trim($this->request['conf_title_app']), 'conf_title_tab' => trim($this->request['conf_title_tab']));
     if ($type == 'add') {
         $this->DB->insert('core_sys_settings_titles', $array);
         $this->registry->output->global_message = $this->lang->words['s_added'];
     } else {
         $this->DB->update('core_sys_settings_titles', $array, 'conf_title_id=' . $this->request['id']);
         $this->registry->output->global_message = $this->lang->words['s_edited'];
     }
     $this->settingsRebuildCache();
     $this->_settingsOverview();
 }