Exemple #1
0
    /**
     * Produces a list of links to the files uploaded by a user
     *
     * @param $userid int optional id of the user. If 0 then $USER->id is used.
     * @param $return boolean optional defaults to false. If true the list is returned rather than printed
     * @return string optional
     */
    function print_user_files($userid=0, $return=false) {
        global $CFG, $USER, $OUTPUT;

        if (!$userid) {
            if (!isloggedin()) {
                return '';
            }
            $userid = $USER->id;
        }

        $output = '';

        $fs = get_file_storage();

        $found = false;

        $submission = $this->get_submission($userid);

        if (($submission) && $files = $fs->get_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id, "timemodified", false)) {
            require_once($CFG->libdir.'/portfoliolib.php');
            require_once($CFG->dirroot . '/mod/assignment/locallib.php');
            $button = new portfolio_add_button();
            foreach ($files as $file) {
                $filename = $file->get_filename();
                $found = true;
                $mimetype = $file->get_mimetype();
                $path = file_encode_url($CFG->wwwroot.'/pluginfile.php', '/'.$this->context->id.'/mod_assignment/submission/'.$submission->id.'/'.$filename);
                $output .= '<a href="'.$path.'" ><img src="'.$OUTPUT->pix_url(file_mimetype_icon($mimetype)).'" class="icon" alt="'.$mimetype.'" />'.s($filename).'</a>';
                if ($this->portfolio_exportable() && has_capability('mod/assignment:exportownsubmission', $this->context)) {
                    $button->set_callback_options('assignment_portfolio_caller', array('id' => $this->cm->id, 'fileid' => $file->get_id()), '/mod/assignment/locallib.php');
                    $button->set_format_by_file($file);
                    $output .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
                }
                $output .= plagiarism_get_links(array('userid'=>$userid, 'file'=>$file, 'cmid'=>$this->cm->id, 'course'=>$this->course, 'assignment'=>$this->assignment));
                $output .= '<br />';
            }
            if (count($files) > 1  && $this->portfolio_exportable() && has_capability('mod/assignment:exportownsubmission', $this->context)) {
                $button->set_callback_options('assignment_portfolio_caller', array('id' => $this->cm->id), '/mod/assignment/locallib.php');
                $output .= '<br />'  . $button->to_html();
            }
        }

        $output = '<div class="files">'.$output.'</div>';

        if ($return) {
            return $output;
        }
        echo $output;
    }
Exemple #2
0
/**
 * Returns attachments as formated text/html optionally with separate images
 *
 * @global object
 * @global object
 * @global object
 * @param object $post
 * @param object $cm
 * @param string $type html/text/separateimages
 * @return mixed string or array of (html text withouth images and image HTML)
 */
