mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Just tidying as I read it. Main problem with it now is that huge block of JS
This commit is contained in:
parent
c65dd2fe99
commit
7a3b93c18a
1 changed files with 603 additions and 596 deletions
|
@ -228,8 +228,7 @@ class repository_type {
|
|||
$instanceoptions['name'] = $this->_typename;
|
||||
repository_static_function($this->_typename, 'create', $this->_typename, 0, get_system_context(), $instanceoptions);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new repository_exception('existingrepository', 'repository');
|
||||
}
|
||||
}
|
||||
|
@ -310,10 +309,10 @@ class repository_type {
|
|||
*/
|
||||
public function move_order($move) {
|
||||
global $DB;
|
||||
//retrieve all types
|
||||
$types = repository_get_types();
|
||||
|
||||
//retrieve this type into the returned array
|
||||
$types = repository_get_types(); // retrieve all types
|
||||
|
||||
/// retrieve this type into the returned array
|
||||
$i = 0;
|
||||
while (!isset($indice) && $i<count($types)) {
|
||||
if ($types[$i]->get_typename() == $this->_typename) {
|
||||
|
@ -322,7 +321,7 @@ class repository_type {
|
|||
$i++;
|
||||
}
|
||||
|
||||
//retrieve adjacent indice
|
||||
/// retrieve adjacent indice
|
||||
switch ($move) {
|
||||
case "up":
|
||||
$adjacentindice = $indice - 1;
|
||||
|
@ -735,6 +734,7 @@ abstract class repository {
|
|||
*/
|
||||
public function set_option($options = array()) {
|
||||
global $DB;
|
||||
|
||||
if (!empty($options['name'])) {
|
||||
$r = new object();
|
||||
$r->id = $this->id;
|
||||
|
@ -931,8 +931,10 @@ class repository_exception extends moodle_exception {
|
|||
*/
|
||||
function repository_check_context($ctx_id) {
|
||||
global $USER;
|
||||
|
||||
$context = get_context_instance_by_id($ctx_id);
|
||||
$level = $context->contextlevel;
|
||||
|
||||
if ($level == CONTEXT_COURSE) {
|
||||
if (!has_capability('moodle/course:view', $context)) {
|
||||
return false;
|
||||
|
@ -983,13 +985,16 @@ function repository_get_editable_types(){
|
|||
*/
|
||||
function repository_get_instances($contexts=array(), $userid = null, $onlyvisible = true, $type=null) {
|
||||
global $DB, $CFG, $USER;
|
||||
|
||||
$params = array();
|
||||
$sql = 'SELECT i.*, r.type AS repositorytype, r.sortorder, r.visible FROM {repository} r, {repository_instances} i WHERE ';
|
||||
$sql .= 'i.typeid = r.id ';
|
||||
|
||||
if (!empty($userid) && is_numeric($userid)) {
|
||||
$sql .= ' AND (i.userid = 0 or i.userid = ?)';
|
||||
$params[] = $userid;
|
||||
}
|
||||
|
||||
foreach ($contexts as $context) {
|
||||
if (empty($firstcontext)) {
|
||||
$firstcontext = true;
|
||||
|
@ -999,6 +1004,7 @@ function repository_get_instances($contexts=array(), $userid = null, $onlyvisibl
|
|||
}
|
||||
$params[] = $context->id;
|
||||
}
|
||||
|
||||
if ($firstcontext) {
|
||||
$sql .=')';
|
||||
}
|
||||
|
@ -1006,18 +1012,20 @@ function repository_get_instances($contexts=array(), $userid = null, $onlyvisibl
|
|||
if ($onlyvisible == true) {
|
||||
$sql .= ' AND (r.visible = 1)';
|
||||
}
|
||||
|
||||
if (isset($type)) {
|
||||
$sql .= ' AND (r.type = ?)';
|
||||
$params[] = $type;
|
||||
}
|
||||
$sql .= ' order by r.sortorder, i.name';
|
||||
|
||||
if (!$repos = $DB->get_records_sql($sql, $params)) {
|
||||
$repos = array();
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
foreach ($repos as $repo) {
|
||||
require_once($CFG->dirroot . '/repository/'. $repo->repositorytype
|
||||
. '/repository.class.php');
|
||||
require_once($CFG->dirroot . '/repository/'. $repo->repositorytype.'/repository.class.php');
|
||||
$options['visible'] = $repo->visible;
|
||||
$options['name'] = $repo->name;
|
||||
$options['type'] = $repo->repositorytype;
|
||||
|
@ -2216,7 +2224,6 @@ final class repository_admin_form extends moodleform {
|
|||
}
|
||||
$this->add_action_buttons(true, get_string('save','repository'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -2239,7 +2246,6 @@ function repository_display_instances_list($context, $typename = null){
|
|||
$output .= "</h2></div>";
|
||||
} else {
|
||||
$baseurl = $CFG->httpswwwroot . '/repository/manage_instances.php?contextid=' . $context->id . '&sesskey=' . sesskey();
|
||||
|
||||
}
|
||||
|
||||
$namestr = get_string('name');
|
||||
|
@ -2255,11 +2261,14 @@ function repository_display_instances_list($context, $typename = null){
|
|||
$instances = repository_get_instances(array($context),null,!$admin,$typename);
|
||||
$instancesnumber = count($instances);
|
||||
$alreadyplugins = array();
|
||||
|
||||
$table = new StdClass;
|
||||
$table->head = array($namestr, $pluginstr, $deletestr, $settingsstr);
|
||||
$table->align = array('left', 'left', 'center','center');
|
||||
$table->data = array();
|
||||
|
||||
$updowncount = 1;
|
||||
|
||||
foreach ($instances as $i) {
|
||||
$settings = '';
|
||||
$settings .= '<a href="' . $baseurl . '&type='.$typename.'&edit=' . $i->id . '">' . $settingsstr . '</a>' . "\n";
|
||||
|
@ -2300,10 +2309,8 @@ function repository_display_instances_list($context, $typename = null){
|
|||
}
|
||||
}
|
||||
$instancehtml .= '</ul>';
|
||||
}
|
||||
//create a unique type of instance
|
||||
else {
|
||||
if (repository_static_function($typename, 'has_multiple_instances')){
|
||||
|
||||
} else if (repository_static_function($typename, 'has_multiple_instances')) { //create a unique type of instance
|
||||
$addable = 1;
|
||||
$instancehtml .= "<form action='".$baseurl."&new=".$typename."' method='post'>
|
||||
<p style='text-align:center'><input type='submit' value='".get_string('createinstance', 'repository')."'/></p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue