unset($current_user_item); $mbuser = $external_id_manager->getExternalId($system,$commsy_user_id); if ( !empty($mbuser) ) { //load last login info before it will be updated if($userRecord = $mediabirdDb->getRecord(MediabirdConfig::tableName('User',true),"id=$mbuser")) { //get last login time $lastLogin = $mediabirdDb->timestamp($userRecord->last_login); //save login time $_SESSION['mb_session_time'] = $lastLogin; } $helper->updateUser($mbuser,$fullname,1,null, $pic_url, $mediabirdDb); } else { $mbuser = $helper->registerUser($fullname,1,null, $pic_url, $mediabirdDb); if ( !empty($mbuser) ) { $external_id_manager->addIDsToDB($system,$mbuser,$commsy_user_id); } else { include_once('functions/error_functions.php'); trigger_error('can not initiate mediabird account',E_USER_ERROR); } } unset($external_id_manager); if ( !empty($language) and strtolower($language) == 'de' ) { $helper->defaultOptions['language'] = MediabirdHtmlHelper::langGerman; }
$helper = new MediabirdHtmlHelper(); unset($action); if (isset($_POST["data"]) && isset($_POST["data"]["action"])) { $action = $_POST["data"]["action"]; } else { if (isset($_GET["action"])) { $action = $_GET["action"]; } } if ($account_link = get_record("studynotes_account_links", "system", "moodle", "external_id", $moodleid)) { $mbuser = $account_link->internal_id; if (!isset($action)) { $helper->updateUser($mbuser, $fullname, 1, $email); } } else { if ($mbuser = $helper->registerUser($fullname, 1, $email)) { $account_link = (object) null; $account_link->external_id = $moodleid; $account_link->internal_id = $mbuser; $account_link->system = "moodle"; insert_record("studynotes_account_links", $account_link, false); } else { error(get_string('error_linking', 'studynotes')); } } $auth = new MediabirdMoodleAuth($mbuser); //set up config MediabirdConfig::$latex_path = $CFG->studynotes_latex_path; MediabirdConfig::$convert_path = $CFG->studynotes_dvipng_path; //set up proxy if (isset($CFG->proxyhost) && strlen($CFG->proxyhost) > 0 && (!isset($CFG->proxytype) || $CFG->proxytype == 'HTTP')) {
/** * Called to invite a user to Mediabird * Should return a Mediabird user ID or null on failure (email not unique or does not exist) * @param $email String Email of user to be invited * @return int Mediabird user id */ function inviteUser ($email) { $retour = NULL; if ( !empty($email) ) { $user_manager = $this->_environment->getUserManager(); $user_manager->setContextLimit($this->_environment->getCurrentPortalID()); $user_manager->setEMailLimit($email); $user_manager->select(); $user_list = $user_manager->get(); if ( isset($user_list) and $user_list->isNotEmpty() and $user_list->getCount() == 1 ) { $user_item = $user_list->getFirst(); if ( isset($user_item) and $user_item->isEmailVisible() ) { $external_id_manager = $this->_environment->getExternalIDManager(); $mbuser = $external_id_manager->getExternalId($this->_system,$user_item->getItemID()); $fullname = $user_item->getFullname(); global $plugin_dir; include($plugin_dir.'/server/helper.php'); $helper = new MediabirdHtmlHelper(); if ( empty($mbuser) ) { #$pic_url = $user_item->getPictureUrl(true); if ( !empty($user_item) ) { $pic_url = $this->_plugin_class->getPictureUrlForCommSyUserByItem($user_item); } $email = null; if ( $user_item->isEmailVisible() ) { $email = $user_item->getEMail(); } $mbuser = $helper->registerUser($fullname, 0, $email, $pic_url, $this->db); $external_id_manager->addIDsToDB($this->_system,$mbuser,$user_item->getItemID()); } unset($external_id_manager); $retour = intval($mbuser); } } } return $retour; }