Documentation fix

This commit is contained in:
PMKuipers 2023-10-19 17:48:43 +02:00
parent f0847a0f14
commit 3c7369ce6b
2 changed files with 18 additions and 11 deletions

View File

@ -19,20 +19,20 @@ abstract class formbase extends moodleform {
* Generate form data from parameters * Generate form data from parameters
* Also validate parameters and access permissions here * Also validate parameters and access permissions here
* *
* @param array $params The parameters for form initialization * @param object $params The parameters for form initialization
* @return array Form data based on parameters * @return array Form data based on parameters
*/ */
abstract public static function init_data(array $params); abstract public static function init_data(object $params);
/** /**
* Validate security access for this form based on the provided parameters * 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. * Return true if validation passes, false or throw an exception if it does not.
* *
* @param array $params The parameters for form initialization * @param object $params The parameters for form initialization
* @return bool True if security validation passes. * @return bool True if security validation passes.
* @throws \moodle_exception if access denied for a specific reason. * @throws \moodle_exception if access denied for a specific reason.
*/ */
abstract public static function check_security(array $params); abstract public static function check_security(object $params);
/** /**
* Process the submission and perform necessary actions * Process the submission and perform necessary actions

View File

@ -1,33 +1,40 @@
<?php <?php
namespace local_treestudyplan\local\forms; 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 * Moodleform class for the studyplan editor. A Moodleform is used here to facilitate a rich editor
* in the studyplan description * in the studyplan description
*/ */
class studyplan_editform extends formbase { 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 * 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. * Return true if validation passes, false or throw an exception if it does not.
* *
* @param array $params The parameters for form initialization * @param object $params The parameters for form initialization
* @return bool True if security validation passes. * @return bool True if security validation passes.
* @throws \moodle_exception if access denied for a specific reason. * @throws \moodle_exception if access denied for a specific reason.
*/ */
public static function check_security(array $params) { 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 * Generate form data from parameters
* Also validate parameters and access permissions here * Also validate parameters and access permissions here
* *
* @param array $params The parameters for form initialization * @param object $params The parameters for form initialization
* @return array Form data based on parameters * @return array Form data based on parameters
*/ */
public static function init_data(array $params) { public static function init_data(object $params) {
$plan = studyplan::find_by_id($params->studyplanid);
} }