コード例 #1
0
ファイル: Follower.php プロジェクト: hamaco/phwittr-on-xoops
 /**
  * @test
  */
 public function isFollowed()
 {
     $user1 = $this->getUser("test1");
     $user2 = $this->getUser("test2");
     $user3 = $this->getUser("test3");
     $this->isFalse(Follower::isFollowed($user1->id, $user2->id));
     $this->isTrue(Follower::isFollowed($user1->id, $user3->id));
     $this->isTrue(Follower::isFollowed($user2->id, $user1->id));
     $this->isTrue(Follower::isFollowed($user2->id, $user3->id));
     $this->isTrue(Follower::isFollowed($user3->id, $user1->id));
     $this->isFalse(Follower::isFollowed($user3->id, $user2->id));
 }
コード例 #2
0
ファイル: Follow.php プロジェクト: hamaco/phwittr-on-xoops
 /**
  * @test
  */
 public function deny()
 {
     $follow = $this->getLogic("follow");
     $user1 = $this->getUser("test1");
     $user2 = $this->getUser("test2");
     $follow->add($user1->id, $user2->id);
     $this->isTrue(Request::isRequested($user1->id, $user2->id));
     $this->isFalse(Follower::isFollowed($user1->id, $user2->id));
     $follow->deny($user2->id, $user1->id);
     $this->isFalse(Request::isRequested($user1->id, $user2->id));
     $this->isFalse(Follower::isFollowed($user1->id, $user2->id));
     $this->clear("Follower");
     $this->clear("Request");
 }
コード例 #3
0
ファイル: Users.php プロジェクト: hamaco/phwittr-on-xoops
 protected function home()
 {
     $protected = $this->aUser->isProtected();
     $this->clientId = $this->session->getClientId();
     if ($authenticated = $this->aclUser->isAuthenticated()) {
         $this->isFollowed = Follower::isFollowed($this->aclUser->id, $this->aUser->uid);
         if ($this->isFollowed) {
             $protected = false;
         }
     }
     if ($protected) {
         if ($authenticated) {
             $this->isRequested = Request::isRequested($this->aclUser->id, $this->aUser->uid);
         }
         $this->view->setName("protected");
     } else {
         $helper = new Helpers_Paginator_Status();
         $this->paginator = $helper->getStatuses($this->aUser->uid, $this->GET_VARS, 50);
         $this->view->setName("home");
     }
 }
コード例 #4
0
ファイル: User.php プロジェクト: hamaco/phwittr-on-xoops
 /**
  * @test
  */
 public function moveRequestsToFollower()
 {
     $user2 = $this->getUser("test2");
     $this->isTrue($user2->isProtected());
     $user1 = $this->getUser("test1");
     $user3 = $this->getUser("test3");
     $request = new Request();
     $request->insert(array("user_id" => $user1->id, "request_id" => $user2->id, "created_at" => now()));
     $request->insert(array("user_id" => $user3->id, "request_id" => $user2->id, "created_at" => now()));
     $this->isTrue(Request::isRequested($user1->id, $user2->id));
     $this->isTrue(Request::isRequested($user3->id, $user2->id));
     $this->isFalse(Follower::isFollowed($user1->id, $user2->id));
     $this->isFalse(Follower::isFollowed($user3->id, $user2->id));
     $user2->private_flag = false;
     $this->getLogic("user")->updateSettings($user2);
     $this->isFalse($user2->isProtected());
     $this->isFalse(Request::isRequested($user1->id, $user2->id));
     $this->isFalse(Request::isRequested($user3->id, $user2->id));
     $this->isTrue(Follower::isFollowed($user1->id, $user2->id));
     $this->isTrue(Follower::isFollowed($user3->id, $user2->id));
     $this->clear("Request");
     $this->clear("Follower");
 }
コード例 #5
0
ファイル: Follow.php プロジェクト: hamaco/phwittr-on-xoops
 /**
  * @userCache
  *
  * @param int $userId   ユーザID
  * @param int $targetId フォロー中ユーザのID
  *
  * @return Logics_Result
  */
 public function remove($userId, $targetId)
 {
     $result = new Logics_Result();
     $aUser = new User($userId);
     $target = new User($targetId);
     if ($aUser->isSelected() && $target->isSelected()) {
         if (!Follower::isFollowed($userId, $targetId) && $target->isProtected()) {
             $request = new Request();
             $request->setCondition("user_id", $userId);
             $request->setCondition("request_id", $targetId);
             $request->delete();
             $result->removeType = "request";
         } else {
             $follower = new Follower();
             $follower->setCondition("user_id", $userId);
             $follower->setCondition("follow_id", $targetId);
             $follower->delete();
             $result->removeType = "follow";
         }
     } else {
         $result->failure();
     }
     return $result;
 }
コード例 #6
0
ファイル: Index.php プロジェクト: hamaco/phwittr-on-xoops
 /**
  * @check param required nNumber
  */
 public function status()
 {
     $this->aStatus = $this->fetchModel("Status", $this->param);
     if (!$this->aStatus) {
         return;
     }
     $isSelf = false;
     $this->aUser = $aUser = new User($this->aStatus->user_id);
     // $this->protected = $aUser->isProtected();
     $this->protected = false;
     if ($this->aclUser->isAuthenticated()) {
         if ($this->aclUser->id === $aUser->uid) {
             $isSelf = true;
             $this->protected = false;
         } elseif (Follower::isFollowed($this->aclUser->id, $aUser->uid)) {
             $this->protected = false;
         }
     }
     if ($isSelf) {
         $this->submenu->setUser($this->aclUser->id);
     } else {
         $this->submenu->setUser($aUser->uid, Views_Submenu::TYPE_OTHERS);
     }
 }