$CFG->pagepath = 'admin/managerepositories';
-$edit = optional_param('edit', 0, PARAM_ALPHANUM);
+$edit = optional_param('edit', 0, PARAM_FORMAT);
$new = optional_param('new', '', PARAM_FORMAT);
-$hide = optional_param('hide', '', PARAM_ALPHANUM);
-$delete = optional_param('delete', 0, PARAM_ALPHANUM);
+$hide = optional_param('hide', '', PARAM_FORMAT);
+$delete = optional_param('delete', 0, PARAM_FORMAT);
$sure = optional_param('sure', '', PARAM_ALPHA);
$move = optional_param('move', '', PARAM_ALPHANUM);
$type = optional_param('type', '', PARAM_ALPHANUM);
if (!confirm_sesskey()) {
print_error('confirmsesskeybad', '', $baseurl);
}
- var_dump($hide);
$repositorytype = repository::get_type_by_typename($hide);
+ if (empty($repositorytype)) {
+ print_error('invalidplugin', 'repository');
+
+ }
$repositorytype->switch_and_update_visibility();
$return = true;
} else if (!empty($delete)) {
$string['back'] = '< Back';
$string['cacheexpire'] = 'Cache expire';
$string['cachecleared'] = 'Cached files are removed';
+$string['cannotinitplugin'] = 'Call plugin_init failed';
$string['clicktohide'] = 'Click here to hide';
$string['clicktoshow'] = 'Click here to show';
$string['close'] = 'Close';
public static function plugin_init() {
//here we create a default instance for this type
- repository::static_function('flickr_public','create', 'flickr_public', 0, get_system_context(), array('name' => get_string('repositoryname', 'repository_flickr_public'),'email_address' => null),1);
+ $id = repository::static_function('flickr_public','create', 'flickr_public', 0, get_system_context(), array('name' => get_string('repositoryname', 'repository_flickr_public'),'email_address' => null), 1);
+ if (empty($id)) {
+ return false;
+ } else {
+ return true;
+ }
}
public function supported_filetypes() {
return array('web_image');
//only create a new type if it doesn't already exist
$existingtype = $DB->get_record('repository', array('type'=>$this->_typename));
if (!$existingtype) {
- //run init function
- if (!repository::static_function($this->_typename, 'plugin_init')) {
- if (!$silent) {
- throw new repository_exception('cannotcreatetype', 'repository');
- }
- }
-
//create the type
$newtype = new stdclass;
$newtype->type = $this->_typename;
$newtype->visible = $this->_visible;
$newtype->sortorder = $this->_sortorder;
$plugin_id = $DB->insert_record('repository', $newtype);
-
//save the options in DB
$this->update_options();
$instanceoptions['name'] = $this->_typename;
repository::static_function($this->_typename, 'create', $this->_typename, 0, get_system_context(), $instanceoptions);
}
+ //run plugin_init function
+ if (!repository::static_function($this->_typename, 'plugin_init')) {
+ if (!$silent) {
+ throw new repository_exception('cannotinitplugin', 'repository');
+ }
+ }
+
if(!empty($plugin_id)) {
// return plugin_id if create successfully
return $plugin_id;