function can_do_default() { global $USER; $id = $this->required_param('id', PARAM_INT); $cmuserid = cm_get_crlmuserid($USER->id); if ($cmuserid != 0 && $cmuserid == $id) { return true; } return usermanagementpage::_has_capability('block/php_report:view'); }
function can_do_default() { global $CURMAN; $id = $this->required_param('id', PARAM_INT); if ($this->is_assigning()) { // we have enrol capabilities on some curriculum $curriculum_contexts = curriculumpage::get_contexts('block/curr_admin:curriculum:enrol'); if (!$curriculum_contexts->is_empty()) { return true; } // find curricula linked to clusters where the target user is a // member, and we have enrol cluster user capabilities $cluster_contexts = clusterpage::get_contexts('block/curr_admin:curriculum:enrol_cluster_user'); $cluster_filter = $cluster_contexts->sql_filter_for_context_level('clst.id', 'cluster'); $sql = "SELECT COUNT(curr.id)\n FROM {$CURMAN->db->prefix_table(CLSTTABLE)} clst\n JOIN {$CURMAN->db->prefix_table(CLSTCURTABLE)} clstcurr\n ON clst.id = clstcurr.clusterid\n JOIN {$CURMAN->db->prefix_table(CURTABLE)} curr\n ON clstcurr.curriculumid = curr.id\n JOIN {$CURMAN->db->prefix_table(CLSTUSERTABLE)} usrclst ON usrclst.clusterid = clst.id AND usrclst.userid = {$id}\n WHERE {$cluster_filter}"; return $CURMAN->db->count_records_select($sql) > 0; } else { return usermanagementpage::_has_capability('block/curr_admin:user:view', $id); } }
function get_item_display_idnumber($column, $item) { global $CFG, $USER; $usermanagementpage = new usermanagementpage(); if ($usermanagementpage->can_do_view()) { $target = $usermanagementpage->get_new_page(array('action' => 'view', 'id' => $item->userid)); $link = $target->get_url(); $elis_link_begin = '<a href="' . $link . '" alt="ELIS profile" title="ELIS profile">'; $elis_link_end = '</a>'; } else { $elis_link_begin = ''; $elis_link_end = ''; } return $elis_link_begin . $item->idnumber . $elis_link_end; }
function action_default() { // Get parameters $sort = optional_param('sort', 'name', PARAM_ALPHA); $dir = optional_param('dir', 'ASC', PARAM_ALPHA); $page = optional_param('page', 0, PARAM_INT); $perpage = optional_param('perpage', 30, PARAM_INT); // how many per page // Define columns $columns = array('idnumber' => get_string('id', 'block_curr_admin'), 'name' => get_string('name', 'block_curr_admin'), 'country' => get_string('country', 'block_curr_admin'), 'language' => get_string('user_language', 'block_curr_admin'), 'timecreated' => get_string('registered_date', 'block_curr_admin')); // Generate SQL filter $filter = new cm_user_filtering(null, 'index.php', array('s' => 'usr', 'section' => 'users')); $extrasql = $filter->get_sql_filter(); // Get list of users $items = usermanagement_get_users($sort, $dir, $page * $perpage, $perpage, $extrasql, usermanagementpage::get_contexts('block/curr_admin:user:view')); $numitems = usermanagement_count_users($extrasql, usermanagementpage::get_contexts('block/curr_admin:user:view')); usermanagementpage::get_contexts('block/curr_admin:user:edit'); usermanagementpage::get_contexts('block/curr_admin:user:delete'); $this->print_list_view($items, $numitems, $columns, $filter); }
function can_do_default() { $id = $this->required_param('id', PARAM_INT); return usermanagementpage::_has_capability('block/curr_admin:user:view', $id); }
/** * Takes a record and transforms it into an appropriate format * This method is set up as a hook to be implented by actual report class * * @param stdClass $record The current report record * @param string $export_format The format being used to render the report * @uses $CFG * @return stdClass The reformatted record */ function transform_record($record, $export_format) { global $CFG; $showcurricula = $this->check_curricula(); if (isset($record->id)) { //add a default curriculum name if appropriate if ($showcurricula && empty($record->name)) { if (!empty($record->preservecurname)) { //actually corresponds to class enrolments $record->name = get_string('noncurriculumcourses', $this->languagefile); } else { //doesn't correspond to anything $record->name = get_string('na', $this->languagefile); } } //link curriculum name to its "view" page if the the current record has a curriculum if ($export_format == table_report::$EXPORT_FORMAT_HTML && !empty($record->curid)) { $page = new curriculumpage(array('id' => $record->curid, 'action' => 'view')); if ($page->can_do()) { $url = $page->get_url(); $record->name = '<a href="' . $url . '" target="_blank">' . $record->name . '</a>'; } } //base url $url = "{$CFG->wwwroot}/blocks/php_report/render_report_page.php"; //params being passed via url $url_params = array('report' => 'user_class_completion_details', 'idnumber' => urlencode($record->useridnumber), 'idnumber_op' => generalized_filter_text::$OPERATOR_IS_EQUAL_TO); //used to track whether to add a ? or a & $first = true; foreach ($url_params as $key => $value) { //append the parameter to the url if ($first) { $url .= '?'; } else { $url .= '&'; } $url .= "{$key}={$value}"; //signal the use of & on subsequent iterations $first = false; } //add parameters related to all these groups to the report $groupnames = array('filter-detailheaders', 'filter-detailcolumns'); foreach ($groupnames as $groupname) { if ($first) { $url .= '?'; } else { $url .= '&'; } $url .= $this->get_param_url_string($groupname); } //extra attributes we are including in the anchor tag $tag_attributes = array('class' => 'external_report_link', 'target' => 'blank_'); //build the additional attributes $attribute_string = ''; foreach ($tag_attributes as $key => $value) { $attribute_string .= " {$key}={$value}"; } //details label for the link. First check to see if this is the first instance of the // student's record. If so then show the details link. $link_text = ''; if (0 != strcmp($this->student_id_num, $record->useridnumber)) { $link_text = get_string('details', $this->languagefile); $this->student_id_num = $record->useridnumber; } if ($export_format == table_report::$EXPORT_FORMAT_HTML) { //replace the empty column with the appropriate link $record->id = '<a href="' . $url . '"' . $attribute_string . '>' . $link_text . '</a>'; } else { //in an export, so don't show link $record->id = ''; } } //show link to user's profile based on capability to view the student management capability $fullname = fullname($record); if ($export_format == php_report::$EXPORT_FORMAT_HTML) { $userpage = new usermanagementpage(array('id' => $record->userid, 'action' => 'view')); if ($userpage->can_do()) { $record->lastname = '<span class="external_report_link"><a href="' . $userpage->get_url() . '" target="_blank">' . $fullname . '</a></span>'; } else { $record->lastname = $fullname; } } else { $record->lastname = $fullname; } //convert times to appropriate format if (!empty($record->timecompleted) && !empty($record->completed)) { $record->timecompleted = $this->format_date($record->timecompleted); } else { $record->timecompleted = get_string('na', $this->languagefile); } if (!empty($record->timeexpired) && !empty($record->completed)) { $record->timeexpired = $this->format_date($record->timeexpired); } else { $record->timeexpired = get_string('na', $this->languagefile); } //N/A for cretificate number if a valid one is not set if (empty($record->certificatecode) || empty($record->completed)) { $record->certificatecode = get_string('na', $this->languagefile); } //copy result of complex query into simple field if (!empty($record->numcredits)) { //use the provided value $record->displaynumcredits = $this->format_credits($record->numcredits); } else { //default to zero $record->displaynumcredits = $this->format_credits(0); } //handle custom field default values and display logic $this->transform_custom_field_data($record); return $record; }
/** * Takes a record and transoforms it into an appropriate format * This method is set up as a hook to be implented by actual report class * * @param stdClass $record The current report record * @param string $export_format The format being used to render the report * * @return stdClass The reformatted record */ function transform_record($record, $export_format) { if ($record->completestatus == STUSTATUS_PASSED) { $record->completestatus = get_string('status_complete', 'rlreport_course_completion_gas_gauge'); } else { $record->completestatus = get_string('status_incomplete', 'rlreport_course_completion_gas_gauge'); } if ($export_format == php_report::$EXPORT_FORMAT_HTML) { //convert user name to their full name and link to the CM user page for that user $userpage = new usermanagementpage(array('id' => $record->cmuserid, 'action' => 'view')); $record->firstname = '<span class="external_report_link"><a href="' . $userpage->get_url() . '" target="_blank">' . fullname($record) . '</a></span>'; } else { $record->firstname = fullname($record); } //calculate the percentage of completion elements satisfied if ($record->numcompletionelements == 0) { $record->percentcomplete = get_string('na', 'rlreport_course_completion_gas_gauge'); } else { $record->percentcomplete = $record->numcompleted / $record->numcompletionelements * 100; $record->percentcomplete = number_format($record->percentcomplete, 1); } //display logic for the count of completion elements //$record->numcompleted = $record->numcompleted . ' / ' . $record->numcompletionelements; $record->numcompleted = get_string('completed_tally', 'rlreport_course_completion_gas_gauge', $record); //format the Moodle gradebook course score // ELIS-4439: now using ELIS grade! //if (empty($record->score) || empty($record->grademax)) { if (!empty($record->elisgrade)) { $record->score = cm_display_grade($record->elisgrade); if (is_numeric($record->score) && $export_format != php_report::$EXPORT_FORMAT_CSV) { $record->score .= get_string('percent_symbol', 'rlreport_course_completion_gas_gauge'); } } else { $record->score = get_string('na', 'rlreport_course_completion_gas_gauge'); } return $record; }
/** * Takes a record and transforms it into an appropriate format * This method is set up as a hook to be implented by actual report class * * @param stdClass $record The current report record * @param string $export_format The format being used to render the report * * @return stdClass The reformatted record */ function transform_record($record, $export_format) { //clear out the class info if there is only one class enrolment for the user and course if (isset($record->numclasses) && $record->numclasses == 1) { $record->classidnumber = ''; } $status = student::$completestatusid_values[$record->completestatus]; $record->completestatus = get_string($status, 'block_curr_admin'); if ($export_format == php_report::$EXPORT_FORMAT_HTML) { //convert user name to their full name and link to the CM user page for that user $userpage = new usermanagementpage(array('id' => $record->cmuserid, 'action' => 'view')); $record->firstname = '<span class="external_report_link"><a href="' . $userpage->get_url() . '" target="_blank">' . fullname($record) . '</a></span>'; } else { $record->firstname = fullname($record); } //calculate the percentage of completion elements satisfied if ($record->numcompletionelements == 0) { $record->percentcomplete = get_string('na', $this->lang_file); } else { $record->percentcomplete = $record->numcompleted / $record->numcompletionelements * 100; $record->percentcomplete = number_format($record->percentcomplete, 1); } //display logic for the count of completion elements //$record->numcompleted = $record->numcompleted . ' / ' . $record->numcompletionelements; $record->numcompleted = get_string('completed_tally', $this->lang_file, $record); //format the Moodle gradebook course score // ELIS-4439: now using ELIS grade! //if (empty($record->score) || empty($record->grademax)) { if (!empty($record->elisgrade)) { $record->score = cm_display_grade($record->elisgrade); if (is_numeric($record->score) && $export_format != php_report::$EXPORT_FORMAT_CSV) { $record->score .= get_string('percent_symbol', $this->lang_file); } } else { $record->score = get_string('na', $this->lang_file); } return $record; }
/** * Takes a record and transforms it into an appropriate format * This method is set up as a hook to be implented by actual report class * * @param stdClass $record The current report record * @param string $export_format The format being used to render the report * * @return stdClass The reformatted record */ function transform_record($record, $export_format) { $user = new user(); $user->firstname = $record->firstname; $user->lastname = $record->r_student; $fullname = fullname($user); $userpage = new usermanagementpage(array('id' => $record->cmuserid, 'action' => 'view')); if ($export_format == php_report::$EXPORT_FORMAT_HTML) { $record->r_student = '<span class="external_report_link"><a href="' . $userpage->get_url() . '">' . $fullname . '</a></span>'; } else { $record->r_student = $fullname; } return $record; }