function certificate_print_user_files($userid = 0)
{
    global $CFG, $USER;
    $filearea = certificate_file_area_name($userid);
    $output = '';
    if ($basedir = certificate_file_area($userid)) {
        if ($files = get_directory_list($basedir)) {
            require_once $CFG->libdir . '/filelib.php';
            foreach ($files as $file) {
                $icon = mimeinfo('icon', $file);
                if ($CFG->slasharguments) {
                    $ffurl = "{$CFG->wwwroot}/file.php/{$filearea}/{$file}";
                } else {
                    $ffurl = "{$CFG->wwwroot}/file.php?file=/{$filearea}/{$file}";
                }
                $output .= '<img align="middle" src="' . $CFG->pixpath . '/f/' . $icon . '" height="16" width="16" alt="' . $icon . '" />' . '<a href="' . $ffurl . '" target="_blank">' . $file . '</a><br />';
            }
        }
    }
    $output = '<div class="files">' . $output . '</div>';
    return $output;
}
Esempio n. 2
0
        }
        $opt = new stdclass();
        $opt->id = $cm->id;
        $opt->action = 'get';
        echo '<center>';
        print_single_button('view.php', $opt, $strgetcertificate, 'get', '_blank');
        echo '</center>';
        add_to_log($course->id, 'certificate', 'received', "view.php?id={$cm->id}", $certificate->id, $cm->id);
        print_footer(NULL, $course);
        exit;
    }
    certificate_issue($course, $certificate, $certrecord, $cm);
    // update certrecord as issued
}
// Output to pdf
certificate_file_area($USER->id);
$filesafe = clean_filename($certificate->name . '.pdf');
$file = $CFG->dataroot . '/' . $course->id . '/moddata/certificate/' . $certificate->id . '/' . $USER->id . '/' . $filesafe;
if ($certificate->savecert == 1) {
    $pdf->Output($file, 'F');
    //save as file
}
if ($certificate->delivery == 0) {
    $pdf->Output($filesafe, 'I');
    // open in browser
} elseif ($certificate->delivery == 1 && $certrecord->certdate == 0) {
    $pdf->Output($filesafe, 'D');
    // force download when create
} elseif ($certificate->delivery == 1 && $certrecord->certdate > 0) {
    $pdf->Output($filesafe, 'I');
    // open in frame when review
            echo '<form action="" method="post" name="form2">';
            echo '<input type="button" name="Submit" value="' . get_string('backbutton', 'certificate') . '" onClick="JavaScript:history.back();" />';
            echo '</form>';
            echo '</center>';
            echo '<iframe name="certframe" id="certframe" frameborder="NO" border="0" style="width:90%;height:500px;border:0px;">';
            echo '</iframe>';
            print_footer(NULL, $course);
        }
    }
}
// Output to pdf
if ($generate) {
    // Load custom type
    require "{$CFG->dirroot}/mod/certificate/type/{$certificate->certificatetype}/certificate.php";
    $userid = $USER->id;
    certificate_file_area($userid);
    $file = $CFG->dataroot . '/' . $course->id . '/moddata/certificate/' . $certificate->id . '/' . $USER->id . '/certificate.pdf';
    if ($certificate->savecert == 1) {
        $pdf->Output($file, 'F');
        //save as file
    }
    if ($certificate->delivery == 0) {
        $pdf->Output('certificate.pdf', 'I');
        // open in browser
    }
    if ($certificate->delivery == 1) {
        $pdf->Output('certificate.pdf', 'D');
        // force download
    }
    if ($certificate->delivery == 2) {
        $pdf->Output('certificate.pdf', 'I');