function saveConfig() { DOCMAN_token::check() or die('Invalid Token'); global $_DOCMAN, $task; $mainframe = JFactory::getApplication(); $_POST = DOCMAN_Utils::stripslashes($_POST); $docmanMax = DOCMAN_Utils::text2number($_POST['maxAllowed']); $_POST['maxAllowed'] = $docmanMax; $sysUploadMax = DOCMAN_Utils::text2number(ini_get('upload_max_filesize')); $sysPostMax = DOCMAN_Utils::text2number(ini_get('post_max_size')); $max = min($sysUploadMax, $sysPostMax); if ($docmanMax < 0) { $mainframe->redirect("index.php?option=com_docman§ion=config", _DML_CONFIG_ERROR_UPLOAD); } $override_edit = _DM_ASSIGN_NONE; $author = JRequest::getBool('assign_edit_author', 0, 'post'); $editor = JRequest::getBool('assign_edit_editor', 0, 'post'); if ($author) { $override_edit = _DM_ASSIGN_BY_AUTHOR; } if ($editor) { $override_edit = _DM_ASSIGN_BY_EDITOR; } if ($author && $editor) { $override_edit = _DM_ASSIGN_BY_AUTHOR_EDITOR; } $_POST['editor_assign'] = $override_edit; unset($_POST['assign_edit_author']); unset($_POST['assign_edit_editor']); $override_down = _DM_ASSIGN_NONE; $author = JRequest::getBool('assign_download_author', 0, 'post'); $editor = JRequest::getBool('assign_download_editor', 0, 'post'); if ($author) { $override_down = _DM_ASSIGN_BY_AUTHOR; } if ($editor) { $override_down = _DM_ASSIGN_BY_EDITOR; } if ($author && $editor) { $override_down = _DM_ASSIGN_BY_AUTHOR_EDITOR; } $_POST['reader_assign'] = $override_down; unset($_POST['assign_download_author']); unset($_POST['assign_download_editor']); foreach ($_POST as $key => $value) { $_DOCMAN->setCfg($key, $value); } if ($_DOCMAN->saveConfig()) { if ($max < $docmanMax) { $mainframe->redirect("index.php?option=com_docman§ion=config", _DML_CONFIG_WARNING . DOCMAN_UTILS::number2text($max)); } else { $section = $task == 'apply' ? '§ion=config' : ''; $mainframe->redirect('index.php?option=com_docman' . $section, _DML_CONFIG_UPDATED); } } else { $mainframe->redirect("index.php?option=com_docman§ion=config", _DML_CONFIG_ERROR); } }
/** * Calculate the maximum upload size from php.ini * * @return int */ public static function getMaxUploadSize() { $sysUploadMax = DOCMAN_Utils::text2number(ini_get('upload_max_filesize')); $sysPostMax = DOCMAN_Utils::text2number(ini_get('post_max_size')); return min($sysUploadMax, $sysPostMax); }