From dc633c99007e79f89664779c41740b8f3df93ed5 Mon Sep 17 00:00:00 2001 From: jerome Date: Wed, 6 Aug 2008 03:30:55 +0000 Subject: [PATCH] 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. --- admin/repositories.php | 102 ------------------ admin/settings/plugins.php | 52 --------- lang/en_utf8/admin.php | 2 - lang/en_utf8/moodle.php | 2 - lib/adminlib.php | 153 --------------------------- repository/boxnet/pluginsettings.php | 7 -- 6 files changed, 318 deletions(-) delete mode 100644 admin/repositories.php delete mode 100644 repository/boxnet/pluginsettings.php diff --git a/admin/repositories.php b/admin/repositories.php deleted file mode 100644 index 45d45060e8..0000000000 --- a/admin/repositories.php +++ /dev/null @@ -1,102 +0,0 @@ -wwwroot/$CFG->admin/settings.php?section=managereps"; - - if (!confirm_sesskey()) { - redirect($returnurl); - } - - // get a list of installed repositories - $installedrepositories = array(); - $repositorylocations = array('repository'); - foreach ($repositorylocations as $repositorylocation) { - $plugins = get_list_of_plugins($repositorylocation); - foreach ($plugins as $plugin) { - $pluginpath = "$CFG->dirroot/$repositorylocation/$plugin/version.php"; - if (is_readable($pluginpath)) { - $installedrepositories["$repositorylocation/$plugin"] = "$repositorylocation/$plugin"; - } - } - } - - // get all the currently selected repositories - if (!empty($CFG->textfilters)) { - $activerepositories = explode(',', $CFG->textfilters); - } else { - $activerepositories = array(); - } - - //====================== - // Process Actions - //====================== - - switch ($action) { - - case 'hide': - $key=array_search($repositorypath, $activerepositories); - // check repositorypath is valid - if ($key===false) { - break; - } - // just delete it - unset($activerepositories[$key]); - break; - - case 'show': - // check repositorypath is valid - if (!array_key_exists($repositorypath, $installedrepositories)) { - print_error('filternotinstalled', 'error', $url, $repositorypath); - } elseif (array_search($repositorypath,$activerepositories)) { - // repositorypath is already active - doubleclick?? - } else { - // add it to installed filters - $activerepositories[] = $repositorypath; - $activerepositories = array_unique($activerepositories); - } - break; - - case 'down': - $key=array_search($repositorypath, $activerepositories); - // check repositorypath is valid - if ($key===false) { - print_error("filternotactive", 'error', $url, $repositorypath ); - } elseif ($key>=(count($activerepositories)-1)) { - // cannot be moved any further down - doubleclick?? - } else { - // swap with $key+1 - $fsave = $activerepositories[$key]; - $activerepositories[$key] = $activerepositories[$key+1]; - $activerepositories[$key+1] = $fsave; - } - break; - - case 'up': - $key=array_search($repositorypath, $activerepositories); - // check repositorypath is valid - if ($key===false) { - print_error("filternotactive", 'error', $url, $repositorypath ); - } elseif ($key<1) { - //cannot be moved any further up - doubleclick?? - } else { - // swap with $key-1 - $fsave = $activerepositories[$key]; - $activerepositories[$key] = $activerepositories[$key-1]; - $activerepositories[$key-1] = $fsave; - } - break; - } - - // save, reset cache and return - set_config('textfilters', implode(',', $activerepositories)); - reset_text_filters_cache(); - redirect($returnurl); - -?> diff --git a/admin/settings/plugins.php b/admin/settings/plugins.php index f36b2fb82c..7b9dc0b022 100644 --- a/admin/settings/plugins.php +++ b/admin/settings/plugins.php @@ -68,58 +68,6 @@ if ($hassiteconfig) { } } - //"Repositories" menu (inside "Site Administration block" > "Modules menu") - $ADMIN->add('modules', new admin_category('repsettings', get_string('repositories'))); - - $temp = new admin_settingpage('managereps', get_string('repsettings', 'admin')); - - if ($ADMIN->fulltree) { - $items = array(); - $items[] = new admin_setting_managerepositories(); - foreach ($items as $item) { - $temp->add($item); - } - } - - $ADMIN->add('repsettings', $temp); - - if (empty($CFG->textfilters)) { - $activerepositories = array(); - } else { - $activerepositories = explode(',', $CFG->textfilters); - } - - $replocations = array('repository'); - foreach ($replocations as $replocation) { - $repositories = get_list_of_plugins($replocation); - - $repbyname = array(); - - foreach ($repositories as $repository) { - $strrepname = get_string('repositoryname', "repository_$repository",null,"$CFG->dirroot/$replocation/$plugin/lang/"); - - if ($strrepname == '[[repositoryname]]') { - $textlib = textlib_get_instance(); - $strrepname = $textlib->strtotitle($repository); - } - $repbyname[$strrepname] = "$replocation/$repository"; - } - ksort($repbyname); - - foreach ($repbyname as $strrepname=>$repositoryfull) { - if (file_exists("$CFG->dirroot/$repositoryfull/pluginsettings.php")) { - - $settings = new admin_settingpage('version'.str_replace('/', '', $repositoryfull), $strrepname, 'moodle/site:config', !in_array($repositoryfull, $activerepositories)); - - if ($ADMIN->fulltree) { - include("$CFG->dirroot/$repositoryfull/pluginsettings.php"); - } - $ADMIN->add('repsettings', $settings); - - } - } - } - //end of admin repositories menu $ADMIN->add('modules', new admin_category('filtersettings', get_string('managefilters'))); // "filtersettings" settingpage diff --git a/lang/en_utf8/admin.php b/lang/en_utf8/admin.php index d8308239b7..2bef5879b3 100644 --- a/lang/en_utf8/admin.php +++ b/lang/en_utf8/admin.php @@ -621,8 +621,6 @@ $string['recaptchaprivatekey'] = 'ReCAPTCHA private key'; $string['releasenoteslink'] = 'For information about this version of Moodle, please see the online Release Notes'; $string['remotelangnotavailable'] = 'Because Moodle can not connect to download.moodle.org, we are unable to do language pack installation automatically. Please download the appropriate zip file(s) from the list below, copy them to your $a directory and unzip them manually.'; $string['renameerrors'] = 'Rename errors'; -$string['repsettings'] = 'Manage Repositories'; -$string['repsettingsgeneral'] = 'General repositories settings'; $string['requiredtemplate'] = 'Required. You may use template syntax here (%%l = lastname, %%f = firstname, %%u = username). See help for details and examples.'; $string['restrictbydefault'] = 'Restrict modules by default'; $string['restrictmodulesfor'] = 'Restrict modules for'; diff --git a/lang/en_utf8/moodle.php b/lang/en_utf8/moodle.php index 00e7856302..ae2c774a90 100644 --- a/lang/en_utf8/moodle.php +++ b/lang/en_utf8/moodle.php @@ -1251,8 +1251,6 @@ $string['rename'] = 'Rename'; $string['renamefileto'] = 'Rename $a to'; $string['report'] = 'Report'; $string['reports'] = 'Reports'; -$string['repositories'] = 'Repositories'; -$string['repositoriesmanage'] = 'Manage Repositories'; $string['requestcourse'] = 'Request a course'; $string['requestedby'] = 'Requested by'; $string['requestreason'] = 'Reason for course request'; diff --git a/lib/adminlib.php b/lib/adminlib.php index 3b895bd27a..5a8bbb1dcd 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -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 = ""; - $hideshow .= "pixpath}/i/hide.gif\" class=\"icon\" alt=\"$strhide\" />"; - $hidden = false; - $displayname = "$name"; - } - else { - $hideshow = ""; - $hideshow .= "pixpath}/i/show.gif\" class=\"icon\" alt=\"$strshow\" />"; - $hidden = true; - $displayname = "$name"; - } - - // get up/down link (only if not hidden) - $updown = ''; - if (!$hidden) { - if ($updowncount>1) { - $updown .= ""; - $updown .= "\"$strup\" "; - } - else { - $updown .= "pixpath/spacer.gif\" class=\"icon\" alt=\"\" /> "; - } - if ($updowncount<$activerepositoriescount) { - $updown .= ""; - $updown .= "\"$strdown\""; - } - else { - $updown .= "pixpath/spacer.gif\" class=\"icon\" alt=\"\" />"; - } - ++$updowncount; - } - - // settings link (if defined) - $settings = ''; - if (in_array($path, $repsettings)) { - $settings = "$strsettings"; - } - - // 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 diff --git a/repository/boxnet/pluginsettings.php b/repository/boxnet/pluginsettings.php deleted file mode 100644 index 1e572a4044..0000000000 --- a/repository/boxnet/pluginsettings.php +++ /dev/null @@ -1,7 +0,0 @@ -add(new admin_setting_configtext('repository_boxnet', "Mock setting example", - '
', '')); - - -?> -- 2.39.5