| Server IP : 165.22.154.248 / Your IP : 216.73.217.54 [ Web Server : Apache/2.4.29 (Ubuntu) System : Linux droplet-integra 4.15.0-197-generic #208-Ubuntu SMP Tue Nov 1 17:23:37 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 7.2.24-0ubuntu0.18.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /proc/9427/cwd/avanza-lms.old.bak9874115/blocks/welcome/ |
Upload File : |
<?php
// Este codigo le pertenece a Escuela Didactica <https://escueladidactica.com>
//
// Construimos procesos de transformación para empresas donde sus
// colaboradores se capaciten con el conocimiento de su empresa
// mediante experiencias educativas digitales.
//
/**
*
* @package block_welcome
* @copyright 2019 Jose Gomez <info@escueladidactica.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
class block_welcome extends block_base {
public function init() {
$this->title = get_string('title', 'block_welcome');
}
public function specialization() {
if (isset($this->config)) {
//Se asigna configuracion de bloque a variables;
if (empty($this->config->title)) {
$this->title = get_string('title', 'block_welcome');
} else {
$this->title = $this->config->title;
}
}
}
public function get_content() {
global $CFG;
$content = "<p>No se pudo cargar el contenido</p>";
if ($this->content !== null) {
return $this->content;
}
if (empty($this->instance)) {
$this->content = '';
return $this->content;
}
if (isloggedin() && !isguestuser()) {
context_block::instance($this->instance->id);
$main = new \block_welcome\output\main($this->instance->id);
$output = $this->page->get_renderer('block_welcome');
$sia = get_config('block_welcome','dbsia');
$full_path = $this->get_path_sia($sia, $CFG->wwwroot, $this->instance->blockname);
$content = $this->validate_path($full_path, $output, $main);
//$content = $output->render($main);
$this->content = new stdClass;
$this->content->text = $content;
//$this->content->footer = $this->get_footer_brand();
}
return $this->content;
}
/*
* Esta funcion es la encargada de mostrar bloque solamente
* cuando se encuentra dentro de un curso
*/
public function applicable_formats() {
return array(
'my' => true,
'course' => true,
'site-index' => true,
);
}
public function get_footer_brand() {
global $CFG;
$html = '<img src="'.$CFG->wwwroot.'/blocks/welcome/pix/escuela-didactica.png" alt="Escuela Didáctica" title="'.get_string('dev_by', 'block_welcome').'" style="max-width: 12px;position: absolute;bottom: 10px;right: 10px;filter: brightness(0);opacity: 0.1;">';
return $html;
}
/**
* Esta funcion permite el uso de get_config() para consultar base de datos de moodle
*/
function has_config() {
return true;
}
public function get_path_sia($sia, $localpath, $blockname){
if (empty($sia)) {
$sia = "none";
}
$srv_sia = get_string("namesrvsia", "block_welcome");
$url_serve = $srv_sia."?wwwroot=".$localpath."&plugin=".$blockname."&key=".$sia;
$ctx = stream_context_create(array(
'http' => array(
'timeout' => 1
)
)
);
$data = file_get_contents($url_serve, true, $ctx);
$json = json_decode($data);
return $json;
}
public function validate_path($path, $output, $main){
$validated = "";
if(!empty($path)){
if ($path->status == 1) {
$validated = $output->render($main);
}
else{
$validated = $path->msn;
}
}
return $validated;
}
}