Moodle 2.0 dev - changes in plugin

Discussion in 'Integration' started by chemistry2004, May 2, 2009.

  1. chemistry2004

    chemistry2004 Member

    Joined:
    Jan 26, 2007
    Messages:
    78
    Hello, fellow moodle users,

    Moodle 2.0 dev is pretty good. However, moodle developers have completely changed the way the sessions are handled. The present amember-moodle plugin does not work as with moodle v1.9. We need to make small modifications in moodle.inc.php file to port it to v2.0 development version. I was playing with the codes and finally here they are. We need modifications at session handling part of the code. We need to modify at three functions function after_logout(), function check_logged_in($get_session=0), function after_login($member). Here are the modifications

    At function_after_logout() - replace the existing code with the following
    PHP:
    $this->query("DELETE FROM [db]sessions WHERE sid = '".$db->escape($session_cookie_value)."'");
    At function check_logged_in($get_session=0) - replace the existing code with the following
    PHP:
    $session_data urldecode($this->query_one("SELECT sessdata FROM [db]sessions WHERE sid = '".$db->escape($session_cookie_value)."'"));
    At function after_login($member) - replace the existing code with the following
    PHP:
    if ($dbsessions)
            {
                
    $created time();
                
    $modified time()+1;
                
    $sessdata base64_encode($session_text);
                
    $firstip $this->moodle_getremoteaddr();
                
    $this->query("REPLACE INTO [db]sessions SET sid = '$session_id', userid = '$moodle_user[id]',
                                timecreated = '
    $created',  timemodified = '$modified', firstip = '$firstip', sessdata = '".$db->escape($sessdata)."'");
            } else {
                
    $this->moodle_fwrite($moodle_settings['dataroot']."/sessions/sess_".$session_id$session_text);
            }
    Thats it.

    chemistry2004
  2. skippybosco

    skippybosco CGI-Central Partner Staff Member

    Joined:
    Aug 22, 2006
    Messages:
    2,526
    Thanks for sharing!

Share This Page