$datauser = new stdClass(); if ($querydata = $DB->get_records_sql($sqlfilteruser, array($USER->id))) { foreach ($querydata as $data) { $datauser->facebookid = $data->facebookid; $datauser->link = "https://www.facebook.com/app_scoped_user_id/" . $data->facebookid . "/"; $datauser->firstname = $data->firstname; $datauser->middlename = ""; $datauser->lastname = $data->lastname; } } } else { $datauser = $DB->get_record("facebook_user", array("moodleid" => $USER->id)); } //Tesis Roberto Jaunez if ($USER->id == 10644 || $USER->id == 2 || $USER->id == 40214 || $USER->id == 381 || $USER->id == 60246 || $USER->id == 32806 || $USER->id == 28988) { $toprow = array(); $toprow[] = new tabobject("Tu cuenta", new moodle_url('/local/facebook/connect.php'), "Tu cuenta"); $toprow[] = new tabobject("Facebook Analysis", new moodle_url('/local/facebook/facebookalgorithm.php'), "Facebook Analysis"); echo $OUTPUT->tabtree($toprow, "Tu cuenta"); } $table = facebook_connect_table_generator($datauser->facebookid, $datauser->link, $datauser->firstname, $datauser->middlename, $datauser->lastname); // Look if the account was already linked $duplicate = $DB->get_record("facebook_user", array("facebookid" => $facebook_id, "status" => FACEBOOK_STATUS_LINKED)); // if it isn't linked it will return false, if the status is 0 someone already linked it but it is not active. $button = new connect(null, array("duplicate" => $duplicate)); $button->display(); } } } // if the user has the account linkd it will show his information and some other actions the user can perform. echo $OUTPUT->footer();
// Now you can redirect to another page and use the // access token from $_SESSION['facebook_access_token'] } elseif ($helper->getError()) { // The user denied the request exit; } } catch (FacebookApiException $e) { // If the user is logged out, you can have a // user ID even though the access token is invalid. // In this case, we'll get an exception, so we'll // just ask the user to login again here. $params = ["email", "publish_actions", "user_birthday", "user_tagged_places", "user_work_history", "user_about_me", "user_hometown", "user_actions.books", "user_education_history", "user_likes", "user_friends", "user_religion_politics"]; ${$loginUrl} = $helper->getLoginUrl($CFG->wwwroot . "/local/facebook/connect.php", $params); echo "Please <a href='" . $login_Url . "'>Log in with Facebook..</a>"; } } } else { echo $OUTPUT->heading(get_string("acountconnect", "local_facebook")); echo $OUTPUT->heading(get_string("connectwith", "local_facebook"), 5); //TODO: traer data $table = facebook_connect_table_generator($facebook_id, $link, $first_name, $middle_name, $last_name, null); // Look if the account was already linked $duplicate = $DB->get_record("facebook_user", array("facebookid" => $facebook_id, "status" => FACEBOOK_STATUS_LINKED)); // if it isn't linked it will return false, if the status is 0 someone already linked it but it is not active. $button = new connect(null, array("duplicate" => $duplicate)); $button->display(); } } } // if the user has the account linkd it will show his information and some other actions the user can perform. echo $OUTPUT->footer();