Source of file ForumReport.php
Size: 2,680 Bytes - Last Modified: 2021-12-23T10:30:31+00:00
/var/www/docs.ssmods.com/process/src/code/reports/ForumReport.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 | <?php /** * Forum Reports. * These are some basic reporting tools which sit in the CMS for the user to view. * No fancy graphing tools or anything just some simple querys and numbers * * @package forum */ /** * Member Signups Report. * Lists the Number of people who have signed up in the past months categorized * by month. */ class ForumReport_MemberSignups extends SS_Report { public function title() { return _t('Forum.FORUMSIGNUPS', 'Forum Signups by Month'); } public function sourceRecords($params = array()) { $membersQuery = new SQLQuery(); $membersQuery->setFrom('"Member"'); $membersQuery->setSelect(array( 'Month' => DB::getConn()->formattedDatetimeClause('"Created"', '%Y-%m'), 'Signups' => 'COUNT("Created")' )); $membersQuery->setGroupBy('"Month"'); $membersQuery->setOrderBy('"Month"', 'DESC'); $members = $membersQuery->execute(); $output = ArrayList::create(); foreach ($members as $member) { $member['Month'] = date('Y F', strtotime($member['Month'])); $output->add(ArrayData::create($member)); } return $output; } public function columns() { $fields = array( 'Month' => 'Month', 'Signups' => 'Signups' ); return $fields; } public function group() { return 'Forum Reports'; } } /** * Member Posts Report. * Lists the Number of Posts made in the forums in the past months categorized * by month. */ class ForumReport_MonthlyPosts extends SS_Report { public function title() { return _t('Forum.FORUMMONTHLYPOSTS', 'Forum Posts by Month'); } public function sourceRecords($params = array()) { $postsQuery = new SQLQuery(); $postsQuery->setFrom('"Post"'); $postsQuery->setSelect(array( 'Month' => DB::getConn()->formattedDatetimeClause('"Created"', '%Y-%m'), 'Posts' => 'COUNT("Created")' )); $postsQuery->setGroupBy('"Month"'); $postsQuery->setOrderBy('"Month"', 'DESC'); $posts = $postsQuery->execute(); $output = ArrayList::create(); foreach ($posts as $post) { $post['Month'] = date('Y F', strtotime($post['Month'])); $output->add(ArrayData::create($post)); } return $output; } public function columns() { $fields = array( 'Month' => 'Month', 'Posts' => 'Posts' ); return $fields; } public function group() { return 'Forum Reports'; } } |