mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
MDL-15402: remove has_admin_config() and has_instance_config() from repository lib and all repository plugins
This commit is contained in:
parent
1d66f2b20e
commit
06e65e1e67
@ -52,11 +52,18 @@ if (!empty($edit) || !empty($new)) {
|
||||
// display the edit form for this instance
|
||||
$mform = new repository_admin_form('', array('plugin' => $plugin, 'instance' => $repositorytype));
|
||||
$fromform = $mform->get_data();
|
||||
|
||||
//detect if we create a new type without config (in this case if don't want to display a setting page during creation)
|
||||
$createnewtype = false;
|
||||
if (!empty($new)) {
|
||||
$adminconfignames = repository_static_function($new, 'get_admin_option_names');
|
||||
$createnewtype = empty($adminconfignames);
|
||||
}
|
||||
// end setup, begin output
|
||||
if ($mform->is_cancelled()){
|
||||
redirect($baseurl);
|
||||
exit;
|
||||
} else if (!empty($fromform) || (!empty($new) && !repository_static_function($new,"has_admin_config"))){
|
||||
} else if (!empty($fromform) || $createnewtype){
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', '', $baseurl);
|
||||
}
|
||||
@ -91,8 +98,7 @@ if (!empty($edit) || !empty($new)) {
|
||||
|
||||
//display instances list and creation form
|
||||
if ($edit){
|
||||
if (repository_static_function($edit,"has_instance_config")
|
||||
|| repository_static_function($edit,"has_multiple_instances")){
|
||||
if (repository_static_function($edit,"has_multiple_instances")){
|
||||
repository_display_instances_list(get_context_instance(CONTEXT_SYSTEM), $edit);
|
||||
}
|
||||
}
|
||||
|
@ -231,9 +231,9 @@ if ($hassiteconfig || has_capability('moodle/question:config', $systemcontext))
|
||||
foreach (repository_get_types()
|
||||
as $repositorytype)
|
||||
{
|
||||
//display setup page for plugins with: general options or instance options or multiple instances
|
||||
if (repository_static_function($repositorytype->get_typename(), 'has_admin_config')
|
||||
|| repository_static_function($repositorytype->get_typename(), 'has_instance_config')
|
||||
//display setup page for plugins with: general options or multiple instances
|
||||
$adminconfignames = repository_static_function($repositorytype->get_typename(), 'get_admin_option_names');
|
||||
if (!empty($adminconfignames)
|
||||
|| repository_static_function($repositorytype->get_typename(), 'has_multiple_instances')) {
|
||||
$ADMIN->add('repositorysettings',
|
||||
new admin_externalpage('repositorysettings'.$repositorytype->get_typename(),
|
||||
|
@ -6154,9 +6154,9 @@ class admin_setting_managerepository extends admin_setting {
|
||||
$updowncount=1;
|
||||
foreach ($instances as $i) {
|
||||
$settings = '';
|
||||
//display edit link only if you can config the type or its instances
|
||||
if ( repository_static_function($i->get_typename(), 'has_admin_config')
|
||||
|| repository_static_function($i->get_typename(), 'has_instance_config')
|
||||
//display edit link only if you can config the type or if it has multiple instances
|
||||
$adminconfignames = repository_static_function($i->get_typename(), 'get_admin_option_names');
|
||||
if ( !empty($adminconfignames)
|
||||
|| repository_static_function($i->get_typename(), 'has_multiple_instances')) {
|
||||
$settings .= '<a href="' . $this->baseurl . '&edit=' . $i->get_typename() . '">'
|
||||
. $settingsstr .'</a>' . "\n";
|
||||
|
@ -157,14 +157,6 @@ class repository_boxnet extends repository {
|
||||
}
|
||||
}
|
||||
|
||||
public static function has_admin_config() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function has_instance_config() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function has_multiple_instances() {
|
||||
return false;
|
||||
}
|
||||
|
@ -1,66 +0,0 @@
|
||||
<?php //$Id$
|
||||
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
require_once(dirname(dirname(__FILE__)) . '/lib.php');
|
||||
require_once(dirname(__FILE__) . '/repository.class.php');
|
||||
|
||||
$repositoryid = optional_param('id', 1, PARAM_INT);
|
||||
$config = optional_param('config', 1, PARAM_INT);
|
||||
$course = optional_param('course', SITEID, PARAM_INT);
|
||||
if (! $course = $DB->get_record("course", array("id"=>$course))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
$user = $USER;
|
||||
$fullname = fullname($user);
|
||||
$strplugin = get_string('repositoryname', 'repository_boxnet');
|
||||
$returnurl = $CFG->wwwroot.'/repository/boxnet/settings.php?id='.$repositoryid;
|
||||
|
||||
require_login($course, false);
|
||||
|
||||
class boxnet_user_form extends moodleform {
|
||||
private $repositoryid;
|
||||
private $userid;
|
||||
public function definition() {
|
||||
global $CFG;
|
||||
$box = new repository_boxnet($this->_customdata['repositoryid']);
|
||||
$ret = $box->get_login();
|
||||
$mform =& $this->_form;
|
||||
$mform->addElement('text', 'name', get_string('username', 'repository_boxnet'), array('size'=>'30', 'value'=>$ret->username));
|
||||
$mform->addElement('passwordunmask', 'passwd', get_string('password', 'repository_boxnet'), array('size'=>'30', 'value'=>$ret->password));
|
||||
$mform->addElement('hidden', 'id', $this->_customdata['repositoryid']);
|
||||
$mform->addElement('hidden', 'user', $this->_customdata['userid']);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
$this->add_action_buttons(true, get_string('savechanges'));
|
||||
}
|
||||
}
|
||||
|
||||
$navlinks[] = array('name' => $fullname, 'link' => $CFG->wwwroot . '/user/view.php?id=' . $user->id, 'type' => 'misc');
|
||||
$navlinks[] = array('name' => get_string('repository', 'repository'), 'link' => $CFG->wwwroot . '/user/repository.php', 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $strplugin, 'link' => null, 'type' => 'misc');
|
||||
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
print_header("$course->fullname: $fullname: $strplugin", $course->fullname,
|
||||
$navigation, "", "", true, " ", navmenu($course));
|
||||
|
||||
$instance = repository_get_instance($repositoryid);
|
||||
$mform = new boxnet_user_form('', array('repositoryid' => $repositoryid, 'userid' => $user->id));
|
||||
$box = new repository_boxnet();
|
||||
if ($data = data_submitted()){
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', '', $baseurl);
|
||||
}
|
||||
$box = new repository_boxnet($repositoryid);
|
||||
$ret = $box->store_login($data->name, $data->passwd, $user->id);
|
||||
if ($ret) {
|
||||
redirect($returnurl, get_string('saved', 'repository_boxnet'));
|
||||
} else {
|
||||
print_error('cannotsave', 'repository_boxnet', $returnurl);
|
||||
}
|
||||
exit;
|
||||
} else {
|
||||
print_heading(get_string('configplugin', 'repository_boxnet'));
|
||||
print_simple_box_start();
|
||||
$mform->display();
|
||||
print_simple_box_end();
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
/// Code fragment to define the version of repository plug-in (box.net)
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$plugin->name = "Box.net Repository";
|
||||
$plugin->version = 2008062701; // The current plug-in version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2007101509; // The current plug-in version (Date: YYYYMMDDXX)
|
||||
$plugin->cron = 3600; // Period for cron to check this plug-in (secs)
|
||||
|
||||
?>
|
@ -174,18 +174,11 @@ class repository_flickr extends repository {
|
||||
));
|
||||
return $dir.$file;
|
||||
}
|
||||
public static function has_admin_config() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function has_multiple_instances() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function has_instance_config() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function instance_config_form(&$mform) {
|
||||
$mform->addElement('text', 'email_address', get_string('emailaddress', 'repository_flickr'));
|
||||
$mform->addRule('email_address', get_string('required'), 'required', null, 'client');
|
||||
@ -208,16 +201,6 @@ class repository_flickr extends repository {
|
||||
if (empty($secret)) {
|
||||
$secret = '';
|
||||
}
|
||||
/*
|
||||
$noticetext = get_string('notice', 'repository_flickr');
|
||||
//$noticetext = 'a[';
|
||||
//var_dump($noticetext);
|
||||
if (strpos($noticetext, '[')==0) {
|
||||
$mform->addElement('static', 'notice', '<strong>'.get_string('notice', 'repository').'</strong>', '<i>'.$noticetext.'</i>');
|
||||
}
|
||||
* */
|
||||
|
||||
|
||||
|
||||
$strrequired = get_string('required');
|
||||
$mform->addElement('text', 'api_key', get_string('apikey', 'repository_flickr'), array('value'=>$api_key,'size' => '40'));
|
||||
|
@ -168,18 +168,11 @@ class repository_flickr_public extends repository {
|
||||
|
||||
return $dir.$file;
|
||||
}
|
||||
public static function has_admin_config() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function has_multiple_instances() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function has_instance_config() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function instance_config_form(&$mform) {
|
||||
$mform->addElement('text', 'email_address', get_string('emailaddress', 'repository_flickr_public'));
|
||||
$mform->addRule('email_address', get_string('required'), 'required', null, 'client');
|
||||
|
@ -113,9 +113,9 @@ class repository_type {
|
||||
|
||||
//set options attribut
|
||||
$this->_options = array();
|
||||
$options = repository_static_function($typename,'get_admin_option_names');
|
||||
//check that the type can be setup
|
||||
if (repository_static_function($typename,"has_admin_config")) {
|
||||
$options = repository_static_function($typename,'get_admin_option_names');
|
||||
if (!empty($options)) {
|
||||
//set the type options
|
||||
foreach ($options as $config) {
|
||||
if (array_key_exists($config,$typeoptions)) {
|
||||
@ -198,11 +198,10 @@ class repository_type {
|
||||
//save the options in DB
|
||||
$this->update_options();
|
||||
|
||||
//if the plugin type has no multiple and no instance config so it wont
|
||||
//if the plugin type has no multiple so it wont
|
||||
//be possible for the administrator to create a instance
|
||||
//in this case we need to create an instance
|
||||
if (!repository_static_function($this->_typename,"has_instance_config")
|
||||
&& !repository_static_function($this->_typename,"has_multiple_instances")) {
|
||||
if (!repository_static_function($this->_typename,"has_multiple_instances")) {
|
||||
$instanceoptions = array();
|
||||
$instanceoptions['name'] = $this->_typename;
|
||||
repository_static_function($this->_typename, 'create', $this->_typename, 0, get_system_context(), $instanceoptions);
|
||||
@ -643,7 +642,7 @@ abstract class repository {
|
||||
$record->userid = $userid;
|
||||
$id = $DB->insert_record('repository_instances', $record);
|
||||
$options = array();
|
||||
if (call_user_func($classname . '::has_instance_config')) {
|
||||
if (call_user_func($classname . '::has_multiple_instances')) {
|
||||
$configs = call_user_func($classname . '::get_instance_option_names');
|
||||
foreach ($configs as $config) {
|
||||
$options[$config] = $params[$config];
|
||||
@ -914,26 +913,18 @@ abstract class repository {
|
||||
|
||||
}
|
||||
|
||||
public static function add_unremovable_instances(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the plugin type has at least one general option field
|
||||
* By default: false
|
||||
* @return boolean
|
||||
* Edit/Create Admin Settings Moodle form
|
||||
* @param object $ Moodle form (passed by reference)
|
||||
*/
|
||||
public static function has_admin_config() {
|
||||
return false;
|
||||
public function admin_config_form(&$mform) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if a plugin instance has at least one config field
|
||||
* By default: false
|
||||
* @return boolean
|
||||
|
||||
/**
|
||||
* Edit/Create Instance Settings Moodle form
|
||||
* @param object $ Moodle form (passed by reference)
|
||||
*/
|
||||
public static function has_instance_config() {
|
||||
return false;
|
||||
public function instance_config_form(&$mform) {
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1269,15 +1260,13 @@ final class repository_instance_form extends moodleform {
|
||||
$mform->addElement('text', 'name', get_string('name'), 'maxlength="100" size="30"');
|
||||
$mform->addRule('name', $strrequired, 'required', null, 'client');
|
||||
|
||||
// let the plugin add the fields they want (either statically or not)
|
||||
if (repository_static_function($this->plugin, 'has_instance_config')) {
|
||||
if (!$this->instance) {
|
||||
$result = repository_static_function($this->plugin, 'instance_config_form', $mform);
|
||||
} else {
|
||||
$result = $this->instance->instance_config_form($mform);
|
||||
}
|
||||
//add fields
|
||||
if (!$this->instance) {
|
||||
$result = repository_static_function($this->plugin, 'instance_config_form', $mform);
|
||||
} else {
|
||||
$result = $this->instance->instance_config_form($mform);
|
||||
}
|
||||
|
||||
|
||||
// and set the data if we have some.
|
||||
if ($this->instance) {
|
||||
$data = array();
|
||||
@ -1347,14 +1336,12 @@ final class repository_admin_form extends moodleform {
|
||||
$mform->addElement('hidden', 'edit', ($this->instance) ? $this->instance->get_typename() : 0);
|
||||
$mform->addElement('hidden', 'new', $this->plugin);
|
||||
$mform->addElement('hidden', 'plugin', $this->plugin);
|
||||
// let the plugin add the fields they want (either statically or not)
|
||||
if (repository_static_function($this->plugin, 'has_admin_config')) {
|
||||
if (!$this->instance) {
|
||||
// let the plugin add its specific fields
|
||||
if (!$this->instance) {
|
||||
$result = repository_static_function($this->plugin, 'admin_config_form', $mform);
|
||||
} else {
|
||||
$classname = 'repository_' . $this->instance->get_typename();
|
||||
$result = call_user_func(array($classname,'admin_config_form'),$mform);
|
||||
}
|
||||
}
|
||||
|
||||
// and set the data if we have some.
|
||||
|
Loading…
x
Reference in New Issue
Block a user