Esempio n. 1
0
 function me()
 {
     $user = null;
     if ($this->sauth->is_logged_in()) {
         $user_id = $this->session->userdata('user_id');
         if (false !== $user_id) {
             $user = $this->user_dal->get_user_by_id($user_id);
         }
     }
     // show error if not logged in
     if (null === $user) {
         if ($this->is_request_json()) {
             $json = array('error' => 'You are not logged in, fella.');
             return send_json($this->output, 401, $json);
         } else {
             return show_error('You are not logged in, fella.', 401);
         }
     }
     // send response for logged in user
     if ($this->is_request_json()) {
         $user_id = $this->session->userdata('user_id');
         return send_json($this->output, 200, array('ok' => true, 'user_id' => (int) $user_id, 'username' => $this->session->userdata('username'), 'avatar_url' => avatar_url_for_logged_in_user(true), 'unread_message_count' => (int) $this->message_dal->unread_messages($user_id), 'online_buddies' => $this->get_online_buddies()));
     } else {
         return redirect_with_format('/user/' . $user->username);
     }
 }
Esempio n. 2
0
        <div class="lc-node welcome">
          <h4>
            Hi, <a href="/user/<?php 
    echo $username;
    ?>
"><?php 
    echo $username;
    ?>
</a>
          </h4>
          <a href="/user/<?php 
    echo $username;
    ?>
">
	    <img src="<?php 
    echo avatar_url_for_logged_in_user();
    ?>
" class="main_avatar" />
          </a>
          <ul>
	    <li><a href="/preferences" id="preferences">Preferences</a></li>
            <li><form action='/auth/logout' method='POST'>
              <input type='submit' id="logout_btn" value="logout" /></form></li>
          </ul>
        </div>
<?php 
}
if ($logged_in) {
    $unread_messages = $this->message_dal->unread_messages($user_id);
    if ($unread_messages === 0) {
        $unread_msg = "No New Messages";
Esempio n. 3
0
<?php

header('Content-Type: application/json');
?>

<?php 
$this->load->helper('avatar');
function null_if_empty_string($string)
{
    if (0 === strlen(trim($string))) {
        return null;
    }
    return $string;
}
if (null === $recent_posts) {
    $recent_posts = array();
}
foreach ($recent_posts as $key => $post) {
    $recent_posts[$key]['created'] = date(DateTime::ISO8601, strtotime($post['created']));
}
$user_profile = array('id' => (int) $user_data->id, 'username' => $user_data->username, 'created' => date(DateTime::ISO8601, strtotime($user_data->created)), 'avatar_url' => avatar_url_for_logged_in_user(true), 'online_status' => strtolower(str_replace(' ', '_', $user_data->online_status)), 'last_login' => null === $user_data->last_login ? null : date(DateTime::ISO8601, strtotime($user_data->last_login)), 'buddy_count' => $buddy_count, 'threads_count' => $user_data->threads_count, 'comments_count' => $user_data->comments_count, 'average_posts_per_day' => $user_data->average_posts, 'about' => null_if_empty_string($user_data->about_blurb), 'name' => null_if_empty_string($user_data->name), 'location' => null_if_empty_string($user_data->location), 'website_1' => null_if_empty_string($user_data->website_1), 'website_2' => null_if_empty_string($user_data->website_2), 'website_3' => null_if_empty_string($user_data->website_3), 'aim' => null_if_empty_string($user_data->aim), 'delicious_username' => null_if_empty_string($user_data->delicious_username), 'facebook' => null_if_empty_string($user_data->facebook), 'flickr_username' => null_if_empty_string($user_data->flickr_username), 'gchat' => null_if_empty_string($user_data->gchat), 'lastfm' => null_if_empty_string($user_data->lastfm), 'msn' => null_if_empty_string($user_data->msn), 'twitter' => null_if_empty_string($user_data->twitter), 'rss_feed_1' => null_if_empty_string($user_data->rss_feed_1), 'rss_feed_2' => null_if_empty_string($user_data->rss_feed_2), 'rss_feed_3' => null_if_empty_string($user_data->rss_feed_3), 'recent_posts' => $recent_posts);
?>

<?php 
echo json_encode($user_profile);