コード例 #1
0
 public function actionView()
 {
     $model = YumFriendship::model()->findByPK($_GET['id']);
     $model->acknowledgetime = date('M/j/y g:i', $model->acknowledgetime);
     $model->requesttime = date('M/j/y g:i', $model->requesttime);
     $model->updatetime = date('M/j/y g:i', $model->updatetime);
     $this->render('view', array('model' => $model));
 }
コード例 #2
0
 public function getFriends($everything = false)
 {
     if ($everything) {
         $condition = 'inviter_id = :uid';
     } else {
         $condition = 'inviter_id = :uid and status = 2';
     }
     $friends = array();
     Yii::import('application.modules.friendship.models.YumFriendship');
     $friendships = YumFriendship::model()->findAll($condition, array(':uid' => $this->id));
     if ($friendships != NULL && !is_array($friendships)) {
         $friendships = array($friendships);
     }
     if ($friendships) {
         foreach ($friendships as $friendship) {
             $friends[] = YumUser::model()->findByPk($friendship->friend_id);
         }
     }
     if ($everything) {
         $condition = 'friend_id = :uid';
     } else {
         $condition = 'friend_id = :uid and status = 2';
     }
     $friendships = YumFriendship::model()->findAll($condition, array(':uid' => $this->id));
     if ($friendships != NULL && !is_array($friendships)) {
         $friendships = array($friendships);
     }
     if ($friendships) {
         foreach ($friendships as $friendship) {
             $friends[] = YumUser::model()->findByPk($friendship->inviter_id);
         }
     }
     return $friends;
 }
コード例 #3
0
 public static function areFriends($uid1, $uid2)
 {
     if (is_numeric($uid1) && is_numeric($uid2)) {
         $friendship = YumFriendship::model()->find('status = 2 and inviter_id = ' . $uid1 . ' and friend_id = ' . $uid2);
         if ($friendship) {
             return true;
         }
         $friendship = YumFriendship::model()->find('status = 2 and inviter_id = ' . $uid2 . ' and friend_id = ' . $uid1);
         if ($friendship) {
             return true;
         }
     }
     return false;
 }