function forum_print_attachments($post, $cm, $type) {
    global $CFG, $DB, $USER, $OUTPUT;

    if (empty($post->attachment)) {
        return $type !== 'separateimages' ? '' : array('', '');
    }

    if (!in_array($type, array('separateimages', 'html', 'text'))) {
        return $type !== 'separateimages' ? '' : array('', '');
    }

    if (!$context = context_module::instance($cm->id)) {
        return $type !== 'separateimages' ? '' : array('', '');
    }
    $strattachment = get_string('attachment', 'forum');

    $fs = get_file_storage();

    $imagereturn = '';
    $output = '';

    $canexport = !empty($CFG->enableportfolios) && (has_capability('mod/forum:exportpost', $context) || ($post->userid == $USER->id && has_capability('mod/forum:exportownpost', $context)));

    if ($canexport) {
        require_once($CFG->libdir.'/portfoliolib.php');
    }

    $files = $fs->get_area_files($context->id, 'mod_forum', 'attachment', $post->id, "timemodified", false);
    if ($files) {
        if ($canexport) {
            $button = new portfolio_add_button();
        }
        foreach ($files as $file) {
            $filename = $file->get_filename();
            $mimetype = $file->get_mimetype();
            $iconimage = $OUTPUT->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon'));
            $path = file_encode_url($CFG->wwwroot.'/pluginfile.php', '/'.$context->id.'/mod_forum/attachment/'.$post->id.'/'.$filename);

            if ($type == 'html') {
                $output .= "<a href=\"$path\">$iconimage</a> ";
                $output .= "<a href=\"$path\">".s($filename)."</a>";
                if ($canexport) {
                    $button->set_callback_options('forum_portfolio_caller', array('postid' => $post->id, 'attachment' => $file->get_id()), 'mod_forum');
                    $button->set_format_by_file($file);
                    $output .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
                }
                $output .= "<br />";

            } else if ($type == 'text') {
                $output .= "$strattachment ".s($filename).":\n$path\n";

            } else { //'returnimages'
                if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) {
                    // Image attachments don't get printed as links
                    $imagereturn .= "<br /><img src=\"$path\" alt=\"\" />";
                    if ($canexport) {
                        $button->set_callback_options('forum_portfolio_caller', array('postid' => $post->id, 'attachment' => $file->get_id()), 'mod_forum');
                        $button->set_format_by_file($file);
                        $imagereturn .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
                    }
                } else {
                    $output .= "<a href=\"$path\">$iconimage</a> ";
                    $output .= format_text("<a href=\"$path\">".s($filename)."</a>", FORMAT_HTML, array('context'=>$context));
                    if ($canexport) {
                        $button->set_callback_options('forum_portfolio_caller', array('postid' => $post->id, 'attachment' => $file->get_id()), 'mod_forum');
                        $button->set_format_by_file($file);
                        $output .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
                    }
                    $output .= '<br />';
                }
            }

            if (!empty($CFG->enableplagiarism)) {
                require_once($CFG->libdir.'/plagiarismlib.php');
                $output .= plagiarism_get_links(array('userid' => $post->userid,
                    'file' => $file,
                    'cmid' => $cm->id,
                    'course' => $post->course,
                    'forum' => $post->forum));
                $output .= '<br />';
            }
        }
    }

    if ($type !== 'separateimages') {
        return $output;

    } else {
        return array($output, $imagereturn);
    }
}
 /**
  * Preprocessing the file list to add the portfolio links if required.
  *
  * @param array $dir
  * @param string $filearea
  * @param string $component
  * @return void
  */
 public function preprocess($dir, $filearea, $component)
 {
     global $CFG;
     foreach ($dir['subdirs'] as $subdir) {
         $this->preprocess($subdir, $filearea, $component);
     }
     foreach ($dir['files'] as $file) {
         $file->portfoliobutton = '';
         if (!empty($CFG->enableportfolios)) {
             $button = new portfolio_add_button();
             if (has_capability('mod/sepl:exportownsubmission', $this->context)) {
                 $portfolioparams = array('cmid' => $this->cm->id, 'fileid' => $file->get_id());
                 $button->set_callback_options('sepl_portfolio_caller', $portfolioparams, 'mod_sepl');
                 $button->set_format_by_file($file);
                 $file->portfoliobutton = $button->to_html(PORTFOLIO_ADD_ICON_LINK);
             }
         }
         $path = '/' . $this->context->id . '/' . $component . '/' . $filearea . '/' . $file->get_itemid() . $file->get_filepath() . $file->get_filename();
         $url = file_encode_url("{$CFG->wwwroot}/pluginfile.php", $path, true);
         $filename = $file->get_filename();
         $file->fileurl = html_writer::link($url, $filename);
     }
 }
Exemple #4
0
 public function preprocess($dir, $filearea) {
     global $CFG;
     foreach ($dir['subdirs'] as $subdir) {
         $this->preprocess($subdir, $filearea);
     }
     foreach ($dir['files'] as $file) {
         $file->portfoliobutton = '';
         if (!empty($CFG->enableportfolios)) {
             $button = new portfolio_add_button();
             if (has_capability('mod/assignment:exportownsubmission', $this->context)) {
                 $button->set_callback_options('assignment_portfolio_caller', array('id' => $this->cm->id, 'fileid' => $file->get_id()), '/mod/assignment/locallib.php');
                 $button->set_format_by_file($file);
                 $file->portfoliobutton = $button->to_html(PORTFOLIO_ADD_ICON_LINK);
             }
         }
         $url = file_encode_url("$CFG->wwwroot/pluginfile.php", '/'.$this->context->id.'/mod_assignment/'.$filearea.'/'.$file->get_itemid(). $file->get_filepath().$file->get_filename(), true);
         $filename = $file->get_filename();
         $file->fileurl = html_writer::link($url, $filename);
     }
 }
