MDL-10870 A few more fixes to the file.php page's navigation
[moodle.git] / mod / resource / lib.php
CommitLineData
d1290cec 1<?php // $Id$
2a439ba7 2
5925d0ef 3if (!isset($CFG->resource_framesize)) {
4 set_config("resource_framesize", 130);
ec81373f 5}
92a419a2 6
66c25030 7if (!isset($CFG->resource_websearch)) {
8 set_config("resource_websearch", "http://google.com/");
ec81373f 9}
66c25030 10
5e91dd3f 11if (!isset($CFG->resource_defaulturl)) {
12 set_config("resource_defaulturl", "http://");
ec81373f 13}
3bfe3922 14
15if (!isset($CFG->resource_filterexternalpages)) {
16 set_config("resource_filterexternalpages", false);
ec81373f 17}
5e91dd3f 18
d18830fe 19if (!isset($CFG->resource_secretphrase)) {
20 set_config("resource_secretphrase", random_string(20));
ec81373f 21}
d18830fe 22
83891eda 23if (!isset($CFG->resource_popup)) {
24 set_config("resource_popup", "");
ec81373f 25}
83891eda 26
33935242 27if (!isset($CFG->resource_windowsettings)) {
28 set_config("resource_windowsettings", "0");
ec81373f 29}
33935242 30
31if (!isset($CFG->resource_parametersettings)) {
32 set_config("resource_parametersettings", "0");
ec81373f 33}
33935242 34
713d78ea 35if (!isset($CFG->resource_allowlocalfiles)) {
36 set_config("resource_allowlocalfiles", "0");
37}
38
37147357 39if (!isset($CFG->resource_hide_repository)) {
40 set_config("resource_hide_repository", "1");
41}
42
a69be0d8 43if (!isset($CFG->resource_autofilerename)) {
44 set_config("resource_autofilerename", "1");
45}
46
47if (!isset($CFG->resource_blockdeletingfile)) {
48 set_config("resource_blockdeletingfile", "1");
49}
50
713d78ea 51define('RESOURCE_LOCALPATH', 'LOCALPATH');
52
ec81373f 53$RESOURCE_WINDOW_OPTIONS = array('resizable', 'scrollbars', 'directories', 'location',
6d77bd61 54 'menubar', 'toolbar', 'status', 'width', 'height');
3d30a455 55
83891eda 56foreach ($RESOURCE_WINDOW_OPTIONS as $popupoption) {
57 $popupoption = "resource_popup$popupoption";
58 if (!isset($CFG->$popupoption)) {
2e708fa0 59 if ($popupoption == 'resource_popupheight') {
83891eda 60 set_config($popupoption, 450);
2e708fa0 61 } else if ($popupoption == 'resource_popupwidth') {
83891eda 62 set_config($popupoption, 620);
63 } else {
2e708fa0 64 set_config($popupoption, 'checked');
83891eda 65 }
ec81373f 66 }
83891eda 67}
68
f145c248 69if (!empty($THEME->customcorners)) {
70 require_once($CFG->dirroot.'/lib/custom_corners_lib.php');
71}
72
d18830fe 73/**
74* resource_base is the base class for resource types
75*
76* This class provides all the functionality for a resource
77*/
78
79class resource_base {
80
81var $cm;
82var $course;
83var $resource;
84
85
86/**
87* Constructor for the base resource class
88*
89* Constructor for the base resource class.
90* If cmid is set create the cm, course, resource objects.
6aac6eef 91* and do some checks to make sure people can be here, and so on.
d18830fe 92*
93* @param cmid integer, the current course module id - not set for new resources
94*/
95function resource_base($cmid=0) {
96
9f741612 97 global $CFG, $COURSE;
6aac6eef 98
d18830fe 99 if ($cmid) {
f9d5371b 100 if (! $this->cm = get_coursemodule_from_id('resource', $cmid)) {
d18830fe 101 error("Course Module ID was incorrect");
102 }
103
104 if (! $this->course = get_record("course", "id", $this->cm->course)) {
105 error("Course is misconfigured");
106 }
107
108 if (! $this->resource = get_record("resource", "id", $this->cm->instance)) {
109 error("Resource ID was incorrect");
110 }
6aac6eef 111
112 $this->strresource = get_string("modulename", "resource");
113 $this->strresources = get_string("modulenameplural", "resource");
114
3b27b0fe 115 $this->navlinks[] = array('name' => $this->strresources, 'link' => "index.php?id={$this->course->id}", 'type' => 'activity');
6aac6eef 116
d02eeded 117 if (!$this->cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $this->cm->id))) {
6aac6eef 118 $pagetitle = strip_tags($this->course->shortname.': '.$this->strresource);
3b27b0fe 119 $this->navlinks[] = array('name' => $this->strresource, 'link' => '', 'type' => 'activityinstance');
120 $this->navigation = build_navigation($this->navlinks);
06dfa0cc 121
122 print_header($pagetitle, $this->course->fullname, $this->navigation, "", "", true, '', navmenu($this->course, $this->cm));
6aac6eef 123 notice(get_string("activityiscurrentlyhidden"), "$CFG->wwwroot/course/view.php?id={$this->course->id}");
124 }
06dfa0cc 125
9f741612 126 } else {
127 $this->course = $COURSE;
ec81373f 128 }
d18830fe 129}
130
131
6aac6eef 132/**
133* Display function does nothing in the base class
134*/
d18830fe 135function display() {
6aac6eef 136
d18830fe 137}
138
139
0440482f 140/**
141* Display the resource with the course blocks.
142*/
143function display_course_blocks_start() {
144
145 global $CFG;
146 global $USER;
147
148 require_once($CFG->libdir.'/blocklib.php');
149 require_once($CFG->libdir.'/pagelib.php');
dbfa9ccd 150 require_once($CFG->dirroot.'/course/lib.php'); //required by some blocks
0440482f 151
152 $PAGE = page_create_object(PAGE_COURSE_VIEW, $this->course->id);
153 $this->PAGE = $PAGE;
154 $pageblocks = blocks_setup($PAGE);
155
156 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
157
158/// Print the page header
159
d2b23346 160 $edit = optional_param('edit', -1, PARAM_BOOL);
161
162 if (($edit != -1) and $PAGE->user_allowed_editing()) {
163 $USER->editing = $edit;
0440482f 164 }
d2b23346 165
3b27b0fe 166 $morenavlinks = array($this->strresources => 'index.php?id='.$this->course->id,
0440482f 167 $this->resource->name => '');
168
3b27b0fe 169 $PAGE->print_header($this->course->shortname.': %fullname%', $morenavlinks);
0440482f 170
171 echo '<table id="layout-table"><tr>';
172
173 if((blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing())) {
174 echo '<td style="width: '.$blocks_preferred_width.'px;" id="left-column">';
f145c248 175 if (!empty($THEME->customcorners)) print_custom_corners_start();
0440482f 176 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
f145c248 177 if (!empty($THEME->customcorners)) print_custom_corners_end();
0440482f 178 echo '</td>';
179 }
180
181 echo '<td id="middle-column">';
f145c248 182 if (!empty($THEME->customcorners)) print_custom_corners_start();
0440482f 183 echo '<div id="resource">';
184
185}
186
187
188/**
189 * Finish displaying the resource with the course blocks
190 */
191function display_course_blocks_end() {
192
193 global $CFG;
194
195 $PAGE = $this->PAGE;
196 $pageblocks = blocks_setup($PAGE);
197 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
198
199 echo '</div>';
f145c248 200 if (!empty($THEME->customcorners)) print_custom_corners_end();
0440482f 201 echo '</td>';
202
203 if((blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing())) {
204 echo '<td style="width: '.$blocks_preferred_width.'px;" id="right-column">';
f145c248 205 if (!empty($THEME->customcorners)) print_custom_corners_start();
0440482f 206 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
f145c248 207 if (!empty($THEME->customcorners)) print_custom_corners_end();
0440482f 208 echo '</td>';
209 }
210
211 echo '</tr></table>';
212
213 print_footer($this->course);
214
215}
216
217
d18830fe 218function add_instance($resource) {
ec81373f 219// Given an object containing all the necessary data,
220// (defined by the form in mod.html) this function
221// will create a new instance and return the id number
cccb016a 222// of the new instance.
2a439ba7 223
cccb016a 224 $resource->timemodified = time();
2a439ba7 225
cccb016a 226 return insert_record("resource", $resource);
227}
2a439ba7 228
cccb016a 229
d18830fe 230function update_instance($resource) {
ec81373f 231// Given an object containing all the necessary data,
232// (defined by the form in mod.html) this function
cccb016a 233// will update an existing instance with new data.
234
235 $resource->id = $resource->instance;
236 $resource->timemodified = time();
237
238 return update_record("resource", $resource);
239}
240
241
f0c6abbf 242function delete_instance($resource) {
243// Given an object containing the resource data
ec81373f 244// this function will permanently delete the instance
245// and any data that depends on it.
cccb016a 246
cccb016a 247 $result = true;
248
249 if (! delete_records("resource", "id", "$resource->id")) {
250 $result = false;
2a439ba7 251 }
252
cccb016a 253 return $result;
2a439ba7 254}
cccb016a 255
9f741612 256function setup_elements(&$mform) {
257 //override to add your own options
258}
2a439ba7 259
9f741612 260function setup_preprocessing(&$default_values){
261 //override to add your own options
262}
d18830fe 263
264} /// end of class definition
265
266
267
268function resource_add_instance($resource) {
269 global $CFG;
ec81373f 270
1b1d3422 271 $resource->type = clean_param($resource->type, PARAM_SAFEDIR); // Just to be safe
79035d46 272
d18830fe 273 require_once("$CFG->dirroot/mod/resource/type/$resource->type/resource.class.php");
1aef6fb7 274 $resourceclass = "resource_$resource->type";
275 $res = new $resourceclass();
d18830fe 276
277 return $res->add_instance($resource);
278}
279
280function resource_update_instance($resource) {
281 global $CFG;
ec81373f 282
1b1d3422 283 $resource->type = clean_param($resource->type, PARAM_SAFEDIR); // Just to be safe
79035d46 284
d18830fe 285 require_once("$CFG->dirroot/mod/resource/type/$resource->type/resource.class.php");
1aef6fb7 286 $resourceclass = "resource_$resource->type";
287 $res = new $resourceclass();
d18830fe 288
289 return $res->update_instance($resource);
290}
291
292function resource_delete_instance($id) {
293 global $CFG;
ec81373f 294
d18830fe 295 if (! $resource = get_record("resource", "id", "$id")) {
296 return false;
297 }
79035d46 298
1b1d3422 299 $resource->type = clean_param($resource->type, PARAM_SAFEDIR); // Just to be safe
ec81373f 300
d18830fe 301 require_once("$CFG->dirroot/mod/resource/type/$resource->type/resource.class.php");
1aef6fb7 302 $resourceclass = "resource_$resource->type";
303 $res = new $resourceclass();
d18830fe 304
f0c6abbf 305 return $res->delete_instance($resource);
d18830fe 306}
307
308
2a439ba7 309function resource_user_outline($course, $user, $mod, $resource) {
ec81373f 310 if ($logs = get_records_select("log", "userid='$user->id' AND module='resource'
ebc3bd2b 311 AND action='view' AND info='$resource->id'", "time ASC")) {
2a439ba7 312
313 $numviews = count($logs);
314 $lastlog = array_pop($logs);
315
9f741612 316 $result = new object();
2a439ba7 317 $result->info = get_string("numviews", "", $numviews);
318 $result->time = $lastlog->time;
319
320 return $result;
321 }
322 return NULL;
323}
324
325
326function resource_user_complete($course, $user, $mod, $resource) {
9fad2dec 327 global $CFG;
2a439ba7 328
ec81373f 329 if ($logs = get_records_select("log", "userid='$user->id' AND module='resource'
ebc3bd2b 330 AND action='view' AND info='$resource->id'", "time ASC")) {
2a439ba7 331 $numviews = count($logs);
332 $lastlog = array_pop($logs);
333
334 $strmostrecently = get_string("mostrecently");
335 $strnumviews = get_string("numviews", "", $numviews);
336
337 echo "$strnumviews - $strmostrecently ".userdate($lastlog->time);
338
339 } else {
4282d7dd 340 print_string("neverseen", "resource");
2a439ba7 341 }
342}
343
84caf038 344function resource_get_participants($resourceid) {
345//Returns the users with data in one resource
346//(NONE, byt must exists on EVERY mod !!)
347
348 return false;
349}
2a439ba7 350
8dddba42 351function resource_get_coursemodule_info($coursemodule) {
ec81373f 352/// Given a course_module object, this function returns any
8dddba42 353/// "extra" information that may be needed when printing
354/// this activity in a course listing.
355///
356/// See get_array_of_activities() in course/lib.php
357///
358
9d361034 359 global $CFG;
360
361 $info = NULL;
362
8dddba42 363 if ($resource = get_record("resource", "id", $coursemodule->instance)) {
85e8239e 364 if (!empty($resource->popup)) {
bfca8b17 365 $info->extra = urlencode("onclick=\"this.target='resource$resource->id'; return ".
839f2456 366 "openpopup('/mod/resource/view.php?inpopup=true&amp;id=".
8dddba42 367 $coursemodule->id.
d18830fe 368 "','resource$resource->id','$resource->popup');\"");
8dddba42 369 }
9d361034 370
f1e0649c 371 require_once($CFG->libdir.'/filelib.php');
9d361034 372
85e8239e 373 if ($resource->type == 'file') {
ec81373f 374 $icon = mimeinfo("icon", $resource->reference);
9d361034 375 if ($icon != 'unknown.gif') {
ec81373f 376 $info->icon ="f/$icon";
85e8239e 377 } else {
ec81373f 378 $info->icon ="f/web.gif";
9d361034 379 }
d18830fe 380 } else if ($resource->type == 'directory') {
ec81373f 381 $info->icon ="f/folder.gif";
9d361034 382 }
8dddba42 383 }
384
9d361034 385 return $info;
8dddba42 386}
ec81373f 387
8367faba 388function resource_fetch_remote_file ($cm, $url, $headers = "" ) {
3bfe3922 389/// Snoopy is an HTTP client in PHP
390
391 global $CFG;
392
393 require_once("$CFG->libdir/snoopy/Snoopy.class.inc");
394
b2b8471e 395 $client = new Snoopy();
ec81373f 396 $ua = 'Moodle/'. $CFG->release . ' (+http://moodle.org';
bf46cd22 397 if ( $CFG->resource_usecache ) {
398 $ua = $ua . ')';
399 } else {
400 $ua = $ua . '; No cache)';
401 }
402 $client->agent = $ua;
403 $client->read_timeout = 5;
404 $client->use_gzip = true;
b2b8471e 405 if (is_array($headers) ) {
406 $client->rawheaders = $headers;
407 }
ec81373f 408
b2b8471e 409 @$client->fetch($url);
bf46cd22 410 if ( $client->status >= 200 && $client->status < 300 ) {
411 $tags = array("A" => "href=",
412 "IMG" => "src=",
413 "LINK" => "href=",
414 "AREA" => "href=",
415 "FRAME" => "src=",
416 "IFRAME" => "src=",
417 "FORM" => "action=");
ec81373f 418
bf46cd22 419 foreach ($tags as $tag => $key) {
839f2456 420 $prefix = "fetch.php?id=$cm->id&amp;url=";
bf46cd22 421 if ( $tag == "IMG" or $tag == "LINK" or $tag == "FORM") {
422 $prefix = "";
423 }
424 $client->results = resource_redirect_tags($client->results, $url, $tag, $key,$prefix);
425 }
426 } else {
427 if ( $client->status >= 400 && $client->status < 500) {
428 $client->results = get_string("fetchclienterror","resource"); // Client error
429 } elseif ( $client->status >= 500 && $client->status < 600) {
430 $client->results = get_string("fetchservererror","resource"); // Server error
431 } else {
432 $client->results = get_string("fetcherror","resource"); // Redirection? HEAD? Unknown error.
af65e103 433 }
af65e103 434 }
b2b8471e 435 return $client;
af65e103 436}
437
438function resource_redirect_tags($text, $url, $tagtoparse, $keytoparse,$prefix = "" ) {
bf46cd22 439 $valid = 1;
af65e103 440 if ( strpos($url,"?") == FALSE ) {
441 $valid = 1;
442 }
443 if ( $valid ) {
444 $lastpoint = strrpos($url,".");
445 $lastslash = strrpos($url,"/");
446 if ( $lastpoint > $lastslash ) {
447 $root = substr($url,0,$lastslash+1);
448 } else {
449 $root = $url;
450 }
ec81373f 451 if ( $root == "http://" or
af65e103 452 $root == "https://") {
453 $root = $url;
454 }
455 if ( substr($root,strlen($root)-1) == '/' ) {
456 $root = substr($root,0,-1);
457 }
ec81373f 458
af65e103 459 $mainroot = $root;
460 $lastslash = strrpos($mainroot,"/");
461 while ( $lastslash > 9) {
462 $mainroot = substr($mainroot,0,$lastslash);
ec81373f 463
af65e103 464 $lastslash = strrpos($mainroot,"/");
465 }
8dddba42 466
ec81373f 467 $regex = "/<$tagtoparse (.+?)>/is";
468 $count = preg_match_all($regex, $text, $hrefs);
af65e103 469 for ( $i = 0; $i < $count; $i++) {
470 $tag = $hrefs[1][$i];
ec81373f 471
af65e103 472 $poshref = strpos(strtolower($tag),strtolower($keytoparse));
473 $start = $poshref + strlen($keytoparse);
474 $left = substr($tag,0,$start);
475 if ( $tag[$start] == '"' ) {
476 $left .= '"';
477 $start++;
478 }
479 $posspace = strpos($tag," ", $start+1);
480 $right = "";
481 if ( $posspace != FALSE) {
482 $right = substr($tag, $posspace);
483 }
484 $end = strlen($tag)-1;
485 if ( $tag[$end] == '"' ) {
486 $right = '"' . $right;
487 }
488 $finalurl = substr($tag,$start,$end-$start+$diff);
489 // Here, we could have these possible values for $finalurl:
490 // file.ext Add current root dir
491 // http://(domain) don't care
492 // http://(domain)/ don't care
493 // http://(domain)/folder don't care
494 // http://(domain)/folder/ don't care
495 // http://(domain)/folder/file.ext don't care
496 // folder/ Add current root dir
497 // folder/file.ext Add current root dir
498 // /folder/ Add main root dir
499 // /folder/file.ext Add main root dir
500
501 // Special case: If finalurl contains a ?, it won't be parsed
bf46cd22 502 $valid = 1;
af65e103 503
504 if ( strpos($finalurl,"?") == FALSE ) {
505 $valid = 1;
506 }
507 if ( $valid ) {
508 if ( $finalurl[0] == "/" ) {
509 $finalurl = $mainroot . $finalurl;
ec81373f 510 } elseif ( strtolower(substr($finalurl,0,7)) != "http://" and
af65e103 511 strtolower(substr($finalurl,0,8)) != "https://") {
512 if ( $finalurl[0] == "/") {
513 $finalurl = $mainroot . $finalurl;
514 } else {
515 $finalurl = "$root/$finalurl";
516 }
517 }
ec81373f 518
af65e103 519 $text = str_replace($tag,"$left$prefix$finalurl$right",$text);
520 }
521 }
522 }
523 return $text;
524}
8dddba42 525
d18830fe 526function resource_is_url($path) {
427c8ccb 527 if (strpos($path, '://')) { // eg http:// https:// ftp:// etc
d18830fe 528 return true;
529 }
427c8ccb 530 if (strpos($path, '/') === 0) { // Starts with slash
531 return true;
532 }
533 return false;
d18830fe 534}
535
89bfeee0 536function resource_get_types() {
9f741612 537 global $CFG;
538
89bfeee0 539 $types = array();
6da4b261 540
3d30a455 541 $standardresources = array('text','html','file','directory');
6da4b261 542 foreach ($standardresources as $resourcetype) {
89bfeee0 543 $type = new object();
544 $type->modclass = MOD_CLASS_RESOURCE;
545 $type->type = "resource&amp;type=$resourcetype";
546 $type->typestr = get_string("resourcetype$resourcetype", 'resource');
547 $types[] = $type;
6da4b261 548 }
549
550 /// Drop-in extra resource types
551 $resourcetypes = get_list_of_plugins('mod/resource/type');
552 foreach ($resourcetypes as $resourcetype) {
37147357 553 if (!empty($CFG->{'resource_hide_'.$resourcetype})) { // Not wanted
554 continue;
555 }
89bfeee0 556 if (!in_array($resourcetype, $standardresources)) {
557 $type = new object();
558 $type->modclass = MOD_CLASS_RESOURCE;
559 $type->type = "resource&amp;type=$resourcetype";
560 $type->typestr = get_string("resourcetype$resourcetype", 'resource');
561 $types[] = $type;
6da4b261 562 }
563 }
89bfeee0 564
565 return $types;
6da4b261 566}
f3221af9 567
568function resource_get_view_actions() {
569 return array('view','view all');
570}
571
572function resource_get_post_actions() {
573 return array();
574}
575
a69be0d8 576function resource_renamefiles($course, $wdir, $oldname, $name) {
577 global $CFG;
578
579 $status = '<p align=\"center\"><strong>'.get_string('affectedresources', 'resource').':</strong><ul>';
580 $updates = false;
581
582 $old = trim($wdir.'/'.$oldname, '/');
583 $new = trim($wdir.'/'.$name, '/');
584
585 $sql = "SELECT r.id, r.reference, r.name, cm.id AS cmid
586 FROM {$CFG->prefix}resource r,
587 {$CFG->prefix}course_modules cm,
588 {$CFG->prefix}modules m
589 WHERE r.course = '{$course->id}'
590 AND m.name = 'resource'
591 AND cm.module = m.id
592 AND cm.instance = r.id
593 AND (r.type = 'file' OR r.type = 'directory')
594 AND (r.reference LIKE '{$old}/%' OR r.reference = '{$old}')";
595 if ($resources = get_records_sql($sql)) {
596 foreach ($resources as $resource) {
597 $r = new object();
598 $r->id = $resource->id;
599 $r->reference = '';
600 if ($resource->reference == $old) {
601 $r->reference = addslashes($new);
602 } else {
603 $r->reference = addslashes(preg_replace('|^'.preg_quote($old, '|').'/|', $new.'/', $resource->reference));
604 }
605 if ($r->reference !== '') {
606 $updates = true;
607 $status .= "<li><a href=\"$CFG->wwwroot/mod/resource/view.php?id=$resource->cmid\" target=\"_blank\">$resource->name</a>: $resource->reference ==> $r->reference</li>";
608 if (!empty($CFG->resource_autofilerename)) {
609 if (!update_record('resource', $r)) {
610 error("Error updating resource with ID $r->id.");
611 }
612 }
613 }
614 }
615 }
616 $status .= '</ul></p>';
617
618 if ($updates) {
619 echo $status;
620 if (empty($CFG->resource_autofilerename)) {
621 notify(get_string('warningdisabledrename', 'resource'));
622 }
623 }
624}
625
626function resource_delete_warning($course, $files) {
627 global $CFG;
628
629 $found = array();
630
631 foreach($files as $key=>$file) {
632 $files[$key] = trim($file, '/');
633 }
634 $sql = "SELECT r.id, r.reference, r.name, cm.id AS cmid
635 FROM {$CFG->prefix}resource r,
636 {$CFG->prefix}course_modules cm,
637 {$CFG->prefix}modules m
638 WHERE r.course = '{$course->id}'
639 AND m.name = 'resource'
640 AND cm.module = m.id
641 AND cm.instance = r.id
642 AND (r.type = 'file' OR r.type = 'directory')";
643 if ($resources = get_records_sql($sql)) {
644 foreach ($resources as $resource) {
645 if ($resource->reference == '') {
646 continue; // top shared directory does not prevent anything
647 }
648 if (in_array($resource->reference, $files)) {
649 $found[$resource->id] = $resource;
650 } else {
651 foreach($files as $file) {
652 if (preg_match('|^'.preg_quote($file, '|').'/|', $resource->reference)) {
653 $found[$resource->id] = $resource;
654 }
655 }
656 }
657 }
658 }
659
660 if (!empty($found)) {
661
662 print_simple_box_start("center");
663 echo '<p><strong>'.get_string('affectedresources', 'resource').':</strong><ul>';
664 foreach($found as $resource) {
665 echo "<li><a href=\"$CFG->wwwroot/mod/resource/view.php?id=$resource->cmid\" target=\"_blank\">$resource->name</a>: $resource->reference</li>";
666 }
667 echo '</ul></p>';
668 print_simple_box_end();
669
670 return true;
671 } else {
672 return false;
673 }
674}
675
2a439ba7 676?>