}
-/**
- * Class for supporting a phpnuke style block as a moodle block
- *
- * @author Jon Papaioannou
- * @package blocks
- */
-class block_nuke extends block_base {
-
- var $content_type = BLOCK_TYPE_NUKE;
-
- function get_content() {
-
- if ($this->content !== NULL) {
- return $this->content;
- }
-
- global $CFG;
- $this->content = &New stdClass;
-
- // This whole thing begs to be written for PHP >= 4.3.0 using glob();
- $dir = $CFG->dirroot .'/blocks/'. $this->name() .'/nuke/';
- if ($dh = @opendir($dir)) {
- while (($file = readdir($dh)) !== false) {
- $regs = array();
- if (ereg('^block\-(.*)\.php$', $file, $regs)) {
- // Found it! Let's prepare the environment...
-
- $oldvals = array();
- if (isset($GLOBALS['admin'])) {
- $oldvals['admin'] = $GLOBALS['admin'];
- }
-
- // isteacher() will eventually be deprecated and blocks
- // should define their own capabilities.
- $GLOBALS['admin'] = isteacher($this->course->id);
-
- @include($dir.$file);
-
- foreach($oldvals as $key => $val) {
- $GLOBALS[$key] = $val;
- }
-
- // We should have $content set now
- if (!isset($content)) {
- return NULL;
- }
- return $this->content->text = $content;
- }
- }
- }
-
- // If we reached here, we couldn't find the nuke block for some reason
- return $this->content->text = get_string('blockmissingnuke');
- }
-}
-
?>