Exemple #5
0
/**
 * Returns attachments as formated text/html optionally with separate images
 *
 * @global object
 * @global object
 * @global object
 * @param object $post
 * @param object $cm
 * @param string $type html/text/separateimages
 * @return mixed string or array of (html text withouth images and image HTML)
 */
function forum_print_attachments($post, $cm, $type)
{
    global $CFG, $DB, $USER, $OUTPUT;
    if (empty($post->attachment)) {
        return $type !== 'separateimages' ? '' : array('', '');
    }
    if (!in_array($type, array('separateimages', 'html', 'text'))) {
        return $type !== 'separateimages' ? '' : array('', '');
    }
    if (!($context = get_context_instance(CONTEXT_MODULE, $cm->id))) {
        return $type !== 'separateimages' ? '' : array('', '');
    }
    $strattachment = get_string('attachment', 'forum');
    $fs = get_file_storage();
    $imagereturn = '';
    $output = '';
    $canexport = has_capability('mod/forum:exportpost', $context) || $post->userid == $USER->id && has_capability('mod/forum:exportownpost', $context);
    require_once $CFG->libdir . '/portfoliolib.php';
    if ($files = $fs->get_area_files($context->id, 'mod_forum', 'attachment', $post->id, "timemodified", false)) {
        $button = new portfolio_add_button();
        foreach ($files as $file) {
            $filename = $file->get_filename();
            $mimetype = $file->get_mimetype();
            $iconimage = '<img src="' . $OUTPUT->pix_url(file_mimetype_icon($mimetype)) . '" class="icon" alt="' . $mimetype . '" />';
            $path = file_encode_url($CFG->wwwroot . '/pluginfile.php', '/' . $context->id . '/mod_forum/attachment/' . $post->id . '/' . $filename);
            if ($type == 'html') {
                $output .= "<a href=\"{$path}\">{$iconimage}</a> ";
                $output .= "<a href=\"{$path}\">" . s($filename) . "</a>";
                if ($canexport) {
                    $button->set_callback_options('forum_portfolio_caller', array('postid' => $post->id, 'attachment' => $file->get_id()), '/mod/forum/locallib.php');
                    $button->set_format_by_file($file);
                    $output .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
                }
                $output .= "<br />";
            } else {
                if ($type == 'text') {
                    $output .= "{$strattachment} " . s($filename) . ":\n{$path}\n";
                } else {
                    //'returnimages'
                    if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) {
                        // Image attachments don't get printed as links
                        $imagereturn .= "<br /><img src=\"{$path}\" alt=\"\" />";
                        if ($canexport) {
                            $button->set_callback_options('forum_portfolio_caller', array('postid' => $post->id, 'attachment' => $file->get_id()), '/mod/forum/locallib.php');
                            $button->set_format_by_file($file);
                            $imagereturn .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
                        }
                    } else {
                        $output .= "<a href=\"{$path}\">{$iconimage}</a> ";
                        $output .= format_text("<a href=\"{$path}\">" . s($filename) . "</a>", FORMAT_HTML, array('context' => $context));
                        if ($canexport) {
                            $button->set_callback_options('forum_portfolio_caller', array('postid' => $post->id, 'attachment' => $file->get_id()), '/mod/forum/locallib.php');
                            $button->set_format_by_file($file);
                            $output .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
                        }
                        $output .= '<br />';
                    }
                }
            }
        }
    }
    if ($type !== 'separateimages') {
        return $output;
    } else {
        return array($output, $imagereturn);
    }
}
Exemple #6
0
/**
 * Returns attachments as formated text/html optionally with separate images
 *
 * @global object
 * @global object
 * @global object
 * @param object $post
 * @param object $cm
 * @param string $type html/text/separateimages
 * @return mixed string or array of (html text withouth images and image HTML)
 */
