* back to the callback functions (passed by reference)
* these MUST be primatives to be added as hidden form fields.
* and the values get cleaned to PARAM_ALPHAEXT or PARAM_NUMBER or PARAM_PATH
+* @param string $callbackfile this can be autodetected if it's in the same file as your caller,
+* but more often, the caller is a script.php and the class in a lib.php
+* so you can pass it here if necessary.
+* this path should be relative (ie, not include) dirroot
* @param boolean $fullform either display the fullform with the dropmenu of available instances
* or just a small icon (which will trigger instance selection in a new screen)
* optional, defaults to true.
* @param boolean $return whether to echo or return content (optional defaults to false (echo)
*/
-function portfolio_add_button($callbackclass, $callbackargs, $fullform=true, $return=false) {
+function portfolio_add_button($callbackclass, $callbackargs, $callbackfile=null, $fullform=true, $return=false) {
global $SESSION, $CFG, $COURSE, $USER;
return;
}
- $backtrace = debug_backtrace();
- if (!array_key_exists(0, $backtrace) || !array_key_exists('file', $backtrace[0]) || !is_readable($backtrace[0]['file'])) {
- debugging(get_string('nocallbackfile', 'portfolio'));
- return;
- }
+ if (empty($callbackfile)) {
+ $backtrace = debug_backtrace();
+ if (!array_key_exists(0, $backtrace) || !array_key_exists('file', $backtrace[0]) || !is_readable($backtrace[0]['file'])) {
+ debugging(get_string('nocallbackfile', 'portfolio'));
+ return;
+ }
- $callbackfile = substr($backtrace[0]['file'], strlen($CFG->dirroot));
+ $callbackfile = substr($backtrace[0]['file'], strlen($CFG->dirroot));
+ } else {
+ if (!is_readable($CFG->dirroot . $callbackfile)) {
+ debugging(get_string('nocallbackfile', 'portfolio'));
+ return;
+ }
+ }
require_once($CFG->dirroot . $callbackfile);
'<a href="'.$ffurl.'" >'.$file.'</a>';
if ($this->portfolio_exportable() && true) { // @todo replace with capability check
$p['file'] = $file;
- $output .= portfolio_add_button('assignment_portfolio_caller', $p, false, true);
+ $output .= portfolio_add_button('assignment_portfolio_caller', $p, null, false, true);
}
$output .= '<br />';
}
if ($this->portfolio_exportable() && true) { //@todo replace with check capability
unset($p['file']);// for all files
- $output .= '<br />' . portfolio_add_button('assignment_portfolio_caller', $p, true, true);
+ $output .= '<br />' . portfolio_add_button('assignment_portfolio_caller', $p, null, true, true);
}
}
}
return $status;
}
$filearea = $CFG->dataroot . '/' . $this->assignment->file_area_name($this->userid);
- //@todo this is a dreadful thing to have to call.
+ //@todo penny this is a dreadful thing to have to call (replace with files api anyway)
require_once($CFG->dirroot . '/backup/lib.php');
if ($this->file) {
return backup_copy_file($filearea . '/' . $this->file, $tempdir . '/' . $this->file);
$mform->display();
} else {
print_box_start('generalbox boxwidthwide boxaligncenter', 'online');
- if ($submission) {
+ if ($submission && true) { // @todo penny replace with capability check later
echo format_text($submission->data1, $submission->data2);
$p = array(
'userid' => $USER->id,
'assignmentid' => $this->cm->id,
);
- portfolio_add_button('assignment_portfolio_caller', $p);
+ portfolio_add_button('assignment_portfolio_caller', $p, '/mod/assignment/lib.php'));
} else if (!has_capability('mod/assignment:submit', $context)) { //fix for #4604
echo '<div style="text-align:center">'. get_string('guestnosubmit', 'assignment').'</div>';
} else if ($this->isopen()){ //fix for #4206
$output .= '<a href="'.$delurl.'"> '
.'<img title="'.$strdelete.'" src="'.$CFG->pixpath.'/t/delete.gif" class="iconsmall" alt="" /></a> ';
}
- if (true) { // @todo replace with capability check
+ if (true) { // @todo penny replace with capability check
$p['file'] = $file;
- $output .= portfolio_add_button('assignment_portfolio_caller', $p, false, true);
+ $output .= portfolio_add_button('assignment_portfolio_caller', $p, '/mod/assignment/lib.php', false, true);
}
$output .= '<br />';
}
- if (true) { //@todo replace with check capability
+ if (true) { //@todo penny replace with check capability
unset($p['file']);// for all files
- $output .= '<br />' . portfolio_add_button('assignment_portfolio_caller', $p, true, true);
+ $output .= '<br />' . portfolio_add_button('assignment_portfolio_caller', $p, '/mod/assignment/lib.php', true, true);
}
}
}