mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-23 23:44:53 +00:00
Generate sample notifications: Education Program
Change-Id: I1ca832d181ba8704a200fee78a84b3ec70106bed
This commit is contained in:
parent
2291ce3d8c
commit
c24e029378
|
@ -21,7 +21,8 @@ class GenerateSampleNotifications extends Maintenance {
|
|||
'user-rights',
|
||||
'cx',
|
||||
'osm',
|
||||
'edit-thanks'
|
||||
'edit-thanks',
|
||||
'edu',
|
||||
);
|
||||
|
||||
public function __construct() {
|
||||
|
@ -116,6 +117,10 @@ class GenerateSampleNotifications extends Maintenance {
|
|||
$this->generateEditThanks( $user, $agent, $otherUser );
|
||||
}
|
||||
|
||||
if ( $this->shouldGenerate( 'edu', $types ) ) {
|
||||
$this->generateEducationProgram( $user, $agent );
|
||||
}
|
||||
|
||||
$this->output( "Completed \n" );
|
||||
}
|
||||
|
||||
|
@ -425,6 +430,42 @@ class GenerateSampleNotifications extends Maintenance {
|
|||
] );
|
||||
$this->output( "{$agent->getName()} and {$otherUser->getName()} are thanking {$user->getName()} for edit {$revision->getId()} on {$title->getPrefixedText()}\n" );
|
||||
}
|
||||
|
||||
private function generateEducationProgram( User $user, User $agent ) {
|
||||
if ( !class_exists( 'EducationProgram\Extension' ) ) {
|
||||
$this->output( 'class EducationProgram\Extension not found' );
|
||||
return;
|
||||
}
|
||||
|
||||
$chem101 = Title::newFromText( 'School/Chemistry101' );
|
||||
if ( !$chem101->exists() ) {
|
||||
$this->addToPageContent( $chem101, $agent, "\nThis is the main page for the Chemistry 101 course\n" );
|
||||
}
|
||||
|
||||
$notificationManager = EducationProgram\Extension::globalInstance()->getNotificationsManager();
|
||||
|
||||
$this->output( "{$agent->getName()} is adding {$user->getName()} to {$chem101->getPrefixedText()} as instructor, student, campus volunteer and online volunteer.\n" );
|
||||
|
||||
$types = array(
|
||||
'ep-instructor-add-notification',
|
||||
'ep-online-add-notification',
|
||||
'ep-campus-add-notification',
|
||||
'ep-student-add-notification',
|
||||
);
|
||||
foreach ( $types as $type ) {
|
||||
$notificationManager->trigger(
|
||||
$type,
|
||||
array(
|
||||
'role-add-title' => $chem101,
|
||||
'agent' => $agent,
|
||||
'users' => array( $user->getId() ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// NOTE: Not generating 'ep-course-talk-notification' for now
|
||||
// as it requires a full setup to actually work (institution, course, instructors, students).
|
||||
}
|
||||
}
|
||||
|
||||
$maintClass = "GenerateSampleNotifications";
|
||||
|
|
Loading…
Reference in a new issue