/** * Create a link that allows for displaying embedded Jasper reports * on an HTML page * * @param $uri The resource id of the necessary report * @param $parameters Additional parameters to be passed to the report * @param $print If true, prints iframe on page * @return The HTML of the iframe containing the report * */ function embeddedreports_generate_link($uri, $parameters = array(), $print = true) { global $USER; $parameters['elisembedded'] = 'true'; if (!is_enabled_auth('mnet')) { error('mnet is disabled'); } // check remote login permissions if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM)) or is_mnet_remote_user($USER) or $USER->username == 'guest' or empty($USER->id)) { print_error('notpermittedtojump', 'mnet'); } $mnet_auth = get_auth_plugin('mnet'); // check for SSO publish permission first if ($mnet_auth->has_service(jasper_mnet_hostid(), 'sso_sp') == false) { print_error('hostnotconfiguredforsso', 'mnet'); } $mnet_link = jasper_mnet_link(jasper_report_link($uri, $parameters)); $result = '<iframe id="reportframe" name="reportframe" src="' . $mnet_link . '"></iframe>'; if ($print) { echo $result; } return $result; }
function get_moodle_url() { if (isset($this->params['report'])) { $reportdata = jasperreportpage::$reports[$this->params['report']]; if (isset($this->params['id'])) { // only handle user forms for now if ($reportdata['type'] == 'user') { return new moodle_url(jasper_mnet_link(jasper_report_link($this->params['report'], array('userid' => $this->params['id'])))); } } return new moodle_url(jasper_mnet_link(jasper_report_link($this->params['report']))); } else { if (isset(jasperreportpage::$js_pages[$this->params['action']])) { return new moodle_url(jasper_mnet_link(jasperreportpage::$js_pages[$this->params['action']])); } else { return newpage::get_moodle_url(); } } }
/** * Get the data to display for this table page. * * @param bool $download Flag to not include HTML for report download. * @return array An array of data records. */ function get_data($download = false) { global $CURMAN, $USER, $CFG; $context = get_context_instance(CONTEXT_SYSTEM); $LIKE = $CURMAN->db->sql_compare(); $FULLNAME = sql_concat('usr.firstname', "' '", 'usr.lastname'); $cselect = 'SELECT COUNT(DISTINCT usr.id) '; $select = "SELECT usr.id,\n usr.idnumber as idnumber,\n clst.display as clustername,\n usr.country as country,\n curass.id as curassid,\n curass.curriculumid as curid,\n cur.name as curname,\n {$FULLNAME} as student "; $tables = "FROM " . $CURMAN->db->prefix_table(USRTABLE) . " usr\n LEFT JOIN " . $CURMAN->db->prefix_table(CURASSTABLE) . " curass ON curass.userid = usr.id\n LEFT JOIN " . $CURMAN->db->prefix_table(CURTABLE) . " cur ON cur.id = curass.curriculumid\n LEFT JOIN " . $CURMAN->db->prefix_table(CLSTUSERTABLE) . " uclst ON uclst.userid = usr.id\n LEFT JOIN " . $CURMAN->db->prefix_table(CLSTTABLE) . " clst ON clst.id = uclst.clusterid "; $where = ''; if (!has_capability('block/curr_admin:viewreports', $context)) { if (has_capability('block/curr_admin:viewgroupreports', $context)) { $clstid = get_field(CLSTUSERTABLE, 'clusterid', 'userid', cm_get_crlmuserid($USER->id)); $where .= "(uclst.clusterid = {$clstid}) "; } } if ($this->extrasql) { $where .= (!empty($where) ? ' AND ' : '') . $this->extrasql . ' '; } if (!empty($where)) { $where = 'WHERE ' . $where . ' '; } if (!empty($this->sort)) { $sort = 'ORDER BY ' . $this->sort . ' ' . $this->dir . ' '; } else { $sort = ''; } if (!empty($this->perpage)) { if ($CURMAN->db->_dbconnection->databaseType == 'postgres7') { $limit = 'LIMIT ' . $this->perpage . ' OFFSET ' . $this->page * $this->perpage; } else { $limit = 'LIMIT ' . $this->page * $this->perpage . ', ' . $this->perpage; } } else { $limit = ''; } /// Count the total number of results. $sql = $cselect . $tables . $where; $this->numrecs = $CURMAN->db->count_records_sql($sql); /// Get the current 'page' of results. $sql = $select . $tables . $where . $sort . $limit; $this->data = $CURMAN->db->get_records_sql($sql); $context = get_context_instance(CONTEXT_SYSTEM, SITEID); if (!empty($this->data)) { foreach ($this->data as $di => $datum) { $datum->currentclassid = 0; $datum->currentclass = ''; $datum->lastclassid = 0; $datum->lastclass = ''; $context = get_context_instance(CONTEXT_SYSTEM, SITEID); $timenow = time(); if (!$download) { // if (has_capability('block/curr_admin:viewlocationusers', $context)) { $datum->student = '<a href="index.php?s=rep&section=rept&type=' . 'induser&user='******'">' . $datum->student . '</a> ' . ' ' . '<a href="' . $CFG->wwwroot . '/auth/mnet/jump.php?hostid=' . jasper_mnet_hostid() . '&wantsurl=' . rawurlencode(jasper_report_link(jasper_common_reports_folder() . '/induser', array('userid' => $datum->id))) . '" target="RL_ELIS_reports">JasperServer</a>' . ' ' . '<a href="index.php?s=rep&section=rept&type=' . 'transcript&user='******'">Transcript</a>'; // } // if (!empty($datum->currentclass) && // has_capability('block/curr_admin:viewlocationusers', $context)) { if (!empty($datum->currentclass)) { $datum->currentclass = '<a href="index.php?s=rep&section=rept&type=' . 'classroster&class=' . $datum->currentclassid . '">' . $datum->currentclass . '</a>'; } // if (!empty($datum->lastclass) && // has_capability('block/curr_admin:viewlocationusers', $context)) { if (!empty($datum->lastclass)) { $datum->lastclass = '<a href="index.php?s=rep&section=rept&type=' . 'classroster&class=' . $datum->lastclassid . '">' . $datum->lastclass . '</a>'; } } $this->data[$di] = $datum; } } }