66 lines
No EOL
2.2 KiB
PHP
66 lines
No EOL
2.2 KiB
PHP
<?php
|
|
|
|
namespace local_treestudyplan\local\forms;
|
|
use local_treestudyplan\studyplan;
|
|
use local_treestudyplan\local\helpers\webservicehelper;
|
|
/**
|
|
* Moodleform class for the studyplan editor. A Moodleform is used here to facilitate a rich editor
|
|
* in the studyplan description
|
|
*/
|
|
class studyplan_editform extends formbase {
|
|
/**
|
|
* Capability required to edit study plans
|
|
* @var string
|
|
*/
|
|
const CAP_EDIT = "local/treestudyplan:editstudyplan";
|
|
/**
|
|
* Validate security access for this form based on the provided parameters
|
|
* Return true if validation passes, false or throw an exception if it does not.
|
|
*
|
|
* @param object $params The parameters for form initialization
|
|
* @return bool True if security validation passes.
|
|
* @throws \moodle_exception if access denied for a specific reason.
|
|
*/
|
|
public static function check_security(object $params) {
|
|
$plan = studyplan::find_by_id($params->studyplanid);
|
|
webservicehelper::require_capabilities(self::CAP_EDIT,$plan->context());
|
|
}
|
|
|
|
/**
|
|
* Generate form data from parameters
|
|
* Also validate parameters and access permissions here
|
|
*
|
|
* @param object $params The parameters for form initialization
|
|
* @return array Form data based on parameters
|
|
*/
|
|
public static function init_data(object $params) {
|
|
$plan = studyplan::find_by_id($params->studyplanid);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* Set up the form definition
|
|
*/
|
|
public function definition() {
|
|
$mform = $this->_form;
|
|
|
|
// Define the form
|
|
$mform->addElement('editor', 'activityeditor',
|
|
get_string('activityeditor', 'assign'), array('rows' => 10), array('maxfiles' => EDITOR_UNLIMITED_FILES,
|
|
'noclean' => true, 'context' => $this->context, 'subdirs' => true));
|
|
$mform->addHelpButton('activityeditor', 'activityeditor', 'assign');
|
|
$mform->setType('activityeditor', PARAM_RAW);
|
|
}
|
|
|
|
/**
|
|
* Process the submission and perform necessary actions
|
|
* @throws \moodle_exception if an error must be given for a specific reason.
|
|
*/
|
|
public function process_submission()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
} |