diff --git a/apps/pc_frontend/i18n/messages.ja.xml b/apps/pc_frontend/i18n/messages.ja.xml index 44edd15..1bc3ddf 100644 --- a/apps/pc_frontend/i18n/messages.ja.xml +++ b/apps/pc_frontend/i18n/messages.ja.xml @@ -218,6 +218,10 @@ [1]1 topic has new comments|(1,Inf]%1% topics have new comments [1,Inf]%1% 件のトピックに新着コメントがあります + + Recently Posted %Community% Topics By This Member + 書き込み一覧 + diff --git a/apps/pc_frontend/modules/communityTopic/templates/_topicCommentByMemberListBox.php b/apps/pc_frontend/modules/communityTopic/templates/_topicCommentByMemberListBox.php new file mode 100644 index 0000000..cf449ed --- /dev/null +++ b/apps/pc_frontend/modules/communityTopic/templates/_topicCommentByMemberListBox.php @@ -0,0 +1,17 @@ + +
+

+
+
    + +
  • getUpdatedAt(), 'XShortDateJa') ?> +getName(), 36), + $topic->getCommunityTopicComment()->count() + ), '@communityTopic_show?id='.$topic->getId()) + ?>
  • + +
+
+
+ diff --git a/config/profile_gadget.yml b/config/profile_gadget.yml new file mode 100644 index 0000000..b99cbe9 --- /dev/null +++ b/config/profile_gadget.yml @@ -0,0 +1,15 @@ +recentCommunityTopicCommentForProfile: + caption: + ja_JP: "書き込み一覧" + description: + ja_JP: "プロフィールを表示中のメンバーが書き込んだコミュニティトピックの一覧を表示します" + component: [communityTopic, topicCommentByMemberListBox] + config: + col: + Name: "col" + Caption: "表示するトピック数" + FormType: "select" + ValueType: "integer" + IsRequired: true + Default: 5 + Choices: {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10} diff --git a/lib/action/opCommunityTopicPluginTopicComponents.class.php b/lib/action/opCommunityTopicPluginTopicComponents.class.php index bcfd9ff..5bfcb3e 100644 --- a/lib/action/opCommunityTopicPluginTopicComponents.class.php +++ b/lib/action/opCommunityTopicPluginTopicComponents.class.php @@ -77,4 +77,17 @@ public function executeSmtMemberLatestTopicList($request) return sfView::SUCCESS; } + + public function executeTopicCommentByMemberListBox($request) + { + if ($request->hasParameter('id') && $request->getParameter('module') == 'member' && $request->getParameter('action') == 'profile') + { + $this->member = Doctrine::getTable('Member')->find($request->getParameter('id')); + } + else + { + $this->member = $this->getUser()->getMember(); + } + $this->communityTopic = Doctrine::getTable('CommunityTopic')->retrivesCommentsByMemberId($this->member->getId(), $this->gadget->getConfig('col')); + } } diff --git a/lib/model/doctrine/PluginCommunityTopicCommentTable.class.php b/lib/model/doctrine/PluginCommunityTopicCommentTable.class.php index 7cb6641..7e2f4fd 100644 --- a/lib/model/doctrine/PluginCommunityTopicCommentTable.class.php +++ b/lib/model/doctrine/PluginCommunityTopicCommentTable.class.php @@ -56,4 +56,21 @@ public function getMaxNumber($communityTopicId) return 0; } + + public function getCommentedIdsByMemberId($memberId) + { + $result = array(); + + $resultSet = $this->createQuery() + ->select('community_topic_id') + ->where('member_id = ?', $memberId) + ->execute(array(), Doctrine::HYDRATE_NONE); + + foreach ($resultSet as $value) + { + $result[] = $value[0]; + } + + return $result; + } } diff --git a/lib/model/doctrine/PluginCommunityTopicTable.class.php b/lib/model/doctrine/PluginCommunityTopicTable.class.php index f6944ea..e398c93 100644 --- a/lib/model/doctrine/PluginCommunityTopicTable.class.php +++ b/lib/model/doctrine/PluginCommunityTopicTable.class.php @@ -120,4 +120,34 @@ public function getResultListPager(Doctrine_Query $query, $page = 1, $size = 20) return $pager; } + + public function retrivesCommentsByMemberId($memberId, $limit = 5) + { + $communityTopicIdsComment = Doctrine::getTable('CommunityTopicComment')->getCommentedIdsByMemberId($memberId); + $communityTopicIdsTopic = Doctrine::getTable('CommunityTopic')->getCommentedIdsByMemberId($memberId); + $communityTopicIds = array_merge($communityTopicIdsComment, $communityTopicIdsTopic); + + return $this->createQuery() + ->whereIn('id', $communityTopicIds) + ->limit($limit) + ->orderBy('updated_at DESC') + ->execute(); + } + + public function getCommentedIdsByMemberId($memberId) + { + $result = array(); + + $resultSet = $this->createQuery() + ->select('id') + ->where('member_id = ?', $memberId) + ->execute(array(), Doctrine::HYDRATE_NONE); + + foreach ($resultSet as $value) + { + $result[] = $value[0]; + } + + return $result; + } }