MDL-15402 finally we decided that the repository activation will be done with capabilities, and that there is no need to have a administration page for enable/disable repository, neither sort, neither settings. In administration we will just be able to setup an instance for Moodle context.

This commit is contained in:
jerome
2008-08-06 03:30:55 +00:00
parent e1f2936860
commit dc633c9900
6 changed files with 0 additions and 318 deletions
-153
View File
@@ -4297,159 +4297,6 @@ class admin_setting_manageportfolio extends admin_setting {
}
/**
* Special class for repositories administration.
*/
class admin_setting_managerepositories extends admin_setting {
function admin_setting_managerepositories() {
parent::admin_setting('repositoriessui', get_string('repsettings', 'admin'), '', '');
}
function get_setting() {
return true;
}
function get_defaultsetting() {
return true;
}
function write_setting($data) {
// do not write any setting
return '';
}
function output_html($data, $query='') {
global $CFG;
$strname = get_string('name');
$strhide = get_string('disable');
$strshow = get_string('enable');
$strhideshow = "$strhide/$strshow";
$strsettings = get_string('settings');
$strup = get_string('up');
$strdown = get_string('down');
$strupdown = "$strup/$strdown";
// get a list of possible repositories (and translate name if possible)
// note repositories are in the dedicated repositories area
$installedrepositories = array();
$repsettings = array();
$replocations = array('repository');
foreach ($replocations as $replocation) {
$plugins = get_list_of_plugins($replocation);
foreach ($plugins as $plugin) {
$pluginpath = "$CFG->dirroot/$replocation/$plugin/repository.class.php";
$settingspath_new = "$CFG->dirroot/$replocation/$plugin/pluginsettings.php";
if (is_readable($pluginpath)) {
$name = trim(get_string("repositoryname", "repository_$plugin",null,"$CFG->dirroot/$replocation/$plugin/lang/"));
if (empty($name) or ($name == '[[repositoryname]]')) {
$textlib = textlib_get_instance();
$name = $textlib->strtotitle($plugin);
}
$installedrepositories["$replocation/$plugin"] = $name;
if (is_readable($settingspath_new)) {
$repsettings[] = "$replocation/$plugin";
}
}
}
}
// get all the currently selected repositories
if (!empty($CFG->textfilters)) {
$oldactiverepositories = explode(',', $CFG->textfilters);
$oldactiverepositories = array_unique($oldactiverepositories);
} else {
$oldactiverepositories = array();
}
// take this opportunity to clean up repositories
$activerepositories = array();
foreach ($oldactiverepositories as $oldactiverepository) {
if (!empty($oldactiverepository) and array_key_exists($oldactiverepository, $installedrepositories)) {
$activerepositories[] = $oldactiverepository;
}
}
// construct the display array with installed repositories
// at the top in the right order
$displayrepositories = array();
foreach ($activerepositories as $activerepository) {
$name = $installedrepositories[$activerepository];
$displayrepositories[$activerepository] = $name;
}
foreach ($installedrepositories as $key => $repository) {
if (!array_key_exists($key, $displayrepositories)) {
$displayrepositories[$key] = $repository;
}
}
$return = print_heading(get_string('activaterep', 'repository'), '', 3, 'main', true);
$return .= print_box_start('generalbox repositoriesui', '', true);
$table = new object();
$table->head = array($strname, $strhideshow, $strupdown, $strsettings);
$table->align = array('left', 'center', 'center', 'center');
$table->width = '90%';
$table->data = array();
$repsurl = "$CFG->wwwroot/$CFG->admin/repositories.php?sesskey=".sesskey();
$imgurl = "$CFG->pixpath/t";
// iterate through repositories adding to display table
$updowncount = 1;
$activerepositoriescount = count($activerepositories);
foreach ($displayrepositories as $path => $name) {
$upath = urlencode($path);
// get hide/show link
if (in_array($path, $activerepositories)) {
$hideshow = "<a href=\"$repsurl&amp;action=hide&amp;filterpath=$upath\">";
$hideshow .= "<img src=\"{$CFG->pixpath}/i/hide.gif\" class=\"icon\" alt=\"$strhide\" /></a>";
$hidden = false;
$displayname = "<span>$name</span>";
}
else {
$hideshow = "<a href=\"$repsurl&amp;action=show&amp;filterpath=$upath\">";
$hideshow .= "<img src=\"{$CFG->pixpath}/i/show.gif\" class=\"icon\" alt=\"$strshow\" /></a>";
$hidden = true;
$displayname = "<span class=\"dimmed_text\">$name</span>";
}
// get up/down link (only if not hidden)
$updown = '';
if (!$hidden) {
if ($updowncount>1) {
$updown .= "<a href=\"$repsurl&amp;action=up&amp;filterpath=$upath\">";
$updown .= "<img src=\"$imgurl/up.gif\" alt=\"$strup\" /></a>&nbsp;";
}
else {
$updown .= "<img src=\"$CFG->pixpath/spacer.gif\" class=\"icon\" alt=\"\" />&nbsp;";
}
if ($updowncount<$activerepositoriescount) {
$updown .= "<a href=\"$repsurl&amp;action=down&amp;filterpath=$upath\">";
$updown .= "<img src=\"$imgurl/down.gif\" alt=\"$strdown\" /></a>";
}
else {
$updown .= "<img src=\"$CFG->pixpath/spacer.gif\" class=\"icon\" alt=\"\" />";
}
++$updowncount;
}
// settings link (if defined)
$settings = '';
if (in_array($path, $repsettings)) {
$settings = "<a href=\"settings.php?section=version".str_replace('/', '',$path)."\">$strsettings</a>";
}
// write data into the table object
$table->data[] = array($displayname, $hideshow, $updown, $settings);
}
$return .= print_table($table, true);
$return .= get_string('tablenosave', 'filters');
$return .= print_box_end(true);
return highlight($query, $return);
}
}
/**
* Initialise admin page - this function does require login and permission