Exemplo n.º 1
0
    //== Portfolio settings ==
    require_once($CFG->libdir. '/portfoliolib.php');
    $catname = get_string('portfolios', 'portfolio');
    $manage = get_string('manageportfolios', 'portfolio');
    $url = "$CFG->wwwroot/$CFG->admin/portfolio.php";

    $ADMIN->add('modules', new admin_category('portfoliosettings', $catname, empty($CFG->enableportfolios)));

    // Add manage page (with table)
    $temp = new admin_page_manageportfolios();
    $ADMIN->add('portfoliosettings', $temp);

    // Add common settings page
    $temp = new admin_settingpage('manageportfolioscommon', get_string('commonportfoliosettings', 'portfolio'));
    $temp->add(new admin_setting_heading('manageportfolioscommon', '', get_string('commonsettingsdesc', 'portfolio')));
    $fileinfo = portfolio_filesize_info(); // make sure this is defined in one place since its used inside portfolio too to detect insane settings
    $fileoptions = $fileinfo['options'];
    $temp->add(new admin_setting_configselect(
        'portfolio_moderate_filesize_threshold',
        get_string('moderatefilesizethreshold', 'portfolio'),
        get_string('moderatefilesizethresholddesc', 'portfolio'),
        $fileinfo['moderate'], $fileoptions));
    $temp->add(new admin_setting_configselect(
        'portfolio_high_filesize_threshold',
        get_string('highfilesizethreshold', 'portfolio'),
        get_string('highfilesizethresholddesc', 'portfolio'),
        $fileinfo['high'], $fileoptions));

    $temp->add(new admin_setting_configtext(
        'portfolio_moderate_db_threshold',
        get_string('moderatedbsizethreshold', 'portfolio'),
Exemplo n.º 2
0
         if ($ADMIN->fulltree) {
             include "{$CFG->dirroot}/{$filterpath}/filtersettings.php";
         }
         $ADMIN->add('filtersettings', $settings);
     }
 }
 $catname = get_string('portfolios', 'portfolio');
 $manage = get_string('manageportfolios', 'portfolio');
 $url = "{$CFG->wwwroot}/{$CFG->admin}/portfolio.php";
 $ADMIN->add('modules', new admin_category('portfoliosettings', $catname, empty($CFG->enableportfolios)));
 // jump through hoops to do what we want
 $temp = new admin_settingpage('manageportfolios', get_string('manageportfolios', 'portfolio'));
 $temp->add(new admin_setting_heading('manageportfolios', get_string('activeportfolios', 'portfolio'), ''));
 $temp->add(new admin_setting_manageportfolio());
 $temp->add(new admin_setting_heading('manageportfolioscommon', get_string('commonsettings', 'admin'), get_string('commonsettingsdesc', 'portfolio')));
 $fileinfo = portfolio_filesize_info();
 // make sure this is defined in one place since its used inside portfolio too to detect insane settings
 $fileoptions = $fileinfo['options'];
 $temp->add(new admin_setting_configselect('portfolio_moderate_filesize_threshold', get_string('moderatefilesizethreshold', 'portfolio'), get_string('moderatefilesizethresholddesc', 'portfolio'), $fileinfo['moderate'], $fileoptions));
 $temp->add(new admin_setting_configselect('portfolio_high_filesize_threshold', get_string('highfilesizethreshold', 'portfolio'), get_string('highfilesizethresholddesc', 'portfolio'), $fileinfo['high'], $fileoptions));
 $temp->add(new admin_setting_configtext('portfolio_moderate_db_threshold', get_string('moderatedbsizethreshold', 'portfolio'), get_string('moderatedbsizethresholddesc', 'portfolio'), 20, PARAM_INTEGER, 3));
 $temp->add(new admin_setting_configtext('portfolio_high_db_threshold', get_string('highdbsizethreshold', 'portfolio'), get_string('highdbsizethresholddesc', 'portfolio'), 50, PARAM_INTEGER, 3));
 $ADMIN->add('portfoliosettings', $temp);
 $ADMIN->add('portfoliosettings', new admin_externalpage('portfolionew', get_string('addnewportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliodelete', get_string('deleteportfolio', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
 $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliocontroller', get_string('manageportfolios', 'portfolio'), $url, 'moodle/site:config', true), '', $url);
 foreach (portfolio_instances(false, false) as $portfolio) {
     require_once $CFG->dirroot . '/portfolio/type/' . $portfolio->get('plugin') . '/lib.php';
     $classname = 'portfolio_plugin_' . $portfolio->get('plugin');
     $ADMIN->add('portfoliosettings', new admin_externalpage('portfoliosettings' . $portfolio->get('id'), $portfolio->get('name'), $url . '?edit=' . $portfolio->get('id'), 'moodle/site:config', !$portfolio->get('visible')), $portfolio->get('name'), $url . ' ?edit=' . $portfolio->get('id'));
 }
/**
* try and determine expected_time for purely file based exports
* or exports that might include large file attachments.
*
 * @global object
* @param mixed $totest - either an array of stored_file objects or a single stored_file object
* @return constant PORTFOLIO_TIME_XXX
*/
function portfolio_expected_time_file($totest)
{
    global $CFG;
    if ($totest instanceof stored_file) {
        $totest = array($totest);
    }
    $size = 0;
    foreach ($totest as $file) {
        if (!$file instanceof stored_file) {
            debugging('something weird passed to portfolio_expected_time_file - not stored_file object');
            debugging(print_r($file, true));
            continue;
        }
        $size += $file->get_filesize();
    }
    $fileinfo = portfolio_filesize_info();
    $moderate = $high = 0;
    // avoid warnings
    foreach (array('moderate', 'high') as $setting) {
        $settingname = 'portfolio_' . $setting . '_filesize_threshold';
        if (empty($CFG->{$settingname}) || !array_key_exists($CFG->{$settingname}, $fileinfo['options'])) {
            debugging("weird or unset admin value for {$settingname}, using default instead");
            ${$setting} = $fileinfo[$setting];
        } else {
            ${$setting} = $CFG->{$settingname};
        }
    }
    if ($size < $moderate) {
        return PORTFOLIO_TIME_LOW;
    } else {
        if ($size < $high) {
            return PORTFOLIO_TIME_MODERATE;
        }
    }
    return PORTFOLIO_TIME_HIGH;
}