mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-15865 - admin portfolio settings are now a settingspage rather than an admin page.
This commit is contained in:
parent
f94988555e
commit
a50ef3d34f
5 changed files with 164 additions and 81 deletions
|
@ -4,7 +4,6 @@ require_once(dirname(dirname(__FILE__)) . '/config.php');
|
||||||
require_once($CFG->libdir . '/portfoliolib.php');
|
require_once($CFG->libdir . '/portfoliolib.php');
|
||||||
require_once($CFG->libdir . '/adminlib.php');
|
require_once($CFG->libdir . '/adminlib.php');
|
||||||
|
|
||||||
admin_externalpage_setup('portfoliosettingsall');
|
|
||||||
|
|
||||||
$CFG->pagepath = 'admin/manageportfolio';
|
$CFG->pagepath = 'admin/manageportfolio';
|
||||||
|
|
||||||
|
@ -16,13 +15,25 @@ $sure = optional_param('sure', '', PARAM_ALPHA);
|
||||||
|
|
||||||
$display = true; // fall through to normal display
|
$display = true; // fall through to normal display
|
||||||
|
|
||||||
|
$pagename = 'portfoliocontroller';
|
||||||
|
|
||||||
|
if ($edit) {
|
||||||
|
$pagename = 'portfoliosettings' . $edit;
|
||||||
|
} else if ($delete) {
|
||||||
|
$pagename = 'portfoliodelete';
|
||||||
|
} else if ($new) {
|
||||||
|
$pagename = 'portfolionew';
|
||||||
|
}
|
||||||
|
admin_externalpage_setup($pagename);
|
||||||
require_login(SITEID, false);
|
require_login(SITEID, false);
|
||||||
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
|
||||||
|
|
||||||
$baseurl = $CFG->wwwroot . '/' . $CFG->admin . '/portfolio.php';
|
$baseurl = $CFG->wwwroot . '/admin/settings.php?section=manageportfolios';
|
||||||
$sesskeyurl = $CFG->wwwroot . '/' . $CFG->admin . '/portfolio.php?sesskey=' . sesskey();
|
$sesskeyurl = $CFG->wwwroot . '/' . $CFG->admin . '/portfolio.php?sesskey=' . sesskey();
|
||||||
$configstr = get_string('manageportfolios', 'portfolio');
|
$configstr = get_string('manageportfolios', 'portfolio');
|
||||||
|
|
||||||
|
$return = true; // direct back to the main page
|
||||||
|
|
||||||
if (!empty($edit) || !empty($new)) {
|
if (!empty($edit) || !empty($new)) {
|
||||||
if (!empty($edit)) {
|
if (!empty($edit)) {
|
||||||
$instance = portfolio_instance($edit);
|
$instance = portfolio_instance($edit);
|
||||||
|
@ -52,6 +63,7 @@ if (!empty($edit) || !empty($new)) {
|
||||||
}
|
}
|
||||||
if ($success) {
|
if ($success) {
|
||||||
$savedstr = get_string('instancesaved', 'portfolio');
|
$savedstr = get_string('instancesaved', 'portfolio');
|
||||||
|
admin_externalpage_print_header();
|
||||||
print_heading($savedstr);
|
print_heading($savedstr);
|
||||||
redirect($baseurl, $savedstr, 3);
|
redirect($baseurl, $savedstr, 3);
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,7 +76,7 @@ if (!empty($edit) || !empty($new)) {
|
||||||
print_simple_box_start();
|
print_simple_box_start();
|
||||||
$mform->display();
|
$mform->display();
|
||||||
print_simple_box_end();
|
print_simple_box_end();
|
||||||
$display = false;
|
$return = false;
|
||||||
}
|
}
|
||||||
} else if (!empty($hide)) {
|
} else if (!empty($hide)) {
|
||||||
if (!confirm_sesskey()) {
|
if (!confirm_sesskey()) {
|
||||||
|
@ -77,6 +89,7 @@ if (!empty($edit) || !empty($new)) {
|
||||||
}
|
}
|
||||||
$instance->set('visible', !$instance->get('visible'));
|
$instance->set('visible', !$instance->get('visible'));
|
||||||
$instance->save();
|
$instance->save();
|
||||||
|
$return = true;
|
||||||
} else if (!empty($delete)) {
|
} else if (!empty($delete)) {
|
||||||
admin_externalpage_print_header();
|
admin_externalpage_print_header();
|
||||||
$instance = portfolio_instance($delete);
|
$instance = portfolio_instance($delete);
|
||||||
|
@ -94,66 +107,13 @@ if (!empty($edit) || !empty($new)) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
notice_yesno(get_string('sure', 'portfolio', $instance->get('name')), $sesskeyurl . '&delete=' . $delete . '&sure=yes', $baseurl);
|
notice_yesno(get_string('sure', 'portfolio', $instance->get('name')), $sesskeyurl . '&delete=' . $delete . '&sure=yes', $baseurl);
|
||||||
$display = false;
|
$return = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// normal display. fall through to here (don't call exit) if you want this to run
|
|
||||||
if ($display) {
|
|
||||||
admin_externalpage_print_header();
|
|
||||||
print_heading($configstr);
|
|
||||||
print_simple_box_start();
|
|
||||||
|
|
||||||
$namestr = get_string('name');
|
if (!empty($return)) {
|
||||||
$pluginstr = get_string('plugin', 'portfolio');
|
// normal display. fall through to here (don't call exit) if you want this to run
|
||||||
|
redirect($baseurl);
|
||||||
$plugins = get_list_of_plugins('portfolio/type');
|
|
||||||
$instances = portfolio_instances(false, false);
|
|
||||||
$alreadyplugins = array();
|
|
||||||
|
|
||||||
$insane = portfolio_plugin_sanity_check($plugins);
|
|
||||||
$insaneinstances = portfolio_instance_sanity_check($instances);
|
|
||||||
|
|
||||||
portfolio_report_insane($insane);
|
|
||||||
portfolio_report_insane($insaneinstances, $instances);
|
|
||||||
|
|
||||||
$table = new StdClass;
|
|
||||||
$table->head = array($namestr, $pluginstr, '');
|
|
||||||
$table->data = array();
|
|
||||||
|
|
||||||
foreach ($instances as $i) {
|
|
||||||
$row = '<a href="' . $sesskeyurl . '&edit=' . $i->get('id') . '"><img src="' . $CFG->pixpath . '/t/edit.gif" alt="' . get_string('edit') . '" /></a>
|
|
||||||
<a href="' . $sesskeyurl . '&delete=' . $i->get('id') . '"><img src="' . $CFG->pixpath . '/t/delete.gif" alt="' . get_string('delete') . '" /></a>';
|
|
||||||
if (array_key_exists($i->get('plugin'), $insane) || array_key_exists($i->get('id'), $insaneinstances)) {
|
|
||||||
$row .= '<img src="' . $CFG->pixpath . '/t/show.gif" alt="' . get_string('hidden', 'portfolio') . '" /><br />';
|
|
||||||
} else {
|
|
||||||
$row .= ' <a href="' . $sesskeyurl . '&hide=' . $i->get('id') . '"><img src="' . $CFG->pixpath . '/t/' . ($i->get('visible') ? 'hide' : 'show') . '.gif" alt="' . get_string($i->get('visible') ? 'hide' : 'show') . '" /></a><br />';
|
|
||||||
}
|
|
||||||
$table->data[] = array($i->get('name'), $i->get('plugin'), $row);
|
|
||||||
if (!in_array($i->get('plugin'), $alreadyplugins)) {
|
|
||||||
$alreadyplugins[] = $i->get('plugin');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print_table($table);
|
|
||||||
|
|
||||||
$instancehtml = '<br /><form action="' . $baseurl . '" method="post">' . get_string('addnewportfolio', 'portfolio') . ': <select name="new">';
|
|
||||||
$addable = 0;
|
|
||||||
foreach ($plugins as $p) {
|
|
||||||
if (!portfolio_static_function($p, 'allows_multiple') && in_array($p, $alreadyplugins)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (array_key_exists($p, $insane)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$instancehtml .= '<option value="' . $p . '">' . $p .'</option>' ."\n";
|
|
||||||
$addable++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($addable) {
|
|
||||||
$instancehtml .= '</select><input type="submit" value="' . get_string('add') . '" /></form>';
|
|
||||||
echo $instancehtml;
|
|
||||||
}
|
|
||||||
print_simple_box_end();
|
|
||||||
}
|
}
|
||||||
print_footer();
|
admin_externalpage_print_footer();
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -145,30 +145,33 @@ if ($hassiteconfig) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require_once($CFG->libdir. '/portfoliolib.php');
|
||||||
|
|
||||||
$catname =get_string('portfolios', 'portfolio');
|
$catname =get_string('portfolios', 'portfolio');
|
||||||
$manage = get_string('manageportfolios', 'portfolio');
|
$manage = get_string('manageportfolios', 'portfolio');
|
||||||
$url = "$CFG->wwwroot/$CFG->admin/portfolio.php";
|
$url = "$CFG->wwwroot/$CFG->admin/portfolio.php";
|
||||||
|
|
||||||
$ADMIN->add('modules', new admin_category('portfoliosettings', $catname));
|
$ADMIN->add('modules', new admin_category('portfoliosettings', $catname));
|
||||||
|
|
||||||
$ADMIN->add(
|
// jump through hoops to do what we want
|
||||||
'portfoliosettings',
|
$temp = new admin_settingpage('manageportfolios', get_string('manageportfolios', 'portfolio'));
|
||||||
new admin_externalpage('portfoliosettingsall', $manage, $url),
|
$temp->add(new admin_setting_configcheckbox('portfolioenabled', get_string('enabled', 'portfolio'), get_string('enableddesc', 'portfolio'), true));
|
||||||
$manage,
|
$temp->add(new admin_setting_manageportfolio());
|
||||||
$url
|
|
||||||
);
|
$ADMIN->add('portfoliosettings', $temp);
|
||||||
require_once($CFG->libdir. '/portfoliolib.php');
|
$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() as $portfolio) {
|
foreach (portfolio_instances() as $portfolio) {
|
||||||
require_once($CFG->dirroot . '/portfolio/type/' . $portfolio->get('plugin') . '/lib.php');
|
require_once($CFG->dirroot . '/portfolio/type/' . $portfolio->get('plugin') . '/lib.php');
|
||||||
$classname = 'portfolio_plugin_' . $portfolio->get('plugin');
|
$classname = 'portfolio_plugin_' . $portfolio->get('plugin');
|
||||||
if (call_user_func(array($classname, 'has_admin_config'))) {
|
$ADMIN->add(
|
||||||
$ADMIN->add(
|
'portfoliosettings',
|
||||||
'portfoliosettings',
|
new admin_externalpage('portfoliosettings' . $portfolio->get('id'), get_string('configure', 'portfolio') . ' ' . $portfolio->get('name'), $url . '?edit=' . $portfolio->get('id')),
|
||||||
new admin_externalpage('portfoliosettings' . $portfolio->get('id'), get_string('configure', 'portfolio') . ' ' . $portfolio->get('name'), $url . '?edit=' . $portfolio->get('id')),
|
$portfolio->get('name'),
|
||||||
$portfolio->get('name'),
|
$url . ' ?edit=' . $portfolio->get('id')
|
||||||
$url . ' ?edit=' . $portfolio->get('id')
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -12,8 +12,11 @@ $string['confirmexport'] = 'Please confirm the following export';
|
||||||
$string['confirmsummary'] = 'Summary of your export';
|
$string['confirmsummary'] = 'Summary of your export';
|
||||||
$string['configure'] = 'Configure';
|
$string['configure'] = 'Configure';
|
||||||
$string['continuetoportfolio'] = 'Continue to your portfolio';
|
$string['continuetoportfolio'] = 'Continue to your portfolio';
|
||||||
|
$string['deleteportfolio'] = 'Delete portfolio instance';
|
||||||
$string['dontwait'] = 'Don\'t wait';
|
$string['dontwait'] = 'Don\'t wait';
|
||||||
$string['err_uniquename'] = 'Portfolio name must be unique (per plugin)';
|
$string['err_uniquename'] = 'Portfolio name must be unique (per plugin)';
|
||||||
|
$string['enabled'] = 'Enable portfolios';
|
||||||
|
$string['enableddesc'] = 'This will allow administrators to configure remote systems for users to export content to';
|
||||||
$string['exporting'] = 'Exporting to portfolio';
|
$string['exporting'] = 'Exporting to portfolio';
|
||||||
$string['exportcomplete'] = 'Portfolio export complete!';
|
$string['exportcomplete'] = 'Portfolio export complete!';
|
||||||
$string['failedtosendpackage'] = 'Failed to send your data to the selected portfolio system!';
|
$string['failedtosendpackage'] = 'Failed to send your data to the selected portfolio system!';
|
||||||
|
|
112
lib/adminlib.php
112
lib/adminlib.php
|
@ -4163,6 +4163,118 @@ class admin_setting_managefilters extends admin_setting {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class admin_setting_manageportfolio extends admin_setting {
|
||||||
|
private $baseurl;
|
||||||
|
function admin_setting_manageportfolio() {
|
||||||
|
global $CFG;
|
||||||
|
parent::admin_setting('manageportfolio', get_string('manageportfolio', 'portfolio'), '', '');
|
||||||
|
$this->baseurl = $CFG->wwwroot . '/' . $CFG->admin . '/portfolio.php?sesskey=' . sesskey();
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_setting() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_defaultsetting() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_full_name() {
|
||||||
|
return 's_manageportfolio';
|
||||||
|
}
|
||||||
|
|
||||||
|
function write_setting($data) {
|
||||||
|
$url = $this->baseurl . '&new=' . $data;
|
||||||
|
redirect($url);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_related($query) {
|
||||||
|
if (parent::is_related($query)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$textlib = textlib_get_instance();
|
||||||
|
$portfolios= get_list_of_plugins('portfolio');
|
||||||
|
foreach ($portfolios as $p) {
|
||||||
|
if (strpos($p, $query) !== false) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (portfolio_instances(false, false) as $instance) {
|
||||||
|
$title = $instance->get('name');
|
||||||
|
if (strpos($textlib->strtolower($title), $query) !== false) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function output_html($data, $query='') {
|
||||||
|
global $CFG;
|
||||||
|
|
||||||
|
$output = print_simple_box_start(true);
|
||||||
|
|
||||||
|
$namestr = get_string('name');
|
||||||
|
$pluginstr = get_string('plugin', 'portfolio');
|
||||||
|
|
||||||
|
$plugins = get_list_of_plugins('portfolio/type');
|
||||||
|
$instances = portfolio_instances(false, false);
|
||||||
|
$alreadyplugins = array();
|
||||||
|
|
||||||
|
$insane = portfolio_plugin_sanity_check($plugins);
|
||||||
|
$insaneinstances = portfolio_instance_sanity_check($instances);
|
||||||
|
|
||||||
|
$output .= portfolio_report_insane($insane, null, true);
|
||||||
|
$output .= portfolio_report_insane($insaneinstances, $instances, true);
|
||||||
|
|
||||||
|
$table = new StdClass;
|
||||||
|
$table->head = array($namestr, $pluginstr, '');
|
||||||
|
$table->data = array();
|
||||||
|
|
||||||
|
foreach ($instances as $i) {
|
||||||
|
$row = '';
|
||||||
|
$row .= '<a href="' . $this->baseurl . '&edit=' . $i->get('id') . '"><img src="' . $CFG->pixpath . '/t/edit.gif" alt="' . get_string('edit') . '" /></a>' . "\n";
|
||||||
|
$row .= '<a href="' . $this->baseurl . '&delete=' . $i->get('id') . '"><img src="' . $CFG->pixpath . '/t/delete.gif" alt="' . get_string('delete') . '" /></a>' . "\n";
|
||||||
|
if (array_key_exists($i->get('plugin'), $insane) || array_key_exists($i->get('id'), $insaneinstances)) {
|
||||||
|
$row .= '<img src="' . $CFG->pixpath . '/t/show.gif" alt="' . get_string('hidden', 'portfolio') . '" />' . "\n";
|
||||||
|
} else {
|
||||||
|
$row .= ' <a href="' . $this->baseurl . '&hide=' . $i->get('id') . '"><img src="' . $CFG->pixpath . '/t/'
|
||||||
|
. ($i->get('visible') ? 'hide' : 'show') . '.gif" alt="' . get_string($i->get('visible') ? 'hide' : 'show') . '" /></a>' . "\n";
|
||||||
|
}
|
||||||
|
$table->data[] = array($i->get('name'), $i->get('plugin'), $row);
|
||||||
|
if (!in_array($i->get('plugin'), $alreadyplugins)) {
|
||||||
|
$alreadyplugins[] = $i->get('plugin');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= print_table($table, true);
|
||||||
|
|
||||||
|
//$instancehtml = '<br /><form action="' . $this->baseurl . '" method="post">'
|
||||||
|
$instancehtml = get_string('addnewportfolio', 'portfolio') . ': <select name="s_manageportfolio">';
|
||||||
|
$addable = 0;
|
||||||
|
foreach ($plugins as $p) {
|
||||||
|
if (!portfolio_static_function($p, 'allows_multiple') && in_array($p, $alreadyplugins)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (array_key_exists($p, $insane)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$instancehtml .= '<option value="' . $p . '">' . $p .'</option>' ."\n";
|
||||||
|
$addable++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($addable) {
|
||||||
|
$instancehtml .= '</select><input type="submit" value="' . get_string('add') . '" /></form>';
|
||||||
|
$output .= $instancehtml;
|
||||||
|
}
|
||||||
|
$output .= print_simple_box_end(true);
|
||||||
|
|
||||||
|
return highlight($query, $output);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise admin page - this function does require login and permission
|
* Initialise admin page - this function does require login and permission
|
||||||
* checks specified in page definition.
|
* checks specified in page definition.
|
||||||
|
|
|
@ -283,7 +283,7 @@ function portfolio_instances($visibleonly=true, $useronly=true) {
|
||||||
|
|
||||||
$instances = array();
|
$instances = array();
|
||||||
foreach ($DB->get_records_sql($sql, $values) as $instance) {
|
foreach ($DB->get_records_sql($sql, $values) as $instance) {
|
||||||
$instances[] = portfolio_instance($instance->id, $instance);
|
$instances[$instance->id] = portfolio_instance($instance->id, $instance);
|
||||||
}
|
}
|
||||||
// @todo check capabilities here - see MDL-15768
|
// @todo check capabilities here - see MDL-15768
|
||||||
return $instances;
|
return $instances;
|
||||||
|
@ -438,7 +438,7 @@ function portfolio_instance_sanity_check($instances=null) {
|
||||||
* @param array $instances if reporting instances rather than whole plugins, pass the array (key = id, value = object) here
|
* @param array $instances if reporting instances rather than whole plugins, pass the array (key = id, value = object) here
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function portfolio_report_insane($insane, $instances=false) {
|
function portfolio_report_insane($insane, $instances=false, $return=false) {
|
||||||
if (empty($insane)) {
|
if (empty($insane)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -453,7 +453,7 @@ function portfolio_report_insane($insane, $instances=false) {
|
||||||
$headerstr = get_string('somepluginsdisabled', 'portfolio');
|
$headerstr = get_string('somepluginsdisabled', 'portfolio');
|
||||||
}
|
}
|
||||||
|
|
||||||
notify($headerstr);
|
$output = notify($headerstr, 'notifyproblem', 'center', true);
|
||||||
$table = new StdClass;
|
$table = new StdClass;
|
||||||
$table->head = array($pluginstr, '');
|
$table->head = array($pluginstr, '');
|
||||||
$table->data = array();
|
$table->data = array();
|
||||||
|
@ -471,8 +471,13 @@ function portfolio_report_insane($insane, $instances=false) {
|
||||||
}
|
}
|
||||||
$table->data[] = array($name, get_string($reason, 'portfolio_' . $plugin));
|
$table->data[] = array($name, get_string($reason, 'portfolio_' . $plugin));
|
||||||
}
|
}
|
||||||
print_table($table);
|
$output .= print_table($table, true);
|
||||||
echo '<br /><br /><br />';
|
$output .= '<br /><br /><br />';
|
||||||
|
|
||||||
|
if ($return) {
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
echo $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue