示例#1
0
 public function authenticate() {
   $profile=ProfileTable::load($this->_username);
   if (!$profile)
     return new Zend_Auth_Result(-1, null, array());
   if (!$profile->checkPassword($this->_password))
     return new Zend_Auth_Result(-3, null, array());
   return new Zend_Auth_Result(1, $profile, array());
 }
function showUsers($list)
{
    echo '<table>';
    /* show avatar, username, location, bio (with link to profile) */
    foreach ($list as $user) {
        echo '<tr><td style="padding-bottom: 1em;">';
        $profile = ProfileTable::load($user);
        if ($profile->getAvatar()) {
            echo '<a href="/profile/show/' . $user . '">' . '<img src="' . $profile->getAvatar() . '" width="64" height="64" /></a>' . '<br />';
        }
        echo '<a href="/profile/show/' . $user . '">' . $user . '</a>';
        echo '</td><td style="padding-bottom: 1em;">';
        echo $profile->getBio();
        echo "<br />";
        echo '<span style="font-size: 80%;">' . $profile->getLocation() . '</span>';
        echo '</td></tr>';
    }
    echo '</table>';
}
  public function showAction() {
    $request=$this->getRequest();
    $other_id=basename($request->getRequestUri());
    $other_profile=ProfileTable::load($other_id);
    $this->view->profile=$other_profile;

    // check if we are following this user 
    $profile=Zend_Auth::getInstance()->getIdentity();
    $user=UserTable::load($profile->getId());
    if ($user->isFollowing($other_id))
      $this->view->is_following=true;
    else
      $this->view->is_following=false;

    $other_user=UserTable::load($other_id);

    // get number of followers
    $this->view->followers_count=$other_user->getFollowersCount();
    // get most recent followers (max 5)
    $this->view->followers=$other_user->getFollowers(0, 5);

    // get number of users i am following
    $this->view->following_count=$other_user->getFollowingCount();
    // get most recent followings (max 5)
    $this->view->following=$other_user->getFollowing(0, 5);

    // get number of my tweets
    $this->view->my_stream_count=$other_user->getMyStreamCount();
    // get my most recent tweets (max 5)
    $this->view->my_stream=$other_user->getMyStream(0, 5);
  }