Skip to content
Snippets Groups Projects
Unverified Commit 5c5d0981 authored by Tobias Reischmann's avatar Tobias Reischmann
Browse files

Changed name to subpluginname

parent dc048d9e
Branches
Tags
No related merge requests found
......@@ -112,7 +112,7 @@ class subplugin_settings {
$steps = $manager->get_step_types();
echo $OUTPUT->single_select(new \moodle_url($PAGE->url,
array('action' => ACTION_STEP_INSTANCE_FORM, 'sesskey' => sesskey())),
'name', $steps, '', array('' => get_string('add_new_step_instance', 'tool_cleanupcourses')));
'subpluginname', $steps, '', array('' => get_string('add_new_step_instance', 'tool_cleanupcourses')));
$table = new step_table('tool_cleanupcourses_steps');
$table->out(5000, false);
......
......@@ -45,15 +45,15 @@ class cleanup_processor {
$triggerlist = \core_component::get_plugin_list('cleanupcoursestrigger');
$triggerclasses = [];
foreach ($enabledtrigger as $trigger) {
require_once($triggerlist[$trigger->name].'/lib.php');
$extendedclass = "tool_cleanupcourses\\trigger\\$trigger->name";
$triggerclasses[$trigger->name] = new $extendedclass();
require_once($triggerlist[$trigger->subpluginname].'/lib.php');
$extendedclass = "tool_cleanupcourses\\trigger\\$trigger->subpluginname";
$triggerclasses[$trigger->subpluginname] = new $extendedclass();
}
$recordset = $this->get_course_recordset();
while ($recordset->valid()) {
$course = $recordset->current();
foreach ($enabledtrigger as $trigger) {
$response = $triggerclasses[$trigger->name]->check_course($course);
$response = $triggerclasses[$trigger->subpluginname]->check_course($course);
if ($response == trigger_response::next()) {
continue;
}
......
......@@ -32,12 +32,12 @@ class step_subplugin extends subplugin {
public $instancename;
/**
* Creates a subplugin with name and optional id.
* @param string $name name of the subplugin
* Creates a subplugin with subpluginname and optional id.
* @param string $subpluginname name of the subplugin
* @param int $id id of the subplugin
*/
public function __construct($instancename, $name, $id = null) {
parent::__construct($name, $id);
public function __construct($instancename, $subpluginname, $id = null) {
parent::__construct($subpluginname, $id);
$this->instancename = $instancename;
}
......@@ -47,13 +47,13 @@ class step_subplugin extends subplugin {
* @return step_subplugin
*/
public static function from_record($record) {
if (!object_property_exists($record, 'name')) {
if (!object_property_exists($record, 'subpluginname')) {
return null;
}
if (!object_property_exists($record, 'instancename')) {
return null;
}
$instance = new self($record->instancename, $record->name);
$instance = new self($record->instancename, $record->subpluginname);
foreach (array_keys((array) $record) as $field) {
if (object_property_exists($instance, $field)) {
$instance->$field = $record->$field;
......
......@@ -32,18 +32,18 @@ class subplugin{
public $id;
/** string name of subplugin */
public $name;
public $subpluginname;
/** subplugin this subplugin is followed by in the cleanup process*/
public $followedby;
/**
* Creates a subplugin with name and optional id.
* @param string $name name of the subplugin
* Creates a subplugin with subpluginname and optional id.
* @param string $subpluginname name of the subplugin
* @param int $id id of the subplugin
*/
public function __construct($name, $id = null) {
$this->name = $name;
public function __construct($subpluginname, $id = null) {
$this->subpluginname = $subpluginname;
$this->id = $id;
}
......@@ -53,10 +53,10 @@ class subplugin{
* @return trigger_subplugin
*/
public static function from_record($record) {
if (!object_property_exists($record, 'name')) {
if (!object_property_exists($record, 'subpluginname')) {
return null;
}
$instance = new self($record->name);
$instance = new self($record->subpluginname);
foreach (array_keys((array) $record) as $field) {
if (object_property_exists($instance, $field)) {
$instance->$field = $record->$field;
......
......@@ -35,12 +35,12 @@ class trigger_subplugin extends subplugin{
public $sortindex;
/**
* Creates a subplugin with name and optional id.
* @param string $name name of the subplugin
* Creates a subplugin with subpluginname and optional id.
* @param string $subpluginname name of the subplugin
* @param int $id id of the subplugin
*/
public function __construct($name, $id = null) {
parent::__construct($name, $id);
public function __construct($subpluginname, $id = null) {
parent::__construct($subpluginname, $id);
}
/**
......@@ -49,10 +49,10 @@ class trigger_subplugin extends subplugin{
* @return trigger_subplugin
*/
public static function from_record($record) {
if (!object_property_exists($record, 'name')) {
if (!object_property_exists($record, 'subpluginname')) {
return null;
}
$instance = new self($record->name);
$instance = new self($record->subpluginname);
foreach (array_keys((array) $record) as $field) {
if (object_property_exists($instance, $field)) {
$instance->$field = $record->$field;
......
......@@ -65,8 +65,8 @@ class form_step_instance extends \moodleform {
$mform->setType($elementname, PARAM_TEXT);
$stepmanager = new step_manager();
$elementname = 'name';
$mform->addElement('select', $elementname, get_string('step_name', 'tool_cleanupcourses'),
$elementname = 'subpluginname';
$mform->addElement('select', $elementname, get_string('step_subpluginname', 'tool_cleanupcourses'),
$stepmanager->get_step_types());
$mform->setType($elementname, PARAM_TEXT);
......@@ -87,7 +87,7 @@ class form_step_instance extends \moodleform {
if ($this->step) {
$mform->setDefault('id', $this->step->id);
$mform->setDefault('instancename', $this->step->instancename);
$mform->setDefault('name', $this->step->name);
$mform->setDefault('subpluginname', $this->step->subpluginname);
$mform->setDefault('followedby', $this->step->followedby);
} else {
$mform->setDefault('id', '');
......
......@@ -181,7 +181,7 @@ class trigger_manager extends subplugin_manager {
$DB->update_record('tool_cleanupcourses_trigger', $subplugin);
}
$record = array(
'name' => $subplugin->name,
'subpluginname' => $subplugin->subpluginname,
);
if (!$DB->record_exists('tool_cleanupcourses_trigger', $record)) {
$subplugin->id = $DB->insert_record('tool_cleanupcourses_trigger', $record);
......@@ -199,7 +199,7 @@ class trigger_manager extends subplugin_manager {
global $DB;
$transaction = $DB->start_delegated_transaction();
$record = array(
'name' => $subplugin->name,
'subpluginname' => $subplugin->subpluginname,
);
if ($record = $DB->get_record('tool_cleanupcourses_trigger', $record)) {
$DB->delete_records('tool_cleanupcourses_trigger', (array) $record);
......
......@@ -32,7 +32,7 @@ class active_processes_table extends \table_sql {
public function __construct($uniqueid) {
parent::__construct($uniqueid);
global $PAGE;
$this->set_sql('c.fullname as course, s.name as name ',
$this->set_sql('c.fullname as course, s.subpluginname as subpluginname ',
'{tool_cleanupcourses_process} p join ' .
'{course} c on p.courseid = c.id join ' .
'{tool_cleanupcourses_step} s on p.stepid = s.id',
......@@ -54,8 +54,8 @@ class active_processes_table extends \table_sql {
*/
public function col_subplugin($row) {
$name = $row->name;
$subpluginname = $row->subpluginname;
return get_string('pluginname', 'cleanupcoursesstep_' . $name);
return get_string('pluginname', 'cleanupcoursesstep_' . $subpluginname);
}
}
\ No newline at end of file
......@@ -35,17 +35,17 @@ class step_table extends \table_sql {
public function __construct($uniqueid) {
parent::__construct($uniqueid);
global $PAGE;
$this->set_sql("id, name, instancename, followedby", '{tool_cleanupcourses_step}', "TRUE");
$this->set_sql("id, subpluginname, instancename, followedby", '{tool_cleanupcourses_step}', "TRUE");
$this->define_baseurl($PAGE->url);
$this->pageable(false);
$this->init();
}
public function init() {
$this->define_columns(['instancename', 'name', 'followedby', 'edit', 'delete']);
$this->define_columns(['instancename', 'subpluginname', 'followedby', 'edit', 'delete']);
$this->define_headers([
get_string('step_instancename', 'tool_cleanupcourses'),
get_string('step_name', 'tool_cleanupcourses'),
get_string('step_subpluginname', 'tool_cleanupcourses'),
get_string('step_followedby', 'tool_cleanupcourses'),
get_string('step_edit', 'tool_cleanupcourses'),
get_string('step_delete', 'tool_cleanupcourses'),
......@@ -55,15 +55,15 @@ class step_table extends \table_sql {
}
/**
* Render name column.
* Render subpluginname column.
* @param $row
* @return string pluginname of the subplugin
*/
public function col_name($row) {
public function col_subpluginname($row) {
$name = $row->name;
$subpluginname = $row->subpluginname;
return get_string('pluginname', 'cleanupcoursesstep_' . $name);
return get_string('pluginname', 'cleanupcoursesstep_' . $subpluginname);
}
/**
......
......@@ -36,16 +36,16 @@ class trigger_table extends \table_sql {
public function __construct($uniqueid) {
parent::__construct($uniqueid);
global $PAGE;
$this->set_sql("id, name, enabled, sortindex, followedby", '{tool_cleanupcourses_trigger}', "TRUE");
$this->set_sql("id, subpluginname, enabled, sortindex, followedby", '{tool_cleanupcourses_trigger}', "TRUE");
$this->define_baseurl($PAGE->url);
$this->pageable(false);
$this->init();
}
public function init() {
$this->define_columns(['name', 'enabled', 'sortindex', 'followedby']);
$this->define_columns(['subpluginname', 'enabled', 'sortindex', 'followedby']);
$this->define_headers([
get_string('trigger_name', 'tool_cleanupcourses'),
get_string('trigger_subpluginname', 'tool_cleanupcourses'),
get_string('trigger_enabled', 'tool_cleanupcourses'),
get_string('trigger_sortindex', 'tool_cleanupcourses'),
get_string('trigger_followedby', 'tool_cleanupcourses'),
......@@ -55,15 +55,15 @@ class trigger_table extends \table_sql {
}
/**
* Render name column.
* Render subpluginname column.
* @param $row
* @return string pluginname of the subplugin
*/
public function col_name($row) {
public function col_subpluginname($row) {
$name = $row->name;
$subpluginname = $row->subpluginname;
return get_string('pluginname', 'cleanupcoursestrigger_' . $name);
return get_string('pluginname', 'cleanupcoursestrigger_' . $subpluginname);
}
/**
......
......@@ -17,7 +17,7 @@
<TABLE NAME="tool_cleanupcourses_trigger" COMMENT="Trigger subplugins for the cleanup courses">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="name" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" COMMENT="name of the subplugin"/>
<FIELD NAME="subpluginname" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" COMMENT="name of the subplugin"/>
<FIELD NAME="enabled" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="tells if the subplugin is enabled"/>
<FIELD NAME="followedby" TYPE="int" LENGTH="3" NOTNULL="false" SEQUENCE="false" COMMENT="tells which step follows this one in the cleanup process"/>
<FIELD NAME="sortindex" TYPE="int" LENGTH="3" NOTNULL="false" SEQUENCE="false" COMMENT="Sortindex of the subplugins"/>
......@@ -30,7 +30,7 @@
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
<FIELD NAME="instancename" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" COMMENT="instancename of the step"/>
<FIELD NAME="name" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" COMMENT="name of the subplugin"/>
<FIELD NAME="subpluginname" TYPE="char" LENGTH="50" NOTNULL="true" SEQUENCE="false" COMMENT="name of the subplugin"/>
<FIELD NAME="followedby" TYPE="int" LENGTH="3" NOTNULL="false" SEQUENCE="false" COMMENT="tells which step follows this one in the cleanup process"/>
</FIELDS>
<KEYS>
......
......@@ -36,12 +36,12 @@ $string['subpluginssettings_edit_instance_heading'] = 'Step Instance';
$string['add_new_step_instance'] = 'Add New Step Instance...';
$string['trigger_name'] = 'Subplugin Name';
$string['trigger_subpluginname'] = 'Subplugin Name';
$string['trigger_enabled'] = 'Enabled';
$string['trigger_sortindex'] = 'Up/Down';
$string['trigger_followedby'] = 'Followed by';
$string['step_name'] = 'Step Type';
$string['step_subpluginname'] = 'Step Type';
$string['step_instancename'] = 'Instance Name';
$string['step_followedby'] = 'Followed by';
$string['step_edit'] = 'Edit';
......
......@@ -58,7 +58,7 @@ abstract class base {
$manager = new step_manager();
$stepinstance = $manager->get_step_instance($instanceid);
if (!$stepinstance || $stepinstance->name !== $this->get_subpluginname()) {
if (!$stepinstance || $stepinstance->subpluginname !== $this->get_subpluginname()) {
return null;
}
......
......@@ -33,7 +33,7 @@ class tool_cleanupcourses_generator extends testing_module_generator {
for ($i = 1; $i <= 3; $i++) {
$record = array(
'id' => $i,
'name' => 'subplugin'.$i,
'subpluginname' => 'subplugin'.$i,
'enabled' => 1,
'sortindex' => $i,
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment