* @param boolean $visible
* @param integer $sortorder (don't really need set, it will be during create() call)
*/
- public function __construct($typename = '', $typeoptions = array(), $visible = false, $sortorder = 0){
+ public function __construct($typename = '', $typeoptions = array(), $visible = true, $sortorder = 0){
global $CFG;
//set type attributs
$id = $DB->insert_record('repository_instances', $record);
$options = array();
if (call_user_func($classname . '::has_instance_config')) {
- $configs = call_user_func($classname . '::get_instance_option_names');
+ $configs = call_user_func($classname . '::get_instance_option_names');
foreach ($configs as $config) {
$options[$config] = $params[$config];
}
function repository_get_instances($context=null, $userid = null, $onlyvisible = true, $type=null){
global $DB, $CFG, $USER;
$params = array();
- $sql = 'SELECT i.*, r.type AS repositorytype, r.visible FROM {repository} r, {repository_instances} i WHERE ';
+ $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 = ?)';
$sql .= ' AND (r.type = ?)';
$params[] = $type;
}
+ $sql .= ' order by r.sortorder, i.name';
if(!$repos = $DB->get_records_sql($sql, $params)) {
$repos = array();
}
$mform =& $this->_form;
$strrequired = get_string('required');
-
+
$mform->addElement('hidden', 'edit', ($this->instance) ? $this->instance->get_typename() : 0);
$mform->addElement('hidden', 'new', $this->plugin);
$mform->addElement('hidden', 'plugin', $this->plugin);
$stropt = get_string('operation', 'repository');
$updown = get_string('updown', 'repository');
$plugins = get_list_of_plugins('repository');
- //retrieve list of instances. In administration context we want to display all
- //instances even if the type is not visible. In course/user context we
- //want to display only visible instances. The repository_get_instances()
- //third parameter displays only visible type.
- $instances = repository_get_instances($context,null,!$admin,$typename);
+ $instances = repository_get_instances($context,null,true,$typename);
$instancesnumber = count($instances);
$alreadyplugins = array();
$table = new StdClass;
//$row .= ' <a href="' . $baseurl . '&type='.$typename.'&hide=' . $i->id . '"><img src="' . $CFG->pixpath . '/t/' . ($i->visible ? 'hide' : 'show') . '.gif" alt="' . get_string($i->visible ? 'hide' : 'show') . '" /></a>' . "\n";
$table->data[] = array($i->name, $type->get_readablename(),$row);
-
- //display a grey row if the type is defined as not visible
- if (isset($type) && !$type->get_visible()){
- $table->rowclass[] = 'dimmed_text';
- } else{
- $table->rowclass[] = '';
- }
-
if (!in_array($i->name, $alreadyplugins)) {
$alreadyplugins[] = $i->name;
}
//create a unique type of instance
else {
if (repository_static_function($typename, 'has_multiple_instances')){
- $addable = 1;
+ $addable = 1;
$instancehtml .= '<li><a href="'.$baseurl.'&new='.$typename.'">'.get_string('create', 'repository')
.' "'.get_string('repositoryname', 'repository_'.$typename).'" '
.get_string('instance', 'repository').'</a></li>';