function institution_view_statistics($limit, $offset, &$institutiondata) { $data = array(); $data['tableheadings'] = array(array('name' => '#'), array('name' => get_string('view')), array('name' => get_string('Owner', 'view')), array('name' => get_string('Visits'), 'class' => 'center'), array('name' => get_string('Comments', 'artefact.comment'), 'class' => 'center')); $data['table'] = institution_view_stats_table($limit, $offset, $institutiondata); $data['tabletitle'] = get_string('viewstatstabletitle', 'admin'); $smarty = smarty_core(); $maxblocktypes = 5; if ($institutiondata['views']) { $smarty->assign('blocktypecounts', get_records_sql_array("\n SELECT\n b.blocktype,\n CASE WHEN bi.artefactplugin IS NULL THEN b.blocktype\n ELSE bi.artefactplugin || '/' || b.blocktype END AS langsection,\n COUNT(b.id) AS blocks\n FROM {block_instance} b\n JOIN {blocktype_installed} bi ON (b.blocktype = bi.name)\n JOIN {view} v ON (b.view = v.id AND v.type = 'portfolio')\n WHERE v.id IN (" . join(',', array_fill(0, $institutiondata['views'], '?')) . ")\n GROUP BY b.blocktype, langsection\n ORDER BY blocks DESC", $institutiondata['viewids'], 0, $maxblocktypes)); } $smarty->assign('viewtypes', true); $smarty->assign('institution', $institutiondata['name']); $smarty->assign('viewcount', $data['table']['count']); $data['summary'] = $smarty->fetch('admin/institutionviewstatssummary.tpl'); return $data; }
define('JSON', 1); require dirname(dirname(dirname(__FILE__))) . '/init.php'; require get_config('libroot') . 'registration.php'; $limit = param_integer('limit', 10); $offset = param_integer('offset', 0); $extradata = json_decode(param_variable('extradata')); $institution = isset($extradata->institution) ? $extradata->institution : 'mahara'; $type = param_alpha('type', 'users'); $subpages = array('users', 'views', 'content', 'historical'); if (!in_array($type, $subpages)) { $type = 'users'; } if ($type == 'historical') { $field = isset($extradata->field) ? $extradata->field : 'count_members'; } $institutiondata = institution_statistics($institution, true); switch ($type) { case 'historical': $data = institution_historical_stats_table($limit, $offset, $field, $institutiondata); break; case 'content': $data = institution_content_stats_table($limit, $offset, $institutiondata); break; case 'views': $data = institution_view_stats_table($limit, $offset, $institutiondata); break; case 'users': default: $data = institution_user_stats_table($limit, $offset, $institutiondata); } json_reply(false, (object) array('message' => false, 'data' => $data));