function quora_print_attachments($post, $cm, $type)
{
    global $CFG, $DB, $USER, $OUTPUT;
    if (empty($post->attachment)) {
        return $type !== 'separateimages' ? '' : array('', '');
    }
    if (!in_array($type, array('separateimages', 'html', 'text'))) {
        return $type !== 'separateimages' ? '' : array('', '');
    }
    if (!($context = context_module::instance($cm->id))) {
        return $type !== 'separateimages' ? '' : array('', '');
    }
    $strattachment = get_string('attachment', 'quora');
    $fs = get_file_storage();
    $imagereturn = '';
    $output = '';
    $canexport = !empty($CFG->enableportfolios) && (has_capability('mod/quora:exportpost', $context) || $post->userid == $USER->id && has_capability('mod/quora:exportownpost', $context));
    if ($canexport) {
        require_once $CFG->libdir . '/portfoliolib.php';
    }
    // We retrieve all files according to the time that they were created.  In the case that several files were uploaded
    // at the sametime (e.g. in the case of drag/drop upload) we revert to using the filename.
    $files = $fs->get_area_files($context->id, 'mod_quora', 'attachment', $post->id, "filename", false);
    if ($files) {
        if ($canexport) {
            $button = new portfolio_add_button();
        }
        foreach ($files as $file) {
            $filename = $file->get_filename();
            $mimetype = $file->get_mimetype();
            $iconimage = $OUTPUT->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon'));
            $path = file_encode_url($CFG->wwwroot . '/pluginfile.php', '/' . $context->id . '/mod_quora/attachment/' . $post->id . '/' . $filename);
            if ($type == 'html') {
                $output .= "<a href=\"{$path}\">{$iconimage}</a> ";
                $output .= "<a href=\"{$path}\">" . s($filename) . "</a>";
                if ($canexport) {
                    $button->set_callback_options('quora_portfolio_caller', array('postid' => $post->id, 'attachment' => $file->get_id()), 'mod_quora');
                    $button->set_format_by_file($file);
                    $output .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
                }
                $output .= "<br />";
            } else {
                if ($type == 'text') {
                    $output .= "{$strattachment} " . s($filename) . ":\n{$path}\n";
                } else {
                    //'returnimages'
                    if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) {
                        // Image attachments don't get printed as links
                        $imagereturn .= "<br /><img src=\"{$path}\" alt=\"\" />";
                        if ($canexport) {
                            $button->set_callback_options('quora_portfolio_caller', array('postid' => $post->id, 'attachment' => $file->get_id()), 'mod_quora');
                            $button->set_format_by_file($file);
                            $imagereturn .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
                        }
                    } else {
                        $output .= "<a href=\"{$path}\">{$iconimage}</a> ";
                        $output .= format_text("<a href=\"{$path}\">" . s($filename) . "</a>", FORMAT_HTML, array('context' => $context));
                        if ($canexport) {
                            $button->set_callback_options('quora_portfolio_caller', array('postid' => $post->id, 'attachment' => $file->get_id()), 'mod_quora');
                            $button->set_format_by_file($file);
                            $output .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
                        }
                        $output .= '<br />';
                    }
                }
            }
            if (!empty($CFG->enableplagiarism)) {
                require_once $CFG->libdir . '/plagiarismlib.php';
                $output .= plagiarism_get_links(array('userid' => $post->userid, 'file' => $file, 'cmid' => $cm->id, 'course' => $cm->course, 'quora' => $cm->instance));
                $output .= '<br />';
            }
        }
    }
    if ($type !== 'separateimages') {
        return $output;
    } else {
        return array($output, $imagereturn);
    }
}
Exemple #7
0
 /**
  * Produces a list of portfolio links to the file recorded byuser
  *
  * @param $submissionid this submission's id
  * @return string the portfolio export link
  */
 public function get_p_links($submissionid)
 {
     global $CFG, $OUTPUT, $DB;
     $output = "";
     $fs = get_file_storage();
     $files = $fs->get_area_files($this->assignment->get_context()->id, ASSIGNSUBMISSION_ONLINEPOODLL_COMPONENT, ASSIGNSUBMISSION_ONLINEPOODLL_FILEAREA, $submissionid, "id", false);
     if (!empty($files)) {
         require_once $CFG->dirroot . '/mod/assignment/locallib.php';
         if ($CFG->enableportfolios) {
             require_once $CFG->libdir . '/portfoliolib.php';
         }
         //Add portfolio download links if appropriate
         foreach ($files as $file) {
             if ($CFG->enableportfolios && has_capability('mod/assign:exportownsubmission', $this->assignment->get_context())) {
                 require_once $CFG->libdir . '/portfoliolib.php';
                 $button = new portfolio_add_button();
                 $button->set_callback_options('assign_portfolio_caller', array('cmid' => $this->assignment->get_course_module()->id, 'component' => "assignsubmission_onlinepoodll", 'area' => ASSIGNSUBMISSION_ONLINEPOODLL_FILEAREA, 'sid' => $submissionid), '/mod/assign/portfolio_callback.php');
                 $button->set_format_by_file($file);
                 $output .= $button->to_html(PORTFOLIO_ADD_TEXT_LINK);
             }
             $output .= '<br />';
         }
     }
     $output = '<div class="files" style="float:left;margin-left:5px;">' . $output . '</div><br clear="all" />';
     return $output;
 }
