Пример #1
0
 /**
  * Checks if a session is active.
  *
  * @param   string   role name
  * @param   array    collection of role names
  * @return  boolean
  */
 public function logged_in($role = NULL)
 {
     $user = $this->session->get($this->config['session_key']);
     if (!(is_object($user) and $user instanceof Model_User and $user->loaded())) {
         if ($fb_uid = FB::get_loggedin_user()) {
             $user = ORM::factory('user')->where('fb_uid', '=', $fb_uid)->find();
             $this->force_login($user);
         }
     }
     return parent::logged_in($role);
 }
Пример #2
0
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
    <head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Facebook API Example</title>
	<?php 
echo FB::feature_loader();
?>
    </head>
    <body>
	<h1> Facebook Connect API Example </h1>
	<div id="comments_post">
	    <h3>Leave a comment:</h3>
	    <form method="POST">
		<div id="user">
		    <?php 
if (FB::get_loggedin_user()) {
    ?>
			<span>
			<?php 
    echo FB::profile_pic();
    ?>
			Welcome, <?php 
    echo FB::name(array('useyou' => 'false'));
    ?>
. You are signed in with your Facebook account.
			</span>
		    <?php 
} else {
    ?>
			Name: <input name="name" size="27"/><br/>
			Or, you can <?php 
Пример #3
0
 /**
  * Gets the currently logged in user from the session.
  * Returns FALSE if no user is currently logged in.
  *
  * @return  mixed
  */
 public function get_user()
 {
     $user = parent::get_user();
     if ($user !== FALSE) {
         return $user;
     }
     if ($fb_uid = FB::get_loggedin_user()) {
         $user = Sprig::factory('User', array('fb_uid' => $fb_uid))->load();
         if (is_object($user) and $user->loaded()) {
             $this->_user = $user;
             return $this->_user;
         }
     }
     return FALSE;
 }