Ayuda con get_record

Re: Ayuda con get_record

de Kenichi Haramoto -
Número de respuestas: 0

Yo al final modifiqué el archivo que está en otro foro sence.lib.php a lo siguiente: 

 

<?

function registerSence ($moodle_course_id,$moodle_user_id,$sence_pass) {

global $CFG, $SESSION, $DB;

$status = true;

if (!isset($SESSION->sence[$moodle_course_id])) {

$course_rec = $DB->get_record("course_sence", array("moodle" => $moodle_course_id));
$user_rec = $DB->get_record("user",array("id"=>$moodle_user_id));

if ($course_rec && $user_rec) {
$host = "notificaciones.sence.cl";
$method = "GET";
$path = "/inicio_sesion";
$data = "rut=".$user_rec->idnumber."&passwd=".$sence_pass."&curso=".$course_rec->sence;
$status = sendUrl($host,$method,$path,$data);
if ($CFG->debug > 7) {
echo "Invocada URL: ".$host.$path."?".$data."<br>";
echo "Respuesta: ".$status;
}
}
$SESSION->sence[$moodle_course_id] = true;
}
return $status;
}

function unregisterSence ($moodle_user_id,$sence_pass) {

global $CFG, $SESSION, $DB;

$status = true;

foreach($SESSION->sence as $key => $value) {

if ($value) {

$course_rec = $DB->get_record("course_sence", array("moodle" => $key));
$user_rec = $DB->get_record("user",array("id"=>$moodle_user_id));

if ($course_rec && $user_rec) {
$host = "notificaciones.sence.cl";
$method = "GET";
$path = "/fin_sesion";
$data = "rut=".$user_rec->idnumber."&passwd=".$sence_pass."&curso=".$course_rec->sence;
$status = sendUrl($host,$method,$path,$data);
if ($CFG->debug > 7) {
echo "Invocada URL: ".$host.$path."?".$data."<br>";
echo "Respuesta: ".$status;
}
}
}
}
return $status;
}

function sendUrl($host,$method,$path,$data,$useragent=0) {

$buf = "";

// Supply a default method of GET if the one passed was empty
if (empty($method)) {
$method = 'GET';
}
$method = strtoupper($method);
$fp = fsockopen($host, 80);
if ($method == 'GET') {
$path .= '?' . $data;
}
fputs($fp, "$method $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
if ($useragent) {
fputs($fp, "User-Agent: MSIE\r\n");
}
if ($method == 'POST') {
fputs($fp,"Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
}
fputs($fp, "Connection: close\r\n\r\n");
if ($method == 'POST') {
fputs($fp, $data);
}

while (!feof($fp)) {
$buf .= fgets($fp,128);
}
fclose($fp);
return $buf;
}
?>

 

Esto ya no me tira errores, pero aun no he podido verificar si funciona en sence. El resto de las instrucciones está acá: https://moodle.org/mod/forum/discuss.php?d=2354

 

éxito