| @@ 23-65 (lines=43) @@ | ||
| 20 | * Lists the Number of people who have signed up in the past months categorized |
|
| 21 | * by month. |
|
| 22 | */ |
|
| 23 | class ForumReport_MemberSignups extends Report |
|
| 24 | { |
|
| 25 | ||
| 26 | public function title() |
|
| 27 | { |
|
| 28 | return _t('Forum.FORUMSIGNUPS', 'Forum Signups by Month'); |
|
| 29 | } |
|
| 30 | ||
| 31 | public function sourceRecords($params = array()) |
|
| 32 | { |
|
| 33 | $membersQuery = new SQLQuery(); |
|
| 34 | $membersQuery->setFrom('"Member"'); |
|
| 35 | $membersQuery->setSelect(array( |
|
| 36 | 'Month' => DB::getConn()->formattedDatetimeClause('"Created"', '%Y-%m'), |
|
| 37 | 'Signups' => 'COUNT("Created")' |
|
| 38 | )); |
|
| 39 | $membersQuery->setGroupBy('"Month"'); |
|
| 40 | $membersQuery->setOrderBy('"Month"', 'DESC'); |
|
| 41 | $members = $membersQuery->execute(); |
|
| 42 | ||
| 43 | $output = ArrayList::create(); |
|
| 44 | foreach ($members as $member) { |
|
| 45 | $member['Month'] = date('Y F', strtotime($member['Month'])); |
|
| 46 | $output->add(ArrayData::create($member)); |
|
| 47 | } |
|
| 48 | return $output; |
|
| 49 | } |
|
| 50 | ||
| 51 | public function columns() |
|
| 52 | { |
|
| 53 | $fields = array( |
|
| 54 | 'Month' => 'Month', |
|
| 55 | 'Signups' => 'Signups' |
|
| 56 | ); |
|
| 57 | ||
| 58 | return $fields; |
|
| 59 | } |
|
| 60 | ||
| 61 | public function group() |
|
| 62 | { |
|
| 63 | return 'Forum Reports'; |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Member Posts Report. |
|
| @@ 72-114 (lines=43) @@ | ||
| 69 | * Lists the Number of Posts made in the forums in the past months categorized |
|
| 70 | * by month. |
|
| 71 | */ |
|
| 72 | class ForumReport_MonthlyPosts extends Report |
|
| 73 | { |
|
| 74 | ||
| 75 | public function title() |
|
| 76 | { |
|
| 77 | return _t('Forum.FORUMMONTHLYPOSTS', 'Forum Posts by Month'); |
|
| 78 | } |
|
| 79 | ||
| 80 | public function sourceRecords($params = array()) |
|
| 81 | { |
|
| 82 | $postsQuery = new SQLQuery(); |
|
| 83 | $postsQuery->setFrom('"Post"'); |
|
| 84 | $postsQuery->setSelect(array( |
|
| 85 | 'Month' => DB::getConn()->formattedDatetimeClause('"Created"', '%Y-%m'), |
|
| 86 | 'Posts' => 'COUNT("Created")' |
|
| 87 | )); |
|
| 88 | $postsQuery->setGroupBy('"Month"'); |
|
| 89 | $postsQuery->setOrderBy('"Month"', 'DESC'); |
|
| 90 | $posts = $postsQuery->execute(); |
|
| 91 | ||
| 92 | $output = ArrayList::create(); |
|
| 93 | foreach ($posts as $post) { |
|
| 94 | $post['Month'] = date('Y F', strtotime($post['Month'])); |
|
| 95 | $output->add(ArrayData::create($post)); |
|
| 96 | } |
|
| 97 | return $output; |
|
| 98 | } |
|
| 99 | ||
| 100 | public function columns() |
|
| 101 | { |
|
| 102 | $fields = array( |
|
| 103 | 'Month' => 'Month', |
|
| 104 | 'Posts' => 'Posts' |
|
| 105 | ); |
|
| 106 | ||
| 107 | return $fields; |
|
| 108 | } |
|
| 109 | ||
| 110 | public function group() |
|
| 111 | { |
|
| 112 | return 'Forum Reports'; |
|
| 113 | } |
|
| 114 | } |
|
| 115 | ||