Adding new function api_get_default_tool_setting() in order to get default values from the configuration.php file see BT#6765

1.9.x
Julio Montoya 11 years ago
parent caaf9bda2c
commit 19c9236050
  1. 6
      main/forum/forumfunction.inc.php
  2. 18
      main/inc/lib/main_api.lib.php

@ -298,13 +298,15 @@ function show_add_forum_form($inputvalues = array(), $lp_id)
$form->addRule('forum_title', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('forum_category', get_lang('ThisFieldIsRequired'), 'required');
$defaultSettingAllowNewThreads = api_get_default_tool_setting('forum', 'allow_new_threads', 0);
// Settings the defaults
if (empty($inputvalues) || !is_array($inputvalues)) {
$defaults['allow_anonymous_group']['allow_anonymous'] = 0;
$defaults['students_can_edit_group']['students_can_edit'] = 0;
$defaults['approval_direct_group']['approval_direct'] = 0;
$defaults['allow_attachments_group']['allow_attachments'] = 1;
$defaults['allow_new_threads_group']['allow_new_threads'] = 0;
$defaults['allow_new_threads_group']['allow_new_threads'] = $defaultSettingAllowNewThreads;
$defaults['default_view_type_group']['default_view_type'] = api_get_setting('default_forum_view');
$defaults['public_private_group_forum_group']['public_private_group_forum'] = 'public';
if (isset($_GET['forumcategory'])) {
@ -319,7 +321,7 @@ function show_add_forum_form($inputvalues = array(), $lp_id)
$defaults['students_can_edit_group']['students_can_edit'] = isset($inputvalues['allow_edit']) ? $inputvalues['allow_edit'] : null;
$defaults['approval_direct_group']['approval_direct'] = isset($inputvalues['approval_direct_post']) ? $inputvalues['approval_direct_post'] : null;
$defaults['allow_attachments_group']['allow_attachments'] = isset($inputvalues['allow_attachments']) ? $inputvalues['allow_attachments'] : null;
$defaults['allow_new_threads_group']['allow_new_threads'] = isset($inputvalues['allow_new_threads']) ? $inputvalues['allow_new_threads'] : null;
$defaults['allow_new_threads_group']['allow_new_threads'] = isset($inputvalues['allow_new_threads']) ? $inputvalues['allow_new_threads'] : $defaultSettingAllowNewThreads;
$defaults['default_view_type_group']['default_view_type'] = isset($inputvalues['default_view']) ? $inputvalues['default_view'] : null;
$defaults['public_private_group_forum_group']['public_private_group_forum'] = isset($inputvalues['forum_group_public_private']) ? $inputvalues['forum_group_public_private'] : null;
$defaults['group_forum'] = isset($inputvalues['forum_of_group']) ? $inputvalues['forum_of_group'] : null;

@ -6637,3 +6637,21 @@ function api_drh_can_access_all_session_content()
}
return false;
}
/**
* @param string $tool
* @param string $setting
* @param mixed $defaultValue
*/
function api_get_default_tool_setting($tool, $setting, $defaultValue)
{
global $_configuration;
if (isset($_configuration[$tool]) &&
isset($_configuration[$tool]['default_settings']) &&
isset($_configuration[$tool]['default_settings'][$setting])
) {
return $_configuration[$tool]['default_settings'][$setting];
}
return $defaultValue;
}

Loading…
Cancel
Save