Proyectos de Subversion Moodle

Rev

Rev 255 | Rev 259 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
177 ariadna 1
<?php
2
require_once(__DIR__ . '/cesa.php');
183 ariadna 3
 
177 ariadna 4
class StaticsBlocks extends Cesa
5
{
254 ariadna 6
    public function __construct($title)
177 ariadna 7
    {
255 ariadna 8
        global $USER, $PAGE, $SITE;
9
        require_login(null, false);
10
 
11
        if (isguestuser()) {
12
            throw new require_login_exception('Guests are not allowed here.');
13
        }
14
 
15
        $this->userID = optional_param('userid', $USER->id, PARAM_INT);
16
        $this->currentUser = $this->userID == $USER->id;
17
        $this->user = core_user::get_user($this->userID);
18
        $this->title = get_string($title);
19
        $this->blockManager = $PAGE->blocks;
20
        $this->regionName = 'side-pre'; // Puedes cambiar la región si lo necesitas
256 ariadna 21
        $this->blockNames = ['cesa_course_rating', 'comments', 'mynotes'];
255 ariadna 22
        $this->blockExists = true;
23
 
24
        if (!$this->user || !core_user::is_real_user($this->userID)) {
25
            throw new moodle_exception('invaliduser', 'error');
26
        }
177 ariadna 27
    }
28
 
187 ariadna 29
    public function renderBlocks()
177 ariadna 30
    {
224 ariadna 31
        global $OUTPUT;
177 ariadna 32
 
183 ariadna 33
        // Añadimos la región si no existe
177 ariadna 34
        $this->addRegion();
35
 
183 ariadna 36
        // Cargamos los bloques existentes
231 ariadna 37
        $this->blockManager->load_blocks(true);
177 ariadna 38
 
183 ariadna 39
        // Validamos si los bloques existen y los agregamos si es necesario
40
        $this->validateIfExistBlocks();
209 ariadna 41
        $this->addBlocksIfNotExist($this->title);
177 ariadna 42
 
187 ariadna 43
        // Renderizamos los bloques en la región específica, sin header ni footer
44
        $blocksView = $OUTPUT->blocks_for_region($this->regionName);
177 ariadna 45
 
187 ariadna 46
        return $blocksView;
177 ariadna 47
    }
48
}
49
 
193 ariadna 50
/* // Instanciamos y renderizamos la página con los bloques estáticos
177 ariadna 51
$statics_blocks = new StaticsBlocks();
193 ariadna 52
echo $statics_blocks->renderBlocks(); */