function referentiel_get_manage_archives($contextid, $titre, $appli, $userid_filtre = 0, $instanceid = 0, $ok_portfolio = false, $report = false, $export_format = '')
{
    // retourne la liste des liens vers des fichiers stockes dans le filearea
    // propose la suppression
    global $CFG;
    global $OUTPUT;
    // Archives older than REFERENTIEL_ARCHIVE_OBSOLETE days will be deleted.
    $delai_destruction = REFERENTIEL_ARCHIVE_OBSOLETE * 24 * 3600;
    $date_obsolete = time() - $delai_destruction;
    $msg = get_string('archive_deleted', 'referentiel', date("Y-m-d H:i:s.", $date_obsolete));
    $s = '';
    $total_size = 0;
    $nfile = 0;
    // fileareas autorisees
    $filearea = 'archive';
    $strauthor = get_string('auteur', 'referentiel');
    $strfilename = get_string('filename', 'referentiel');
    $strfilesize = get_string('filesize', 'referentiel');
    $strtimecreated = get_string('timecreated', 'referentiel');
    $strtimemodified = get_string('timemodified', 'referentiel');
    $strmimetype = get_string('mimetype', 'referentiel');
    $strmenu = get_string('delete');
    $strportfolio = get_string('publishporttfolio', 'referentiel');
    $strurl = get_string('url');
    // publication via potfolio
    if ($ok_portfolio) {
        require_once $CFG->libdir . '/portfoliolib.php';
    }
    $fs = get_file_storage();
    if ($files = $fs->get_area_files($contextid, 'mod_referentiel', $filearea, 0, "timemodified", false)) {
        $table = new html_table();
        if ($ok_portfolio) {
            $table->head = array($strauthor, $strfilename, $strfilesize, $strtimecreated, $strtimemodified, $strmimetype, $strmenu, $strportfolio);
            $table->align = array("right", "center", "left", "left", "left", "center", "center", "center");
        } else {
            $table->head = array($strauthor, $strfilename, $strfilesize, $strtimecreated, $strtimemodified, $strmimetype, $strmenu);
            $table->align = array("right", "center", "left", "left", "left", "center", "center");
        }
        $ok = false;
        //drapeau d'affichage
        foreach ($files as $file) {
            // print_object($file);
            $filesize = $file->get_filesize();
            $filename = $file->get_filename();
            $mimetype = $file->get_mimetype();
            $filepath = $file->get_filepath();
            $iconimage = '<img src="' . $OUTPUT->pix_url(file_mimetype_icon($mimetype)) . '" class="icon" alt="' . $mimetype . '" />';
            $userid = 0;
            $author = '';
            $parts = explode('/', $filepath);
            if (is_array($parts)) {
                $refrefid = $parts[1];
                if (isset($parts[2])) {
                    $userid = trim($parts[2]);
                    // echo "<br />USER:$userid\n";
                    $author = '#' . $userid . ' ' . referentiel_get_user_info($userid);
                }
            }
            $fullpath = '/' . $contextid . '/mod_referentiel/' . $filearea . '/' . '0' . $filepath . $filename;
            // echo "<br />FULPATH :: $fullpath \n";
            $timecreated = userdate($file->get_timecreated(), "%Y/%m/%d-%H:%M", 99, false);
            $timemodified = userdate($file->get_timemodified(), "%Y/%m/%d-%H:%M", 99, false);
            $link = new moodle_url($CFG->wwwroot . '/pluginfile.php' . $fullpath);
            $url = ' <a href="' . $link . '" target="_blank">' . $iconimage . $filename . '</a><br />' . "\n";
            $delete_link = '<input type="checkbox" name="deletefile[]"  value="' . $fullpath . '" />' . "\n";
            if ($userid && ($userid_filtre == 0 || $userid == $userid_filtre)) {
                // afficher ce fichier
                $ok = true;
                $output_button = '';
                // Publish button
                if ($ok_portfolio) {
                    $params = array('instanceid' => $instanceid, 'attachment' => $file->get_id(), 'report' => $report, 'export_format' => $export_format);
                    // DEBUG
                    /*
                    echo "<br />DEBUG :: lib_archive.php :: 585 :: PARAM PORTFOLIO<br />\n";
                    print_object($params);
                    echo "<br />\n";
                    // exit;
                    */
                    $button = new portfolio_add_button();
                    // Version anterieure à Moodle 2.4
                    //                    $button->set_callback_options('referentiel_portfolio_caller',
                    //                        $params, '/mod/referentiel/portfolio/mahara/locallib_portfolio.php');
                    // Version Moodle 2.4
                    $button->set_callback_options('referentiel_portfolio_caller', $params, 'mod_referentiel');
                    $button->set_format_by_file($file);
                    // $button->set_formats(array(PORTFOLIO_FORMAT_FILE));
                    // $output_button = "<a href=\"$path\">$iconimage</a> ";
                    $output_button .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
                    $table->data[] = array($author, $url, display_size($filesize), $timecreated, $timemodified, $mimetype, $delete_link, $output_button);
                } else {
                    $table->data[] = array($author, $url, display_size($filesize), $timecreated, $timemodified, $mimetype, $delete_link);
                }
                $total_size += $filesize;
                $nfile++;
            }
        }
        if ($ok) {
            if ($ok_portfolio) {
                $table->data[] = array('', get_string('nbfile', 'referentiel', $nfile), get_string('totalsize', 'referentiel', display_size($total_size)), '', '', '', '');
            } else {
                $table->data[] = array('', get_string('nbfile', 'referentiel', $nfile), get_string('totalsize', 'referentiel', display_size($total_size)), '', '');
            }
            echo $OUTPUT->box_start('generalbox  boxaligncenter');
            echo '<div align="center">' . "\n";
            echo '<h3>' . $titre . '</h3>' . "\n";
            // message d'information
            echo '<p><i>' . $msg . '</i></p>' . "\n";
            echo '<form method="post" action="' . $appli . '">' . "\n";
            echo "\n" . '<input type="hidden" name="sesskey" value="' . sesskey() . '" />' . "\n";
            echo '<div align="center">' . "\n";
            echo '<input type="button" name="select_all_archive" id="select_tous_enseignants" value="' . get_string('select_all', 'referentiel') . '"  onClick="return checkall()" />' . "\n";
            //        echo '&nbsp; &nbsp; &nbsp; <input type="button" name="select_not_any_archive" id="select_aucun_enseignant" value="'.get_string('select_not_any', 'referentiel').'"  onClick="return uncheckall()" />'."\n";
            //        echo '<input type="reset" value="'.get_string('corriger', 'referentiel').'" />'."\n";
            echo '&nbsp; <input type="reset" value="' . get_string('select_not_any', 'referentiel') . '" />' . "\n";
            echo '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;';
            echo '<input type="submit" name="save" value="' . get_string('deletefile', 'referentiel') . '" />' . "\n";
            echo '<input type="submit" name="cancel" value="' . get_string('quit', 'referentiel') . '" />' . "\n";
            echo '</div>' . "\n";
            echo html_writer::table($table);
            echo '<div align="center">' . "\n";
            echo '<input type="button" name="select_all_archive" id="select_tous_enseignants" value="' . get_string('select_all', 'referentiel') . '"  onClick="return checkall()" />' . "\n";
            //        echo '&nbsp; &nbsp; &nbsp; <input type="button" name="select_not_any_archive" id="select_aucun_enseignant" value="'.get_string('select_not_any', 'referentiel').'"  onClick="return uncheckall()" />'."\n";
            //        echo '<input type="reset" value="'.get_string('corriger', 'referentiel').'" />'."\n";
            echo '&nbsp;  <input type="reset" value="' . get_string('select_not_any', 'referentiel') . '" />' . "\n";
            echo '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;';
            echo '<input type="submit" name="save" value="' . get_string('deletefile', 'referentiel') . '" />' . "\n";
            echo '<input type="submit" name="cancel" value="' . get_string('quit', 'referentiel') . '" />' . "\n";
            echo '</div>' . "\n";
            echo '</form>' . "\n";
            echo '</div>' . "\n";
            echo $OUTPUT->box_end();
        }
    }
}
Exemple #9
0
 /**
  * Produces a list of portfolio links to the file recorded byuser
  *
  * @param $submissionid this submission's id
  * @return string the portfolio export link
  */
 public function get_p_links($submissionid)
 {
     global $CFG, $OUTPUT, $DB;
     $output = "";
     $fs = get_file_storage();
     $files = $fs->get_area_files($this->assignment->get_context()->id, ASSIGNSUBMISSION_ONLINEPOODLL_COMPONENT, ASSIGNSUBMISSION_ONLINEPOODLL_FILEAREA, $submissionid, "id", false);
     if (!empty($files)) {
         //this was nec for portfolios prior to M2.7.
         if (file_exists($CFG->dirroot . '/mod/assignment/locallib.php')) {
             require_once $CFG->dirroot . '/mod/assignment/locallib.php';
         }
         if ($CFG->enableportfolios) {
             require_once $CFG->libdir . '/portfoliolib.php';
         }
         //Add portfolio download links if appropriate
         foreach ($files as $file) {
             //in the case of splash images we will have two files.
             //we just want one link, and for the video file
             if ($this->get_config('recordertype') == OP_REPLYVIDEO) {
                 $fname = $file->get_filename();
                 $fext = pathinfo($fname, PATHINFO_EXTENSION);
                 if ($fext == 'jpg' || $fext == 'png') {
                     continue;
                 }
             }
             if ($CFG->enableportfolios && has_capability('mod/assign:exportownsubmission', $this->assignment->get_context())) {
                 require_once $CFG->libdir . '/portfoliolib.php';
                 $button = new portfolio_add_button();
                 //API changes. See https://github.com/moodle/moodle/blob/master/portfolio/upgrade.txt#L6
                 if ($CFG->version < 2012120300) {
                     $finalparam = '/mod/assign/portfolio_callback.php';
                 } else {
                     $finalparam = 'mod_assign';
                 }
                 $button->set_callback_options('assign_portfolio_caller', array('cmid' => $this->assignment->get_course_module()->id, 'component' => ASSIGNSUBMISSION_ONLINEPOODLL_COMPONENT, 'area' => ASSIGNSUBMISSION_ONLINEPOODLL_FILEAREA, 'sid' => $submissionid), $finalparam);
                 $button->set_format_by_file($file);
                 $output .= $button->to_html(PORTFOLIO_ADD_TEXT_LINK);
             }
             $output .= '<br />';
         }
     }
     $output = '<div class="files" style="float:left;margin-left:5px;">' . $output . '</div><br clear="all" />';
     return $output;
 }