public function getFriendsAndMyStatuses($userId, $params, $limit = null) { if ($limit === null) { $limit = self::DEFAULT_ITEM_LIMIT; } $ids = Follower::getFriendIds($userId); $ids[] = $userId; $join = new Sabel_Db_Join("Status"); $paginator = new Paginator($join->add("Users")); $paginator->setCondition(C::create(C::IN, "Users.uid", $ids)); $paginator->setDefaultOrder("Status.created_at", "desc"); return $paginator->build($limit, $params); }
/** * @transaction * * @param int $userId ユーザID * * @return Logics_Result */ public function destroy($userId) { $result = new Logics_Result(); $aUser = new User($userId); if ($aUser->isSelected()) { $or = new Sabel_Db_Condition_Or(); $or->add(C::create(C::EQUAL, "user_id", $aUser->id)); $or->add(C::create(C::EQUAL, "request_id", $aUser->id)); $request = new Request(); $request->delete($or); $or = new Sabel_Db_Condition_Or(); $or->add(C::create(C::EQUAL, "user_id", $aUser->id)); $or->add(C::create(C::EQUAL, "follow_id", $aUser->id)); $follower = new Follower(); $follower->delete($or); $status = new Status(); $status->delete("user_id", $userId); $aUser->save(array("delete_flag" => true)); } return $result; }