function gallery_init($cmid = 0) {
    global $CFG, $USER;
    require_once(gallery_get_embedpath());
    $initparams = array('embedUri' => 'view.php?id='.$cmid,
                        'g2Uri' => $CFG->gallery_g2uri,
                        'loginRedirect' => $CFG->wwwroot.'/login/index.php',
                        'activeUserId' => $USER->id,
                        'fullInit' => true);
//    $initparams = array();
    $ret = GalleryEmbed::init($initparams); 
    if ($ret && $ret && $ret->getErrorCode() & ERROR_MISSING_OBJECT) {
        // user mapping has gone bonkers - map the user
        gallery_map_user_to_gallery();
        // try again after user mapping
        $ret = GalleryEmbed::init($initparams);
        if ($ret) {
            error('User mapping failed twice<br /><br />'.$ret->getAsHtml());
        }
    } else {
        // user map successful
        // update user to make sure everything is in sync
        $ret = GalleryEmbed::updateUser($USER->id, array('username'       => $USER->username,
                                                         'email'          => $USER->email,
                                                         'fullname'       => $USER->firstname.' '.$USER->lastname,
                                                         'language'       => gallery_moodle_to_gallery_language(),
                                                         'hashedpassword' => $USER->password,
                                                         'hashmethod'     => 'md5'));
        if ($ret) {
            error('Gallery User update failed <br />'.$ret->getAsHtml());
        }
    }
    gallery_r();
    return true;
}
Posts: 32509
please see:
- http://codex.gallery2.org/Gallery2:API_Changes_From_2.0_To_2.1#GalleryEmbedApi
- http://codex.gallery2.org/Gallery2:Integration_Howto#Changing_integration_code_from_Gallery_2.0_-_2.0.2_to_Gallery_2.1_compatible_integration_code
--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage
Posts: 3
I have already checked out those pages. The code is fine, and it works on windows machines but it does not work in Linux systems. I don't know why though.
Posts: 3
I am still wondering if there is anyone else that would know why this code would work fine in a Windows hosted environment, but not in a linux one. I have had a few people review the code and the 1 bug has been fixed, but it still does not work correctly in Linux. It seems that there is a path error or a database error that I have been unable to figure out.